summaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
authorBryant G. Ly <bryantly@linux.vnet.ibm.com>2017-06-06 09:28:51 -0500
committerNicholas Bellinger <nab@linux-iscsi.org>2017-07-06 23:11:31 -0700
commitee01825220f01c0befea25f08325962fa9374ee2 (patch)
tree8423385f45b34cd97eaa9299599b678f0ba7fb42 /drivers/target
parent801fc54d5d943e8a6a6bc26bc94fb9b90938ff68 (diff)
downloadlinux-ee01825220f01c0befea25f08325962fa9374ee2.tar.bz2
tcmu: Make dev_config configurable
This allows for userspace to change the device path after it has been created. Thus giving the user the ability to change the path. The use case for this is to allow for virtual optical to have media change. Signed-off-by: Bryant G. Ly <bryantly@linux.vnet.ibm.com> Reviewed-By: Mike Christie <mchristi@redhat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/target_core_user.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index c8c84b71dc91..7c6475731895 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -1548,6 +1548,46 @@ static ssize_t tcmu_cmd_time_out_store(struct config_item *item, const char *pag
}
CONFIGFS_ATTR(tcmu_, cmd_time_out);
+static ssize_t tcmu_dev_path_show(struct config_item *item, char *page)
+{
+ struct se_dev_attrib *da = container_of(to_config_group(item),
+ struct se_dev_attrib, da_group);
+ struct tcmu_dev *udev = TCMU_DEV(da->da_dev);
+
+ return snprintf(page, PAGE_SIZE, "%s\n", udev->dev_config);
+}
+
+static ssize_t tcmu_dev_path_store(struct config_item *item, const char *page,
+ size_t count)
+{
+ struct se_dev_attrib *da = container_of(to_config_group(item),
+ struct se_dev_attrib, da_group);
+ struct tcmu_dev *udev = TCMU_DEV(da->da_dev);
+ char *copy = NULL;
+ int ret;
+
+ copy = kstrdup(page, GFP_KERNEL);
+ if (!copy) {
+ kfree(copy);
+ return -EINVAL;
+ }
+ strlcpy(udev->dev_config, copy, TCMU_CONFIG_LEN);
+
+ /* Check if device has been configured before */
+ if (tcmu_dev_configured(udev)) {
+ ret = tcmu_netlink_event(TCMU_CMD_RECONFIG_DEVICE,
+ udev->uio_info.name,
+ udev->uio_info.uio_dev->minor);
+ if (ret) {
+ pr_err("Unable to reconfigure device\n");
+ return ret;
+ }
+ }
+
+ return count;
+}
+CONFIGFS_ATTR(tcmu_, dev_path);
+
static ssize_t tcmu_dev_size_show(struct config_item *item, char *page)
{
struct se_dev_attrib *da = container_of(to_config_group(item),
@@ -1626,6 +1666,7 @@ CONFIGFS_ATTR(tcmu_, emulate_write_cache);
struct configfs_attribute *tcmu_attrib_attrs[] = {
&tcmu_attr_cmd_time_out,
+ &tcmu_attr_dev_path,
&tcmu_attr_dev_size,
&tcmu_attr_emulate_write_cache,
NULL,