> @@ -79,6 +80,7 @@ static int sd_zbc_do_report_zones(struct scsi_disk *sdkp,
> unsigned char *buf,
> put_unaligned_be32(buflen, &cmd[10]);
> if (partial)
> cmd[14] = ZBC_REPORT_ZONE_PARTIAL;
> +
> memset(buf, 0, buflen);
>
> result = scsi_execute_req(sdp, cmd, DMA_FROM_DEVICE,
Spurious whitespace change.
> +static void *sd_zbc_alloc_report_buffer(struct request_queue *q,
> + unsigned int nr_zones, size_t *buflen,
> + gfp_t gfp_mask)
> +{
> + size_t bufsize;
> + void *buf;
> +
> + /*
> + * Report zone buffer size should be at most 64B times the number of
> + * zones requested plus the 64B reply header, but should be at least
> + * SECTOR_SIZE for ATA devices.
> + * Make sure that this size does not exceed the hardware capabilities.
> + * Furthermore, since the report zone command cannot be split, make
> + * sure that the allocated buffer can always be mapped by limiting the
> + * number of pages allocated to the HBA max segments limit.
> + */
> + nr_zones = min(nr_zones, SD_ZBC_REPORT_MAX_ZONES);
> + bufsize = roundup((nr_zones + 1) * 64, 512);
> + bufsize = min_t(size_t, bufsize,
> + queue_max_hw_sectors(q) << SECTOR_SHIFT);
> + bufsize = min_t(size_t, bufsize, queue_max_segments(q) << PAGE_SHIFT);
> +
> + buf = __vmalloc(bufsize, gfp_mask, PAGE_KERNEL);
__vmalloc is odd in that it takes a gfp parameter, but can't actually
use it for the page table allocations. So you'll need to do
memalloc_noio_save here, or even better do that in the block layer and
remove the gfp_t parameter from ->report_zones.