Skip to content

Commit 573d5ab

Browse files
Christoph Hellwigaxboe
authored andcommitted
md: set md-specific flags for all queue limits
The md driver wants to enforce a number of flags for all devices, even when not inheriting them from the underlying devices. To make sure these flags survive the queue_limits_set calls that md uses to update the queue limits without deriving them form the previous limits add a new md_init_stacking_limits helper that calls blk_set_stacking_limits and sets these flags. Fixes: 1122c0c ("block: move cache control settings out of queue->flags") Reported-by: kernel test robot <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent cf546dd commit 573d5ab

File tree

6 files changed

+14
-9
lines changed

6 files changed

+14
-9
lines changed

drivers/md/md.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5853,6 +5853,14 @@ static void mddev_delayed_delete(struct work_struct *ws)
58535853
kobject_put(&mddev->kobj);
58545854
}
58555855

5856+
void md_init_stacking_limits(struct queue_limits *lim)
5857+
{
5858+
blk_set_stacking_limits(lim);
5859+
lim->features = BLK_FEAT_WRITE_CACHE | BLK_FEAT_FUA |
5860+
BLK_FEAT_IO_STAT | BLK_FEAT_NOWAIT;
5861+
}
5862+
EXPORT_SYMBOL_GPL(md_init_stacking_limits);
5863+
58565864
struct mddev *md_alloc(dev_t dev, char *name)
58575865
{
58585866
/*
@@ -5871,10 +5879,6 @@ struct mddev *md_alloc(dev_t dev, char *name)
58715879
int shift;
58725880
int unit;
58735881
int error;
5874-
struct queue_limits lim = {
5875-
.features = BLK_FEAT_WRITE_CACHE | BLK_FEAT_FUA |
5876-
BLK_FEAT_IO_STAT | BLK_FEAT_NOWAIT,
5877-
};
58785882

58795883
/*
58805884
* Wait for any previous instance of this device to be completely
@@ -5914,7 +5918,7 @@ struct mddev *md_alloc(dev_t dev, char *name)
59145918
*/
59155919
mddev->hold_active = UNTIL_STOP;
59165920

5917-
disk = blk_alloc_disk(&lim, NUMA_NO_NODE);
5921+
disk = blk_alloc_disk(NULL, NUMA_NO_NODE);
59185922
if (IS_ERR(disk)) {
59195923
error = PTR_ERR(disk);
59205924
goto out_free_mddev;

drivers/md/md.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,7 @@ extern int strict_strtoul_scaled(const char *cp, unsigned long *res, int scale);
893893

894894
extern int mddev_init(struct mddev *mddev);
895895
extern void mddev_destroy(struct mddev *mddev);
896+
void md_init_stacking_limits(struct queue_limits *lim);
896897
struct mddev *md_alloc(dev_t dev, char *name);
897898
void mddev_put(struct mddev *mddev);
898899
extern int md_run(struct mddev *mddev);

drivers/md/raid0.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ static int raid0_set_limits(struct mddev *mddev)
379379
struct queue_limits lim;
380380
int err;
381381

382-
blk_set_stacking_limits(&lim);
382+
md_init_stacking_limits(&lim);
383383
lim.max_hw_sectors = mddev->chunk_sectors;
384384
lim.max_write_zeroes_sectors = mddev->chunk_sectors;
385385
lim.io_min = mddev->chunk_sectors << 9;

drivers/md/raid1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3194,7 +3194,7 @@ static int raid1_set_limits(struct mddev *mddev)
31943194
struct queue_limits lim;
31953195
int err;
31963196

3197-
blk_set_stacking_limits(&lim);
3197+
md_init_stacking_limits(&lim);
31983198
lim.max_write_zeroes_sectors = 0;
31993199
err = mddev_stack_rdev_limits(mddev, &lim, MDDEV_STACK_INTEGRITY);
32003200
if (err) {

drivers/md/raid10.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3974,7 +3974,7 @@ static int raid10_set_queue_limits(struct mddev *mddev)
39743974
struct queue_limits lim;
39753975
int err;
39763976

3977-
blk_set_stacking_limits(&lim);
3977+
md_init_stacking_limits(&lim);
39783978
lim.max_write_zeroes_sectors = 0;
39793979
lim.io_min = mddev->chunk_sectors << 9;
39803980
lim.io_opt = lim.io_min * raid10_nr_stripes(conf);

drivers/md/raid5.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7708,7 +7708,7 @@ static int raid5_set_limits(struct mddev *mddev)
77087708
*/
77097709
stripe = roundup_pow_of_two(data_disks * (mddev->chunk_sectors << 9));
77107710

7711-
blk_set_stacking_limits(&lim);
7711+
md_init_stacking_limits(&lim);
77127712
lim.io_min = mddev->chunk_sectors << 9;
77137713
lim.io_opt = lim.io_min * (conf->raid_disks - conf->max_degraded);
77147714
lim.features |= BLK_FEAT_RAID_PARTIAL_STRIPES_EXPENSIVE;

0 commit comments

Comments
 (0)