Skip to content

Commit eea6ef3

Browse files
mikechristiemartinkpetersen
authored andcommitted
scsi: sd: Have pr commands retry UAs
It's common to get a UA when doing PR commands. It could be due to a target restarting, transport level relogin or other PR commands like a release causing it. The upper layers don't get the sense and in some cases have no idea if it's a SCSI device, so this has the sd layer retry. Signed-off-by: Mike Christie <michael.christie@oracle.com> Link: https://lore.kernel.org/r/20240123002220.129141-15-michael.christie@oracle.com Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 8d24677 commit eea6ef3

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

drivers/scsi/sd.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,8 +1800,22 @@ static int sd_pr_in_command(struct block_device *bdev, u8 sa,
18001800
struct scsi_device *sdev = sdkp->device;
18011801
struct scsi_sense_hdr sshdr;
18021802
u8 cmd[10] = { PERSISTENT_RESERVE_IN, sa };
1803+
struct scsi_failure failure_defs[] = {
1804+
{
1805+
.sense = UNIT_ATTENTION,
1806+
.asc = SCMD_FAILURE_ASC_ANY,
1807+
.ascq = SCMD_FAILURE_ASCQ_ANY,
1808+
.allowed = 5,
1809+
.result = SAM_STAT_CHECK_CONDITION,
1810+
},
1811+
{}
1812+
};
1813+
struct scsi_failures failures = {
1814+
.failure_definitions = failure_defs,
1815+
};
18031816
const struct scsi_exec_args exec_args = {
18041817
.sshdr = &sshdr,
1818+
.failures = &failures,
18051819
};
18061820
int result;
18071821

@@ -1888,8 +1902,22 @@ static int sd_pr_out_command(struct block_device *bdev, u8 sa, u64 key,
18881902
struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk);
18891903
struct scsi_device *sdev = sdkp->device;
18901904
struct scsi_sense_hdr sshdr;
1905+
struct scsi_failure failure_defs[] = {
1906+
{
1907+
.sense = UNIT_ATTENTION,
1908+
.asc = SCMD_FAILURE_ASC_ANY,
1909+
.ascq = SCMD_FAILURE_ASCQ_ANY,
1910+
.allowed = 5,
1911+
.result = SAM_STAT_CHECK_CONDITION,
1912+
},
1913+
{}
1914+
};
1915+
struct scsi_failures failures = {
1916+
.failure_definitions = failure_defs,
1917+
};
18911918
const struct scsi_exec_args exec_args = {
18921919
.sshdr = &sshdr,
1920+
.failures = &failures,
18931921
};
18941922
int result;
18951923
u8 cmd[16] = { 0, };

0 commit comments

Comments
 (0)