hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/s390/block/dasd_fba.c
....@@ -771,27 +771,51 @@
771771 }
772772
773773 /*
774
- * max_blocks is dependent on the amount of storage that is available
775
- * in the static io buffer for each device. Currently each device has
776
- * 8192 bytes (=2 pages). For 64 bit one dasd_mchunkt_t structure has
777
- * 24 bytes, the struct dasd_ccw_req has 136 bytes and each block can use
778
- * up to 16 bytes (8 for the ccw and 8 for the idal pointer). In
779
- * addition we have one define extent ccw + 16 bytes of data and a
780
- * locate record ccw for each block (stupid devices!) + 16 bytes of data.
781
- * That makes:
782
- * (8192 - 24 - 136 - 8 - 16) / 40 = 200.2 blocks at maximum.
783
- * We want to fit two into the available memory so that we can immediately
784
- * start the next request if one finishes off. That makes 100.1 blocks
785
- * for one request. Give a little safety and the result is 96.
774
+ * Initialize block layer request queue.
786775 */
776
+static void dasd_fba_setup_blk_queue(struct dasd_block *block)
777
+{
778
+ unsigned int logical_block_size = block->bp_block;
779
+ struct request_queue *q = block->request_queue;
780
+ unsigned int max_bytes, max_discard_sectors;
781
+ int max;
782
+
783
+ max = DASD_FBA_MAX_BLOCKS << block->s2b_shift;
784
+ blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
785
+ q->limits.max_dev_sectors = max;
786
+ blk_queue_logical_block_size(q, logical_block_size);
787
+ blk_queue_max_hw_sectors(q, max);
788
+ blk_queue_max_segments(q, USHRT_MAX);
789
+ /* With page sized segments each segment can be translated into one idaw/tidaw */
790
+ blk_queue_max_segment_size(q, PAGE_SIZE);
791
+ blk_queue_segment_boundary(q, PAGE_SIZE - 1);
792
+
793
+ q->limits.discard_granularity = logical_block_size;
794
+ q->limits.discard_alignment = PAGE_SIZE;
795
+
796
+ /* Calculate max_discard_sectors and make it PAGE aligned */
797
+ max_bytes = USHRT_MAX * logical_block_size;
798
+ max_bytes = ALIGN_DOWN(max_bytes, PAGE_SIZE);
799
+ max_discard_sectors = max_bytes / logical_block_size;
800
+
801
+ blk_queue_max_discard_sectors(q, max_discard_sectors);
802
+ blk_queue_max_write_zeroes_sectors(q, max_discard_sectors);
803
+ blk_queue_flag_set(QUEUE_FLAG_DISCARD, q);
804
+}
805
+
806
+static int dasd_fba_pe_handler(struct dasd_device *device, __u8 tbvpm)
807
+{
808
+ return dasd_generic_verify_path(device, tbvpm);
809
+}
810
+
787811 static struct dasd_discipline dasd_fba_discipline = {
788812 .owner = THIS_MODULE,
789813 .name = "FBA ",
790814 .ebcname = "FBA ",
791
- .max_blocks = 96,
792815 .check_device = dasd_fba_check_characteristics,
793816 .do_analysis = dasd_fba_do_analysis,
794
- .verify_path = dasd_generic_verify_path,
817
+ .pe_handler = dasd_fba_pe_handler,
818
+ .setup_blk_queue = dasd_fba_setup_blk_queue,
795819 .fill_geometry = dasd_fba_fill_geometry,
796820 .start_IO = dasd_start_IO,
797821 .term_IO = dasd_term_IO,