Skip to contentSkip to conversation

reiserfs: replace open-coded atomic_dec_and_mutex_lock()

PATCH In review Nikitas Angelinas 2 participants 2 messages Nov 3, 2019 – Nov 5, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 reiserfs: replace open-coded atomic_dec_and_mutex_lock()

Replace the open-coded logic of atomic_dec_and_mutex_lock() in reiserfs_file_release().

---
 fs/reiserfs/file.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
fs/reiserfs/file.c +2 -8
index 843aadc..84cf8bd 100644
@@ -38,16 +38,10 @@ static int reiserfs_file_release(struct inode *inode, struct file *filp)
 
 	BUG_ON(!S_ISREG(inode->i_mode));
 
-        if (atomic_add_unless(&REISERFS_I(inode)->openers, -1, 1))
+	if (!atomic_dec_and_mutex_lock(&REISERFS_I(inode)->openers,
+				       &REISERFS_I(inode)->tailpack))
 		return 0;
 
-	mutex_lock(&REISERFS_I(inode)->tailpack);
-
-        if (!atomic_dec_and_test(&REISERFS_I(inode)->openers)) {
-		mutex_unlock(&REISERFS_I(inode)->tailpack);
-		return 0;
-	}
-
 	/* fast out for when nothing needs to be done */
 	if ((!(REISERFS_I(inode)->i_flags & i_pack_on_close_mask) ||
 	     !tail_has_to_be_packed(inode)) &&
Signature · 1 line
2.10.0
#1 lore raw
Quoted 4 lines · Nikitas Angelinas

Replace the open-coded logic of atomic_dec_and_mutex_lock() in reiserfs_file_release().

Thanks! The patch looks good to me. I've added it to my tree.

Honza

Quoted 30 lines
---
 fs/reiserfs/file.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
fs/reiserfs/file.c +2 -8
index 843aadc..84cf8bd 100644
@@ -38,16 +38,10 @@ static int reiserfs_file_release(struct inode *inode, struct file *filp)
 
 	BUG_ON(!S_ISREG(inode->i_mode));
 
-        if (atomic_add_unless(&REISERFS_I(inode)->openers, -1, 1))
+	if (!atomic_dec_and_mutex_lock(&REISERFS_I(inode)->openers,
+				       &REISERFS_I(inode)->tailpack))
 		return 0;
 
-	mutex_lock(&REISERFS_I(inode)->tailpack);
-
-        if (!atomic_dec_and_test(&REISERFS_I(inode)->openers)) {
-		mutex_unlock(&REISERFS_I(inode)->tailpack);
-		return 0;
-	}
-
 	/* fast out for when nothing needs to be done */
 	if ((!(REISERFS_I(inode)->i_flags & i_pack_on_close_mask) ||
 	     !tail_has_to_be_packed(inode)) &&
Signature · 1 line
2.10.0
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR