blk-settings.c (9d4d8572a539ef807e21c196f145aa365fd52f0e) | blk-settings.c (a805a4fa4fa376bbc145762bb8b09caa2fa8af48) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Functions related to setting various queue properties from drivers 4 */ 5#include <linux/kernel.h> 6#include <linux/module.h> 7#include <linux/init.h> 8#include <linux/bio.h> --- 46 unchanged lines hidden (view full) --- 55 lim->discard_alignment = 0; 56 lim->discard_misaligned = 0; 57 lim->logical_block_size = lim->physical_block_size = lim->io_min = 512; 58 lim->bounce_pfn = (unsigned long)(BLK_BOUNCE_ANY >> PAGE_SHIFT); 59 lim->alignment_offset = 0; 60 lim->io_opt = 0; 61 lim->misaligned = 0; 62 lim->zoned = BLK_ZONED_NONE; | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Functions related to setting various queue properties from drivers 4 */ 5#include <linux/kernel.h> 6#include <linux/module.h> 7#include <linux/init.h> 8#include <linux/bio.h> --- 46 unchanged lines hidden (view full) --- 55 lim->discard_alignment = 0; 56 lim->discard_misaligned = 0; 57 lim->logical_block_size = lim->physical_block_size = lim->io_min = 512; 58 lim->bounce_pfn = (unsigned long)(BLK_BOUNCE_ANY >> PAGE_SHIFT); 59 lim->alignment_offset = 0; 60 lim->io_opt = 0; 61 lim->misaligned = 0; 62 lim->zoned = BLK_ZONED_NONE; |
63 lim->zone_write_granularity = 0; |
|
63} 64EXPORT_SYMBOL(blk_set_default_limits); 65 66/** 67 * blk_set_stacking_limits - set default limits for stacking devices 68 * @lim: the queue_limits structure to reset 69 * 70 * Description: --- 291 unchanged lines hidden (view full) --- 362 q->limits.physical_block_size = q->limits.logical_block_size; 363 364 if (q->limits.io_min < q->limits.physical_block_size) 365 q->limits.io_min = q->limits.physical_block_size; 366} 367EXPORT_SYMBOL(blk_queue_physical_block_size); 368 369/** | 64} 65EXPORT_SYMBOL(blk_set_default_limits); 66 67/** 68 * blk_set_stacking_limits - set default limits for stacking devices 69 * @lim: the queue_limits structure to reset 70 * 71 * Description: --- 291 unchanged lines hidden (view full) --- 363 q->limits.physical_block_size = q->limits.logical_block_size; 364 365 if (q->limits.io_min < q->limits.physical_block_size) 366 q->limits.io_min = q->limits.physical_block_size; 367} 368EXPORT_SYMBOL(blk_queue_physical_block_size); 369 370/** |
371 * blk_queue_zone_write_granularity - set zone write granularity for the queue 372 * @q: the request queue for the zoned device 373 * @size: the zone write granularity size, in bytes 374 * 375 * Description: 376 * This should be set to the lowest possible size allowing to write in 377 * sequential zones of a zoned block device. 378 */ 379void blk_queue_zone_write_granularity(struct request_queue *q, 380 unsigned int size) 381{ 382 if (WARN_ON_ONCE(!blk_queue_is_zoned(q))) 383 return; 384 385 q->limits.zone_write_granularity = size; 386 387 if (q->limits.zone_write_granularity < q->limits.logical_block_size) 388 q->limits.zone_write_granularity = q->limits.logical_block_size; 389} 390EXPORT_SYMBOL_GPL(blk_queue_zone_write_granularity); 391 392/** |
|
370 * blk_queue_alignment_offset - set physical block alignment offset 371 * @q: the request queue for the device 372 * @offset: alignment offset in bytes 373 * 374 * Description: 375 * Some devices are naturally misaligned to compensate for things like 376 * the legacy DOS partition table 63-sector offset. Low-level drivers 377 * should call this function for devices whose first sector is not --- 248 unchanged lines hidden (view full) --- 626 t->max_hw_discard_sectors = min_not_zero(t->max_hw_discard_sectors, 627 b->max_hw_discard_sectors); 628 t->discard_granularity = max(t->discard_granularity, 629 b->discard_granularity); 630 t->discard_alignment = lcm_not_zero(t->discard_alignment, alignment) % 631 t->discard_granularity; 632 } 633 | 393 * blk_queue_alignment_offset - set physical block alignment offset 394 * @q: the request queue for the device 395 * @offset: alignment offset in bytes 396 * 397 * Description: 398 * Some devices are naturally misaligned to compensate for things like 399 * the legacy DOS partition table 63-sector offset. Low-level drivers 400 * should call this function for devices whose first sector is not --- 248 unchanged lines hidden (view full) --- 649 t->max_hw_discard_sectors = min_not_zero(t->max_hw_discard_sectors, 650 b->max_hw_discard_sectors); 651 t->discard_granularity = max(t->discard_granularity, 652 b->discard_granularity); 653 t->discard_alignment = lcm_not_zero(t->discard_alignment, alignment) % 654 t->discard_granularity; 655 } 656 |
657 t->zone_write_granularity = max(t->zone_write_granularity, 658 b->zone_write_granularity); |
|
634 t->zoned = max(t->zoned, b->zoned); 635 return ret; 636} 637EXPORT_SYMBOL(blk_stack_limits); 638 639/** 640 * disk_stack_limits - adjust queue limits for stacked drivers 641 * @disk: MD/DM gendisk (top) --- 200 unchanged lines hidden (view full) --- 842 * When @model is BLK_ZONED_HM (host managed), this should be called only 843 * if zoned block device support is enabled (CONFIG_BLK_DEV_ZONED option). 844 * If @model specifies BLK_ZONED_HA (host aware), the effective model used 845 * depends on CONFIG_BLK_DEV_ZONED settings and on the existence of partitions 846 * on the disk. 847 */ 848void blk_queue_set_zoned(struct gendisk *disk, enum blk_zoned_model model) 849{ | 659 t->zoned = max(t->zoned, b->zoned); 660 return ret; 661} 662EXPORT_SYMBOL(blk_stack_limits); 663 664/** 665 * disk_stack_limits - adjust queue limits for stacked drivers 666 * @disk: MD/DM gendisk (top) --- 200 unchanged lines hidden (view full) --- 867 * When @model is BLK_ZONED_HM (host managed), this should be called only 868 * if zoned block device support is enabled (CONFIG_BLK_DEV_ZONED option). 869 * If @model specifies BLK_ZONED_HA (host aware), the effective model used 870 * depends on CONFIG_BLK_DEV_ZONED settings and on the existence of partitions 871 * on the disk. 872 */ 873void blk_queue_set_zoned(struct gendisk *disk, enum blk_zoned_model model) 874{ |
875 struct request_queue *q = disk->queue; 876 |
|
850 switch (model) { 851 case BLK_ZONED_HM: 852 /* 853 * Host managed devices are supported only if 854 * CONFIG_BLK_DEV_ZONED is enabled. 855 */ 856 WARN_ON_ONCE(!IS_ENABLED(CONFIG_BLK_DEV_ZONED)); 857 break; 858 case BLK_ZONED_HA: 859 /* 860 * Host aware devices can be treated either as regular block 861 * devices (similar to drive managed devices) or as zoned block 862 * devices to take advantage of the zone command set, similarly 863 * to host managed devices. We try the latter if there are no 864 * partitions and zoned block device support is enabled, else 865 * we do nothing special as far as the block layer is concerned. 866 */ 867 if (!IS_ENABLED(CONFIG_BLK_DEV_ZONED) || | 877 switch (model) { 878 case BLK_ZONED_HM: 879 /* 880 * Host managed devices are supported only if 881 * CONFIG_BLK_DEV_ZONED is enabled. 882 */ 883 WARN_ON_ONCE(!IS_ENABLED(CONFIG_BLK_DEV_ZONED)); 884 break; 885 case BLK_ZONED_HA: 886 /* 887 * Host aware devices can be treated either as regular block 888 * devices (similar to drive managed devices) or as zoned block 889 * devices to take advantage of the zone command set, similarly 890 * to host managed devices. We try the latter if there are no 891 * partitions and zoned block device support is enabled, else 892 * we do nothing special as far as the block layer is concerned. 893 */ 894 if (!IS_ENABLED(CONFIG_BLK_DEV_ZONED) || |
868 disk_has_partitions(disk)) | 895 !xa_empty(&disk->part_tbl)) |
869 model = BLK_ZONED_NONE; 870 break; 871 case BLK_ZONED_NONE: 872 default: 873 if (WARN_ON_ONCE(model != BLK_ZONED_NONE)) 874 model = BLK_ZONED_NONE; 875 break; 876 } 877 | 896 model = BLK_ZONED_NONE; 897 break; 898 case BLK_ZONED_NONE: 899 default: 900 if (WARN_ON_ONCE(model != BLK_ZONED_NONE)) 901 model = BLK_ZONED_NONE; 902 break; 903 } 904 |
878 disk->queue->limits.zoned = model; | 905 q->limits.zoned = model; 906 if (model != BLK_ZONED_NONE) { 907 /* 908 * Set the zone write granularity to the device logical block 909 * size by default. The driver can change this value if needed. 910 */ 911 blk_queue_zone_write_granularity(q, 912 queue_logical_block_size(q)); 913 } |
879} 880EXPORT_SYMBOL_GPL(blk_queue_set_zoned); 881 882static int __init blk_settings_init(void) 883{ 884 blk_max_low_pfn = max_low_pfn - 1; 885 blk_max_pfn = max_pfn - 1; 886 return 0; 887} 888subsys_initcall(blk_settings_init); | 914} 915EXPORT_SYMBOL_GPL(blk_queue_set_zoned); 916 917static int __init blk_settings_init(void) 918{ 919 blk_max_low_pfn = max_low_pfn - 1; 920 blk_max_pfn = max_pfn - 1; 921 return 0; 922} 923subsys_initcall(blk_settings_init); |