scsi: add a helper function to check the LUN holds a reservation or not
Change-Id: I8cf71783ad4af4f7bdef823018f907933b793c9d Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/455765 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
66bace41d7
commit
4f95ec427c
@ -73,6 +73,13 @@ spdk_scsi_pr_registrant_is_holder(struct spdk_scsi_lun *lun,
|
|||||||
return (lun->reservation.holder == reg);
|
return (lun->reservation.holder == reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* LUN holds a reservation or not */
|
||||||
|
static inline bool
|
||||||
|
spdk_scsi_pr_has_reservation(struct spdk_scsi_lun *lun)
|
||||||
|
{
|
||||||
|
return !(lun->reservation.holder == NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
spdk_scsi_pr_register_registrant(struct spdk_scsi_lun *lun,
|
spdk_scsi_pr_register_registrant(struct spdk_scsi_lun *lun,
|
||||||
struct spdk_scsi_port *initiator_port,
|
struct spdk_scsi_port *initiator_port,
|
||||||
@ -199,7 +206,7 @@ spdk_scsi_pr_out_reserve(struct spdk_scsi_task *task,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* reservation holder already exists */
|
/* reservation holder already exists */
|
||||||
if (lun->reservation.holder) {
|
if (spdk_scsi_pr_has_reservation(lun)) {
|
||||||
if (rtype != lun->reservation.rtype) {
|
if (rtype != lun->reservation.rtype) {
|
||||||
SPDK_ERRLOG("Reservation type doesn't match\n");
|
SPDK_ERRLOG("Reservation type doesn't match\n");
|
||||||
goto conflict;
|
goto conflict;
|
||||||
@ -313,7 +320,7 @@ spdk_scsi_pr_out_release(struct spdk_scsi_task *task,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* no reservation holder */
|
/* no reservation holder */
|
||||||
if (!lun->reservation.holder) {
|
if (!spdk_scsi_pr_has_reservation(lun)) {
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_SCSI, "RELEASE: no reservation holder\n");
|
SPDK_DEBUGLOG(SPDK_LOG_SCSI, "RELEASE: no reservation holder\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -429,7 +436,7 @@ spdk_scsi_pr_out_preempt(struct spdk_scsi_task *task,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* no persistent reservation */
|
/* no persistent reservation */
|
||||||
if (lun->reservation.holder == NULL) {
|
if (!spdk_scsi_pr_has_reservation(lun)) {
|
||||||
spdk_scsi_pr_remove_all_regs_by_key(lun, sa_rkey);
|
spdk_scsi_pr_remove_all_regs_by_key(lun, sa_rkey);
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_SCSI, "PREEMPT: no persistent reservation\n");
|
SPDK_DEBUGLOG(SPDK_LOG_SCSI, "PREEMPT: no persistent reservation\n");
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -598,7 +605,7 @@ spdk_scsi_pr_in_read_reservations(struct spdk_scsi_task *task,
|
|||||||
param = (struct spdk_scsi_pr_in_read_reservations_data *)(data);
|
param = (struct spdk_scsi_pr_in_read_reservations_data *)(data);
|
||||||
|
|
||||||
to_be32(¶m->header.pr_generation, lun->pr_generation);
|
to_be32(¶m->header.pr_generation, lun->pr_generation);
|
||||||
if (lun->reservation.holder) {
|
if (spdk_scsi_pr_has_reservation(lun)) {
|
||||||
all_regs = spdk_scsi_pr_is_all_registrants_type(lun);
|
all_regs = spdk_scsi_pr_is_all_registrants_type(lun);
|
||||||
if (all_regs) {
|
if (all_regs) {
|
||||||
to_be64(¶m->rkey, 0);
|
to_be64(¶m->rkey, 0);
|
||||||
@ -742,7 +749,7 @@ spdk_scsi_pr_check(struct spdk_scsi_task *task)
|
|||||||
bool dma_to_device = false;
|
bool dma_to_device = false;
|
||||||
|
|
||||||
/* no reservation holders */
|
/* no reservation holders */
|
||||||
if (lun->reservation.holder == NULL) {
|
if (!spdk_scsi_pr_has_reservation(lun)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user