* [PATCH 5/6] tcmu: refactor nl dev_size attr with new helpers
@ 2018-04-16 11:04 Zhu Lingshan
2018-04-19 0:15 ` Mike Christie
2018-04-19 9:47 ` Zhu Lingshan
0 siblings, 2 replies; 3+ messages in thread
From: Zhu Lingshan @ 2018-04-16 11:04 UTC (permalink / raw)
To: target-devel
use new netlink events helpers tcmu_netlink_init() and
tcmu_netlink_send() to refactor netlink event attribute
TCMU_ATTR_DEV_SIZE(belongs to TCMU_CMD_RECONFIG_DEVICE)
which is also dev_size in configFS.
Signed-off-by: Zhu Lingshan <lszhu@suse.com>
---
drivers/target/target_core_user.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index f98b986e6d50..d913fb15f1b4 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -2300,6 +2300,27 @@ static ssize_t tcmu_dev_size_show(struct config_item *item, char *page)
return snprintf(page, PAGE_SIZE, "%zu\n", udev->dev_size);
}
+static int tcmu_send_dev_size_event(struct tcmu_dev *udev, u64 size)
+{
+ struct sk_buff *skb = NULL;
+ void *msg_header = NULL;
+ int ret = 0;
+
+ ret = tcmu_netlink_event_init(udev, TCMU_CMD_RECONFIG_DEVICE,
+ &skb, &msg_header);
+ if (ret < 0)
+ return ret;
+ ret = nla_put_u64_64bit(skb, TCMU_ATTR_DEV_SIZE,
+ size, TCMU_ATTR_PAD);
+ if (ret < 0) {
+ nlmsg_free(skb);
+ return ret;
+ }
+ ret = tcmu_netlink_event_send(udev, TCMU_CMD_RECONFIG_DEVICE,
+ &skb, &msg_header);
+ return ret;
+}
+
static ssize_t tcmu_dev_size_store(struct config_item *item, const char *page,
size_t count)
{
@@ -2315,8 +2336,7 @@ static ssize_t tcmu_dev_size_store(struct config_item *item, const char *page,
/* Check if device has been configured before */
if (tcmu_dev_configured(udev)) {
- ret = tcmu_netlink_event(udev, TCMU_CMD_RECONFIG_DEVICE,
- TCMU_ATTR_DEV_SIZE, &val);
+ ret = tcmu_send_dev_size_event(udev, val);
if (ret) {
pr_err("Unable to reconfigure device\n");
return ret;
--
2.14.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 5/6] tcmu: refactor nl dev_size attr with new helpers
2018-04-16 11:04 [PATCH 5/6] tcmu: refactor nl dev_size attr with new helpers Zhu Lingshan
@ 2018-04-19 0:15 ` Mike Christie
2018-04-19 9:47 ` Zhu Lingshan
1 sibling, 0 replies; 3+ messages in thread
From: Mike Christie @ 2018-04-19 0:15 UTC (permalink / raw)
To: target-devel
On 04/16/2018 06:04 AM, Zhu Lingshan wrote:
> use new netlink events helpers tcmu_netlink_init() and
> tcmu_netlink_send() to refactor netlink event attribute
> TCMU_ATTR_DEV_SIZE(belongs to TCMU_CMD_RECONFIG_DEVICE)
> which is also dev_size in configFS.
>
> Signed-off-by: Zhu Lingshan <lszhu@suse.com>
> ---
> drivers/target/target_core_user.c | 24 ++++++++++++++++++++++--
> 1 file changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
> index f98b986e6d50..d913fb15f1b4 100644
> --- a/drivers/target/target_core_user.c
> +++ b/drivers/target/target_core_user.c
> @@ -2300,6 +2300,27 @@ static ssize_t tcmu_dev_size_show(struct config_item *item, char *page)
> return snprintf(page, PAGE_SIZE, "%zu\n", udev->dev_size);
> }
>
> +static int tcmu_send_dev_size_event(struct tcmu_dev *udev, u64 size)
> +{
> + struct sk_buff *skb = NULL;
> + void *msg_header = NULL;
> + int ret = 0;
> +
> + ret = tcmu_netlink_event_init(udev, TCMU_CMD_RECONFIG_DEVICE,
> + &skb, &msg_header);
> + if (ret < 0)
> + return ret;
> + ret = nla_put_u64_64bit(skb, TCMU_ATTR_DEV_SIZE,
> + size, TCMU_ATTR_PAD);
> + if (ret < 0) {
> + nlmsg_free(skb);
> + return ret;
> + }
> + ret = tcmu_netlink_event_send(udev, TCMU_CMD_RECONFIG_DEVICE,
> + &skb, &msg_header);
You need to tab/space this over to match the other style.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 5/6] tcmu: refactor nl dev_size attr with new helpers
2018-04-16 11:04 [PATCH 5/6] tcmu: refactor nl dev_size attr with new helpers Zhu Lingshan
2018-04-19 0:15 ` Mike Christie
@ 2018-04-19 9:47 ` Zhu Lingshan
1 sibling, 0 replies; 3+ messages in thread
From: Zhu Lingshan @ 2018-04-19 9:47 UTC (permalink / raw)
To: target-devel
Thanks Mike, V2 is sent out :)
On 2018/4/19 8:15, Mike Christie wrote:
> On 04/16/2018 06:04 AM, Zhu Lingshan wrote:
>> use new netlink events helpers tcmu_netlink_init() and
>> tcmu_netlink_send() to refactor netlink event attribute
>> TCMU_ATTR_DEV_SIZE(belongs to TCMU_CMD_RECONFIG_DEVICE)
>> which is also dev_size in configFS.
>>
>> Signed-off-by: Zhu Lingshan <lszhu@suse.com>
>> ---
>> drivers/target/target_core_user.c | 24 ++++++++++++++++++++++--
>> 1 file changed, 22 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
>> index f98b986e6d50..d913fb15f1b4 100644
>> --- a/drivers/target/target_core_user.c
>> +++ b/drivers/target/target_core_user.c
>> @@ -2300,6 +2300,27 @@ static ssize_t tcmu_dev_size_show(struct config_item *item, char *page)
>> return snprintf(page, PAGE_SIZE, "%zu\n", udev->dev_size);
>> }
>>
>> +static int tcmu_send_dev_size_event(struct tcmu_dev *udev, u64 size)
>> +{
>> + struct sk_buff *skb = NULL;
>> + void *msg_header = NULL;
>> + int ret = 0;
>> +
>> + ret = tcmu_netlink_event_init(udev, TCMU_CMD_RECONFIG_DEVICE,
>> + &skb, &msg_header);
>> + if (ret < 0)
>> + return ret;
>> + ret = nla_put_u64_64bit(skb, TCMU_ATTR_DEV_SIZE,
>> + size, TCMU_ATTR_PAD);
>> + if (ret < 0) {
>> + nlmsg_free(skb);
>> + return ret;
>> + }
>> + ret = tcmu_netlink_event_send(udev, TCMU_CMD_RECONFIG_DEVICE,
>> + &skb, &msg_header);
> You need to tab/space this over to match the other style.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-04-19 9:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-16 11:04 [PATCH 5/6] tcmu: refactor nl dev_size attr with new helpers Zhu Lingshan
2018-04-19 0:15 ` Mike Christie
2018-04-19 9:47 ` Zhu Lingshan
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.