[PATCH 3/3] scsi: return PR generation if no reservation is held

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For READ RESERVATION the PRgeneration value is always present, even
if no reservations are held.

Signed-off-by: Hannes Reinecke <hare@xxxxxxxxxx>
---
 drivers/scsi/sd.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 950d8c9fb884..daa61feaf441 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2008,9 +2008,13 @@ static int sd_pr_read_reservation(struct block_device *bdev,
 	if (result)
 		return result;
 
+	rsv->generation = get_unaligned_be32(&data[0]);
+	rsv->type = 0;
 	len = get_unaligned_be32(&data[4]);
-	if (!len)
+	if (!len) {
+		rsv->key = 0;
 		return 0;
+	}
 
 	/* Make sure we have at least the key and type */
 	if (len < 14) {
@@ -2020,9 +2024,9 @@ static int sd_pr_read_reservation(struct block_device *bdev,
 		return -EINVAL;
 	}
 
-	rsv->generation = get_unaligned_be32(&data[0]);
 	rsv->key = get_unaligned_be64(&data[8]);
-	rsv->type = scsi_pr_type_to_block(data[21] & 0x0f);
+	if (len == 16)
+		rsv->type = scsi_pr_type_to_block(data[21] & 0x0f);
 	return 0;
 }
 
-- 
2.35.3





[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux