From patchwork Tue May 30 18:31:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bryant G. Ly" X-Patchwork-Id: 9755115 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 E7514602BF for ; Tue, 30 May 2017 18:31:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D825127165 for ; Tue, 30 May 2017 18:31:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD1CC2785D; Tue, 30 May 2017 18:31:43 +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=-6.9 required=2.0 tests=BAYES_00,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 3226828405 for ; Tue, 30 May 2017 18:31:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751096AbdE3Sbi (ORCPT ); Tue, 30 May 2017 14:31:38 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33404 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751062AbdE3Sbg (ORCPT ); Tue, 30 May 2017 14:31:36 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v4UIStjk046430 for ; Tue, 30 May 2017 14:31:35 -0400 Received: from e13.ny.us.ibm.com (e13.ny.us.ibm.com [129.33.205.203]) by mx0b-001b2d01.pphosted.com with ESMTP id 2asdev1prh-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 30 May 2017 14:31:35 -0400 Received: from localhost by e13.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 30 May 2017 14:31:34 -0400 Received: from b01cxnp23032.gho.pok.ibm.com (9.57.198.27) by e13.ny.us.ibm.com (146.89.104.200) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 30 May 2017 14:31:31 -0400 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v4UIVW0U43122910; Tue, 30 May 2017 18:31:32 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C7919112047; Tue, 30 May 2017 14:31:34 -0400 (EDT) Received: from bryants-mbp-3.rchland.ibm.com (unknown [9.10.80.125]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id 72376112054; Tue, 30 May 2017 14:31:34 -0400 (EDT) From: "Bryant G. Ly" To: nab@linux-iscsi.org, mchristi@redhat.com Cc: seroyer@linux.vnet.ibm.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, "Bryant G. Ly" Subject: [PATCH v2 5/5] tcmu: Add Type of reconfig into netlink Date: Tue, 30 May 2017 13:31:20 -0500 X-Mailer: git-send-email 2.5.4 (Apple Git-61) In-Reply-To: <1496169080-58746-1-git-send-email-bryantly@linux.vnet.ibm.com> References: <1496169080-58746-1-git-send-email-bryantly@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17053018-0008-0000-0000-0000022E41D4 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007146; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000212; SDB=6.00867831; UDB=6.00431217; IPR=6.00647710; BA=6.00005387; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015648; XFM=3.00000015; UTC=2017-05-30 18:31:33 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17053018-0009-0000-0000-000035772636 Message-Id: <1496169080-58746-6-git-send-email-bryantly@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-30_12:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705300337 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 adds more info about the attribute being changed, so that usersapce can easily figure out what is happening. Signed-off-by: Bryant G. Ly --- drivers/target/target_core_user.c | 27 +++++++++++++++++++++------ include/uapi/linux/target_core_user.h | 1 + 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index 7575bc9..2d461c4 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -190,6 +190,13 @@ static struct genl_family tcmu_genl_family __ro_after_init = { .netnsok = true, }; +enum tcmu_reconfig_types { + No_reconfig, + Config_path, + Config_size, + Config_writecache +}; + #define tcmu_cmd_set_dbi_cur(cmd, index) ((cmd)->dbi_cur = (index)) #define tcmu_cmd_reset_dbi_cur(cmd) tcmu_cmd_set_dbi_cur(cmd, 0) #define tcmu_cmd_set_dbi(cmd, index) ((cmd)->dbi[(cmd)->dbi_cur++] = (index)) @@ -1176,7 +1183,8 @@ static int tcmu_release(struct uio_info *info, struct inode *inode) return 0; } -static int tcmu_netlink_event(enum tcmu_genl_cmd cmd, const char *name, int minor) +static int tcmu_netlink_event(enum tcmu_genl_cmd cmd, const char *name, + int minor, int type) { struct sk_buff *skb; void *msg_header; @@ -1198,6 +1206,10 @@ static int tcmu_netlink_event(enum tcmu_genl_cmd cmd, const char *name, int mino if (ret < 0) goto free_skb; + ret = nla_put_u32(skb, TCMU_ATTR_TYPE, type); + if (ret < 0) + goto free_skb; + genlmsg_end(skb, msg_header); ret = genlmsg_multicast_allns(&tcmu_genl_family, skb, 0, @@ -1301,7 +1313,7 @@ static int tcmu_configure_device(struct se_device *dev) kref_get(&udev->kref); ret = tcmu_netlink_event(TCMU_CMD_ADDED_DEVICE, udev->uio_info.name, - udev->uio_info.uio_dev->minor); + udev->uio_info.uio_dev->minor, No_reconfig); if (ret) goto err_netlink; @@ -1383,7 +1395,7 @@ static void tcmu_free_device(struct se_device *dev) if (tcmu_dev_configured(udev)) { tcmu_netlink_event(TCMU_CMD_REMOVED_DEVICE, udev->uio_info.name, - udev->uio_info.uio_dev->minor); + udev->uio_info.uio_dev->minor, No_reconfig); uio_unregister_device(&udev->uio_info); } @@ -1577,7 +1589,8 @@ static ssize_t tcmu_dev_path_store(struct config_item *item, const char *page, if (tcmu_dev_configured(udev)) { ret = tcmu_netlink_event(TCMU_CMD_RECONFIG_DEVICE, udev->uio_info.name, - udev->uio_info.uio_dev->minor); + udev->uio_info.uio_dev->minor, + Config_path); if (ret) { pr_err("Unable to reconfigure device\n"); return ret; @@ -1615,7 +1628,8 @@ static ssize_t tcmu_dev_size_store(struct config_item *item, const char *page, if (tcmu_dev_configured(udev)) { ret = tcmu_netlink_event(TCMU_CMD_RECONFIG_DEVICE, udev->uio_info.name, - udev->uio_info.uio_dev->minor); + udev->uio_info.uio_dev->minor, + Config_size); if (ret) { pr_err("Unable to reconfigure device\n"); return ret; @@ -1654,7 +1668,8 @@ static ssize_t tcmu_emulate_write_cache_store(struct config_item *item, if (tcmu_dev_configured(udev)) { ret = tcmu_netlink_event(TCMU_CMD_RECONFIG_DEVICE, udev->uio_info.name, - udev->uio_info.uio_dev->minor); + udev->uio_info.uio_dev->minor, + Config_writecache); if (ret) { pr_err("Unable to reconfigure device\n"); return ret; diff --git a/include/uapi/linux/target_core_user.h b/include/uapi/linux/target_core_user.h index 403a61f..ebad1f8 100644 --- a/include/uapi/linux/target_core_user.h +++ b/include/uapi/linux/target_core_user.h @@ -139,6 +139,7 @@ enum tcmu_genl_attr { TCMU_ATTR_UNSPEC, TCMU_ATTR_DEVICE, TCMU_ATTR_MINOR, + TCMU_ATTR_TYPE, __TCMU_ATTR_MAX, }; #define TCMU_ATTR_MAX (__TCMU_ATTR_MAX - 1)