Skip to content

Commit 97894f7

Browse files
Christoph Hellwigliu-song-6
authored andcommitted
md/raid1: use the atomic queue limit update APIs
Build the queue limits outside the queue and apply them using queue_limits_set. To make the code more obvious also split the queue limits handling into a separate helper function. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed--by: Song Liu <[email protected]> Tested-by: Song Liu <[email protected]> Signed-off-by: Song Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 56cf22d commit 97894f7

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

drivers/md/raid1.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,12 +1926,11 @@ static int raid1_add_disk(struct mddev *mddev, struct md_rdev *rdev)
19261926
for (mirror = first; mirror <= last; mirror++) {
19271927
p = conf->mirrors + mirror;
19281928
if (!p->rdev) {
1929-
if (!mddev_is_dm(mddev))
1930-
disk_stack_limits(mddev->gendisk, rdev->bdev,
1931-
rdev->data_offset << 9);
1929+
err = mddev_stack_new_rdev(mddev, rdev);
1930+
if (err)
1931+
return err;
19321932

19331933
raid1_add_conf(conf, rdev, mirror, false);
1934-
err = 0;
19351934
/* As all devices are equivalent, we don't need a full recovery
19361935
* if this was recently any drive of the array
19371936
*/
@@ -3195,12 +3194,21 @@ static struct r1conf *setup_conf(struct mddev *mddev)
31953194
return ERR_PTR(err);
31963195
}
31973196

3197+
static int raid1_set_limits(struct mddev *mddev)
3198+
{
3199+
struct queue_limits lim;
3200+
3201+
blk_set_stacking_limits(&lim);
3202+
lim.max_write_zeroes_sectors = 0;
3203+
mddev_stack_rdev_limits(mddev, &lim);
3204+
return queue_limits_set(mddev->queue, &lim);
3205+
}
3206+
31983207
static void raid1_free(struct mddev *mddev, void *priv);
31993208
static int raid1_run(struct mddev *mddev)
32003209
{
32013210
struct r1conf *conf;
32023211
int i;
3203-
struct md_rdev *rdev;
32043212
int ret;
32053213

32063214
if (mddev->level != 1) {
@@ -3228,10 +3236,9 @@ static int raid1_run(struct mddev *mddev)
32283236
return PTR_ERR(conf);
32293237

32303238
if (!mddev_is_dm(mddev)) {
3231-
blk_queue_max_write_zeroes_sectors(mddev->queue, 0);
3232-
rdev_for_each(rdev, mddev)
3233-
disk_stack_limits(mddev->gendisk, rdev->bdev,
3234-
rdev->data_offset << 9);
3239+
ret = raid1_set_limits(mddev);
3240+
if (ret)
3241+
goto abort;
32353242
}
32363243

32373244
mddev->degraded = 0;

0 commit comments

Comments
 (0)