Skip to content

Commit fde07a4

Browse files
Christoph Hellwigaxboe
authored andcommitted
dasd: use the atomic queue limits API
Pass the constant limits directly to blk_mq_alloc_disk, set the nonrot flag there as well, and then use the commit API to change the transfer size and logical block size dependent values. This relies on the assumption that no I/O can be pending before the devices moves into the ready state and doesn't need extra freezing for changes to the queue limits. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Stefan Haberland <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 0127a47 commit fde07a4

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

drivers/s390/block/dasd.c

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ static int dasd_state_basic_to_known(struct dasd_device *device)
308308
static int dasd_state_basic_to_ready(struct dasd_device *device)
309309
{
310310
struct dasd_block *block = device->block;
311-
struct request_queue *q;
311+
struct queue_limits lim;
312312
int rc = 0;
313313

314314
/* make disk known with correct capacity */
@@ -328,31 +328,26 @@ static int dasd_state_basic_to_ready(struct dasd_device *device)
328328
goto out;
329329
}
330330

331-
q = block->gdp->queue;
332-
blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
333-
q->limits.max_dev_sectors = device->discipline->max_sectors(block);
334-
blk_queue_max_hw_sectors(q, q->limits.max_dev_sectors);
335-
blk_queue_logical_block_size(q, block->bp_block);
336-
blk_queue_max_segments(q, USHRT_MAX);
337-
338-
/* With page sized segments each segment can be translated into one idaw/tidaw */
339-
blk_queue_max_segment_size(q, PAGE_SIZE);
340-
blk_queue_segment_boundary(q, PAGE_SIZE - 1);
341-
blk_queue_dma_alignment(q, PAGE_SIZE - 1);
331+
lim = queue_limits_start_update(block->gdp->queue);
332+
lim.max_dev_sectors = device->discipline->max_sectors(block);
333+
lim.max_hw_sectors = lim.max_dev_sectors;
334+
lim.logical_block_size = block->bp_block;
342335

343336
if (device->discipline->has_discard) {
344-
unsigned int max_bytes, max_discard_sectors;
337+
unsigned int max_bytes;
345338

346-
q->limits.discard_granularity = block->bp_block;
339+
lim.discard_granularity = block->bp_block;
347340

348341
/* Calculate max_discard_sectors and make it PAGE aligned */
349342
max_bytes = USHRT_MAX * block->bp_block;
350343
max_bytes = ALIGN_DOWN(max_bytes, PAGE_SIZE);
351-
max_discard_sectors = max_bytes / block->bp_block;
352344

353-
blk_queue_max_discard_sectors(q, max_discard_sectors);
354-
blk_queue_max_write_zeroes_sectors(q, max_discard_sectors);
345+
lim.max_hw_discard_sectors = max_bytes / block->bp_block;
346+
lim.max_write_zeroes_sectors = lim.max_hw_discard_sectors;
355347
}
348+
rc = queue_limits_commit_update(block->gdp->queue, &lim);
349+
if (rc)
350+
return rc;
356351

357352
set_capacity(block->gdp, block->blocks << block->s2b_shift);
358353
device->state = DASD_STATE_READY;

drivers/s390/block/dasd_genhd.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ MODULE_PARM_DESC(nr_hw_queues, "Default number of hardware queues for new DASD d
3434
*/
3535
int dasd_gendisk_alloc(struct dasd_block *block)
3636
{
37+
struct queue_limits lim = {
38+
/*
39+
* With page sized segments, each segment can be translated into
40+
* one idaw/tidaw.
41+
*/
42+
.max_segment_size = PAGE_SIZE,
43+
.seg_boundary_mask = PAGE_SIZE - 1,
44+
.dma_alignment = PAGE_SIZE - 1,
45+
.max_segments = USHRT_MAX,
46+
};
3747
struct gendisk *gdp;
3848
struct dasd_device *base;
3949
int len, rc;
@@ -53,11 +63,12 @@ int dasd_gendisk_alloc(struct dasd_block *block)
5363
if (rc)
5464
return rc;
5565

56-
gdp = blk_mq_alloc_disk(&block->tag_set, NULL, block);
66+
gdp = blk_mq_alloc_disk(&block->tag_set, &lim, block);
5767
if (IS_ERR(gdp)) {
5868
blk_mq_free_tag_set(&block->tag_set);
5969
return PTR_ERR(gdp);
6070
}
71+
blk_queue_flag_set(QUEUE_FLAG_NONROT, gdp->queue);
6172

6273
/* Initialize gendisk structure. */
6374
gdp->major = DASD_MAJOR;

0 commit comments

Comments
 (0)