afs: Handle osi_NewVnode failures
[openafs.git] / src / afs / DARWIN / osi_vcache.c
index 54c6e77..26493e6 100644 (file)
 #include "afsincludes.h"        /*AFS-based standard headers */
 
 struct vcache *
-osi_NewVnode(void) {
+osi_NewVnode(void)
+{
     struct vcache *tvc;
 
     tvc = afs_osi_Alloc(sizeof(struct vcache));
-    osi_Assert(tvc != NULL);
+    if (tvc == NULL) {
+       return NULL;
+    }
     tvc->v = NULL; /* important to clean this, or use memset 0 */
 
     return tvc;
@@ -27,7 +30,8 @@ osi_NewVnode(void) {
 
 #if defined(AFS_DARWIN80_ENV)
 int
-osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
+osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep)
+{
     *slept = 0;
 
     /* we ignore defersleep, as we *always* need to sleep */
@@ -62,7 +66,8 @@ osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
 }
 #else
 int
-osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
+osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep)
+{
     if (!VREFCOUNT_GT(avc,0)
         || ((VREFCOUNT(avc) == 1) && (UBCINFOEXISTS(AFSTOV(avc))))
         && avc->opens == 0 && (avc->f.states & CUnlinkedDel) == 0)
@@ -83,12 +88,14 @@ osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
 #endif /* AFS_DARWIN80_ENV */
 
 void
-osi_PrePopulateVCache(struct vcache *avc) {
+osi_PrePopulateVCache(struct vcache *avc)
+{
     memset(avc, 0, sizeof(struct vcache));
 }
 
 void
-osi_AttachVnode(struct vcache *avc, int seq) {
+osi_AttachVnode(struct vcache *avc, int seq)
+{
     ReleaseWriteLock(&afs_xvcache);
     AFS_GUNLOCK();
     afs_darwin_getnewvnode(avc);  /* includes one refcount */
@@ -102,7 +109,8 @@ osi_AttachVnode(struct vcache *avc, int seq) {
 }
 
 void
-osi_PostPopulateVCache(struct vcache *avc) {
+osi_PostPopulateVCache(struct vcache *avc)
+{
 #if !defined(AFS_DARWIN80_ENV)
    avc->v->v_mount = afs_globalVFS;
    vSetType(avc, VREG);
@@ -110,3 +118,10 @@ osi_PostPopulateVCache(struct vcache *avc) {
    vSetType(avc, VNON);
 #endif
 }
+
+int
+osi_vnhold(struct vcache *avc)
+{
+    VN_HOLD(AFSTOV(avc));
+    return 0;
+}