bytes_pinned is always accessed under space_info->lock, except in
btrfs_preempt_reclaim_metadata_space, however the other members are
accessed under that lock. The reserved member of the rsv's are also
partially accessed under a lock and partially not. Move all these
accesses into the same lock to ensure consistency.
Signed-off-by: Niels Dossche <[email protected]>
Signed-off-by: Niels Dossche <[email protected]>
---
fs/btrfs/space-info.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
index 294242c194d8..62382ae1eb02 100644
--- a/fs/btrfs/space-info.c
+++ b/fs/btrfs/space-info.c
@@ -1061,7 +1061,6 @@ static void btrfs_preempt_reclaim_metadata_space(struct work_struct *work)
trans_rsv->reserved;
if (block_rsv_size < space_info->bytes_may_use)
delalloc_size = space_info->bytes_may_use - block_rsv_size;
- spin_unlock(&space_info->lock);
/*
* We don't want to include the global_rsv in our calculation,
@@ -1092,6 +1091,8 @@ static void btrfs_preempt_reclaim_metadata_space(struct work_struct *work)
flush = FLUSH_DELAYED_REFS_NR;
}
+ spin_unlock(&space_info->lock);
+
/*
* We don't want to reclaim everything, just a portion, so scale
* down the to_reclaim by 1/4. If it takes us down to 0,
--
2.35.1
On Fri, Feb 25, 2022 at 10:20:28PM +0100, Niels Dossche wrote:
> bytes_pinned is always accessed under space_info->lock, except in
> btrfs_preempt_reclaim_metadata_space, however the other members are
> accessed under that lock. The reserved member of the rsv's are also
> partially accessed under a lock and partially not. Move all these
> accesses into the same lock to ensure consistency.
>
> Signed-off-by: Niels Dossche <[email protected]>
> Signed-off-by: Niels Dossche <[email protected]>
Reviewed-by: Josef Bacik <[email protected]>
Thanks,
Josef
On Fri, Feb 25, 2022 at 10:20:28PM +0100, Niels Dossche wrote:
> bytes_pinned is always accessed under space_info->lock, except in
> btrfs_preempt_reclaim_metadata_space, however the other members are
> accessed under that lock. The reserved member of the rsv's are also
> partially accessed under a lock and partially not. Move all these
> accesses into the same lock to ensure consistency.
>
> Signed-off-by: Niels Dossche <[email protected]>
> Signed-off-by: Niels Dossche <[email protected]>
Added to misc-next, thanks.