From b51f9b228490ba61306060460164aed8f2e8fc8b Mon Sep 17 00:00:00 2001
From: Mike Christie <mchristi@redhat.com>
Date: Sun, 11 Jun 2017 15:59:25 -0500
Subject: [PATCH 1/1] tcmu: reconfigure netlink attr changes
1. TCMU_ATTR_TYPE is too generic when it describes only the
reconfiguration type, so rename to TCMU_ATTR_RECONFIG_TYPE.
2. Only return the reconfig type when it is a TCMU_CMD_RECONFIG_DEVICE
command.
3. CONFIG_* is probably too generic, so add a TCMU_* prefix.
Signed-off-by: Mike Christie <mchristi@redhat.com>
---
drivers/target/target_core_user.c | 20 ++++++++++++--------
include/uapi/linux/target_core_user.h | 10 +++++-----
2 files changed, 17 insertions(+), 13 deletions(-)
@@ -1199,9 +1199,11 @@ static int tcmu_netlink_event(enum tcmu_genl_cmd cmd, const char *name,
if (ret < 0)
goto free_skb;
- ret = nla_put_u32(skb, TCMU_ATTR_TYPE, type);
- if (ret < 0)
- goto free_skb;
+ if (cmd == TCMU_CMD_RECONFIG_DEVICE) {
+ ret = nla_put_u32(skb, TCMU_ATTR_RECONFIG_TYPE, type);
+ if (ret < 0)
+ goto free_skb;
+ }
genlmsg_end(skb, msg_header);
@@ -1306,7 +1308,8 @@ 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, NO_RECONFIG);
+ udev->uio_info.uio_dev->minor,
+ TCMU_CONFIG_NONE);
if (ret)
goto err_netlink;
@@ -1388,7 +1391,8 @@ 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, NO_RECONFIG);
+ udev->uio_info.uio_dev->minor,
+ TCMU_CONFIG_NONE);
uio_unregister_device(&udev->uio_info);
}
@@ -1583,7 +1587,7 @@ static ssize_t tcmu_dev_path_store(struct config_item *item, const char *page,
ret = tcmu_netlink_event(TCMU_CMD_RECONFIG_DEVICE,
udev->uio_info.name,
udev->uio_info.uio_dev->minor,
- CONFIG_PATH);
+ TCMU_CONFIG_PATH);
if (ret) {
pr_err("Unable to reconfigure device\n");
return ret;
@@ -1622,7 +1626,7 @@ static ssize_t tcmu_dev_size_store(struct config_item *item, const char *page,
ret = tcmu_netlink_event(TCMU_CMD_RECONFIG_DEVICE,
udev->uio_info.name,
udev->uio_info.uio_dev->minor,
- CONFIG_SIZE);
+ TCMU_CONFIG_SIZE);
if (ret) {
pr_err("Unable to reconfigure device\n");
return ret;
@@ -1662,7 +1666,7 @@ static ssize_t tcmu_emulate_write_cache_store(struct config_item *item,
ret = tcmu_netlink_event(TCMU_CMD_RECONFIG_DEVICE,
udev->uio_info.name,
udev->uio_info.uio_dev->minor,
- CONFIG_WRITECACHE);
+ TCMU_CONFIG_WRITECACHE);
if (ret) {
pr_err("Unable to reconfigure device\n");
return ret;
@@ -139,16 +139,16 @@ enum tcmu_genl_attr {
TCMU_ATTR_UNSPEC,
TCMU_ATTR_DEVICE,
TCMU_ATTR_MINOR,
- TCMU_ATTR_TYPE,
+ TCMU_ATTR_RECONFIG_TYPE,
__TCMU_ATTR_MAX,
};
#define TCMU_ATTR_MAX (__TCMU_ATTR_MAX - 1)
enum tcmu_reconfig_types {
- NO_RECONFIG,
- CONFIG_PATH,
- CONFIG_SIZE,
- CONFIG_WRITECACHE,
+ TCMU_CONFIG_NONE,
+ TCMU_CONFIG_PATH,
+ TCMU_CONFIG_SIZE,
+ TCMU_CONFIG_WRITECACHE,
};
#endif
--
1.8.3.1