• Nikolay Borisov's avatar
    btrfs: Handle pending/pinned chunks before blockgroup relocation during device shrink · 61d0d0d2
    Nikolay Borisov authored
    During device shrink pinned/pending chunks (i.e. those which have been
    deleted/created respectively, in the current transaction and haven't
    touched disk) need to be accounted when doing device shrink. Presently
    this happens after the main relocation loop in btrfs_shrink_device,
    which could lead to making another go in the body of the function.
    
    Since there is no hard requirement to perform pinned/pending chunks
    handling after the relocation loop, move the code before it. This leads
    to simplifying the code flow around - i.e. no need to use 'goto again'.
    
    A notable side effect of this change is that modification of the
    device's size requires a transaction to be started and committed before
    the relocation loop starts. This is necessary to ensure that relocation
    process sees the shrunk device size.
    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>
    61d0d0d2
volumes.c 207 KB