Unionfs ODF: Move around locking order in unions_readdir()
authorRachita Kothiyal <rachita@dewey.fsl.cs.sunysb.edu>
Sun, 18 May 2008 07:19:33 +0000 (03:19 -0400)
committerRachita Kothiyal <rachita@dewey.fsl.cs.sunysb.edu>
Sun, 18 May 2008 07:19:33 +0000 (03:19 -0400)
Signed-off-by: Rachita Kothiyal <rachita@fsl.cs.sunysb.edu>
fs/unionfs/dirfops.c

index ca49ad1b429c8aa0a528ff6604a14e63ec1a3aa9..3926972f2a8e1461a59d17964a6b969ab3a8e19e 100644 (file)
@@ -38,7 +38,7 @@ static int unionfs_readdir(struct file *file, void *dirent, filldir_t filldir)
 
        err = unionfs_file_revalidate(file, false);
        if (unlikely(err))
-               goto out;
+               goto out_unlock;
 
        inode = dentry->d_inode;
 
@@ -48,7 +48,7 @@ static int unionfs_readdir(struct file *file, void *dirent, filldir_t filldir)
        if (IS_ERR(odf_cache)) {
                err = PTR_ERR(odf_cache);
                odf_cache = NULL;
-               goto out;
+               goto out_unlock;
        }
 
        /* check if cached dir does not exist */
@@ -61,7 +61,7 @@ static int unionfs_readdir(struct file *file, void *dirent, filldir_t filldir)
                err = odf_cache_dir(file->f_path.dentry, odf_cache,
                                    &file->f_path.dentry->d_inode->i_mtime);
                if (err)
-                       goto out;
+                       goto out_unlock;
 
                /*
                 * Reset file position, since an operation like rm *
@@ -71,6 +71,7 @@ static int unionfs_readdir(struct file *file, void *dirent, filldir_t filldir)
                 */
                file->f_pos = 0;
        }
+       unionfs_unlock_dentry(dentry);
 
        dget(odf_cache);
        mntget(UNIONFS_SB(file->f_path.dentry->d_sb)->odf.path.mnt);
@@ -123,12 +124,15 @@ static int unionfs_readdir(struct file *file, void *dirent, filldir_t filldir)
        if (file->f_pos >= size)
                file->f_pos = DIREOF;
 
+       goto out;
+
+out_unlock:
+       unionfs_unlock_dentry(dentry);
 out:
        kfree(name);
        if (odf_file)
                filp_close(odf_file, NULL);
        dput(odf_cache);
-       unionfs_unlock_dentry(dentry);
        unionfs_read_unlock(dentry->d_sb);
        return err;
 }