Commit 62d01929 authored by Kou Jiawei's avatar Kou Jiawei Committed by Jim Harris
Browse files

lib/scsi: sync holder's reservation key if registrant key is updated



When SPDK acts as a SCSI target, a host may perform the following
operations on a specific IT nexus, leading to an issue:

1. Register & Ignore Existing Key, SAK=0x0a -> OK
2. Reserve, RK=0x0a -> OK
3. Register & Ignore Existing Key, SAK=0x0b, RK=0x0a -> OK
4. Read Reservation -> returns old RK=0x0a, but expected RK=0x0b.

The root cause is that when a "Register" or "Register & Ignore
Existing Key" operation changes the reservation key (RKey) of an
already registered nexus, SPDK fails to update the reservation
holder's key if that nexus is also the reservation holder.

This patch fixes the issue by ensuring the holder's reservation key
is also updated in this scenario.

Change-Id: I8c85ab74b88e972beb528e54ce564cc6ed53775d
Signed-off-by: default avatarKou Jiawei <kou.jiawei@zte.com.cn>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/26264


Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarChangpeng Liu <changpeliu@tencent.com>
parent a7c2f6e2
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -164,6 +164,9 @@ scsi_pr_replace_registrant_key(struct spdk_scsi_lun *lun,
{
	SPDK_DEBUGLOG(scsi, "REGISTER: replace with new "
		      "reservation key 0x%"PRIx64"\n", sa_rkey);
	if (lun->reservation.holder == reg) {
		lun->reservation.crkey = sa_rkey;
	}
	reg->rkey = sa_rkey;
	lun->pr_generation++;
}