Skip to content

Commit

Permalink
btrfs: add comments regarding locking to struct btrfs_delayed_ref_root
Browse files Browse the repository at this point in the history
Add some comments to struct btrfs_delayed_ref_root's fields to mention
what its spinlock protects.

Reviewed-by: Boris Burkov <boris@bur.io>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
fdmanana authored and kdave committed Nov 11, 2024
1 parent a8985ac commit d3aaeea
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions fs/btrfs/delayed-ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,19 +213,33 @@ struct btrfs_delayed_ref_root {
*/
struct xarray dirty_extents;

/* this spin lock protects the rbtree and the entries inside */
/*
* Protects the rbtree href_root, its entries and the following fields:
* num_heads, num_heads_ready, pending_csums and run_delayed_start.
*/
spinlock_t lock;

/* total number of head nodes in tree */
/* Total number of head refs, protected by the spinlock 'lock'. */
unsigned long num_heads;

/* total number of head nodes ready for processing */
/*
* Total number of head refs ready for processing, protected by the
* spinlock 'lock'.
*/
unsigned long num_heads_ready;

/*
* Track space reserved for deleting csums of data extents.
* Protected by the spinlock 'lock'.
*/
u64 pending_csums;

unsigned long flags;

/*
* Track from which bytenr to start searching ref heads.
* Protected by the spinlock 'lock'.
*/
u64 run_delayed_start;

/*
Expand Down

0 comments on commit d3aaeea

Please sign in to comment.