diff mbox

[23/33] TCMU PR: func to handle PR read keys but no regs

Message ID 20180615182342.6239-23-lszhu@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Zhu Lingshan June 15, 2018, 6:23 p.m. UTC
When try to execute Persistent Reservation Read Keys,
but tcmu_pr_info_get() returns -ENODATA, this means there are no
registrations, so we should generate a fake empty struct
tcmu_pr_info, so that the code can keep running, but we don't
want to store it in the TCMU device, this is different from
tcmu_pr_info_init().

Signed-off-by: Zhu Lingshan <lszhu@suse.com>
---
 drivers/target/target_core_user.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
diff mbox

Patch

diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index c3adff826163..2fcdfc97ca75 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -2829,6 +2829,23 @@  tcmu_execute_pr_register(struct se_cmd *cmd, u64 old_key,
 	return ret;
 }
 
+static int tcmu_pr_info_mock_empty(struct tcmu_pr_info **_pr_info)
+{
+	struct tcmu_pr_info *pr_info;
+
+	pr_info = kzalloc(sizeof(*pr_info), GFP_KERNEL);
+	if (!pr_info)
+		return -ENOMEM;
+
+	pr_info->vers = TCMU_PR_INFO_XATTR_VERS;
+	INIT_LIST_HEAD(&pr_info->regs);
+
+	*_pr_info = pr_info;
+	pr_debug("successfully initialized mock PR info\n");
+
+	return 0;
+}
+
 static int tcmu_configure_device(struct se_device *dev)
 {
 	struct tcmu_dev *udev = TCMU_DEV(dev);