All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Bryant G. Ly" <bryantly@linux.vnet.ibm.com>
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" <bryantly@linux.vnet.ibm.com>
Subject: [PATCH v2 4/5] tcmu: Make dev_config configurable
Date: Tue, 30 May 2017 13:31:19 -0500	[thread overview]
Message-ID: <1496169080-58746-5-git-send-email-bryantly@linux.vnet.ibm.com> (raw)
In-Reply-To: <1496169080-58746-1-git-send-email-bryantly@linux.vnet.ibm.com>

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>
---
 drivers/target/target_core_user.c | 41 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index c8c84b7..7575bc9 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) {
+		kree(copy);
+		return -EINVAL;
+	}
+	strcpy(udev->dev_config, copy);
+
+	/* 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,
-- 
2.5.4 (Apple Git-61)

  parent reply	other threads:[~2017-05-30 18:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-30 18:31 [PATCH v2 0/5] TCMU Enable Reconfiguration Patches Bryant G. Ly
2017-05-30 18:31 ` [PATCH v2 1/5] tcmu: Support emulate_write_cache Bryant G. Ly
2017-05-30 18:31 ` [PATCH v2 2/5] tcmu: Add netlink for device reconfiguration Bryant G. Ly
2017-05-30 18:31 ` [PATCH v2 3/5] tcmu: Make dev_size configurable via userspace Bryant G. Ly
2017-05-30 18:31 ` Bryant G. Ly [this message]
2017-05-30 23:21   ` [PATCH v2 4/5] tcmu: Make dev_config configurable kbuild test robot
2017-06-06  2:02   ` Mike Christie
2017-05-30 18:31 ` [PATCH v2 5/5] tcmu: Add Type of reconfig into netlink Bryant G. Ly
2017-06-06  2:10   ` Mike Christie
2017-06-03  6:58 ` [PATCH v2 0/5] TCMU Enable Reconfiguration Patches Nicholas A. Bellinger

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=1496169080-58746-5-git-send-email-bryantly@linux.vnet.ibm.com \
    --to=bryantly@linux.vnet.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mchristi@redhat.com \
    --cc=nab@linux-iscsi.org \
    --cc=seroyer@linux.vnet.ibm.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.