Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/dasd: Make dasd_setup_queue() a discipline function

ECKD, FBA, and the DIAG discipline use slightly different block layer
settings. In preparation of even more diverse queue settings, make
dasd_setup_queue() a discipline function.

Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>

authored by

Jan Höppner and committed by
Vasily Gorbik
a0610a8a 91dc4a19

+103 -80
+2 -51
drivers/s390/block/dasd.c
··· 70 70 * SECTION: prototypes for static functions of dasd.c 71 71 */ 72 72 static int dasd_alloc_queue(struct dasd_block *); 73 - static void dasd_setup_queue(struct dasd_block *); 74 73 static void dasd_free_queue(struct dasd_block *); 75 74 static int dasd_flush_block_queue(struct dasd_block *); 76 75 static void dasd_device_tasklet(unsigned long); ··· 357 358 } 358 359 return rc; 359 360 } 360 - dasd_setup_queue(block); 361 + if (device->discipline->setup_blk_queue) 362 + device->discipline->setup_blk_queue(block); 361 363 set_capacity(block->gdp, 362 364 block->blocks << block->s2b_shift); 363 365 device->state = DASD_STATE_READY; ··· 3247 3247 block->request_queue->queuedata = block; 3248 3248 3249 3249 return 0; 3250 - } 3251 - 3252 - /* 3253 - * Allocate and initialize request queue. 3254 - */ 3255 - static void dasd_setup_queue(struct dasd_block *block) 3256 - { 3257 - unsigned int logical_block_size = block->bp_block; 3258 - struct request_queue *q = block->request_queue; 3259 - unsigned int max_bytes, max_discard_sectors; 3260 - int max; 3261 - 3262 - if (block->base->features & DASD_FEATURE_USERAW) { 3263 - /* 3264 - * the max_blocks value for raw_track access is 256 3265 - * it is higher than the native ECKD value because we 3266 - * only need one ccw per track 3267 - * so the max_hw_sectors are 3268 - * 2048 x 512B = 1024kB = 16 tracks 3269 - */ 3270 - max = 2048; 3271 - } else { 3272 - max = block->base->discipline->max_blocks << block->s2b_shift; 3273 - } 3274 - blk_queue_flag_set(QUEUE_FLAG_NONROT, q); 3275 - q->limits.max_dev_sectors = max; 3276 - blk_queue_logical_block_size(q, logical_block_size); 3277 - blk_queue_max_hw_sectors(q, max); 3278 - blk_queue_max_segments(q, USHRT_MAX); 3279 - /* with page sized segments we can translate each segement into 3280 - * one idaw/tidaw 3281 - */ 3282 - blk_queue_max_segment_size(q, PAGE_SIZE); 3283 - blk_queue_segment_boundary(q, PAGE_SIZE - 1); 3284 - 3285 - /* Only activate blocklayer discard support for devices that support it */ 3286 - if (block->base->features & DASD_FEATURE_DISCARD) { 3287 - q->limits.discard_granularity = logical_block_size; 3288 - q->limits.discard_alignment = PAGE_SIZE; 3289 - 3290 - /* Calculate max_discard_sectors and make it PAGE aligned */ 3291 - max_bytes = USHRT_MAX * logical_block_size; 3292 - max_bytes = ALIGN(max_bytes, PAGE_SIZE) - PAGE_SIZE; 3293 - max_discard_sectors = max_bytes / logical_block_size; 3294 - 3295 - blk_queue_max_discard_sectors(q, max_discard_sectors); 3296 - blk_queue_max_write_zeroes_sectors(q, max_discard_sectors); 3297 - blk_queue_flag_set(QUEUE_FLAG_DISCARD, q); 3298 - } 3299 3250 } 3300 3251 3301 3252 /*
+21 -1
drivers/s390/block/dasd_diag.c
··· 615 615 "dump sense not available for DIAG data"); 616 616 } 617 617 618 + /* 619 + * Initialize block layer request queue. 620 + */ 621 + static void dasd_diag_setup_blk_queue(struct dasd_block *block) 622 + { 623 + unsigned int logical_block_size = block->bp_block; 624 + struct request_queue *q = block->request_queue; 625 + int max; 626 + 627 + max = DIAG_MAX_BLOCKS << block->s2b_shift; 628 + blk_queue_flag_set(QUEUE_FLAG_NONROT, q); 629 + q->limits.max_dev_sectors = max; 630 + blk_queue_logical_block_size(q, logical_block_size); 631 + blk_queue_max_hw_sectors(q, max); 632 + blk_queue_max_segments(q, USHRT_MAX); 633 + /* With page sized segments each segment can be translated into one idaw/tidaw */ 634 + blk_queue_max_segment_size(q, PAGE_SIZE); 635 + blk_queue_segment_boundary(q, PAGE_SIZE - 1); 636 + } 637 + 618 638 static struct dasd_discipline dasd_diag_discipline = { 619 639 .owner = THIS_MODULE, 620 640 .name = "DIAG", 621 641 .ebcname = "DIAG", 622 - .max_blocks = DIAG_MAX_BLOCKS, 623 642 .check_device = dasd_diag_check_device, 624 643 .verify_path = dasd_generic_verify_path, 625 644 .fill_geometry = dasd_diag_fill_geometry, 645 + .setup_blk_queue = dasd_diag_setup_blk_queue, 626 646 .start_IO = dasd_start_diag, 627 647 .term_IO = dasd_diag_term_IO, 628 648 .handle_terminated_request = dasd_diag_handle_terminated_request,
+33 -14
drivers/s390/block/dasd_eckd.c
··· 6349 6349 dasd_schedule_requeue(device); 6350 6350 } 6351 6351 6352 + /* 6353 + * Initialize block layer request queue. 6354 + */ 6355 + static void dasd_eckd_setup_blk_queue(struct dasd_block *block) 6356 + { 6357 + unsigned int logical_block_size = block->bp_block; 6358 + struct request_queue *q = block->request_queue; 6359 + struct dasd_device *device = block->base; 6360 + int max; 6361 + 6362 + if (device->features & DASD_FEATURE_USERAW) { 6363 + /* 6364 + * the max_blocks value for raw_track access is 256 6365 + * it is higher than the native ECKD value because we 6366 + * only need one ccw per track 6367 + * so the max_hw_sectors are 6368 + * 2048 x 512B = 1024kB = 16 tracks 6369 + */ 6370 + max = DASD_ECKD_MAX_BLOCKS_RAW << block->s2b_shift; 6371 + } else { 6372 + max = DASD_ECKD_MAX_BLOCKS << block->s2b_shift; 6373 + } 6374 + blk_queue_flag_set(QUEUE_FLAG_NONROT, q); 6375 + q->limits.max_dev_sectors = max; 6376 + blk_queue_logical_block_size(q, logical_block_size); 6377 + blk_queue_max_hw_sectors(q, max); 6378 + blk_queue_max_segments(q, USHRT_MAX); 6379 + /* With page sized segments each segment can be translated into one idaw/tidaw */ 6380 + blk_queue_max_segment_size(q, PAGE_SIZE); 6381 + blk_queue_segment_boundary(q, PAGE_SIZE - 1); 6382 + } 6383 + 6352 6384 static struct ccw_driver dasd_eckd_driver = { 6353 6385 .driver = { 6354 6386 .name = "dasd-eckd", ··· 6401 6369 .int_class = IRQIO_DAS, 6402 6370 }; 6403 6371 6404 - /* 6405 - * max_blocks is dependent on the amount of storage that is available 6406 - * in the static io buffer for each device. Currently each device has 6407 - * 8192 bytes (=2 pages). For 64 bit one dasd_mchunkt_t structure has 6408 - * 24 bytes, the struct dasd_ccw_req has 136 bytes and each block can use 6409 - * up to 16 bytes (8 for the ccw and 8 for the idal pointer). In 6410 - * addition we have one define extent ccw + 16 bytes of data and one 6411 - * locate record ccw + 16 bytes of data. That makes: 6412 - * (8192 - 24 - 136 - 8 - 16 - 8 - 16) / 16 = 499 blocks at maximum. 6413 - * We want to fit two into the available memory so that we can immediately 6414 - * start the next request if one finishes off. That makes 249.5 blocks 6415 - * for one request. Give a little safety and the result is 240. 6416 - */ 6417 6372 static struct dasd_discipline dasd_eckd_discipline = { 6418 6373 .owner = THIS_MODULE, 6419 6374 .name = "ECKD", 6420 6375 .ebcname = "ECKD", 6421 - .max_blocks = 190, 6422 6376 .check_device = dasd_eckd_check_characteristics, 6423 6377 .uncheck_device = dasd_eckd_uncheck_device, 6424 6378 .do_analysis = dasd_eckd_do_analysis, ··· 6412 6394 .basic_to_ready = dasd_eckd_basic_to_ready, 6413 6395 .online_to_ready = dasd_eckd_online_to_ready, 6414 6396 .basic_to_known = dasd_eckd_basic_to_known, 6397 + .setup_blk_queue = dasd_eckd_setup_blk_queue, 6415 6398 .fill_geometry = dasd_eckd_fill_geometry, 6416 6399 .start_IO = dasd_start_IO, 6417 6400 .term_IO = dasd_term_IO,
+6
drivers/s390/block/dasd_eckd.h
··· 109 109 #define DASD_ECKD_PATH_THRHLD 256 110 110 #define DASD_ECKD_PATH_INTERVAL 300 111 111 112 + /* 113 + * Maximum number of blocks to be chained 114 + */ 115 + #define DASD_ECKD_MAX_BLOCKS 190 116 + #define DASD_ECKD_MAX_BLOCKS_RAW 256 117 + 112 118 /***************************************************************************** 113 119 * SECTION: Type Definitions 114 120 ****************************************************************************/
+32 -13
drivers/s390/block/dasd_fba.c
··· 770 770 } 771 771 772 772 /* 773 - * max_blocks is dependent on the amount of storage that is available 774 - * in the static io buffer for each device. Currently each device has 775 - * 8192 bytes (=2 pages). For 64 bit one dasd_mchunkt_t structure has 776 - * 24 bytes, the struct dasd_ccw_req has 136 bytes and each block can use 777 - * up to 16 bytes (8 for the ccw and 8 for the idal pointer). In 778 - * addition we have one define extent ccw + 16 bytes of data and a 779 - * locate record ccw for each block (stupid devices!) + 16 bytes of data. 780 - * That makes: 781 - * (8192 - 24 - 136 - 8 - 16) / 40 = 200.2 blocks at maximum. 782 - * We want to fit two into the available memory so that we can immediately 783 - * start the next request if one finishes off. That makes 100.1 blocks 784 - * for one request. Give a little safety and the result is 96. 773 + * Initialize block layer request queue. 785 774 */ 775 + static void dasd_fba_setup_blk_queue(struct dasd_block *block) 776 + { 777 + unsigned int logical_block_size = block->bp_block; 778 + struct request_queue *q = block->request_queue; 779 + unsigned int max_bytes, max_discard_sectors; 780 + int max; 781 + 782 + max = DASD_FBA_MAX_BLOCKS << block->s2b_shift; 783 + blk_queue_flag_set(QUEUE_FLAG_NONROT, q); 784 + q->limits.max_dev_sectors = max; 785 + blk_queue_logical_block_size(q, logical_block_size); 786 + blk_queue_max_hw_sectors(q, max); 787 + blk_queue_max_segments(q, USHRT_MAX); 788 + /* With page sized segments each segment can be translated into one idaw/tidaw */ 789 + blk_queue_max_segment_size(q, PAGE_SIZE); 790 + blk_queue_segment_boundary(q, PAGE_SIZE - 1); 791 + 792 + q->limits.discard_granularity = logical_block_size; 793 + q->limits.discard_alignment = PAGE_SIZE; 794 + 795 + /* Calculate max_discard_sectors and make it PAGE aligned */ 796 + max_bytes = USHRT_MAX * logical_block_size; 797 + max_bytes = ALIGN(max_bytes, PAGE_SIZE) - PAGE_SIZE; 798 + max_discard_sectors = max_bytes / logical_block_size; 799 + 800 + blk_queue_max_discard_sectors(q, max_discard_sectors); 801 + blk_queue_max_write_zeroes_sectors(q, max_discard_sectors); 802 + blk_queue_flag_set(QUEUE_FLAG_DISCARD, q); 803 + } 804 + 786 805 static struct dasd_discipline dasd_fba_discipline = { 787 806 .owner = THIS_MODULE, 788 807 .name = "FBA ", 789 808 .ebcname = "FBA ", 790 - .max_blocks = 96, 791 809 .check_device = dasd_fba_check_characteristics, 792 810 .do_analysis = dasd_fba_do_analysis, 793 811 .verify_path = dasd_generic_verify_path, 812 + .setup_blk_queue = dasd_fba_setup_blk_queue, 794 813 .fill_geometry = dasd_fba_fill_geometry, 795 814 .start_IO = dasd_start_IO, 796 815 .term_IO = dasd_term_IO,
+5
drivers/s390/block/dasd_fba.h
··· 9 9 #ifndef DASD_FBA_H 10 10 #define DASD_FBA_H 11 11 12 + /* 13 + * Maximum number of blocks to be chained 14 + */ 15 + #define DASD_FBA_MAX_BLOCKS 96 16 + 12 17 struct DE_fba_data { 13 18 struct { 14 19 unsigned char perm:2; /* Permissions on this extent */
+4 -1
drivers/s390/block/dasd_int.h
··· 268 268 struct module *owner; 269 269 char ebcname[8]; /* a name used for tagging and printks */ 270 270 char name[8]; /* a name used for tagging and printks */ 271 - int max_blocks; /* maximum number of blocks to be chained */ 272 271 273 272 struct list_head list; /* used for list of disciplines */ 274 273 ··· 306 307 int (*online_to_ready) (struct dasd_device *); 307 308 int (*basic_to_known)(struct dasd_device *); 308 309 310 + /* 311 + * Initialize block layer request queue. 312 + */ 313 + void (*setup_blk_queue)(struct dasd_block *); 309 314 /* (struct dasd_device *); 310 315 * Device operation functions. build_cp creates a ccw chain for 311 316 * a block device request, start_io starts the request and