• Josef Bacik's avatar
    btrfs: add get_tree callback for new mount API · 3bb17a25
    Josef Bacik authored
    This is the actual mounting callback for the new mount API.  Implement
    this using our current fill super as a guideline, making the appropriate
    adjustments for the new mount API.
    
    Our old mount operation had two fs_types, one to handle the actual
    opening, and the one that we called to handle the actual opening and
    then did the subvol lookup for returning the actual root dentry.  This
    is mirrored here, but simply with different behaviors for ->get_tree.
    We use the existence of ->s_fs_info to tell which part we're in.  The
    initial call allocates the fs_info, then call mount_fc() with a
    duplicated fc to do the actual open_ctree part.  Then we take that
    vfsmount and use it to look up our subvolume that we're mounting and
    return that as our s_root.  This idea was taken from Christians attempt
    to convert us to the new mount API [1].
    
    In btrfs_get_tree_super() the mount device is scanned and opened in one
    go under uuid_mutex we expect that all related devices have been already
    scanned, either by mount or from the outside. A device forget can be
    called on some of the devices as the whole context is not protected but
    it's an unlikely event, though it's a minor behaviour change.
    
    References: https://lore.kernel.org/all/20230626-fs-btrfs-mount-api-v1-2-045e9735a00b@kernel.org/Reviewed-by: default avatarChristian Brauner <brauner@kernel.org>
    Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
    Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    [ add note about device scanning ]
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    3bb17a25
super.c 96.6 KB