Message ID | 20221221162758.407742-1-kbusch@meta.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | block: save user max_sectors limit | expand |
On Thu, Dec 22, 2022 at 04:32:10PM +0800, kernel test robot wrote:
> >> block/blk-settings.c:138:49: warning: comparison of distinct pointer types ('typeof (limits->max_sectors) *' (aka 'unsigned int *') and 'typeof (BLK_DEF_MAX_SECTORS) *' (aka 'int *')) [-Wcompare-distinct-pointer-types]
Yeah, that's not going to work. BLK_DEF_MAX_SECTORS should probably
become an unsigned constant to fix this.
On Thu, Dec 22, 2022 at 09:40:11AM +0100, Christoph Hellwig wrote: > On Thu, Dec 22, 2022 at 04:32:10PM +0800, kernel test robot wrote: > > >> block/blk-settings.c:138:49: warning: comparison of distinct pointer types ('typeof (limits->max_sectors) *' (aka 'unsigned int *') and 'typeof (BLK_DEF_MAX_SECTORS) *' (aka 'int *')) [-Wcompare-distinct-pointer-types] > > Yeah, that's not going to work. BLK_DEF_MAX_SECTORS should probably > become an unsigned constant to fix this. Hm, I should have used max_t() instead of max(). But thinking on this again, we probably want to respect the user setting even if it's lower than the default too, not just if its larger. I believe that will require a new queue limit to save that value.
Keith, > But thinking on this again, we probably want to respect the user > setting even if it's lower than the default too, not just if its > larger. I believe that will require a new queue limit to save that > value. Yeah, I have struggled with the same problem for various user parameter overrides in SCSI. Lowering defaults or detected values is fairly common.
diff --git a/block/blk-settings.c b/block/blk-settings.c index 0477c4d527fee..523348926a800 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -135,7 +135,8 @@ void blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_secto limits->max_hw_sectors = max_hw_sectors; max_sectors = min_not_zero(max_hw_sectors, limits->max_dev_sectors); - max_sectors = min_t(unsigned int, max_sectors, BLK_DEF_MAX_SECTORS); + max_sectors = min_t(unsigned int, max_sectors, max(limits->max_sectors, + BLK_DEF_MAX_SECTORS)); max_sectors = round_down(max_sectors, limits->logical_block_size >> SECTOR_SHIFT); limits->max_sectors = max_sectors;