• Boris Burkov's avatar
    btrfs: lift read-write mount setup from mount and remount · 44c0ca21
    Boris Burkov authored
    Mounting rw and remounting from ro to rw naturally share invariants and
    functionality which result in a correctly setup rw filesystem. Luckily,
    there is even a strong unity in the code which implements them. In
    mount's open_ctree, these operations mostly happen after an early return
    for ro file systems, and in remount, they happen in a section devoted to
    remounting ro->rw, after some remount specific validation passes.
    
    However, there are unfortunately a few differences. There are small
    deviations in the order of some of the operations, remount does not
    start orphan cleanup in root_tree or fs_tree, remount does not create
    the free space tree, and remount does not handle "one-shot" mount
    options like clear_cache and uuid tree rescan.
    
    Since we want to add building the free space tree to remount, and also
    to start the same orphan cleanup process on a filesystem mounted as ro
    then remounted rw, we would benefit from unifying the logic between the
    two code paths.
    
    This patch only lifts the existing common functionality, and leaves a
    natural path for fixing the discrepancies.
    Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
    Signed-off-by: default avatarBoris Burkov <boris@bur.io>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    44c0ca21
disk-io.h 5.45 KB