@@ -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);
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(+)