On 1/23/20 7:30 AM, Nikolay Borisov wrote:
On 17.01.20 г. 23:26 ч., Josef Bacik wrote:
In adding things like eb leak checking and root leak checking there were
a lot of weird corner cases that come from the fact that
1) We do not init the fs_info until we get to open_ctree time in the
normal case and
2) The test infrastructure half-init's the fs_info for things that it
needs.
This makes it really annoying to make changes because you have to add
init in two different places, have special cases for testing fs_info's
that may not have certain things init'ed, and cases for fs_info's that
didn't make it to open_ctree and thus are not fully init'ed.
Fix this by extracting out the non-allocating init of the fs info into
it's own public function and use that to make sure we're all getting
consistent views of an allocated fs_info.
Imo it will be better if btrfs_init_fs_info is called from
init_mount_fs_info. And then called explicitly from the test code. That
way we keep the initialization close. Otherwise having it in
btrfs_mount_root is just confusing and not very obvious what's going on.
I'm not sure what's confusing about it, we're allocating the structure and then
initializing it. And as I point out in the changelog, this is necessary because
the error handling is bonkers because we can fail at multiple places _before_
open_ctree, and having random garbage in the fs_info makes proper cleanup a
pain. Thus it _has_ to be exported and the fs_info _has_ to have it's static
elements properly initialized in order to make cleanup in the error cases clean
and sane. Thanks,
Josef