viced: REALLYCLOSE origfdP after CoW
authorAndrew Deason <adeason@sinenomine.net>
Fri, 25 Mar 2011 20:54:01 +0000 (15:54 -0500)
committerDerrick Brashear <shadow@dementia.org>
Sat, 26 Mar 2011 15:24:56 +0000 (08:24 -0700)
In StoreData_RXStyle, we save a pointer to the original FdHandle_t if
we need to CopyOnWrite the target vnode, for the purposes of possibly
copying additional data later on.

After the CopyOnWrite call, this points to an inode that is not in the
current volume, and is thus less likely to be accessed. In CopyOnWrite
itself, the original file handle is FDH_REALLYCLOSE'd because of this,
so the handle does not remain in the cache. Do the same in
StoreData_RXStyle, so origfdP is always FDH_REALLYCLOSE'd after we
have called CopyOnWrite.

Change-Id: Ibe33d26120eb354318147f3a31fe32d38c6a70c6
Reviewed-on: http://gerrit.openafs.org/4344
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/viced/afsfileprocs.c

index 71ea49b..a8f9975 100644 (file)
@@ -7464,7 +7464,7 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
            if (fdP == NULL) {
                ViceLog(25,
                        ("StoreData : Reopen after CopyOnWrite failed\n"));
-               FDH_CLOSE(origfdP);
+               FDH_REALLYCLOSE(origfdP);
                return ENOENT;
            }
        }
@@ -7496,7 +7496,7 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
         AdjustDiskUsage(volptr, adjustSize,
                         adjustSize - SpareComp(volptr)))) {
        FDH_CLOSE(fdP);
-       if (origfdP) FDH_CLOSE(origfdP);
+       if (origfdP) FDH_REALLYCLOSE(origfdP);
        return (errorCode);
     }
 
@@ -7596,7 +7596,7 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
        targetptr->changed_newTime = 1;
        if (origfdP && (bytesTransfered < Length))      /* Need to "finish" CopyOnWrite still */
            CopyOnWrite2(origfdP, fdP, Pos + bytesTransfered, NewLength - Pos - bytesTransfered);
-       if (origfdP) FDH_CLOSE(origfdP);
+       if (origfdP) FDH_REALLYCLOSE(origfdP);
        FDH_CLOSE(fdP);
        /* set disk usage to be correct */
        VAdjustDiskUsage(&errorCode, volptr,
@@ -7613,7 +7613,7 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
                        afs_printable_VnodeId_u(targetptr->vnodeNumber),
                        V_name(volptr), CoW_off, CoW_len, errorCode));
        }
-       FDH_CLOSE(origfdP);
+       FDH_REALLYCLOSE(origfdP);
     }
     FDH_CLOSE(fdP);