linux/drivers/scsi
Damien Le Moal b091ac6168 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: 515ce60613 ("scsi: sd_zbc: Fix sd_zbc_report_zones() buffer allocation")
Fixes: e76239a374 ("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>
2019-07-11 20:04:39 -06:00
..
aacraid treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 18 2019-05-21 11:28:46 +02:00
aic7xxx treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
aic94xx treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 457 2019-06-19 17:09:09 +02:00
arcmsr treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
arm treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
be2iscsi treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 338 2019-06-05 17:37:07 +02:00
bfa treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 292 2019-06-05 17:36:38 +02:00
bnx2fc SCSI fixes on 20190524 2019-05-24 17:30:28 -07:00
bnx2i treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
csiostor treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
cxgbi SCSI fixes on 20190601 2019-06-02 09:26:34 -07:00
cxlflash treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
device_handler SCSI fixes on 20190601 2019-06-02 09:26:34 -07:00
dpt treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
esas2r treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
fcoe treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 335 2019-06-05 17:37:06 +02:00
fnic scsi: fnic: Remove set but not used variable 'vdev' 2019-01-29 01:16:09 -05:00
hisi_sas treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
ibmvscsi treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
ibmvscsi_tgt treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
isci scsi: isci: initialize shost fully before calling scsi_add_host() 2019-01-08 22:27:24 -05:00
libfc treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 335 2019-06-05 17:37:06 +02:00
libsas treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 372 2019-06-05 17:37:10 +02:00
lpfc lpfc: add sysfs interface to post NVME RSCN 2019-06-21 11:08:38 +02:00
megaraid treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
mpt3sas SCSI misc on 20190507 2019-05-08 10:12:46 -07:00
mvsas treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 457 2019-06-19 17:09:09 +02:00
pcmcia treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 118 2019-05-24 17:39:02 +02:00
pm8001 scsi: pm8001: fix spelling mistake, interupt -> interrupt 2019-04-03 23:45:59 -04:00
qedf treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 440 2019-06-05 17:37:17 +02:00
qedi SCSI fixes on 20190622 2019-06-22 09:39:03 -07:00
qla2xxx SCSI fixes on 20190622 2019-06-22 09:39:03 -07:00
qla4xxx treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
smartpqi scsi: smartpqi: unlock on error in pqi_submit_raid_request_synchronous() 2019-06-04 22:22:29 -04:00
snic scsi: snic: no need to check return value of debugfs_create functions 2019-01-29 00:40:54 -05:00
sym53c8xx_2 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
ufs SCSI fixes on 20190622 2019-06-22 09:39:03 -07:00
.gitignore
3w-9xxx.c scsi: 3w-9xxx: fix calls to dma_set_mask_and_coherent() 2019-02-25 21:37:25 -05:00
3w-9xxx.h
3w-sas.c SCSI fixes on 20190302 2019-03-02 11:39:54 -08:00
3w-sas.h
3w-xxxx.c scsi: 3w-xxxx: fix indentation issue, add missing tab 2018-12-19 21:54:07 -05:00
3w-xxxx.h
53c700_d.h_shipped
53c700.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 61 2019-05-24 17:36:45 +02:00
53c700.h
53c700.scr
a100u2w.c cross-tree: phase out dma_zalloc_coherent() 2019-01-08 07:58:37 -05:00
a100u2w.h
a2091.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
a2091.h
a3000.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
a3000.h
a4000t.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
advansys.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
aha152x.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 118 2019-05-24 17:39:02 +02:00
aha152x.h
aha1542.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
aha1542.h
aha1740.c scsi: flip the default on use_clustering 2018-12-18 23:13:12 -05:00
aha1740.h
am53c974.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
atari_scsi.c nvram: Replace nvram_* function exports with static functions 2019-01-22 10:21:43 +01:00
atp870u.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
atp870u.h
BusLogic.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 388 2019-06-05 17:37:11 +02:00
BusLogic.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 388 2019-06-05 17:37:11 +02:00
bvme6000_scsi.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
ch.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
constants.c
dc395x.c scsi: remove the use_clustering flag 2018-12-18 23:19:21 -05:00
dc395x.h
dmx3191d.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 61 2019-05-24 17:36:45 +02:00
dpt_i2o.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
dpti.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
esp_scsi.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
esp_scsi.h
FlashPoint.c
g_NCR5380.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
gdth_ioctl.h scsi: gdth: remove dead code under #ifdef GDTH_IOCTL_PROC 2019-01-08 21:58:35 -05:00
gdth_proc.c scsi: gdth: use generic DMA API 2019-01-08 21:58:35 -05:00
gdth_proc.h scsi: gdth: remove gdth_{alloc,free}_ioctl 2019-01-08 21:57:42 -05:00
gdth.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 148 2019-05-30 11:25:18 -07:00
gdth.h scsi: gdth: remove ISA and EISA support 2019-01-08 21:58:35 -05:00
gvp11.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
gvp11.h
hosts.c treewide: Add SPDX license identifier for missed files 2019-05-21 10:50:45 +02:00
hpsa_cmd.h scsi: hpsa: correct ioaccel2 chaining 2019-06-07 09:19:08 -04:00
hpsa.c scsi: hpsa: correct ioaccel2 chaining 2019-06-07 09:19:08 -04:00
hpsa.h
hptiop.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 285 2019-06-05 17:36:37 +02:00
hptiop.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 285 2019-06-05 17:36:37 +02:00
imm.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
imm.h
initio.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 18 2019-05-21 11:28:46 +02:00
initio.h
ipr.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
ipr.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
ips.c scsi: remove the use_clustering flag 2018-12-18 23:19:21 -05:00
ips.h
iscsi_boot_sysfs.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 287 2019-06-05 17:36:37 +02:00
iscsi_tcp.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
iscsi_tcp.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
jazz_esp.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
lasi700.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 61 2019-05-24 17:36:45 +02:00
libiscsi_tcp.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
libiscsi.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
mac53c94.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
mac53c94.h
mac_esp.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
mac_scsi.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
Makefile scsi: remove the SCSI OSD library 2019-02-05 21:28:52 -05:00
megaraid.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
megaraid.h
mesh.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
mesh.h
mvme16x_scsi.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
mvme147.c scsi: flip the default on use_clustering 2018-12-18 23:13:12 -05:00
mvme147.h
mvumi.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 167 2019-05-30 11:26:39 -07:00
mvumi.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 167 2019-05-30 11:26:39 -07:00
myrb.c SCSI misc on 20181224 2018-12-28 14:48:06 -08:00
myrb.h
myrs.c scsi: myrs: Fix uninitialized variable 2019-05-20 10:56:43 -04:00
myrs.h
ncr53c8xx.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 61 2019-05-24 17:36:45 +02:00
ncr53c8xx.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 61 2019-05-24 17:36:45 +02:00
NCR5380.c scsi: NCR5380: Remove set but unused variable 2019-03-19 14:18:46 -04:00
NCR5380.h
nsp32_debug.c
nsp32_io.h
nsp32.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 118 2019-05-24 17:39:02 +02:00
nsp32.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 118 2019-05-24 17:39:02 +02:00
osst_detect.h
osst_options.h
osst.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
osst.h
pmcraid.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
pmcraid.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
ppa.c scsi: ppa: mark expected switch fall-through 2019-04-08 18:39:04 -05:00
ppa.h
ps3rom.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 164 2019-05-30 11:26:38 -07:00
qla1280.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 118 2019-05-24 17:39:02 +02:00
qla1280.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 118 2019-05-24 17:39:02 +02:00
qlogicfas408.c scsi: qlogicfas408: clean up a couple of indentation issues 2019-03-19 17:11:37 -04:00
qlogicfas408.h
qlogicfas.c scsi: remove the use_clustering flag 2018-12-18 23:19:21 -05:00
qlogicpti.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
qlogicpti.h scsi: qlogicpti: Use of_node_name_eq for node name comparisons 2019-02-13 22:07:03 -05:00
raid_class.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 437 2019-06-05 17:37:17 +02:00
script_asm.pl treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 61 2019-05-24 17:36:45 +02:00
scsi_common.c
scsi_debug.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 45 2019-05-24 17:27:12 +02:00
scsi_debugfs.c
scsi_debugfs.h
scsi_devinfo.c scsi: core: add new RDAC LENOVO/DE_Series device 2019-04-03 23:27:23 -04:00
scsi_dh.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
scsi_error.c treewide: Add SPDX license identifier for missed files 2019-05-21 10:50:45 +02:00
scsi_ioctl.c treewide: Add SPDX license identifier for missed files 2019-05-21 10:50:45 +02:00
scsi_lib_dma.c
scsi_lib.c treewide: Add SPDX license identifier for missed files 2019-05-21 10:50:45 +02:00
scsi_logging.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 428 2019-06-05 17:37:16 +02:00
scsi_logging.h
scsi_netlink.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
scsi_pm.c treewide: Add SPDX license identifier for missed files 2019-05-21 10:50:45 +02:00
scsi_priv.h scsi: sd: Revert "Rely on the driver core for asynchronous probing" 2019-04-29 17:13:12 -04:00
scsi_proc.c
scsi_sas_internal.h
scsi_scan.c scsi: core: map PQ=1, PDT=other values to SCSI_SCAN_TARGET_PRESENT 2019-04-15 22:25:00 -04:00
scsi_sysctl.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 209 2019-05-30 11:29:53 -07:00
scsi_sysfs.c treewide: Add SPDX license identifier for missed files 2019-05-21 10:50:45 +02:00
scsi_trace.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 336 2019-06-05 17:37:07 +02:00
scsi_transport_api.h
scsi_transport_fc.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
scsi_transport_iscsi.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
scsi_transport_sas.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 209 2019-05-30 11:29:53 -07:00
scsi_transport_spi.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
scsi_transport_srp.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 502 2019-06-19 17:09:56 +02:00
scsi.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
scsi.h
scsicam.c
sd_dif.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 410 2019-06-05 17:37:14 +02:00
sd_zbc.c sd_zbc: Fix report zones buffer allocation 2019-07-11 20:04:39 -06:00
sd.c SCSI fixes on 20190524 2019-05-24 17:30:28 -07:00
sd.h block: Kill gfp_t argument of blkdev_report_zones() 2019-07-11 20:04:37 -06:00
sense_codes.h
ses.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 176 2019-05-30 11:29:19 -07:00
sg.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 45 2019-05-24 17:27:12 +02:00
sgiwd93.c scsi: remove the use_clustering flag 2018-12-18 23:19:21 -05:00
sim710.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 61 2019-05-24 17:36:45 +02:00
sni_53c710.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 61 2019-05-24 17:36:45 +02:00
sr_ioctl.c
sr_vendor.c
sr.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
sr.h
st_options.h
st.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
st.h
stex.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
storvsc_drv.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 320 2019-06-05 17:37:05 +02:00
sun3_scsi_vme.c
sun3_scsi.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
sun3x_esp.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
sun_esp.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
virtio_scsi.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 78 2019-05-24 17:37:51 +02:00
vmw_pvscsi.c scsi: vmw_pscsi: Fix use-after-free in pvscsi_queue_lck() 2019-06-20 16:34:02 -04:00
vmw_pvscsi.h
wd33c93.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 118 2019-05-24 17:39:02 +02:00
wd33c93.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 118 2019-05-24 17:39:02 +02:00
wd719x.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
wd719x.h
xen-scsifront.c scsi: xen-scsifront: remove DISABLE_CLUSTERING 2018-12-18 23:13:12 -05:00
zalon.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
zorro7xx.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
zorro_esp.c