Skip to content

Commit 5401813

Browse files
mjguzikbrauner
authored andcommitted
vfs: replace WARN(down_read_trylock, ...) abuse with proper asserts
Note the macro used here works regardless of LOCKDEP. Signed-off-by: Mateusz Guzik <mjguzik@gmail.com> Link: https://lore.kernel.org/r/20240602123720.775702-1-mjguzik@gmail.com Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 620c266 commit 5401813

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

fs/dcache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ void shrink_dcache_for_umount(struct super_block *sb)
15481548
{
15491549
struct dentry *dentry;
15501550

1551-
WARN(down_read_trylock(&sb->s_umount), "s_umount should've been locked");
1551+
rwsem_assert_held_write(&sb->s_umount);
15521552

15531553
dentry = sb->s_root;
15541554
sb->s_root = NULL;

fs/quota/dquot.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,9 +2246,7 @@ int dquot_disable(struct super_block *sb, int type, unsigned int flags)
22462246
int cnt;
22472247
struct quota_info *dqopt = sb_dqopt(sb);
22482248

2249-
/* s_umount should be held in exclusive mode */
2250-
if (WARN_ON_ONCE(down_read_trylock(&sb->s_umount)))
2251-
up_read(&sb->s_umount);
2249+
rwsem_assert_held_write(&sb->s_umount);
22522250

22532251
/* Cannot turn off usage accounting without turning off limits, or
22542252
* suspend quotas and simultaneously turn quotas off. */
@@ -2510,9 +2508,7 @@ int dquot_resume(struct super_block *sb, int type)
25102508
int ret = 0, cnt;
25112509
unsigned int flags;
25122510

2513-
/* s_umount should be held in exclusive mode */
2514-
if (WARN_ON_ONCE(down_read_trylock(&sb->s_umount)))
2515-
up_read(&sb->s_umount);
2511+
rwsem_assert_held_write(&sb->s_umount);
25162512

25172513
for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
25182514
if (type != -1 && cnt != type)

0 commit comments

Comments
 (0)