diff mbox series

[1/2] btrfs: cleanup fs_devices pointer usage in btrfs_trim_fs

Message ID f2c9215ef5edac3b142c78043249e69600f2c557.1625237377.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series misc cleanup patches | expand

Commit Message

Anand Jain July 4, 2021, 12:04 p.m. UTC
Drop variable
  struct list_head *devices
and add new variable
  struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;

so that fs_devices is used at two locations within btrfs_trim_fs() function
and also helps to access fs_devices->devices.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/extent-tree.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

David Sterba July 7, 2021, 3:06 p.m. UTC | #1
On Sun, Jul 04, 2021 at 08:04:57PM +0800, Anand Jain wrote:
> Drop variable
>   struct list_head *devices
> and add new variable
>   struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
> 
> so that fs_devices is used at two locations within btrfs_trim_fs() function
> and also helps to access fs_devices->devices.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>

Added to misc-next, thanks.
diff mbox series

Patch

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 268ce58d4569..d5925bebd379 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -5950,9 +5950,9 @@  static int btrfs_trim_free_extents(struct btrfs_device *device, u64 *trimmed)
  */
 int btrfs_trim_fs(struct btrfs_fs_info *fs_info, struct fstrim_range *range)
 {
+	struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
 	struct btrfs_block_group *cache = NULL;
 	struct btrfs_device *device;
-	struct list_head *devices;
 	u64 group_trimmed;
 	u64 range_end = U64_MAX;
 	u64 start;
@@ -6016,9 +6016,9 @@  int btrfs_trim_fs(struct btrfs_fs_info *fs_info, struct fstrim_range *range)
 		btrfs_warn(fs_info,
 			"failed to trim %llu block group(s), last error %d",
 			bg_failed, bg_ret);
-	mutex_lock(&fs_info->fs_devices->device_list_mutex);
-	devices = &fs_info->fs_devices->devices;
-	list_for_each_entry(device, devices, dev_list) {
+
+	mutex_lock(&fs_devices->device_list_mutex);
+	list_for_each_entry(device, &fs_devices->devices, dev_list) {
 		if (test_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state))
 			continue;
 
@@ -6031,7 +6031,7 @@  int btrfs_trim_fs(struct btrfs_fs_info *fs_info, struct fstrim_range *range)
 
 		trimmed += group_trimmed;
 	}
-	mutex_unlock(&fs_info->fs_devices->device_list_mutex);
+	mutex_unlock(&fs_devices->device_list_mutex);
 
 	if (dev_failed)
 		btrfs_warn(fs_info,