* [PATCH] reiserfs: replace open-coded atomic_dec_and_mutex_lock()
@ 2019-11-03 9:44 Nikitas Angelinas
2019-11-05 11:25 ` Jan Kara
0 siblings, 1 reply; 2+ messages in thread
From: Nikitas Angelinas @ 2019-11-03 9:44 UTC (permalink / raw)
To: Andrew Morton, zhengbin, zhengbin13, Jan Kara
Cc: Al Viro, reiserfs-devel, linux-kernel, nikitas.angelinas
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] reiserfs: replace open-coded atomic_dec_and_mutex_lock()
2019-11-03 9:44 [PATCH] reiserfs: replace open-coded atomic_dec_and_mutex_lock() Nikitas Angelinas
@ 2019-11-05 11:25 ` Jan Kara
0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2019-11-05 11:25 UTC (permalink / raw)
To: Nikitas Angelinas
Cc: Andrew Morton, zhengbin, zhengbin13, Jan Kara, Al Viro,
reiserfs-devel, linux-kernel
On Sun 03-11-19 01:44:54, Nikitas Angelinas wrote:
> Replace the open-coded logic of atomic_dec_and_mutex_lock() in
> reiserfs_file_release().
>
> Signed-off-by: Nikitas Angelinas <nikitas.angelinas@gmail.com>
Thanks! The patch looks good to me. I've added it to my tree.
Honza
> ---
> 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
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-11-05 11:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-03 9:44 [PATCH] reiserfs: replace open-coded atomic_dec_and_mutex_lock() Nikitas Angelinas
2019-11-05 11:25 ` Jan Kara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox