Linux-Block Archive on lore.kernel.org
 help / Atom feed
* [PATCH 1/1] nbd: add netlink reconfigure resize support
@ 2019-05-16  0:38 Mike Christie
  2019-05-26 20:43 ` Mike Christie
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Christie @ 2019-05-16  0:38 UTC (permalink / raw)
  To: josef, linux-block; +Cc: Mike Christie

If the device is setup with ioctl we can resize the device after the
initial setup, but if the device is setup with netlink we cannot use the
resize related ioctls and there is no netlink reconfigure size ATTR
handling code.

This patch adds netlink reconfigure resize support to match the ioctl
interface.

Signed-off-by: Mike Christie <mchristi@redhat.com>
---
 drivers/block/nbd.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 053958a8a2ba..68b9d4b2d1be 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1939,6 +1939,15 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
 		goto out;
 	}
 
+	if (info->attrs[NBD_ATTR_SIZE_BYTES]) {
+		u64 bytes = nla_get_u64(info->attrs[NBD_ATTR_SIZE_BYTES]);
+		nbd_size_set(nbd, config->blksize,
+			     div64_u64(bytes, config->blksize));
+	}
+	if (info->attrs[NBD_ATTR_BLOCK_SIZE_BYTES]) {
+		u64 bsize = nla_get_u64(info->attrs[NBD_ATTR_BLOCK_SIZE_BYTES]);
+		nbd_size_set(nbd, bsize, div64_u64(config->bytesize, bsize));
+	}
 	if (info->attrs[NBD_ATTR_TIMEOUT]) {
 		u64 timeout = nla_get_u64(info->attrs[NBD_ATTR_TIMEOUT]);
 		nbd->tag_set.timeout = timeout * HZ;
-- 
2.21.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] nbd: add netlink reconfigure resize support
  2019-05-16  0:38 [PATCH 1/1] nbd: add netlink reconfigure resize support Mike Christie
@ 2019-05-26 20:43 ` Mike Christie
  0 siblings, 0 replies; 4+ messages in thread
From: Mike Christie @ 2019-05-26 20:43 UTC (permalink / raw)
  To: josef, linux-block

Ignore this patch. I had copied nbd_genl_connect, but there is no need
to do 2 nbd_size_set calls if both attrs are set. I am going to resubmit
a new patch.

On 05/15/2019 07:38 PM, Mike Christie wrote:
> If the device is setup with ioctl we can resize the device after the
> initial setup, but if the device is setup with netlink we cannot use the
> resize related ioctls and there is no netlink reconfigure size ATTR
> handling code.
> 
> This patch adds netlink reconfigure resize support to match the ioctl
> interface.
> 
> Signed-off-by: Mike Christie <mchristi@redhat.com>
> ---
>  drivers/block/nbd.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index 053958a8a2ba..68b9d4b2d1be 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -1939,6 +1939,15 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
>  		goto out;
>  	}
>  
> +	if (info->attrs[NBD_ATTR_SIZE_BYTES]) {
> +		u64 bytes = nla_get_u64(info->attrs[NBD_ATTR_SIZE_BYTES]);
> +		nbd_size_set(nbd, config->blksize,
> +			     div64_u64(bytes, config->blksize));
> +	}
> +	if (info->attrs[NBD_ATTR_BLOCK_SIZE_BYTES]) {
> +		u64 bsize = nla_get_u64(info->attrs[NBD_ATTR_BLOCK_SIZE_BYTES]);
> +		nbd_size_set(nbd, bsize, div64_u64(config->bytesize, bsize));
> +	}
>  	if (info->attrs[NBD_ATTR_TIMEOUT]) {
>  		u64 timeout = nla_get_u64(info->attrs[NBD_ATTR_TIMEOUT]);
>  		nbd->tag_set.timeout = timeout * HZ;
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] nbd: add netlink reconfigure resize support
  2019-05-26 21:49 Mike Christie
@ 2019-05-27 23:30 ` Mike Christie
  0 siblings, 0 replies; 4+ messages in thread
From: Mike Christie @ 2019-05-27 23:30 UTC (permalink / raw)
  To: josef, linux-block

On 05/26/2019 04:49 PM, Mike Christie wrote:
> If the device is setup with ioctl we can resize the device after the
> initial setup, but if the device is setup with netlink we cannot use the
> resize related ioctls and there is no netlink reconfigure size ATTR
> handling code.
> 
> This patch adds netlink reconfigure resize support to match the ioctl
> interface.
> 
> Signed-off-by: Mike Christie <mchristi@redhat.com>
> ---
> 
> V2:
> - Merge reconfig and connect resize related code to helper and avoid
> multiple nbd_size_set calls.
> 
>  drivers/block/nbd.c | 29 +++++++++++++++++++----------
>  1 file changed, 19 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index 053958a8a2ba..d75b67c12392 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -1674,6 +1674,21 @@ nbd_device_policy[NBD_DEVICE_ATTR_MAX + 1] = {
>  	[NBD_DEVICE_CONNECTED]		=	{ .type = NLA_U8 },
>  };
>  
> +static void nbd_genl_set_size(struct genl_info *info, struct nbd_device *nbd)
> +{
> +	struct nbd_config *config = nbd->config;
> +	u64 bsize = config->blksize;
> +	u64 bytes = config->bytesize;
> +
> +	if (info->attrs[NBD_ATTR_SIZE_BYTES])
> +		bytes = nla_get_u64(info->attrs[NBD_ATTR_SIZE_BYTES]);
> +
> +	if (info->attrs[NBD_ATTR_BLOCK_SIZE_BYTES])
> +		bsize = nla_get_u64(info->attrs[NBD_ATTR_BLOCK_SIZE_BYTES]);
> +
> +	nbd_size_set(nbd, bsize, div64_u64(bytes, bsize));
> +}
> +

I'm sorry. I do not know what I am thinking. Ignore this patch too. It
is bad. It will always be called in the reconfig case.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/1] nbd: add netlink reconfigure resize support
@ 2019-05-26 21:49 Mike Christie
  2019-05-27 23:30 ` Mike Christie
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Christie @ 2019-05-26 21:49 UTC (permalink / raw)
  To: josef, linux-block; +Cc: Mike Christie

If the device is setup with ioctl we can resize the device after the
initial setup, but if the device is setup with netlink we cannot use the
resize related ioctls and there is no netlink reconfigure size ATTR
handling code.

This patch adds netlink reconfigure resize support to match the ioctl
interface.

Signed-off-by: Mike Christie <mchristi@redhat.com>
---

V2:
- Merge reconfig and connect resize related code to helper and avoid
multiple nbd_size_set calls.

 drivers/block/nbd.c | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 053958a8a2ba..d75b67c12392 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1674,6 +1674,21 @@ nbd_device_policy[NBD_DEVICE_ATTR_MAX + 1] = {
 	[NBD_DEVICE_CONNECTED]		=	{ .type = NLA_U8 },
 };
 
+static void nbd_genl_set_size(struct genl_info *info, struct nbd_device *nbd)
+{
+	struct nbd_config *config = nbd->config;
+	u64 bsize = config->blksize;
+	u64 bytes = config->bytesize;
+
+	if (info->attrs[NBD_ATTR_SIZE_BYTES])
+		bytes = nla_get_u64(info->attrs[NBD_ATTR_SIZE_BYTES]);
+
+	if (info->attrs[NBD_ATTR_BLOCK_SIZE_BYTES])
+		bsize = nla_get_u64(info->attrs[NBD_ATTR_BLOCK_SIZE_BYTES]);
+
+	nbd_size_set(nbd, bsize, div64_u64(bytes, bsize));
+}
+
 static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)
 {
 	struct nbd_device *nbd = NULL;
@@ -1761,16 +1776,8 @@ static int nbd_genl_connect(struct sk_buff *skb, struct genl_info *info)
 	refcount_set(&nbd->config_refs, 1);
 	set_bit(NBD_BOUND, &config->runtime_flags);
 
-	if (info->attrs[NBD_ATTR_SIZE_BYTES]) {
-		u64 bytes = nla_get_u64(info->attrs[NBD_ATTR_SIZE_BYTES]);
-		nbd_size_set(nbd, config->blksize,
-			     div64_u64(bytes, config->blksize));
-	}
-	if (info->attrs[NBD_ATTR_BLOCK_SIZE_BYTES]) {
-		u64 bsize =
-			nla_get_u64(info->attrs[NBD_ATTR_BLOCK_SIZE_BYTES]);
-		nbd_size_set(nbd, bsize, div64_u64(config->bytesize, bsize));
-	}
+	nbd_genl_set_size(info, nbd);
+
 	if (info->attrs[NBD_ATTR_TIMEOUT]) {
 		u64 timeout = nla_get_u64(info->attrs[NBD_ATTR_TIMEOUT]);
 		nbd->tag_set.timeout = timeout * HZ;
@@ -1939,6 +1946,8 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info)
 		goto out;
 	}
 
+	nbd_genl_set_size(info, nbd);
+
 	if (info->attrs[NBD_ATTR_TIMEOUT]) {
 		u64 timeout = nla_get_u64(info->attrs[NBD_ATTR_TIMEOUT]);
 		nbd->tag_set.timeout = timeout * HZ;
-- 
2.21.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-16  0:38 [PATCH 1/1] nbd: add netlink reconfigure resize support Mike Christie
2019-05-26 20:43 ` Mike Christie
2019-05-26 21:49 Mike Christie
2019-05-27 23:30 ` Mike Christie

Linux-Block Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-block/0 linux-block/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-block linux-block/ https://lore.kernel.org/linux-block \
		linux-block@vger.kernel.org linux-block@archiver.kernel.org
	public-inbox-index linux-block


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-block


AGPL code for this site: git clone https://public-inbox.org/ public-inbox