OSDN Git Service

btrfs: Separate space_info create/update
authorNikolay Borisov <nborisov@suse.com>
Mon, 22 May 2017 06:35:49 +0000 (09:35 +0300)
committerDavid Sterba <dsterba@suse.com>
Mon, 19 Jun 2017 16:26:00 +0000 (18:26 +0200)
commit2be12ef79fe9f5333cb9fadc85ef20b6832a56d7
treece415bb63e2db297a99d78d2242bce5404e985aa
parent555ba411aa33c9241e78ff37afc40f6a33721620
btrfs: Separate space_info create/update

Currently the struct space_info creation code is intermixed in the
udpate_space_info function. There are well-defined points at which the
we actually want to create brand-new space_info structs (e.g. during
mount of the filesystem as well as sometimes when adding/initialising
new chunks). In such cases update_space_info is called with 0 as the
bytes parameter. All of this makes for spaghetti code.

Fix it by factoring out the creation code in a separate
create_space_info structure. This also allows to simplify the internals.
Also remove BUG_ON from do_alloc_chunk since the callers handle errors.
Furthermore it will make the update_space_info function not fail,
allowing us to remove error handling in callers. This will come in a
follow up patch.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c