Commit 48ce8b05 authored by Evgeniy Dushistov's avatar Evgeniy Dushistov Committed by Dave Kleikamp

JFS: commit_mutex cleanups

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: default avatarEvgeniy Dushistov <dushistov@mail.ru>
Signed-off-by: default avatarDave Kleikamp <shaggy@austin.ibm.com>
parent 672c6108
...@@ -2944,7 +2944,7 @@ int jfs_sync(void *arg) ...@@ -2944,7 +2944,7 @@ int jfs_sync(void *arg)
* Inode is being freed * Inode is being freed
*/ */
list_del_init(&jfs_ip->anon_inode_list); 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 * inode will be removed from anonymous list
* when it is committed * when it is committed
......
...@@ -165,8 +165,8 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode, ...@@ -165,8 +165,8 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode,
out3: out3:
txEnd(tid); txEnd(tid);
mutex_unlock(&JFS_IP(dip)->commit_mutex);
mutex_unlock(&JFS_IP(ip)->commit_mutex); mutex_unlock(&JFS_IP(ip)->commit_mutex);
mutex_unlock(&JFS_IP(dip)->commit_mutex);
if (rc) { if (rc) {
free_ea_wmap(ip); free_ea_wmap(ip);
ip->i_nlink = 0; ip->i_nlink = 0;
...@@ -300,8 +300,8 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode) ...@@ -300,8 +300,8 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode)
out3: out3:
txEnd(tid); txEnd(tid);
mutex_unlock(&JFS_IP(dip)->commit_mutex);
mutex_unlock(&JFS_IP(ip)->commit_mutex); mutex_unlock(&JFS_IP(ip)->commit_mutex);
mutex_unlock(&JFS_IP(dip)->commit_mutex);
if (rc) { if (rc) {
free_ea_wmap(ip); free_ea_wmap(ip);
ip->i_nlink = 0; ip->i_nlink = 0;
...@@ -384,8 +384,8 @@ static int jfs_rmdir(struct inode *dip, struct dentry *dentry) ...@@ -384,8 +384,8 @@ static int jfs_rmdir(struct inode *dip, struct dentry *dentry)
if (rc == -EIO) if (rc == -EIO)
txAbort(tid, 1); txAbort(tid, 1);
txEnd(tid); txEnd(tid);
mutex_unlock(&JFS_IP(dip)->commit_mutex);
mutex_unlock(&JFS_IP(ip)->commit_mutex); mutex_unlock(&JFS_IP(ip)->commit_mutex);
mutex_unlock(&JFS_IP(dip)->commit_mutex);
goto out2; goto out2;
} }
...@@ -422,8 +422,8 @@ static int jfs_rmdir(struct inode *dip, struct dentry *dentry) ...@@ -422,8 +422,8 @@ static int jfs_rmdir(struct inode *dip, struct dentry *dentry)
txEnd(tid); txEnd(tid);
mutex_unlock(&JFS_IP(dip)->commit_mutex);
mutex_unlock(&JFS_IP(ip)->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 * Truncating the directory index table is not guaranteed. It
...@@ -503,8 +503,8 @@ static int jfs_unlink(struct inode *dip, struct dentry *dentry) ...@@ -503,8 +503,8 @@ static int jfs_unlink(struct inode *dip, struct dentry *dentry)
if (rc == -EIO) if (rc == -EIO)
txAbort(tid, 1); /* Marks FS Dirty */ txAbort(tid, 1); /* Marks FS Dirty */
txEnd(tid); txEnd(tid);
mutex_unlock(&JFS_IP(dip)->commit_mutex);
mutex_unlock(&JFS_IP(ip)->commit_mutex); mutex_unlock(&JFS_IP(ip)->commit_mutex);
mutex_unlock(&JFS_IP(dip)->commit_mutex);
IWRITE_UNLOCK(ip); IWRITE_UNLOCK(ip);
goto out1; goto out1;
} }
...@@ -527,8 +527,8 @@ static int jfs_unlink(struct inode *dip, struct dentry *dentry) ...@@ -527,8 +527,8 @@ static int jfs_unlink(struct inode *dip, struct dentry *dentry)
if ((new_size = commitZeroLink(tid, ip)) < 0) { if ((new_size = commitZeroLink(tid, ip)) < 0) {
txAbort(tid, 1); /* Marks FS Dirty */ txAbort(tid, 1); /* Marks FS Dirty */
txEnd(tid); txEnd(tid);
mutex_unlock(&JFS_IP(dip)->commit_mutex);
mutex_unlock(&JFS_IP(ip)->commit_mutex); mutex_unlock(&JFS_IP(ip)->commit_mutex);
mutex_unlock(&JFS_IP(dip)->commit_mutex);
IWRITE_UNLOCK(ip); IWRITE_UNLOCK(ip);
rc = new_size; rc = new_size;
goto out1; goto out1;
...@@ -556,9 +556,8 @@ static int jfs_unlink(struct inode *dip, struct dentry *dentry) ...@@ -556,9 +556,8 @@ static int jfs_unlink(struct inode *dip, struct dentry *dentry)
txEnd(tid); txEnd(tid);
mutex_unlock(&JFS_IP(dip)->commit_mutex);
mutex_unlock(&JFS_IP(ip)->commit_mutex); mutex_unlock(&JFS_IP(ip)->commit_mutex);
mutex_unlock(&JFS_IP(dip)->commit_mutex);
while (new_size && (rc == 0)) { while (new_size && (rc == 0)) {
tid = txBegin(dip->i_sb, 0); tid = txBegin(dip->i_sb, 0);
...@@ -847,8 +846,8 @@ static int jfs_link(struct dentry *old_dentry, ...@@ -847,8 +846,8 @@ static int jfs_link(struct dentry *old_dentry,
out: out:
txEnd(tid); txEnd(tid);
mutex_unlock(&JFS_IP(dir)->commit_mutex);
mutex_unlock(&JFS_IP(ip)->commit_mutex); mutex_unlock(&JFS_IP(ip)->commit_mutex);
mutex_unlock(&JFS_IP(dir)->commit_mutex);
jfs_info("jfs_link: rc:%d", rc); jfs_info("jfs_link: rc:%d", rc);
return rc; return rc;
...@@ -1037,8 +1036,8 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry, ...@@ -1037,8 +1036,8 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry,
out3: out3:
txEnd(tid); txEnd(tid);
mutex_unlock(&JFS_IP(dip)->commit_mutex);
mutex_unlock(&JFS_IP(ip)->commit_mutex); mutex_unlock(&JFS_IP(ip)->commit_mutex);
mutex_unlock(&JFS_IP(dip)->commit_mutex);
if (rc) { if (rc) {
free_ea_wmap(ip); free_ea_wmap(ip);
ip->i_nlink = 0; ip->i_nlink = 0;
...@@ -1160,10 +1159,11 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -1160,10 +1159,11 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
if (S_ISDIR(new_ip->i_mode)) { if (S_ISDIR(new_ip->i_mode)) {
new_ip->i_nlink--; new_ip->i_nlink--;
if (new_ip->i_nlink) { if (new_ip->i_nlink) {
mutex_unlock(&JFS_IP(new_dir)->commit_mutex); mutex_unlock(&JFS_IP(new_ip)->commit_mutex);
mutex_unlock(&JFS_IP(old_ip)->commit_mutex);
if (old_dir != new_dir) if (old_dir != new_dir)
mutex_unlock(&JFS_IP(old_dir)->commit_mutex); 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) if (!S_ISDIR(old_ip->i_mode) && new_ip)
IWRITE_UNLOCK(new_ip); IWRITE_UNLOCK(new_ip);
jfs_error(new_ip->i_sb, jfs_error(new_ip->i_sb,
...@@ -1281,13 +1281,12 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -1281,13 +1281,12 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
out4: out4:
txEnd(tid); 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) if (new_ip)
mutex_unlock(&JFS_IP(new_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);
while (new_size && (rc == 0)) { while (new_size && (rc == 0)) {
tid = txBegin(new_ip->i_sb, 0); tid = txBegin(new_ip->i_sb, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment