Message ID | 3c6359337ba942d628b989cc7458cde4d9a5373a.1707491248.git.fdmanana@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: cleanups and minor performance change to setting/clearing delalloc | expand |
On 2024/2/10 04:30, fdmanana@kernel.org wrote: > From: Filipe Manana <fdmanana@suse.com> > > The merge and split callbacks for an inode's io tree are supposed to be > called while the io tree's spinlock is being held, so that the given > extent_state records are stable, not modified or freed while the callbacks > are using them. So add lockdep assertions in the callbacks. > > Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Thanks, Qu > --- > fs/btrfs/inode.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c > index 778bb6754e00..c7a5fb1f8b3e 100644 > --- a/fs/btrfs/inode.c > +++ b/fs/btrfs/inode.c > @@ -2300,6 +2300,8 @@ void btrfs_split_delalloc_extent(struct btrfs_inode *inode, > struct btrfs_fs_info *fs_info = inode->root->fs_info; > u64 size; > > + lockdep_assert_held(&inode->io_tree.lock); > + > /* not delalloc, ignore it */ > if (!(orig->state & EXTENT_DELALLOC)) > return; > @@ -2338,6 +2340,8 @@ void btrfs_merge_delalloc_extent(struct btrfs_inode *inode, struct extent_state > u64 new_size, old_size; > u32 num_extents; > > + lockdep_assert_held(&inode->io_tree.lock); > + > /* not delalloc, ignore it */ > if (!(other->state & EXTENT_DELALLOC)) > return;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 778bb6754e00..c7a5fb1f8b3e 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -2300,6 +2300,8 @@ void btrfs_split_delalloc_extent(struct btrfs_inode *inode, struct btrfs_fs_info *fs_info = inode->root->fs_info; u64 size; + lockdep_assert_held(&inode->io_tree.lock); + /* not delalloc, ignore it */ if (!(orig->state & EXTENT_DELALLOC)) return; @@ -2338,6 +2340,8 @@ void btrfs_merge_delalloc_extent(struct btrfs_inode *inode, struct extent_state u64 new_size, old_size; u32 num_extents; + lockdep_assert_held(&inode->io_tree.lock); + /* not delalloc, ignore it */ if (!(other->state & EXTENT_DELALLOC)) return;