Skip to content

Commit 7f9d35d

Browse files
damien-lemoalaxboe
authored andcommitted
scsi: sd_zbc: Rearrange code
Move the urswrz check out of sd_zbc_read_zones() and into sd_zbc_read_zoned_characteristics() where that value is obtained (read from the disk zoned characteristics VPD page). Since this function now does more than simply reading the VPD page, rename it to sd_zbc_check_zoned_characteristics(). Also fix the error message displayed when reading that VPD page fails. Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.com> Acked-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>
1 parent cdffab7 commit 7f9d35d

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

drivers/scsi/sd_zbc.c

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -305,19 +305,19 @@ void sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes,
305305
}
306306

307307
/**
308-
* sd_zbc_read_zoned_characteristics - Read zoned block device characteristics
308+
* sd_zbc_check_zoned_characteristics - Check zoned block device characteristics
309309
* @sdkp: Target disk
310310
* @buf: Buffer where to store the VPD page data
311311
*
312-
* Read VPD page B6.
312+
* Read VPD page B6, get information and check that reads are unconstrained.
313313
*/
314-
static int sd_zbc_read_zoned_characteristics(struct scsi_disk *sdkp,
315-
unsigned char *buf)
314+
static int sd_zbc_check_zoned_characteristics(struct scsi_disk *sdkp,
315+
unsigned char *buf)
316316
{
317317

318318
if (scsi_get_vpd_page(sdkp->device, 0xb6, buf, 64)) {
319319
sd_printk(KERN_NOTICE, sdkp,
320-
"Unconstrained-read check failed\n");
320+
"Read zoned characteristics VPD page failed\n");
321321
return -ENODEV;
322322
}
323323

@@ -335,6 +335,18 @@ static int sd_zbc_read_zoned_characteristics(struct scsi_disk *sdkp,
335335
sdkp->zones_max_open = get_unaligned_be32(&buf[16]);
336336
}
337337

338+
/*
339+
* Check for unconstrained reads: host-managed devices with
340+
* constrained reads (drives failing read after write pointer)
341+
* are not supported.
342+
*/
343+
if (!sdkp->urswrz) {
344+
if (sdkp->first_scan)
345+
sd_printk(KERN_NOTICE, sdkp,
346+
"constrained reads devices are not supported\n");
347+
return -ENODEV;
348+
}
349+
338350
return 0;
339351
}
340352

@@ -675,24 +687,11 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf)
675687
*/
676688
return 0;
677689

678-
/* Get zoned block device characteristics */
679-
ret = sd_zbc_read_zoned_characteristics(sdkp, buf);
690+
/* Check zoned block device characteristics (unconstrained reads) */
691+
ret = sd_zbc_check_zoned_characteristics(sdkp, buf);
680692
if (ret)
681693
goto err;
682694

683-
/*
684-
* Check for unconstrained reads: host-managed devices with
685-
* constrained reads (drives failing read after write pointer)
686-
* are not supported.
687-
*/
688-
if (!sdkp->urswrz) {
689-
if (sdkp->first_scan)
690-
sd_printk(KERN_NOTICE, sdkp,
691-
"constrained reads devices are not supported\n");
692-
ret = -ENODEV;
693-
goto err;
694-
}
695-
696695
/* Check capacity */
697696
ret = sd_zbc_check_capacity(sdkp, buf);
698697
if (ret)

0 commit comments

Comments
 (0)