]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
bcachefs: Fix bch2_fs_get_tree() error path
authorFlorian Albrechtskirchinger <falbrechtskirchinger@gmail.com>
Thu, 27 Mar 2025 13:31:08 +0000 (14:31 +0100)
committerKent Overstreet <kent.overstreet@linux.dev>
Fri, 28 Mar 2025 17:51:09 +0000 (13:51 -0400)
When a filesystem is mounted read-only, subsequent attempts to mount it
as read-write fail with EBUSY. Previously, the error path in
bch2_fs_get_tree() would unconditionally call __bch2_fs_stop(),
improperly freeing resources for a filesystem that was still actively
mounted. This change modifies the error path to only call
__bch2_fs_stop() if the superblock has no valid root dentry, ensuring
resources are not cleaned up prematurely when the filesystem is in use.

Signed-off-by: Florian Albrechtskirchinger <falbrechtskirchinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/fs.c

index fbca200f763654374daace884e8c3d3105b5aced..89a30bde12206181e029497cff2c7b43dbbfef2a 100644 (file)
@@ -2290,7 +2290,8 @@ err_stop_fs:
        goto err;
 
 err_put_super:
-       __bch2_fs_stop(c);
+       if (!sb->s_root)
+               __bch2_fs_stop(c);
        deactivate_locked_super(sb);
        goto err;
 }