OSDN Git Service

btrfs: Factor out tree roots initialization during mount
authorNikolay Borisov <nborisov@suse.com>
Tue, 15 Oct 2019 15:42:20 +0000 (18:42 +0300)
committerDavid Sterba <dsterba@suse.com>
Mon, 18 Nov 2019 16:51:46 +0000 (17:51 +0100)
commitb8522a1e5f421e003a8d2a8937eb3a095ce33f5d
tree5c4ce9efdf2fb3a492e1b54152105d903359048e
parentbd2336b2ac119e65457261528883d9623d41315f
btrfs: Factor out tree roots initialization during mount

The code responsible for reading and initializing tree roots is
scattered in open_ctree among 2 labels, emulating a loop. This is rather
confusing to reason about. Instead, factor the code to a new function,
init_tree_roots which implements the same logical flow.

There are a couple of notable differences, namely:

* Instead of using next_backup_root it's using the newly introduced
  read_backup_root.

* If read_backup_root returns an error init_tree_roots propagates the
  error and there is no special handling of that case e.g. the code jumps
  straight to 'fail_tree_roots' label. The old code, however, was
  (erroneously) jumping to 'fail_block_groups' label if next_backup_root
  did fail, this was unnecessary since the tree roots init logic doesn't
  modify the state of block groups.

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/disk-io.c