Skip to content

Commit 06bae87

Browse files
ndosschekdave
authored andcommitted
btrfs: extend locking to all space_info members accesses
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. This could potentially race and lead to a flush instead of a commit but it's not a big problem as it's only for preemptive flush. CC: stable@vger.kernel.org # 5.15+ Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Niels Dossche <niels.dossche@ugent.be> Signed-off-by: Niels Dossche <dossche.niels@gmail.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent ca5e4ea commit 06bae87

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

fs/btrfs/space-info.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,6 @@ static void btrfs_preempt_reclaim_metadata_space(struct work_struct *work)
10611061
trans_rsv->reserved;
10621062
if (block_rsv_size < space_info->bytes_may_use)
10631063
delalloc_size = space_info->bytes_may_use - block_rsv_size;
1064-
spin_unlock(&space_info->lock);
10651064

10661065
/*
10671066
* 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)
10921091
flush = FLUSH_DELAYED_REFS_NR;
10931092
}
10941093

1094+
spin_unlock(&space_info->lock);
1095+
10951096
/*
10961097
* We don't want to reclaim everything, just a portion, so scale
10971098
* down the to_reclaim by 1/4. If it takes us down to 0,

0 commit comments

Comments
 (0)