All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhu Lingshan <lszhu@suse.com>
To: target-devel@vger.kernel.org
Subject: [PATCH 25/33] TCMU PR: netlink support for passthrough PR info
Date: Fri, 15 Jun 2018 18:23:34 +0000	[thread overview]
Message-ID: <20180615182342.6239-25-lszhu@suse.com> (raw)

This patch added netlink support for passthrough Persistent
Reservation information.

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

diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index a89c866a755d..09a341e935a9 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -348,6 +348,7 @@ static struct nla_policy tcmu_attr_policy[TCMU_ATTR_MAX+1] = {
 	[TCMU_ATTR_CMD_STATUS]	= { .type = NLA_S32 },
 	[TCMU_ATTR_DEVICE_ID]	= { .type = NLA_U32 },
 	[TCMU_ATTR_SUPP_KERN_CMD_REPLY] = { .type = NLA_U8 },
+	[TCMU_ATTR_PR_INFO] = { .type = NLA_STRING },
 };
 
 static int tcmu_genl_cmd_done(struct genl_info *info, int completed_cmd)
@@ -389,6 +390,16 @@ static int tcmu_genl_cmd_done(struct genl_info *info, int completed_cmd)
 		nl_cmd->status = rc;
 	}
 
+	if (completed_cmd = TCMU_CMD_GET_PR_INFO) {
+		if (!info->attrs[TCMU_ATTR_PR_INFO]) {
+			ret = -EINVAL;
+		} else {
+			nla_strlcpy(udev->pr_info.pr_info_buf,
+				    info->attrs[TCMU_ATTR_PR_INFO],
+				    TCMU_PR_INFO_XATTR_MAX_SIZE);
+		}
+	}
+
 	spin_unlock(&udev->nl_cmd_lock);
 	if (!is_removed)
 		 target_undepend_item(&dev->dev_group.cg_item);
@@ -413,6 +424,18 @@ static int tcmu_genl_reconfig_dev_done(struct sk_buff *skb,
 	return tcmu_genl_cmd_done(info, TCMU_CMD_RECONFIG_DEVICE);
 }
 
+static int tcmu_genl_get_pr_info_done(struct sk_buff *skb,
+				      struct genl_info *info)
+{
+	return tcmu_genl_cmd_done(info, TCMU_CMD_GET_PR_INFO);
+}
+
+static int tcmu_genl_set_pr_info_done(struct sk_buff *skb,
+				      struct genl_info *info)
+{
+	return tcmu_genl_cmd_done(info, TCMU_CMD_SET_PR_INFO);
+}
+
 static int tcmu_genl_set_features(struct sk_buff *skb, struct genl_info *info)
 {
 	if (info->attrs[TCMU_ATTR_SUPP_KERN_CMD_REPLY]) {
@@ -450,6 +473,18 @@ static const struct genl_ops tcmu_genl_ops[] = {
 		.policy	= tcmu_attr_policy,
 		.doit	= tcmu_genl_reconfig_dev_done,
 	},
+	{
+		.cmd	= TCMU_CMD_GET_PR_INFO_DONE,
+		.flags	= GENL_ADMIN_PERM,
+		.policy	= tcmu_attr_policy,
+		.doit	= tcmu_genl_get_pr_info_done,
+	},
+	{
+		.cmd	= TCMU_CMD_SET_PR_INFO_DONE,
+		.flags	= GENL_ADMIN_PERM,
+		.policy	= tcmu_attr_policy,
+		.doit	= tcmu_genl_set_pr_info_done,
+	},
 };
 
 /* Our generic netlink family */
-- 
2.17.1


                 reply	other threads:[~2018-06-15 18:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180615182342.6239-25-lszhu@suse.com \
    --to=lszhu@suse.com \
    --cc=target-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.