Unionfs: check UNIONFS_D() before unionfs_check_dentry during release
authorRachita Kothiyal <rachita@dewey.fsl.cs.sunysb.edu>
Fri, 14 Mar 2008 03:36:31 +0000 (23:36 -0400)
committerRachita Kothiyal <rachita@dewey.fsl.cs.sunysb.edu>
Fri, 14 Mar 2008 03:36:31 +0000 (23:36 -0400)
When we are at the point of releasing a unionfs dentry, check the sanity of
the dentry after we have established that UNIONFS_D() is not NULL.  This
solves a potential race between two threads trying to release the same
dentry.

Signed-off-by: Rachita Kothiyal <rachita@fsl.cs.sunysb.edu>
fs/unionfs/dentry.c

index 8f9ea7da63906c1fde69520b13b9656e7424ce31..3faae792cb6b5134bd0fb1b3db94b0665e3750f9 100644 (file)
@@ -503,13 +503,14 @@ static void unionfs_d_release(struct dentry *dentry)
        /* must lock our branch configuration here */
        unionfs_lock_dentry(dentry, UNIONFS_DMUTEX_CHILD);
 
-       unionfs_check_dentry(dentry);
        /* this could be a negative dentry, so check first */
        if (unlikely(!UNIONFS_D(dentry) || dbstart(dentry) < 0)) {
                unionfs_unlock_dentry(dentry);
                goto out;       /* due to a (normal) failed lookup */
        }
 
+       unionfs_check_dentry(dentry);
+
        /* Release all the lower dentries */
        bstart = dbstart(dentry);
        bend = dbend(dentry);