public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nikitas Angelinas <nikitas.angelinas@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	zhengbin@vostro, zhengbin13@huawei.com, Jan Kara <jack@suse.cz>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	reiserfs-devel@vger.kernel.org, linux-kernel@vger.kernel.org,
	nikitas.angelinas@gmail.com
Subject: [PATCH] reiserfs: replace open-coded atomic_dec_and_mutex_lock()
Date: Sun, 3 Nov 2019 01:44:54 -0800	[thread overview]
Message-ID: <20191103094431.GA18576-nikitas.angelinas@gmail.com> (raw)

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

Signed-off-by: Nikitas Angelinas <nikitas.angelinas@gmail.com>
---
 fs/reiserfs/file.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index 843aadc..84cf8bd 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -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)) &&
-- 
2.10.0


             reply	other threads:[~2019-11-03  9:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-03  9:44 Nikitas Angelinas [this message]
2019-11-05 11:25 ` [PATCH] reiserfs: replace open-coded atomic_dec_and_mutex_lock() Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191103094431.GA18576-nikitas.angelinas@gmail.com \
    --to=nikitas.angelinas@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=jack@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=reiserfs-devel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=zhengbin13@huawei.com \
    --cc=zhengbin@vostro \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox