• Nikolay Borisov's avatar
    btrfs: Handle one more split-brain scenario during fsid change · 7a62d0f0
    Nikolay Borisov authored
    This commit continues hardening the scanning code to handle cases where
    power loss could have caused disks in a multi-disk filesystem to be
    in inconsistent state. Namely handle the situation that can occur when
    some of the disks in multi-disk fs have completed their fsid change i.e
    they have METADATA_UUID incompat flag set, have cleared the
    CHANGING_FSID_V2 flag and their fsid/metadata_uuid are different. At
    the same time the other half of the disks will have their
    fsid/metadata_uuid unchanged and will only have CHANGING_FSID_V2 flag.
    
    This is handled by introducing code in the scan path which:
    
     a) Handles the case when a device with CHANGING_FSID_V2 flag is
     scanned and as a result btrfs_fs_devices is created with matching
     fsid/metdata_uuid. Subsequently, when a device with completed fsid
     change is scanned it will detect this via the new code in find_fsid
     i.e that such an fs_devices exist that fsid_change flag is set to true,
     it's metadata_uuid/fsid match and the metadata_uuid of the scanned
     device matches that of the fs_devices. In this case, it's important to
     note that the devices which has its fsid change completed will have a
     higher generation number than the device with FSID_CHANGING_V2 flag
     set, so its superblock block will be used during mount. To prevent an
     assertion triggering because the sb used for mounting will have
     differing fsid/metadata_uuid than the ones in the fs_devices struct
     also add code in device_list_add which overwrites the values in
     fs_devices.
    
     b) Alternatively we can end up with a device that completed its
     fsid change be scanned first which will create the respective
     btrfs_fs_devices struct with differing fsid/metadata_uuid. In this
     case when a device with FSID_CHANGING_V2 flag set is scanned it will
     call the newly added find_fsid_inprogress function which will return
     the correct fs_devices.
    Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    7a62d0f0
volumes.c 205 KB