Skip to content

Commit a431269

Browse files
Hannes Reineckekawasaki
authored andcommitted
scsi: return PR generation if no reservation is held
For READ RESERVATION the PRgeneration value is always present, even if no reservations are held. Signed-off-by: Hannes Reinecke <[email protected]>
1 parent 2831934 commit a431269

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

drivers/scsi/sd.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,9 +2008,13 @@ static int sd_pr_read_reservation(struct block_device *bdev,
20082008
if (result)
20092009
return result;
20102010

2011+
rsv->generation = get_unaligned_be32(&data[0]);
2012+
rsv->type = 0;
20112013
len = get_unaligned_be32(&data[4]);
2012-
if (!len)
2014+
if (!len) {
2015+
rsv->key = 0;
20132016
return 0;
2017+
}
20142018

20152019
/* Make sure we have at least the key and type */
20162020
if (len < 14) {
@@ -2020,9 +2024,9 @@ static int sd_pr_read_reservation(struct block_device *bdev,
20202024
return -EINVAL;
20212025
}
20222026

2023-
rsv->generation = get_unaligned_be32(&data[0]);
20242027
rsv->key = get_unaligned_be64(&data[8]);
2025-
rsv->type = scsi_pr_type_to_block(data[21] & 0x0f);
2028+
if (len == 16)
2029+
rsv->type = scsi_pr_type_to_block(data[21] & 0x0f);
20262030
return 0;
20272031
}
20282032

0 commit comments

Comments
 (0)