Skip to content

Commit

Permalink
md: pass in max_sectors for pers->sync_request()
Browse files Browse the repository at this point in the history
For different sync_action, sync_thread will use different max_sectors,
see details in md_sync_max_sectors(), currently both md_do_sync() and
pers->sync_request() in eatch iteration have to get the same
max_sectors. Hence pass in max_sectors for pers->sync_request() to
prevent redundant code.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
  • Loading branch information
YuKuai-huawei authored and intel-lab-lkp committed Jun 3, 2024
1 parent 85e49aa commit e148a76
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
5 changes: 3 additions & 2 deletions drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -9186,7 +9186,8 @@ void md_do_sync(struct md_thread *thread)
if (test_bit(MD_RECOVERY_INTR, &mddev->recovery))
break;

sectors = mddev->pers->sync_request(mddev, j, &skipped);
sectors = mddev->pers->sync_request(mddev, j, max_sectors,
&skipped);
if (sectors == 0) {
set_bit(MD_RECOVERY_INTR, &mddev->recovery);
break;
Expand Down Expand Up @@ -9276,7 +9277,7 @@ void md_do_sync(struct md_thread *thread)
mddev->curr_resync_completed = mddev->curr_resync;
sysfs_notify_dirent_safe(mddev->sysfs_completed);
}
mddev->pers->sync_request(mddev, max_sectors, &skipped);
mddev->pers->sync_request(mddev, max_sectors, max_sectors, &skipped);

if (!test_bit(MD_RECOVERY_CHECK, &mddev->recovery) &&
mddev->curr_resync > MD_RESYNC_ACTIVE) {
Expand Down
3 changes: 2 additions & 1 deletion drivers/md/md.h
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,8 @@ struct md_personality
int (*hot_add_disk) (struct mddev *mddev, struct md_rdev *rdev);
int (*hot_remove_disk) (struct mddev *mddev, struct md_rdev *rdev);
int (*spare_active) (struct mddev *mddev);
sector_t (*sync_request)(struct mddev *mddev, sector_t sector_nr, int *skipped);
sector_t (*sync_request)(struct mddev *mddev, sector_t sector_nr,
sector_t max_sector, int *skipped);
int (*resize) (struct mddev *mddev, sector_t sectors);
sector_t (*size) (struct mddev *mddev, sector_t sectors, int raid_disks);
int (*check_reshape) (struct mddev *mddev);
Expand Down
5 changes: 2 additions & 3 deletions drivers/md/raid1.c
Original file line number Diff line number Diff line change
Expand Up @@ -2757,12 +2757,12 @@ static struct r1bio *raid1_alloc_init_r1buf(struct r1conf *conf)
*/

static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
int *skipped)
sector_t max_sector, int *skipped)
{
struct r1conf *conf = mddev->private;
struct r1bio *r1_bio;
struct bio *bio;
sector_t max_sector, nr_sectors;
sector_t nr_sectors;
int disk = -1;
int i;
int wonly = -1;
Expand All @@ -2778,7 +2778,6 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
if (init_resync(conf))
return 0;

max_sector = mddev->dev_sectors;
if (sector_nr >= max_sector) {
/* If we aborted, we need to abort the
* sync on the 'current' bitmap chunk (there will
Expand Down
8 changes: 2 additions & 6 deletions drivers/md/raid10.c
Original file line number Diff line number Diff line change
Expand Up @@ -3140,12 +3140,12 @@ static void raid10_set_cluster_sync_high(struct r10conf *conf)
*/

static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
int *skipped)
sector_t max_sector, int *skipped)
{
struct r10conf *conf = mddev->private;
struct r10bio *r10_bio;
struct bio *biolist = NULL, *bio;
sector_t max_sector, nr_sectors;
sector_t nr_sectors;
int i;
int max_sync;
sector_t sync_blocks;
Expand Down Expand Up @@ -3175,10 +3175,6 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
return 0;

skipped:
max_sector = mddev->dev_sectors;
if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery) ||
test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery))
max_sector = mddev->resync_max_sectors;
if (sector_nr >= max_sector) {
conf->cluster_sync_low = 0;
conf->cluster_sync_high = 0;
Expand Down
3 changes: 1 addition & 2 deletions drivers/md/raid5.c
Original file line number Diff line number Diff line change
Expand Up @@ -6459,11 +6459,10 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr, int *sk
}

static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_nr,
int *skipped)
sector_t max_sector, int *skipped)
{
struct r5conf *conf = mddev->private;
struct stripe_head *sh;
sector_t max_sector = mddev->dev_sectors;
sector_t sync_blocks;
int still_degraded = 0;
int i;
Expand Down

0 comments on commit e148a76

Please sign in to comment.