@@ -2450,6 +2450,8 @@ static sense_reason_t
core_scsi3_emulate_pro_reserve(struct se_cmd *cmd, int type, int scope,
u64 res_key)
{
+ struct se_device *dev = cmd->se_dev;
+
switch (type) {
case PR_TYPE_WRITE_EXCLUSIVE:
case PR_TYPE_EXCLUSIVE_ACCESS:
@@ -2457,7 +2459,14 @@ core_scsi3_emulate_pro_reserve(struct se_cmd *cmd, int type, int scope,
case PR_TYPE_EXCLUSIVE_ACCESS_REGONLY:
case PR_TYPE_WRITE_EXCLUSIVE_ALLREG:
case PR_TYPE_EXCLUSIVE_ACCESS_ALLREG:
- return core_scsi3_pro_reserve(cmd, type, scope, res_key);
+ if (dev->transport->pr_ops &&
+ dev->transport->pr_ops->pr_register &&
+ dev->passthrough_pr)
+ return dev->transport->pr_ops->pr_reserve(cmd, type,
+ res_key);
+ else
+ return core_scsi3_pro_reserve(cmd, type, scope,
+ res_key);
default:
pr_err("SPC-3 PR: Unknown Service Action RESERVE Type:"
" 0x%02x\n", type);
@@ -3011,6 +3011,7 @@ tcmu_execute_pr_reserve(struct se_cmd *cmd, int type, u64 key)
sense_reason_t ret;
int retries = 0;
+ mutex_lock(&udev->pr_info.pr_info_lock);
udev->pr_info.pr_info_buf = kzalloc(TCMU_PR_INFO_XATTR_MAX_SIZE,
GFP_KERNEL);
if (!udev->pr_info.pr_info_buf)
@@ -3127,6 +3128,7 @@ tcmu_execute_pr_reserve(struct se_cmd *cmd, int type, u64 key)
tcmu_pr_info_free(pr_info);
kfree(pr_xattr);
kfree(udev->pr_info.pr_info_buf);
+ mutex_unlock(&udev->pr_info.pr_info_lock);
return ret;
}
This patch would enable the passthrough Persist Reservation Reserve operation routine for TCMU devices. If dev->passthrough_pr is 1, both dev->transport->pr_ops and dev->transport->pr_ops->pr_register are not NULL, core_scsi3_emulate_pro_reserve() will call dev->transport->pr_ops->pr_reserve to passthrough data to user space. Signed-off-by: Zhu Lingshan <lszhu@suse.com> --- drivers/target/target_core_pr.c | 11 ++++++++++- drivers/target/target_core_user.c | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-)