From patchwork Fri Jun 15 18:23:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Lingshan X-Patchwork-Id: 10467317 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BAE4960384 for ; Fri, 15 Jun 2018 18:25:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A90A828E3B for ; Fri, 15 Jun 2018 18:25:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E0A928E40; Fri, 15 Jun 2018 18:25:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5313F28E3B for ; Fri, 15 Jun 2018 18:25:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756527AbeFOSZW (ORCPT ); Fri, 15 Jun 2018 14:25:22 -0400 Received: from smtp2.provo.novell.com ([137.65.250.81]:32969 "EHLO smtp2.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756524AbeFOSZU (ORCPT ); Fri, 15 Jun 2018 14:25:20 -0400 Received: from vstart.localdomain (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (TLS encrypted); Fri, 15 Jun 2018 12:25:16 -0600 From: Zhu Lingshan To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, nab@linux-iscsi.org, mchristi@redhat.com, martin.petersen@oracle.com Cc: hare@suse.de, lduncan@suse.com, ddiss@suse.de, lszhu@suse.de, Zhu Lingshan Subject: [PATCH 25/33] TCMU PR: netlink support for passthrough PR info Date: Sat, 16 Jun 2018 02:23:34 +0800 Message-Id: <20180615182342.6239-25-lszhu@suse.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180615182342.6239-1-lszhu@suse.com> References: <20180615182342.6239-1-lszhu@suse.com> Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch added netlink support for passthrough Persistent Reservation information. Signed-off-by: Zhu Lingshan --- 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 */