Skip to content

Commit 8ba0ae7

Browse files
asjkdave
authored andcommitted
btrfs: drop optimal argument from find_live_mirror()
Drop optimal argument from the function find_live_mirror() as we can deduce it in the function itself. Also rename optimal to preferred_mirror. Signed-off-by: Anand Jain <anand.jain@oracle.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 99f92a7 commit 8ba0ae7

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

fs/btrfs/volumes.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5275,10 +5275,11 @@ int btrfs_is_parity_mirror(struct btrfs_fs_info *fs_info, u64 logical, u64 len)
52755275

52765276
static int find_live_mirror(struct btrfs_fs_info *fs_info,
52775277
struct map_lookup *map, int first,
5278-
int optimal, int dev_replace_is_ongoing)
5278+
int dev_replace_is_ongoing)
52795279
{
52805280
int i;
52815281
int num_stripes;
5282+
int preferred_mirror;
52825283
int tolerance;
52835284
struct btrfs_device *srcdev;
52845285

@@ -5290,6 +5291,8 @@ static int find_live_mirror(struct btrfs_fs_info *fs_info,
52905291
else
52915292
num_stripes = map->num_stripes;
52925293

5294+
preferred_mirror = first + current->pid % num_stripes;
5295+
52935296
if (dev_replace_is_ongoing &&
52945297
fs_info->dev_replace.cont_reading_from_srcdev_mode ==
52955298
BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_AVOID)
@@ -5303,9 +5306,9 @@ static int find_live_mirror(struct btrfs_fs_info *fs_info,
53035306
* mirror is available
53045307
*/
53055308
for (tolerance = 0; tolerance < 2; tolerance++) {
5306-
if (map->stripes[optimal].dev->bdev &&
5307-
(tolerance || map->stripes[optimal].dev != srcdev))
5308-
return optimal;
5309+
if (map->stripes[preferred_mirror].dev->bdev &&
5310+
(tolerance || map->stripes[preferred_mirror].dev != srcdev))
5311+
return preferred_mirror;
53095312
for (i = first; i < first + num_stripes; i++) {
53105313
if (map->stripes[i].dev->bdev &&
53115314
(tolerance || map->stripes[i].dev != srcdev))
@@ -5316,7 +5319,7 @@ static int find_live_mirror(struct btrfs_fs_info *fs_info,
53165319
/* we couldn't find one that doesn't fail. Just return something
53175320
* and the io error handling code will clean up eventually
53185321
*/
5319-
return optimal;
5322+
return preferred_mirror;
53205323
}
53215324

53225325
static inline int parity_smaller(u64 a, u64 b)
@@ -5843,7 +5846,6 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info,
58435846
stripe_index = mirror_num - 1;
58445847
else {
58455848
stripe_index = find_live_mirror(fs_info, map, 0,
5846-
current->pid % map->num_stripes,
58475849
dev_replace_is_ongoing);
58485850
mirror_num = stripe_index + 1;
58495851
}
@@ -5871,8 +5873,6 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info,
58715873
int old_stripe_index = stripe_index;
58725874
stripe_index = find_live_mirror(fs_info, map,
58735875
stripe_index,
5874-
stripe_index +
5875-
current->pid % map->sub_stripes,
58765876
dev_replace_is_ongoing);
58775877
mirror_num = stripe_index - old_stripe_index + 1;
58785878
}

0 commit comments

Comments
 (0)