]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
libafs/LINUX: avoid leaks due to corrupt dir
authorJeffrey Hutzelman <jhutz@cmu.edu>
Wed, 12 Jun 2013 20:22:36 +0000 (16:22 -0400)
committerStephan Wiesand <stephan.wiesand@desy.de>
Fri, 6 Feb 2015 10:05:12 +0000 (05:05 -0500)
When a corrupt directory is discovered, scanning stops immediately and
readdir returns ENOENT.  Currently, the vcache lock is unlocked and the
dcache containing the directory is released, but that's not enough.
It's also necessary to unlock the dcache, on which we hold a read lock,
and to clear the vcache state which records an in-progress readdir.

Reviewed-on: http://gerrit.openafs.org/9971
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
(cherry picked from commit a2bfa0e853fb4954fd06a00ea6fbc55c39e76b8a)

Change-Id: Id648822cd45087e5c0d320e8cfdcd6659bb33559
Reviewed-on: http://gerrit.openafs.org/11707
Reviewed-by: Perry Ruiter <pruiter@sinenomine.net>
Reviewed-by: Daria Brashear <shadow@your-file-system.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
src/afs/LINUX/osi_vnodeops.c

index 959e3209ce4da351f01c70aff0923c058bbe989f..ea274f6d0bb31d77f8bc1a9637cbccc1a87b1338 100644 (file)
@@ -392,10 +392,8 @@ afs_linux_readdir(struct file *fp, void *dirbuf, filldir_t filldir)
        if (code) {
            afs_warn("Corrupt directory (inode %lx, dirpos %d)",
                     (unsigned long)&tdc->f.inode, dirpos);
-           ReleaseSharedLock(&avc->lock);
-           afs_PutDCache(tdc);
            code = -ENOENT;
-           goto out;
+           goto unlock_out;
         }
 
        ino = afs_calc_inum(avc->f.fid.Cell, avc->f.fid.Fid.Volume,
@@ -461,7 +459,9 @@ afs_linux_readdir(struct file *fp, void *dirbuf, filldir_t filldir)
 #else
     fp->f_pos = (loff_t) offset;
 #endif
+    code = 0;
 
+unlock_out:
     ReleaseReadLock(&tdc->lock);
     afs_PutDCache(tdc);
     UpgradeSToWLock(&avc->lock, 813);
@@ -469,7 +469,6 @@ afs_linux_readdir(struct file *fp, void *dirbuf, filldir_t filldir)
     avc->dcreaddir = 0;
     avc->readdir_pid = 0;
     ReleaseSharedLock(&avc->lock);
-    code = 0;
 
 out:
     afs_PutFakeStat(&fakestat);