]> Pileus Git - ~andy/linux/commitdiff
JFS: commit_mutex cleanups
authorEvgeniy Dushistov <dushistov@mail.ru>
Mon, 5 Jun 2006 13:21:03 +0000 (08:21 -0500)
committerDave Kleikamp <shaggy@austin.ibm.com>
Mon, 5 Jun 2006 13:21:03 +0000 (08:21 -0500)
I look at code, and see that
1)locks wasn't release in the opposite order in which they were taken
2)in jfs_rename we lock new_ip, and in "error path" we didn't unlock it
3)I see strange expression: "! !"

May be this worth to fix?

Signed-off-by: Evgeniy Dushistov <dushistov@mail.ru>
Signed-off-by: Dave Kleikamp <shaggy@austin.ibm.com>
fs/jfs/jfs_txnmgr.c
fs/jfs/namei.c

index ac3d66948e8ceae440e77d944bd2667f9a9e8e76..49618dd94f9a2f597cd034595bb45e2a4ce57f2c 100644 (file)
@@ -2944,7 +2944,7 @@ int jfs_sync(void *arg)
                                 * Inode is being freed
                                 */
                                list_del_init(&jfs_ip->anon_inode_list);
-                       } else if (! !mutex_trylock(&jfs_ip->commit_mutex)) {
+                       } else if (mutex_trylock(&jfs_ip->commit_mutex)) {
                                /*
                                 * inode will be removed from anonymous list
                                 * when it is committed
index 09ea03f622778a0d5c568db9192eec9e2ea5ceb9..295268ad231b5ec1f26c78cb43489d434122c907 100644 (file)
@@ -165,8 +165,8 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode,
 
       out3:
        txEnd(tid);
-       mutex_unlock(&JFS_IP(dip)->commit_mutex);
        mutex_unlock(&JFS_IP(ip)->commit_mutex);
+       mutex_unlock(&JFS_IP(dip)->commit_mutex);
        if (rc) {
                free_ea_wmap(ip);
                ip->i_nlink = 0;
@@ -300,8 +300,8 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode)
 
       out3:
        txEnd(tid);
-       mutex_unlock(&JFS_IP(dip)->commit_mutex);
        mutex_unlock(&JFS_IP(ip)->commit_mutex);
+       mutex_unlock(&JFS_IP(dip)->commit_mutex);
        if (rc) {
                free_ea_wmap(ip);
                ip->i_nlink = 0;
@@ -384,8 +384,8 @@ static int jfs_rmdir(struct inode *dip, struct dentry *dentry)
                if (rc == -EIO)
                        txAbort(tid, 1);
                txEnd(tid);
-               mutex_unlock(&JFS_IP(dip)->commit_mutex);
                mutex_unlock(&JFS_IP(ip)->commit_mutex);
+               mutex_unlock(&JFS_IP(dip)->commit_mutex);
 
                goto out2;
        }
@@ -422,8 +422,8 @@ static int jfs_rmdir(struct inode *dip, struct dentry *dentry)
 
        txEnd(tid);
 
-       mutex_unlock(&JFS_IP(dip)->commit_mutex);
        mutex_unlock(&JFS_IP(ip)->commit_mutex);
+       mutex_unlock(&JFS_IP(dip)->commit_mutex);
 
        /*
         * Truncating the directory index table is not guaranteed.  It
@@ -503,8 +503,8 @@ static int jfs_unlink(struct inode *dip, struct dentry *dentry)
                if (rc == -EIO)
                        txAbort(tid, 1);        /* Marks FS Dirty */
                txEnd(tid);
-               mutex_unlock(&JFS_IP(dip)->commit_mutex);
                mutex_unlock(&JFS_IP(ip)->commit_mutex);
+               mutex_unlock(&JFS_IP(dip)->commit_mutex);
                IWRITE_UNLOCK(ip);
                goto out1;
        }
@@ -527,8 +527,8 @@ static int jfs_unlink(struct inode *dip, struct dentry *dentry)
                if ((new_size = commitZeroLink(tid, ip)) < 0) {
                        txAbort(tid, 1);        /* Marks FS Dirty */
                        txEnd(tid);
-                       mutex_unlock(&JFS_IP(dip)->commit_mutex);
                        mutex_unlock(&JFS_IP(ip)->commit_mutex);
+                       mutex_unlock(&JFS_IP(dip)->commit_mutex);
                        IWRITE_UNLOCK(ip);
                        rc = new_size;
                        goto out1;
@@ -556,9 +556,8 @@ static int jfs_unlink(struct inode *dip, struct dentry *dentry)
 
        txEnd(tid);
 
-       mutex_unlock(&JFS_IP(dip)->commit_mutex);
        mutex_unlock(&JFS_IP(ip)->commit_mutex);
-
+       mutex_unlock(&JFS_IP(dip)->commit_mutex);
 
        while (new_size && (rc == 0)) {
                tid = txBegin(dip->i_sb, 0);
@@ -847,8 +846,8 @@ static int jfs_link(struct dentry *old_dentry,
       out:
        txEnd(tid);
 
-       mutex_unlock(&JFS_IP(dir)->commit_mutex);
        mutex_unlock(&JFS_IP(ip)->commit_mutex);
+       mutex_unlock(&JFS_IP(dir)->commit_mutex);
 
        jfs_info("jfs_link: rc:%d", rc);
        return rc;
@@ -1037,8 +1036,8 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry,
 
       out3:
        txEnd(tid);
-       mutex_unlock(&JFS_IP(dip)->commit_mutex);
        mutex_unlock(&JFS_IP(ip)->commit_mutex);
+       mutex_unlock(&JFS_IP(dip)->commit_mutex);
        if (rc) {
                free_ea_wmap(ip);
                ip->i_nlink = 0;
@@ -1160,10 +1159,11 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                if (S_ISDIR(new_ip->i_mode)) {
                        new_ip->i_nlink--;
                        if (new_ip->i_nlink) {
-                               mutex_unlock(&JFS_IP(new_dir)->commit_mutex);
-                               mutex_unlock(&JFS_IP(old_ip)->commit_mutex);
+                               mutex_unlock(&JFS_IP(new_ip)->commit_mutex);
                                if (old_dir != new_dir)
                                        mutex_unlock(&JFS_IP(old_dir)->commit_mutex);
+                               mutex_unlock(&JFS_IP(old_ip)->commit_mutex);
+                               mutex_unlock(&JFS_IP(new_dir)->commit_mutex);
                                if (!S_ISDIR(old_ip->i_mode) && new_ip)
                                        IWRITE_UNLOCK(new_ip);
                                jfs_error(new_ip->i_sb,
@@ -1281,13 +1281,12 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 
       out4:
        txEnd(tid);
-
-       mutex_unlock(&JFS_IP(new_dir)->commit_mutex);
-       mutex_unlock(&JFS_IP(old_ip)->commit_mutex);
-       if (old_dir != new_dir)
-               mutex_unlock(&JFS_IP(old_dir)->commit_mutex);
        if (new_ip)
                mutex_unlock(&JFS_IP(new_ip)->commit_mutex);
+       if (old_dir != new_dir)
+               mutex_unlock(&JFS_IP(old_dir)->commit_mutex);
+       mutex_unlock(&JFS_IP(old_ip)->commit_mutex);
+       mutex_unlock(&JFS_IP(new_dir)->commit_mutex);
 
        while (new_size && (rc == 0)) {
                tid = txBegin(new_ip->i_sb, 0);