vfs: replace WARN(down_read_trylock, ...) abuse with proper asserts
authorMateusz Guzik <mjguzik@gmail.com>
Sun, 2 Jun 2024 12:37:19 +0000 (14:37 +0200)
committerChristian Brauner <brauner@kernel.org>
Mon, 3 Jun 2024 13:45:47 +0000 (15:45 +0200)
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>
fs/dcache.c
fs/quota/dquot.c

index 1ee6404..58b89c9 100644 (file)
@@ -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;
index 627eb2f..a2b256d 100644 (file)
@@ -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)