summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorDamien Le Moal2019-07-01 07:09:17 +0200
committerJens Axboe2019-07-12 04:04:39 +0200
commitb091ac616846a1da75b1f2566b41255ce7f0e0a6 (patch)
tree7a0f9b432f6692dfe2b6b07b494bfe7ad887f46e /block
parentblock: Kill gfp_t argument of blkdev_report_zones() (diff)
downloadkernel-qcow2-linux-b091ac616846a1da75b1f2566b41255ce7f0e0a6.tar.gz
kernel-qcow2-linux-b091ac616846a1da75b1f2566b41255ce7f0e0a6.tar.xz
kernel-qcow2-linux-b091ac616846a1da75b1f2566b41255ce7f0e0a6.zip
sd_zbc: Fix report zones buffer allocation
During disk scan and revalidation done with sd_revalidate(), the zones of a zoned disk are checked using the helper function blk_revalidate_disk_zones() if a configuration change is detected (change in the number of zones or zone size). The function blk_revalidate_disk_zones() issues report_zones calls that are very large, that is, to obtain zone information for all zones of the disk with a single command. The size of the report zones command buffer necessary for such large request generally is lower than the disk max_hw_sectors and KMALLOC_MAX_SIZE (4MB) and succeeds on boot (no memory fragmentation), but often fail at run time (e.g. hot-plug event). This causes the disk revalidation to fail and the disk capacity to be changed to 0. This problem can be avoided by using vmalloc() instead of kmalloc() for the buffer allocation. To limit the amount of memory to be allocated, this patch also introduces the arbitrary SD_ZBC_REPORT_MAX_ZONES maximum number of zones to report with a single report zones command. This limit may be lowered further to satisfy the disk max_hw_sectors limit. Finally, to ensure that the vmalloc-ed buffer can always be mapped in a request, the buffer size is further limited to at most queue_max_segments() pages, allowing successful mapping of the buffer even in the worst case scenario where none of the buffer pages are contiguous. Fixes: 515ce6061312 ("scsi: sd_zbc: Fix sd_zbc_report_zones() buffer allocation") Fixes: e76239a3748c ("block: add a report_zones method") Cc: stable@vger.kernel.org Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
0 files changed, 0 insertions, 0 deletions