Skip to content

Commit a35989a

Browse files
damien-lemoalmartinkpetersen
authored andcommitted
scsi: sd_zbc: Improve report zones error printout
In the case of a report zones command failure, instead of simply printing the host_byte and driver_byte values returned, print a message that is more human readable and useful, adding sense codes too. To do so, use the already defined sd_print_sense_hdr() and sd_print_result() functions by moving the declaration of these functions into sd.h. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Damien Le Moal <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 45dc8f2 commit a35989a

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

drivers/scsi/sd.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ static void sd_eh_reset(struct scsi_cmnd *);
122122
static int sd_eh_action(struct scsi_cmnd *, int);
123123
static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer);
124124
static void scsi_disk_release(struct device *cdev);
125-
static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *);
126-
static void sd_print_result(const struct scsi_disk *, const char *, int);
127125

128126
static DEFINE_IDA(sd_index_ida);
129127

@@ -3704,15 +3702,13 @@ static void __exit exit_sd(void)
37043702
module_init(init_sd);
37053703
module_exit(exit_sd);
37063704

3707-
static void sd_print_sense_hdr(struct scsi_disk *sdkp,
3708-
struct scsi_sense_hdr *sshdr)
3705+
void sd_print_sense_hdr(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr)
37093706
{
37103707
scsi_print_sense_hdr(sdkp->device,
37113708
sdkp->disk ? sdkp->disk->disk_name : NULL, sshdr);
37123709
}
37133710

3714-
static void sd_print_result(const struct scsi_disk *sdkp, const char *msg,
3715-
int result)
3711+
void sd_print_result(const struct scsi_disk *sdkp, const char *msg, int result)
37163712
{
37173713
const char *hb_string = scsi_hostbyte_string(result);
37183714
const char *db_string = scsi_driverbyte_string(result);
@@ -3727,4 +3723,3 @@ static void sd_print_result(const struct scsi_disk *sdkp, const char *msg,
37273723
"%s: Result: hostbyte=0x%02x driverbyte=0x%02x\n",
37283724
msg, host_byte(result), driver_byte(result));
37293725
}
3730-

drivers/scsi/sd.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,7 @@ static inline void sd_zbc_complete(struct scsi_cmnd *cmd,
239239

240240
#endif /* CONFIG_BLK_DEV_ZONED */
241241

242+
void sd_print_sense_hdr(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr);
243+
void sd_print_result(const struct scsi_disk *sdkp, const char *msg, int result);
244+
242245
#endif /* _SCSI_DISK_H */

drivers/scsi/sd_zbc.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ static int sd_zbc_do_report_zones(struct scsi_disk *sdkp, unsigned char *buf,
8787
timeout, SD_MAX_RETRIES, NULL);
8888
if (result) {
8989
sd_printk(KERN_ERR, sdkp,
90-
"REPORT ZONES lba %llu failed with %d/%d\n",
91-
(unsigned long long)lba,
92-
host_byte(result), driver_byte(result));
90+
"REPORT ZONES start lba %llu failed\n", lba);
91+
sd_print_result(sdkp, "REPORT ZONES", result);
92+
if (driver_byte(result) == DRIVER_SENSE &&
93+
scsi_sense_valid(&sshdr))
94+
sd_print_sense_hdr(sdkp, &sshdr);
9395
return -EIO;
9496
}
9597

0 commit comments

Comments
 (0)