Skip to content

Commit 2645695

Browse files
committed
jfs: clean up jfs_rename and fix out of order unlock
The end of jfs_rename(), which is also used by the error paths, included a call to IWRITE_UNLOCK(new_ip) after labels out1, out2 and out3. If we come in through these labels, IWRITE_LOCK() has not been called yet. In moving that call to the correct spot, I also moved some exceptional truncate code earlier as well, since the early error paths don't need to deal with it, and I renamed out4: to out_tx: so a future patch by Jan Kara doesn't need to deal with renumbering or confusing out-of-order labels. Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
1 parent f7f31ad commit 2645695

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

fs/jfs/namei.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
11611161
rc = dtModify(tid, new_dir, &new_dname, &ino,
11621162
old_ip->i_ino, JFS_RENAME);
11631163
if (rc)
1164-
goto out4;
1164+
goto out_tx;
11651165
drop_nlink(new_ip);
11661166
if (S_ISDIR(new_ip->i_mode)) {
11671167
drop_nlink(new_ip);
@@ -1186,7 +1186,7 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
11861186
if ((new_size = commitZeroLink(tid, new_ip)) < 0) {
11871187
txAbort(tid, 1); /* Marks FS Dirty */
11881188
rc = new_size;
1189-
goto out4;
1189+
goto out_tx;
11901190
}
11911191
tblk = tid_to_tblock(tid);
11921192
tblk->xflag |= COMMIT_DELETE;
@@ -1204,15 +1204,15 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
12041204
if (rc) {
12051205
jfs_err("jfs_rename didn't expect dtSearch to fail "
12061206
"w/rc = %d", rc);
1207-
goto out4;
1207+
goto out_tx;
12081208
}
12091209

12101210
ino = old_ip->i_ino;
12111211
rc = dtInsert(tid, new_dir, &new_dname, &ino, &btstack);
12121212
if (rc) {
12131213
if (rc == -EIO)
12141214
jfs_err("jfs_rename: dtInsert returned -EIO");
1215-
goto out4;
1215+
goto out_tx;
12161216
}
12171217
if (S_ISDIR(old_ip->i_mode))
12181218
inc_nlink(new_dir);
@@ -1227,7 +1227,7 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
12271227
jfs_err("jfs_rename did not expect dtDelete to return rc = %d",
12281228
rc);
12291229
txAbort(tid, 1); /* Marks Filesystem dirty */
1230-
goto out4;
1230+
goto out_tx;
12311231
}
12321232
if (S_ISDIR(old_ip->i_mode)) {
12331233
drop_nlink(old_dir);
@@ -1286,7 +1286,7 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
12861286

12871287
rc = txCommit(tid, ipcount, iplist, commit_flag);
12881288

1289-
out4:
1289+
out_tx:
12901290
txEnd(tid);
12911291
if (new_ip)
12921292
mutex_unlock(&JFS_IP(new_ip)->commit_mutex);
@@ -1309,13 +1309,6 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
13091309
}
13101310
if (new_ip && (new_ip->i_nlink == 0))
13111311
set_cflag(COMMIT_Nolink, new_ip);
1312-
out3:
1313-
free_UCSname(&new_dname);
1314-
out2:
1315-
free_UCSname(&old_dname);
1316-
out1:
1317-
if (new_ip && !S_ISDIR(new_ip->i_mode))
1318-
IWRITE_UNLOCK(new_ip);
13191312
/*
13201313
* Truncating the directory index table is not guaranteed. It
13211314
* may need to be done iteratively
@@ -1326,7 +1319,13 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,
13261319

13271320
clear_cflag(COMMIT_Stale, old_dir);
13281321
}
1329-
1322+
if (new_ip && !S_ISDIR(new_ip->i_mode))
1323+
IWRITE_UNLOCK(new_ip);
1324+
out3:
1325+
free_UCSname(&new_dname);
1326+
out2:
1327+
free_UCSname(&old_dname);
1328+
out1:
13301329
jfs_info("jfs_rename: returning %d", rc);
13311330
return rc;
13321331
}

0 commit comments

Comments
 (0)