* [PATCH v1 1/4] tcmu: Support emulate_write_cache
2017-05-26 14:27 [PATCH v1 0/4] TCMU Enable Reconfiguration Patches Bryant G. Ly
@ 2017-05-26 14:27 ` Bryant G. Ly
2017-05-26 14:27 ` [PATCH v1 2/4] tcmu: Add netlink for device reconfiguration Bryant G. Ly
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Bryant G. Ly @ 2017-05-26 14:27 UTC (permalink / raw)
To: nab, mchristi; +Cc: seroyer, linux-scsi, target-devel, Bryant G. Ly
This will enable the toggling of write_cache in tcmu through targetcli-fb
Signed-off-by: Bryant G. Ly <bryantly@linux.vnet.ibm.com>
Reviewed-By: Mike Christie <mchristi@redhat.com>
---
drivers/target/target_core_user.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index beb5f09..0c797cc 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -1290,6 +1290,8 @@ static int tcmu_configure_device(struct se_device *dev)
/* Other attributes can be configured in userspace */
if (!dev->dev_attrib.hw_max_sectors)
dev->dev_attrib.hw_max_sectors = 128;
+ if (!dev->dev_attrib.emulate_write_cache)
+ dev->dev_attrib.emulate_write_cache = 0;
dev->dev_attrib.hw_queue_depth = 128;
/*
@@ -1546,6 +1548,32 @@ 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_emulate_write_cache_show(struct config_item *item,
+ char *page)
+{
+ struct se_dev_attrib *da = container_of(to_config_group(item),
+ struct se_dev_attrib, da_group);
+
+ return snprintf(page, PAGE_SIZE, "%i\n", da->emulate_write_cache);
+}
+
+static ssize_t tcmu_emulate_write_cache_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);
+ int val;
+ int ret;
+
+ ret = kstrtouint(page, 0, &val);
+ if (ret < 0)
+ return ret;
+
+ da->emulate_write_cache = val;
+ return count;
+}
+CONFIGFS_ATTR(tcmu_, emulate_write_cache);
+
static struct configfs_attribute **tcmu_attrs;
static struct target_backend_ops tcmu_ops = {
@@ -1682,6 +1710,8 @@ static int __init tcmu_module_init(void)
tcmu_attrs[i] = passthrough_attrib_attrs[i];
}
tcmu_attrs[i] = &tcmu_attr_cmd_time_out;
+ i++;
+ tcmu_attrs[i] = &tcmu_attr_emulate_write_cache;
tcmu_ops.tb_dev_attrib_attrs = tcmu_attrs;
ret = transport_backend_register(&tcmu_ops);
--
2.5.4 (Apple Git-61)
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v1 2/4] tcmu: Add netlink for device reconfiguration
2017-05-26 14:27 [PATCH v1 0/4] TCMU Enable Reconfiguration Patches Bryant G. Ly
2017-05-26 14:27 ` [PATCH v1 1/4] tcmu: Support emulate_write_cache Bryant G. Ly
@ 2017-05-26 14:27 ` Bryant G. Ly
2017-05-26 14:27 ` [PATCH v1 3/4] tcmu: Make dev_size configurable via userspace Bryant G. Ly
2017-05-26 14:27 ` [PATCH v1 4/4] tcmu: Make dev_config configurable Bryant G. Ly
3 siblings, 0 replies; 7+ messages in thread
From: Bryant G. Ly @ 2017-05-26 14:27 UTC (permalink / raw)
To: nab, mchristi; +Cc: seroyer, linux-scsi, target-devel, Bryant G. Ly
This gives tcmu the ability to handle events that can cause
reconfiguration, such as resize, path changes, write_cache, etc...
Signed-off-by: Bryant G. Ly <bryantly@linux.vnet.ibm.com>
Reviewed-By: Mike Christie <mchristi@redhat.com>
---
drivers/target/target_core_user.c | 12 ++++++++++++
include/uapi/linux/target_core_user.h | 1 +
2 files changed, 13 insertions(+)
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index 0c797cc..ae91822 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -1562,6 +1562,7 @@ static ssize_t tcmu_emulate_write_cache_store(struct config_item *item,
{
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);
int val;
int ret;
@@ -1570,6 +1571,17 @@ static ssize_t tcmu_emulate_write_cache_store(struct config_item *item,
return ret;
da->emulate_write_cache = val;
+
+ /* 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_, emulate_write_cache);
diff --git a/include/uapi/linux/target_core_user.h b/include/uapi/linux/target_core_user.h
index af17b41..403a61f 100644
--- a/include/uapi/linux/target_core_user.h
+++ b/include/uapi/linux/target_core_user.h
@@ -130,6 +130,7 @@ enum tcmu_genl_cmd {
TCMU_CMD_UNSPEC,
TCMU_CMD_ADDED_DEVICE,
TCMU_CMD_REMOVED_DEVICE,
+ TCMU_CMD_RECONFIG_DEVICE,
__TCMU_CMD_MAX,
};
#define TCMU_CMD_MAX (__TCMU_CMD_MAX - 1)
--
2.5.4 (Apple Git-61)
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v1 3/4] tcmu: Make dev_size configurable via userspace
2017-05-26 14:27 [PATCH v1 0/4] TCMU Enable Reconfiguration Patches Bryant G. Ly
2017-05-26 14:27 ` [PATCH v1 1/4] tcmu: Support emulate_write_cache Bryant G. Ly
2017-05-26 14:27 ` [PATCH v1 2/4] tcmu: Add netlink for device reconfiguration Bryant G. Ly
@ 2017-05-26 14:27 ` Bryant G. Ly
2017-05-29 20:01 ` Mike Christie
2017-05-26 14:27 ` [PATCH v1 4/4] tcmu: Make dev_config configurable Bryant G. Ly
3 siblings, 1 reply; 7+ messages in thread
From: Bryant G. Ly @ 2017-05-26 14:27 UTC (permalink / raw)
To: nab, mchristi; +Cc: seroyer, linux-scsi, target-devel, Bryant G. Ly
Allow tcmu backstores to be able to set the device size
after it has been configured via set attribute.
Part of support in userspace to support certain backstores
changing device size.
Signed-off-by: Bryant G. Ly <bryantly@linux.vnet.ibm.com>
---
drivers/target/target_core_user.c | 59 +++++++++++++++++++++++++++++++++++----
1 file changed, 54 insertions(+), 5 deletions(-)
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index ae91822..c8c84b7 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -1548,6 +1548,44 @@ 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_size_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, "%zu\n", udev->dev_size);
+}
+
+static ssize_t tcmu_dev_size_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);
+ unsigned long val;
+ int ret;
+
+ ret = kstrtoul(page, 0, &val);
+ if (ret < 0)
+ return ret;
+ udev->dev_size = val;
+
+ /* 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_size);
+
static ssize_t tcmu_emulate_write_cache_show(struct config_item *item,
char *page)
{
@@ -1586,6 +1624,13 @@ static ssize_t tcmu_emulate_write_cache_store(struct config_item *item,
}
CONFIGFS_ATTR(tcmu_, emulate_write_cache);
+struct configfs_attribute *tcmu_attrib_attrs[] = {
+ &tcmu_attr_cmd_time_out,
+ &tcmu_attr_dev_size,
+ &tcmu_attr_emulate_write_cache,
+ NULL,
+};
+
static struct configfs_attribute **tcmu_attrs;
static struct target_backend_ops tcmu_ops = {
@@ -1685,7 +1730,7 @@ static int unmap_thread_fn(void *data)
static int __init tcmu_module_init(void)
{
- int ret, i, len = 0;
+ int ret, i, k, len = 0;
BUILD_BUG_ON((sizeof(struct tcmu_cmd_entry) % TCMU_OP_ALIGN_SIZE) != 0);
@@ -1710,7 +1755,10 @@ static int __init tcmu_module_init(void)
for (i = 0; passthrough_attrib_attrs[i] != NULL; i++) {
len += sizeof(struct configfs_attribute *);
}
- len += sizeof(struct configfs_attribute *) * 2;
+ for (i = 0; tcmu_attrib_attrs[i] != NULL; i++) {
+ len += sizeof(struct configfs_attribute *);
+ }
+ len += sizeof(struct configfs_attribute *);
tcmu_attrs = kzalloc(len, GFP_KERNEL);
if (!tcmu_attrs) {
@@ -1721,9 +1769,10 @@ static int __init tcmu_module_init(void)
for (i = 0; passthrough_attrib_attrs[i] != NULL; i++) {
tcmu_attrs[i] = passthrough_attrib_attrs[i];
}
- tcmu_attrs[i] = &tcmu_attr_cmd_time_out;
- i++;
- tcmu_attrs[i] = &tcmu_attr_emulate_write_cache;
+ for (k = 0; tcmu_attrib_attrs[k] != NULL; k++) {
+ tcmu_attrs[i] = tcmu_attrib_attrs[k];
+ i++;
+ }
tcmu_ops.tb_dev_attrib_attrs = tcmu_attrs;
ret = transport_backend_register(&tcmu_ops);
--
2.5.4 (Apple Git-61)
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v1 3/4] tcmu: Make dev_size configurable via userspace
2017-05-26 14:27 ` [PATCH v1 3/4] tcmu: Make dev_size configurable via userspace Bryant G. Ly
@ 2017-05-29 20:01 ` Mike Christie
0 siblings, 0 replies; 7+ messages in thread
From: Mike Christie @ 2017-05-29 20:01 UTC (permalink / raw)
To: Bryant G. Ly, nab; +Cc: seroyer, linux-scsi, target-devel
On 05/26/2017 09:27 AM, Bryant G. Ly wrote:
> Allow tcmu backstores to be able to set the device size
> after it has been configured via set attribute.
>
> Part of support in userspace to support certain backstores
> changing device size.
>
> Signed-off-by: Bryant G. Ly <bryantly@linux.vnet.ibm.com>
> ---
> drivers/target/target_core_user.c | 59 +++++++++++++++++++++++++++++++++++----
> 1 file changed, 54 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
> index ae91822..c8c84b7 100644
> --- a/drivers/target/target_core_user.c
> +++ b/drivers/target/target_core_user.c
> @@ -1548,6 +1548,44 @@ 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_size_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, "%zu\n", udev->dev_size);
> +}
> +
> +static ssize_t tcmu_dev_size_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);
> + unsigned long val;
> + int ret;
> +
> + ret = kstrtoul(page, 0, &val);
> + if (ret < 0)
> + return ret;
> + udev->dev_size = val;
> +
> + /* Check if device has been configured before */
> + if (tcmu_dev_configured(udev)) {
> + ret = tcmu_netlink_event(TCMU_CMD_RECONFIG_DEVICE,
If we send an event for each attribute changed, maybe we want to add a
type or more info about the attr being changed, so userspace can easily
figure it out and it does not have to rescan everything multiple times.
Or maybe we just want to add a reconfig attr or control opt where after
userspace has reconfigured everything it wanted to runner can rescan
everything and updates itself.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v1 4/4] tcmu: Make dev_config configurable
2017-05-26 14:27 [PATCH v1 0/4] TCMU Enable Reconfiguration Patches Bryant G. Ly
` (2 preceding siblings ...)
2017-05-26 14:27 ` [PATCH v1 3/4] tcmu: Make dev_size configurable via userspace Bryant G. Ly
@ 2017-05-26 14:27 ` Bryant G. Ly
2017-05-29 19:57 ` Mike Christie
3 siblings, 1 reply; 7+ messages in thread
From: Bryant G. Ly @ 2017-05-26 14:27 UTC (permalink / raw)
To: nab, mchristi; +Cc: seroyer, linux-scsi, target-devel, Bryant G. Ly
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 | 40 +++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index c8c84b7..3036a57 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -1548,6 +1548,45 @@ 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;
+
+ copy = kstrdup(page, GFP_KERNEL);
+
+ if (!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 +1665,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)
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v1 4/4] tcmu: Make dev_config configurable
2017-05-26 14:27 ` [PATCH v1 4/4] tcmu: Make dev_config configurable Bryant G. Ly
@ 2017-05-29 19:57 ` Mike Christie
0 siblings, 0 replies; 7+ messages in thread
From: Mike Christie @ 2017-05-29 19:57 UTC (permalink / raw)
To: Bryant G. Ly, nab; +Cc: seroyer, linux-scsi, target-devel
On 05/26/2017 09:27 AM, Bryant G. Ly wrote:
> 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 | 40 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 40 insertions(+)
>
> diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
> index c8c84b7..3036a57 100644
> --- a/drivers/target/target_core_user.c
> +++ b/drivers/target/target_core_user.c
> @@ -1548,6 +1548,45 @@ 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;
> +
> + copy = kstrdup(page, GFP_KERNEL);
Cen remove the extra newline
> +
> + if (!copy)
> + return -EINVAL;
> +
> + strcpy(udev->dev_config, copy);
Missing a kree(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 +1665,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,
>
^ permalink raw reply [flat|nested] 7+ messages in thread