btrfs: Handle pending/pinned chunks before blockgroup relocation during device shrink
authorNikolay Borisov <nborisov@suse.com>
Mon, 25 Mar 2019 12:31:23 +0000 (14:31 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 29 Apr 2019 17:02:36 +0000 (19:02 +0200)
commit61d0d0d2cbb7e52d3defe8089d5f360cf6d836ef
tree962c4198e51d879d60578177abe92a2857f164e9
parentbbbf7243d62d8be73b7ef60721c127b36b2d523e
btrfs: Handle pending/pinned chunks before blockgroup relocation during device shrink

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: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c