Skip to content

Commit

Permalink
md/raid0: use the atomic queue limit update APIs
Browse files Browse the repository at this point in the history
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 <hch@lst.de>
Reviewed--by: Song Liu <song@kernel.org>
Tested-by: Song Liu <song@kernel.org>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20240303140150.5435-6-hch@lst.de
  • Loading branch information
Christoph Hellwig authored and Song Liu committed Mar 6, 2024
1 parent e305fce commit 56cf22d
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions drivers/md/raid0.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,19 @@ static void raid0_free(struct mddev *mddev, void *priv)
free_conf(mddev, conf);
}

static int raid0_set_limits(struct mddev *mddev)
{
struct queue_limits lim;

blk_set_stacking_limits(&lim);
lim.max_hw_sectors = mddev->chunk_sectors;
lim.max_write_zeroes_sectors = mddev->chunk_sectors;
lim.io_min = mddev->chunk_sectors << 9;
lim.io_opt = lim.io_min * mddev->raid_disks;
mddev_stack_rdev_limits(mddev, &lim);
return queue_limits_set(mddev->queue, &lim);
}

static int raid0_run(struct mddev *mddev)
{
struct r0conf *conf;
Expand All @@ -400,19 +413,9 @@ static int raid0_run(struct mddev *mddev)
}
conf = mddev->private;
if (!mddev_is_dm(mddev)) {
struct md_rdev *rdev;

blk_queue_max_hw_sectors(mddev->queue, mddev->chunk_sectors);
blk_queue_max_write_zeroes_sectors(mddev->queue, mddev->chunk_sectors);

blk_queue_io_min(mddev->queue, mddev->chunk_sectors << 9);
blk_queue_io_opt(mddev->queue,
(mddev->chunk_sectors << 9) * mddev->raid_disks);

rdev_for_each(rdev, mddev) {
disk_stack_limits(mddev->gendisk, rdev->bdev,
rdev->data_offset << 9);
}
ret = raid0_set_limits(mddev);
if (ret)
goto out_free_conf;
}

/* calculate array device size */
Expand All @@ -426,8 +429,10 @@ static int raid0_run(struct mddev *mddev)

ret = md_integrity_register(mddev);
if (ret)
free_conf(mddev, conf);

goto out_free_conf;
return 0;
out_free_conf:
free_conf(mddev, conf);
return ret;
}

Expand Down

0 comments on commit 56cf22d

Please sign in to comment.