From: Jan Kara <jack@suse.cz>
To: Mateusz Guzik <mjguzik@gmail.com>
Cc: brauner@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] vfs: replace WARN(down_read_trylock, ...) abuse with proper asserts
Date: Mon, 3 Jun 2024 13:09:57 +0200 [thread overview]
Message-ID: <20240603110957.we2e2af33qsesmmj@quack3> (raw)
In-Reply-To: <20240602123720.775702-1-mjguzik@gmail.com>
On Sun 02-06-24 14:37:19, Mateusz Guzik wrote:
> Note the macro used here works regardless of LOCKDEP.
>
> Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Nice cleanup. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/dcache.c | 2 +-
> fs/quota/dquot.c | 8 ++------
> 2 files changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/fs/dcache.c b/fs/dcache.c
> index 407095188f83..a0a944fd3a1c 100644
> --- a/fs/dcache.c
> +++ b/fs/dcache.c
> @@ -1548,7 +1548,7 @@ void shrink_dcache_for_umount(struct super_block *sb)
> {
> struct dentry *dentry;
>
> - WARN(down_read_trylock(&sb->s_umount), "s_umount should've been locked");
> + rwsem_assert_held_write(&sb->s_umount);
>
> dentry = sb->s_root;
> sb->s_root = NULL;
> diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
> index 627eb2f72ef3..a2b256dac36e 100644
> --- a/fs/quota/dquot.c
> +++ b/fs/quota/dquot.c
> @@ -2246,9 +2246,7 @@ int dquot_disable(struct super_block *sb, int type, unsigned int flags)
> int cnt;
> struct quota_info *dqopt = sb_dqopt(sb);
>
> - /* s_umount should be held in exclusive mode */
> - if (WARN_ON_ONCE(down_read_trylock(&sb->s_umount)))
> - up_read(&sb->s_umount);
> + rwsem_assert_held_write(&sb->s_umount);
>
> /* Cannot turn off usage accounting without turning off limits, or
> * suspend quotas and simultaneously turn quotas off. */
> @@ -2510,9 +2508,7 @@ int dquot_resume(struct super_block *sb, int type)
> int ret = 0, cnt;
> unsigned int flags;
>
> - /* s_umount should be held in exclusive mode */
> - if (WARN_ON_ONCE(down_read_trylock(&sb->s_umount)))
> - up_read(&sb->s_umount);
> + rwsem_assert_held_write(&sb->s_umount);
>
> for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
> if (type != -1 && cnt != type)
> --
> 2.39.2
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2024-06-03 11:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-02 12:37 [PATCH] vfs: replace WARN(down_read_trylock, ...) abuse with proper asserts Mateusz Guzik
2024-06-03 11:09 ` Jan Kara [this message]
2024-06-03 13:47 ` Christian Brauner
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=20240603110957.we2e2af33qsesmmj@quack3 \
--to=jack@suse.cz \
--cc=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mjguzik@gmail.com \
--cc=viro@zeniv.linux.org.uk \
/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