]> www.infradead.org Git - users/hch/misc.git/commitdiff
path_has_submounts(): use guard(mount_locked_reader)
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 2 Sep 2025 23:55:41 +0000 (19:55 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 16 Sep 2025 01:26:44 +0000 (21:26 -0400)
Needed there since the callback passed to d_walk() (path_check_mount())
is using __path_is_mountpoint(), which uses __lookup_mnt().

Has to be taken in the caller - d_walk() might take rename_lock spinlock
component and that nests inside mount_lock.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/dcache.c

index 60046ae23d5148730888da2250bd72df317d65ad..ab21a8402db03d5e41ee87c9549c12a0a5feea01 100644 (file)
@@ -1390,6 +1390,7 @@ struct check_mount {
        unsigned int mounted;
 };
 
+/* locks: mount_locked_reader && dentry->d_lock */
 static enum d_walk_ret path_check_mount(void *data, struct dentry *dentry)
 {
        struct check_mount *info = data;
@@ -1416,9 +1417,8 @@ int path_has_submounts(const struct path *parent)
 {
        struct check_mount data = { .mnt = parent->mnt, .mounted = 0 };
 
-       read_seqlock_excl(&mount_lock);
+       guard(mount_locked_reader)();
        d_walk(parent->dentry, &data, path_check_mount);
-       read_sequnlock_excl(&mount_lock);
 
        return data.mounted;
 }