[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240328-hans-v1-1-4cd558959407@kernel.org>
Date: Thu, 28 Mar 2024 14:56:31 +0100
From: Johannes Thumshirn <jth@...nel.org>
To: Chris Mason <clm@...com>, Josef Bacik <josef@...icpanda.com>,
David Sterba <dsterba@...e.com>
Cc: linux-btrfs@...r.kernel.org, linux-kernel@...r.kernel.org,
Hans Holmberg <Hans.Holmberg@....com>, Naohiro Aota <Naohiro.Aota@....com>,
hch@....de, Damien LeMoal <dlemoal@...nel.org>, Boris Burkov <boris@....io>,
Johannes Thumshirn <johannes.thumshirn@....com>
Subject: [PATCH RFC PATCH 1/3] btrfs: zoned: traverse device list in should
reclaim under rcu_read_lock
From: Johannes Thumshirn <johannes.thumshirn@....com>
As btrfs_zoned_should_reclaim() traverses the device list with the
device_list_mutex held. But we're never changing the device list. All we
do is gathering the used and total bytes.
So change the list traversal from the holding the device_list_mutex to
rcu_read_lock(). This also opens up the possibilities to call
btrfs_zoned_should_reclaim() with the chunk_mutex held.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@....com>
---
fs/btrfs/zoned.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 4cba80b34387..d51faf7f4162 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -2446,7 +2446,7 @@ bool btrfs_zoned_should_reclaim(struct btrfs_fs_info *fs_info)
if (fs_info->bg_reclaim_threshold == 0)
return false;
- mutex_lock(&fs_devices->device_list_mutex);
+ rcu_read_lock();
list_for_each_entry(device, &fs_devices->devices, dev_list) {
if (!device->bdev)
continue;
@@ -2454,7 +2454,7 @@ bool btrfs_zoned_should_reclaim(struct btrfs_fs_info *fs_info)
total += device->disk_total_bytes;
used += device->bytes_used;
}
- mutex_unlock(&fs_devices->device_list_mutex);
+ rcu_read_unlock();
factor = div64_u64(used * 100, total);
return factor >= fs_info->bg_reclaim_threshold;
--
2.35.3
Powered by blists - more mailing lists