]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE14-writedcache-enforce-xdcache-writelock-20071208
authorDerrick Brashear <shadow@dementia.org>
Sat, 8 Dec 2007 18:00:44 +0000 (18:00 +0000)
committerDerrick Brashear <shadow@dementia.org>
Sat, 8 Dec 2007 18:00:44 +0000 (18:00 +0000)
LICENSE IPL10
FIXES 59136

in order that the writes to CacheItems not be addled, we need to *actually*
hold a *write* lock when we write. not even just read as the comment says.

and certainly not none as was happening in the dir package.

(cherry picked from commit c0a04c21cf36e4c8e25be9703f715f30d1bf55a6)

src/afs/VNOPS/afs_vnop_create.c
src/afs/VNOPS/afs_vnop_dirops.c
src/afs/VNOPS/afs_vnop_link.c
src/afs/VNOPS/afs_vnop_rename.c
src/afs/VNOPS/afs_vnop_symlink.c
src/afs/afs_dcache.c

index fbb33fc2738d42fbe0245b4c66bb4793340ccb5c..bdf35a9b437abf02ca6d0cdfd4631fb917d4879e 100644 (file)
@@ -353,7 +353,9 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
        UpgradeSToWLock(&tdc->lock, 631);
     if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) {
        /* we can do it locally */
+       ObtainWriteLock(&afs_xdcache, 291);
        code = afs_dir_Create(tdc, aname, &newFid.Fid);
+       ReleaseWriteLock(&afs_xdcache);
        if (code) {
            ZapDCE(tdc);
            DZap(tdc);
index 0079acfe74a1735d5f16f0e9fde36bbe68b07d6f..5e73dd0d643d18ba2df65f0afa224ee5eb7917d0 100644 (file)
@@ -132,7 +132,9 @@ afs_mkdir(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
        ObtainWriteLock(&tdc->lock, 632);
     if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) {
        /* we can do it locally */
+       ObtainWriteLock(&afs_xdcache, 294);
        code = afs_dir_Create(tdc, aname, &newFid.Fid);
+       ReleaseWriteLock(&afs_xdcache);
        if (code) {
            ZapDCE(tdc);        /* surprise error -- use invalid value */
            DZap(tdc);
index cbd59aabf4fa99bf2a9c9e06b847b244a381450c..04c08a6dc4be3ea1aed5b9f1467b7ca3e1859afe 100644 (file)
@@ -127,7 +127,9 @@ afs_link(avc, OSI_VC_ARG(adp), aname, acred)
        ObtainWriteLock(&tdc->lock, 635);
     if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) {
        /* we can do it locally */
+       ObtainWriteLock(&afs_xdcache, 290);
        code = afs_dir_Create(tdc, aname, &avc->fid.Fid);
+       ReleaseWriteLock(&afs_xdcache);
        if (code) {
            ZapDCE(tdc);        /* surprise error -- invalid value */
            DZap(tdc);
index 1af38a21c4eb470efe298aa5b5cd967ffb5c52dc..02c67f99c06cefe3515713cddce14eb33883132d 100644 (file)
@@ -227,7 +227,9 @@ afsrename(struct vcache *aodp, char *aname1, struct vcache *andp,
                code = afs_dir_Delete(tdc2, aname2);
            }
            if (code == 0) {
+               ObtainWriteLock(&afs_xdcache, 292);
                code = afs_dir_Create(tdc2, aname2, &fileFid.Fid);
+               ReleaseWriteLock(&afs_xdcache);
            }
            if (code != 0) {
                ZapDCE(tdc1);
index 205e40743c0146d89c3233ff5cea13bb6fc2a6b8..eaad9d8b944c721b2698f302cd9ca1ffce660429 100644 (file)
@@ -173,7 +173,9 @@ int afs_symlink
     /* otherwise, we should see if we can make the change to the dir locally */
     if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) {
        /* we can do it locally */
+       ObtainWriteLock(&afs_xdcache, 293);
        code = afs_dir_Create(tdc, aname, &newFid.Fid);
+       ReleaseWriteLock(&afs_xdcache);
        if (code) {
            ZapDCE(tdc);        /* surprise error -- use invalid value */
            DZap(tdc);
index b4101852be26923588a62a93ca178df86805e86f..7015ec06bf128ded95006315b6d02b35c9f65381 100644 (file)
@@ -2860,6 +2860,7 @@ afs_WriteDCache(register struct dcache *adc, int atime)
     if (cacheDiskType == AFS_FCACHE_TYPE_MEM)
        return 0;
     AFS_STATCNT(afs_WriteDCache);
+    osi_Assert(WriteLocked(&afs_xdcache));
     if (atime)
        adc->f.modTime = osi_Time();
     /*