Skip to contentSkip to conversation

udf: avoid unneeded up_write when fail to add entry in ->symlink

PATCH In review Chao Yu 2 participants 2 messages Aug 9, 2014 – Aug 11, 2014 UDF filesystem

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/1 udf: avoid unneeded up_write when fail to add entry in ->symlink

We have released the ->i_data_sem before invoking udf_add_entry(), so in following error path, we should not release this lock again.

---
 fs/udf/namei.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/udf/namei.c +2 -1
index 9737cba..83a0600 100644
@@ -1014,7 +1014,7 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
 
 	fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err);
 	if (!fi)
-		goto out_no_entry;
+		goto out_fail;
 	cfi.icb.extLength = cpu_to_le32(sb->s_blocksize);
 	cfi.icb.extLocation = cpu_to_lelb(iinfo->i_location);
 	if (UDF_SB(inode->i_sb)->s_lvid_bh) {
@@ -1036,6 +1036,7 @@ out:
 
 out_no_entry:
 	up_write(&iinfo->i_data_sem);
+out_fail:
 	inode_dec_link_count(inode);
 	iput(inode);
 	goto out;
Signature · 1 line
2.0.1.474.g72c7794
#1 lore raw
Quoted 2 lines · Chao Yu

We have released the ->i_data_sem before invoking udf_add_entry(), so in following error path, we should not release this lock again.

Good catch. I've merged the patch to my tree. Thanks.

Honza

Quoted 31 lines
---
 fs/udf/namei.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/udf/namei.c +2 -1
index 9737cba..83a0600 100644
@@ -1014,7 +1014,7 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
 
 	fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err);
 	if (!fi)
-		goto out_no_entry;
+		goto out_fail;
 	cfi.icb.extLength = cpu_to_le32(sb->s_blocksize);
 	cfi.icb.extLocation = cpu_to_lelb(iinfo->i_location);
 	if (UDF_SB(inode->i_sb)->s_lvid_bh) {
@@ -1036,6 +1036,7 @@ out:
 
 out_no_entry:
 	up_write(&iinfo->i_data_sem);
+out_fail:
 	inode_dec_link_count(inode);
 	iput(inode);
 	goto out;
Signature · 1 line
2.0.1.474.g72c7794
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR