Unionfs ODF: Check UNIONFS_D before grabbing dentry lock
authorRachita Kothiyal <rachita@dewey.fsl.cs.sunysb.edu>
Sun, 18 May 2008 07:28:34 +0000 (03:28 -0400)
committerRachita Kothiyal <rachita@dewey.fsl.cs.sunysb.edu>
Sun, 18 May 2008 07:28:34 +0000 (03:28 -0400)
First check if the UNIONFS_D() is non NULL, and only then grab
a lock on the dentry.  Since trying to grab a lock, which is a
member of UNIONFS_D(), doesn't make sense if it is itself NULL

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

index 3faae792cb6b5134bd0fb1b3db94b0665e3750f9..d03470888025c71f2148fa1e506bfead92663dca 100644 (file)
@@ -499,16 +499,14 @@ static void unionfs_d_release(struct dentry *dentry)
 {
        int bindex, bstart, bend;
 
+       /* this could be a negative dentry, so check first */
+       if (unlikely(!UNIONFS_D(dentry) || dbstart(dentry) < 0))
+               goto out;       /* due to a (normal) failed lookup */
+
        unionfs_read_lock(dentry->d_sb, UNIONFS_SMUTEX_CHILD);
        /* must lock our branch configuration here */
        unionfs_lock_dentry(dentry, UNIONFS_DMUTEX_CHILD);
 
-       /* 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 */
@@ -529,9 +527,10 @@ static void unionfs_d_release(struct dentry *dentry)
 
        unionfs_unlock_dentry(dentry);
 
+
+       unionfs_read_unlock(dentry->d_sb);
 out:
        free_dentry_private_data(dentry);
-       unionfs_read_unlock(dentry->d_sb);
        return;
 }