Message ID | 20240226103004.281412-7-hch@lst.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [01/16] block: add a queue_limits_set helper | expand |
Hi, 在 2024/02/26 18:29, Christoph Hellwig 写道: > Build the queue limits outside the queue and apply them using > queue_limits_set. Also remove the bogus ->gendisk and ->queue NULL > checks in the are while touching it. The checking of mddev->gendisk can't be removed, because this is used to distinguish dm-raid and md/raid. And the same for following patches. Thanks, Kuai > > Signed-off-by: Christoph Hellwig <hch@lst.de> > --- > drivers/md/raid1.c | 24 ++++++++++-------------- > 1 file changed, 10 insertions(+), 14 deletions(-) > > diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c > index 286f8b16c7bde7..752ff99736a636 100644 > --- a/drivers/md/raid1.c > +++ b/drivers/md/raid1.c > @@ -1791,10 +1791,9 @@ static int raid1_add_disk(struct mddev *mddev, struct md_rdev *rdev) > for (mirror = first; mirror <= last; mirror++) { > p = conf->mirrors + mirror; > if (!p->rdev) { > - if (mddev->gendisk) > - disk_stack_limits(mddev->gendisk, rdev->bdev, > - rdev->data_offset << 9); > - > + err = mddev_stack_new_rdev(mddev, rdev); > + if (err) > + return err; > p->head_position = 0; > rdev->raid_disk = mirror; > err = 0; > @@ -3089,9 +3088,9 @@ static struct r1conf *setup_conf(struct mddev *mddev) > static void raid1_free(struct mddev *mddev, void *priv); > static int raid1_run(struct mddev *mddev) > { > + struct queue_limits lim; > struct r1conf *conf; > int i; > - struct md_rdev *rdev; > int ret; > > if (mddev->level != 1) { > @@ -3118,15 +3117,12 @@ static int raid1_run(struct mddev *mddev) > if (IS_ERR(conf)) > return PTR_ERR(conf); > > - if (mddev->queue) > - blk_queue_max_write_zeroes_sectors(mddev->queue, 0); > - > - rdev_for_each(rdev, mddev) { > - if (!mddev->gendisk) > - continue; > - disk_stack_limits(mddev->gendisk, rdev->bdev, > - rdev->data_offset << 9); > - } > + blk_set_stacking_limits(&lim); > + lim.max_write_zeroes_sectors = 0; > + mddev_stack_rdev_limits(mddev, &lim); > + ret = queue_limits_set(mddev->queue, &lim); > + if (ret) > + goto abort; > > mddev->degraded = 0; > for (i = 0; i < conf->raid_disks; i++) >
On Mon, Feb 26, 2024 at 07:29:08PM +0800, Yu Kuai wrote: > Hi, > > 在 2024/02/26 18:29, Christoph Hellwig 写道: >> Build the queue limits outside the queue and apply them using >> queue_limits_set. Also remove the bogus ->gendisk and ->queue NULL >> checks in the are while touching it. > > The checking of mddev->gendisk can't be removed, because this is used to > distinguish dm-raid and md/raid. And the same for following patches. Ah. Well, we should make that more obvious then. This is what I currently have: http://git.infradead.org/?p=users/hch/block.git;a=shortlog;h=refs/heads/md-blk-limits particularly: http://git.infradead.org/?p=users/hch/block.git;a=commitdiff;h=24b2fd15f57f06629d2254ebec480e1e28b96636
On Tue, Feb 27, 2024 at 7:26 AM Christoph Hellwig <hch@lst.de> wrote: > > On Mon, Feb 26, 2024 at 07:29:08PM +0800, Yu Kuai wrote: > > Hi, > > > > 在 2024/02/26 18:29, Christoph Hellwig 写道: > >> Build the queue limits outside the queue and apply them using > >> queue_limits_set. Also remove the bogus ->gendisk and ->queue NULL > >> checks in the are while touching it. > > > > The checking of mddev->gendisk can't be removed, because this is used to > > distinguish dm-raid and md/raid. And the same for following patches. > > Ah. Well, we should make that more obvious then. This is what I > currently have: > > http://git.infradead.org/?p=users/hch/block.git;a=shortlog;h=refs/heads/md-blk-limits > > particularly: > > http://git.infradead.org/?p=users/hch/block.git;a=commitdiff;h=24b2fd15f57f06629d2254ebec480e1e28b96636 Yes! I was thinking about something like mddev_is_dm() to make these checks less confusing. Thanks! Song
Hi, 在 2024/02/28 5:54, Song Liu 写道: > On Tue, Feb 27, 2024 at 7:26 AM Christoph Hellwig <hch@lst.de> wrote: >> >> On Mon, Feb 26, 2024 at 07:29:08PM +0800, Yu Kuai wrote: >>> Hi, >>> >>> 在 2024/02/26 18:29, Christoph Hellwig 写道: >>>> Build the queue limits outside the queue and apply them using >>>> queue_limits_set. Also remove the bogus ->gendisk and ->queue NULL >>>> checks in the are while touching it. >>> >>> The checking of mddev->gendisk can't be removed, because this is used to >>> distinguish dm-raid and md/raid. And the same for following patches. >> >> Ah. Well, we should make that more obvious then. This is what I >> currently have: >> >> http://git.infradead.org/?p=users/hch/block.git;a=shortlog;h=refs/heads/md-blk-limits >> >> particularly: >> >> http://git.infradead.org/?p=users/hch/block.git;a=commitdiff;h=24b2fd15f57f06629d2254ebec480e1e28b96636 > > Yes! I was thinking about something like mddev_is_dm() to make these > checks less confusing. Thanks! Yes, this looks good. Thanks, Kuai > > Song > . >
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 286f8b16c7bde7..752ff99736a636 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1791,10 +1791,9 @@ static int raid1_add_disk(struct mddev *mddev, struct md_rdev *rdev) for (mirror = first; mirror <= last; mirror++) { p = conf->mirrors + mirror; if (!p->rdev) { - if (mddev->gendisk) - disk_stack_limits(mddev->gendisk, rdev->bdev, - rdev->data_offset << 9); - + err = mddev_stack_new_rdev(mddev, rdev); + if (err) + return err; p->head_position = 0; rdev->raid_disk = mirror; err = 0; @@ -3089,9 +3088,9 @@ static struct r1conf *setup_conf(struct mddev *mddev) static void raid1_free(struct mddev *mddev, void *priv); static int raid1_run(struct mddev *mddev) { + struct queue_limits lim; struct r1conf *conf; int i; - struct md_rdev *rdev; int ret; if (mddev->level != 1) { @@ -3118,15 +3117,12 @@ static int raid1_run(struct mddev *mddev) if (IS_ERR(conf)) return PTR_ERR(conf); - if (mddev->queue) - blk_queue_max_write_zeroes_sectors(mddev->queue, 0); - - rdev_for_each(rdev, mddev) { - if (!mddev->gendisk) - continue; - disk_stack_limits(mddev->gendisk, rdev->bdev, - rdev->data_offset << 9); - } + blk_set_stacking_limits(&lim); + lim.max_write_zeroes_sectors = 0; + mddev_stack_rdev_limits(mddev, &lim); + ret = queue_limits_set(mddev->queue, &lim); + if (ret) + goto abort; mddev->degraded = 0; for (i = 0; i < conf->raid_disks; i++)
Build the queue limits outside the queue and apply them using queue_limits_set. Also remove the bogus ->gendisk and ->queue NULL checks in the are while touching it. Signed-off-by: Christoph Hellwig <hch@lst.de> --- drivers/md/raid1.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)