linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/45][v2] Cleanup how we handle root refs, part 1
@ 2019-12-17 15:35 Josef Bacik
  2019-12-17 15:35 ` [PATCH 01/45] btrfs: push __setup_root into btrfs_alloc_root Josef Bacik
                   ` (44 more replies)
  0 siblings, 45 replies; 46+ messages in thread
From: Josef Bacik @ 2019-12-17 15:35 UTC (permalink / raw)
  To: linux-btrfs, kernel-team

v1->v2:
- Fixed a error missed put in an error condition in relink_extent_backref
- Added "btrfs: make the init of static elements in fs_info" so that we could
  clean up fs_info init and make the leak detectors work for the self tests.

-- original email --
In testing with the recent fsstress I stumbled upon a deadlock in how we deal
with disappearing subvolumes.  We sort of half-ass a srcu lock to protect us,
but it's used inconsistently so doesn't really provide us with actual
protection, mostly it just makes us feel good.

In order to do away with this srcu thing we need to have proper ref counting for
our roots.  We currently refcount them, but only to handle the actual kfree, it
doesn't really control the lifetime of the root.  And again, this is not done in
any sort of consistent manner so it doesn't actually protect us.

This is the first set of patches, and yes I realize there are a lot of them.
Most of them are just "hold a ref on the root" in all of the call sites that
called btrfs_read_fs_root*() variations.  Now that we're going to actually hold
references to roots we need to make sure we put the reference when we're done
with them, so these patches go through each callsite and make sure we drop the
references appropriately.

Then there's a variety of cleanups and consolidations to make things clearer and
make it so we only have 1 place to get roots.

Finally there's the root leak detection patch.  I used this with a bunch of
testing to make sure I was never leaking roots with these patches.  I've been
testing these for several weeks cleaning up all the corners, so they should be
in relatively good shape.  Most of the patches are small so straightforward to
review.

This is just part 1, this is the prep work we need to make the root lifetime a
little saner, and will allow us to drop the subvol srcu, as well as the inode
rbtree.  It doesn't really fundamentally change how roots are handled other than
making the refcounting actually protect us from freeing the root while we're
using it.  That work will come later.  Thanks,

Josef



^ permalink raw reply	[flat|nested] 46+ messages in thread

end of thread, other threads:[~2019-12-17 15:38 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-17 15:35 [PATCH 0/45][v2] Cleanup how we handle root refs, part 1 Josef Bacik
2019-12-17 15:35 ` [PATCH 01/45] btrfs: push __setup_root into btrfs_alloc_root Josef Bacik
2019-12-17 15:35 ` [PATCH 02/45] btrfs: move fs root init stuff into btrfs_init_fs_root Josef Bacik
2019-12-17 15:35 ` [PATCH 03/45] btrfs: make btrfs_find_orphan_roots use btrfs_get_fs_root Josef Bacik
2019-12-17 15:35 ` [PATCH 04/45] btrfs: export and use btrfs_read_tree_root Josef Bacik
2019-12-17 15:35 ` [PATCH 05/45] btrfs: make relocation use btrfs_read_tree_root() Josef Bacik
2019-12-17 15:35 ` [PATCH 06/45] btrfs: kill btrfs_read_fs_root Josef Bacik
2019-12-17 15:35 ` [PATCH 07/45] btrfs: kill the btrfs_read_fs_root_no_name helper Josef Bacik
2019-12-17 15:35 ` [PATCH 08/45] btrfs: make the fs root init functions static Josef Bacik
2019-12-17 15:35 ` [PATCH 09/45] btrfs: handle NULL roots in btrfs_put/btrfs_grab_fs_root Josef Bacik
2019-12-17 15:36 ` [PATCH 10/45] btrfs: hold a ref on fs roots while they're in the radix tree Josef Bacik
2019-12-17 15:36 ` [PATCH 11/45] btrfs: hold a ref on the root in resolve_indirect_ref Josef Bacik
2019-12-17 15:36 ` [PATCH 12/45] btrfs: hold a root ref in btrfs_get_dentry Josef Bacik
2019-12-17 15:36 ` [PATCH 13/45] btrfs: hold a ref on the root in __btrfs_run_defrag_inode Josef Bacik
2019-12-17 15:36 ` [PATCH 14/45] btrfs: hold a ref for the root in record_one_backref Josef Bacik
2019-12-17 15:36 ` [PATCH 15/45] btrfs: grab a ref on the root in relink_extent_backref Josef Bacik
2019-12-17 15:36 ` [PATCH 16/45] btrfs: hold a ref on the root in fixup_tree_root_location Josef Bacik
2019-12-17 15:36 ` [PATCH 17/45] btrfs: hold a ref on the root in create_subvol Josef Bacik
2019-12-17 15:36 ` [PATCH 18/45] btrfs: hold a ref on the root in search_ioctl Josef Bacik
2019-12-17 15:36 ` [PATCH 19/45] btrfs: hold a ref on the root in btrfs_search_path_in_tree Josef Bacik
2019-12-17 15:36 ` [PATCH 20/45] btrfs: hold a ref on the root in btrfs_search_path_in_tree_user Josef Bacik
2019-12-17 15:36 ` [PATCH 21/45] btrfs: hold a ref on the root in btrfs_ioctl_get_subvol_info Josef Bacik
2019-12-17 15:36 ` [PATCH 22/45] btrfs: hold ref on root in btrfs_ioctl_default_subvol Josef Bacik
2019-12-17 15:36 ` [PATCH 23/45] btrfs: hold a ref on the root in build_backref_tree Josef Bacik
2019-12-17 15:36 ` [PATCH 24/45] btrfs: hold a ref on the root in prepare_to_merge Josef Bacik
2019-12-17 15:36 ` [PATCH 25/45] btrfs: hold a ref on the root in merge_reloc_roots Josef Bacik
2019-12-17 15:36 ` [PATCH 26/45] btrfs: hold a ref on the root in record_reloc_root_in_trans Josef Bacik
2019-12-17 15:36 ` [PATCH 27/45] btrfs: hold a ref on the root in find_data_references Josef Bacik
2019-12-17 15:36 ` [PATCH 28/45] btrfs: hold a ref on the root in create_reloc_inode Josef Bacik
2019-12-17 15:36 ` [PATCH 29/45] btrfs: hold a ref on the root in btrfs_recover_relocation Josef Bacik
2019-12-17 15:36 ` [PATCH 30/45] btrfs: push grab_fs_root into read_fs_root Josef Bacik
2019-12-17 15:36 ` [PATCH 31/45] btrfs: hold a ref for the root in btrfs_find_orphan_roots Josef Bacik
2019-12-17 15:36 ` [PATCH 32/45] btrfs: hold a ref on the root in scrub_print_warning_inode Josef Bacik
2019-12-17 15:36 ` [PATCH 33/45] btrfs: hold a ref on the root in btrfs_ioctl_send Josef Bacik
2019-12-17 15:36 ` [PATCH 34/45] btrfs: hold a ref on the root in get_subvol_name_from_objectid Josef Bacik
2019-12-17 15:36 ` [PATCH 35/45] btrfs: hold a ref on the root in create_pending_snapshot Josef Bacik
2019-12-17 15:36 ` [PATCH 36/45] btrfs: hold a ref on the root in btrfs_recover_log_trees Josef Bacik
2019-12-17 15:36 ` [PATCH 37/45] btrfs: hold a ref on the root in btrfs_check_uuid_tree_entry Josef Bacik
2019-12-17 15:36 ` [PATCH 38/45] btrfs: hold a ref on the root in open_ctree Josef Bacik
2019-12-17 15:36 ` [PATCH 39/45] btrfs: use btrfs_put_fs_root to free roots always Josef Bacik
2019-12-17 15:36 ` [PATCH 40/45] btrfs: push btrfs_grab_fs_root into btrfs_get_fs_root Josef Bacik
2019-12-17 15:36 ` [PATCH 41/45] btrfs: free more things in btrfs_free_fs_info Josef Bacik
2019-12-17 15:36 ` [PATCH 42/45] btrfs: move fs_info init work into it's own helper function Josef Bacik
2019-12-17 15:36 ` [PATCH 43/45] btrfs: make the init of static elements in fs_info separate Josef Bacik
2019-12-17 15:36 ` [PATCH 44/45] btrfs: add a leak check for roots Josef Bacik
2019-12-17 15:36 ` [PATCH 45/45] btrfs: rename btrfs_put_fs_root and btrfs_grab_fs_root Josef Bacik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).