linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/7] block: fix MAINTAINERS email for nbd
@ 2018-05-16 18:51 Josef Bacik
  2018-05-16 18:51 ` [PATCH 2/7] nbd: fix nbd device deletion Josef Bacik
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Josef Bacik @ 2018-05-16 18:51 UTC (permalink / raw)
  To: axboe, nbd, linux-block, kernel-team; +Cc: Josef Bacik

From: Josef Bacik <jbacik@fb.com>

I've been missing stuff because it's been going into my work email which
is a black hole.  Update to the email I actually use so I stop missing
patches and bug reports.

Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index df6e9bb2559a..10eca48b11b4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9700,7 +9700,7 @@ S:	Maintained
 F:	drivers/net/ethernet/netronome/
 
 NETWORK BLOCK DEVICE (NBD)
-M:	Josef Bacik <jbacik@fb.com>
+M:	Josef Bacik <josef@toxicpanda.com>
 S:	Maintained
 L:	linux-block@vger.kernel.org
 L:	nbd@other.debian.org
-- 
2.14.3

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

* [PATCH 2/7] nbd: fix nbd device deletion
  2018-05-16 18:51 [PATCH 1/7] block: fix MAINTAINERS email for nbd Josef Bacik
@ 2018-05-16 18:51 ` Josef Bacik
  2018-05-16 18:51 ` [PATCH 3/7] nbd: update size when connected Josef Bacik
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Josef Bacik @ 2018-05-16 18:51 UTC (permalink / raw)
  To: axboe, nbd, linux-block, kernel-team; +Cc: Josef Bacik, stable

From: Josef Bacik <jbacik@fb.com>

This fixes a use after free bug, we shouldn't be doing disk->queue right
after we do del_gendisk(disk).  Save the queue and do the cleanup after
the del_gendisk.

Fixes: c6a4759ea0c9 ("nbd: add device refcounting")
cc: stable@vger.kernel.org
Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 drivers/block/nbd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index afbc202ca6fd..9710a0c338b0 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -173,9 +173,12 @@ static const struct device_attribute pid_attr = {
 static void nbd_dev_remove(struct nbd_device *nbd)
 {
 	struct gendisk *disk = nbd->disk;
+	struct request_queue *q;
+
 	if (disk) {
+		q = disk->queue;
 		del_gendisk(disk);
-		blk_cleanup_queue(disk->queue);
+		blk_cleanup_queue(q);
 		blk_mq_free_tag_set(&nbd->tag_set);
 		disk->private_data = NULL;
 		put_disk(disk);
-- 
2.14.3

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

* [PATCH 3/7] nbd: update size when connected
  2018-05-16 18:51 [PATCH 1/7] block: fix MAINTAINERS email for nbd Josef Bacik
  2018-05-16 18:51 ` [PATCH 2/7] nbd: fix nbd device deletion Josef Bacik
@ 2018-05-16 18:51 ` Josef Bacik
  2018-05-16 18:51 ` [PATCH 4/7] nbd: use bd_set_size when updating disk size Josef Bacik
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Josef Bacik @ 2018-05-16 18:51 UTC (permalink / raw)
  To: axboe, nbd, linux-block, kernel-team; +Cc: Josef Bacik, stable

From: Josef Bacik <jbacik@fb.com>

I messed up changing the size of an NBD device while it was connected by
not actually updating the device or doing the uevent.  Fix this by
updating everything if we're connected and we change the size.

cc: stable@vger.kernel.org
Fixes: 639812a ("nbd: don't set the device size until we're connected")
Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 drivers/block/nbd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 9710a0c338b0..b709abf3cb79 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -246,6 +246,8 @@ static void nbd_size_set(struct nbd_device *nbd, loff_t blocksize,
 	struct nbd_config *config = nbd->config;
 	config->blksize = blocksize;
 	config->bytesize = blocksize * nr_blocks;
+	if (nbd->task_recv != NULL)
+		nbd_size_update(nbd);
 }
 
 static void nbd_complete_rq(struct request *req)
-- 
2.14.3

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

* [PATCH 4/7] nbd: use bd_set_size when updating disk size
  2018-05-16 18:51 [PATCH 1/7] block: fix MAINTAINERS email for nbd Josef Bacik
  2018-05-16 18:51 ` [PATCH 2/7] nbd: fix nbd device deletion Josef Bacik
  2018-05-16 18:51 ` [PATCH 3/7] nbd: update size when connected Josef Bacik
@ 2018-05-16 18:51 ` Josef Bacik
  2018-05-16 18:51 ` [PATCH 5/7] nbd: clear_sock on netlink disconnect Josef Bacik
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Josef Bacik @ 2018-05-16 18:51 UTC (permalink / raw)
  To: axboe, nbd, linux-block, kernel-team; +Cc: Josef Bacik, stable

From: Josef Bacik <jbacik@fb.com>

When we stopped relying on the bdev everywhere I broke updating the
block device size on the fly, which ceph relies on.  We can't just do
set_capacity, we also have to do bd_set_size so things like parted will
notice the device size change.

Fixes: 29eaadc ("nbd: stop using the bdev everywhere")
cc: stable@vger.kernel.org
Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 drivers/block/nbd.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index b709abf3cb79..64278f472efe 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -234,9 +234,18 @@ static void nbd_size_clear(struct nbd_device *nbd)
 static void nbd_size_update(struct nbd_device *nbd)
 {
 	struct nbd_config *config = nbd->config;
+	struct block_device *bdev = bdget_disk(nbd->disk, 0);
+
 	blk_queue_logical_block_size(nbd->disk->queue, config->blksize);
 	blk_queue_physical_block_size(nbd->disk->queue, config->blksize);
 	set_capacity(nbd->disk, config->bytesize >> 9);
+	if (bdev) {
+		if (bdev->bd_disk)
+			bd_set_size(bdev, config->bytesize);
+		else
+			bdev->bd_invalidated = 1;
+		bdput(bdev);
+	}
 	kobject_uevent(&nbd_to_dev(nbd)->kobj, KOBJ_CHANGE);
 }
 
@@ -1114,7 +1123,6 @@ static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *b
 	if (ret)
 		return ret;
 
-	bd_set_size(bdev, config->bytesize);
 	if (max_part)
 		bdev->bd_invalidated = 1;
 	mutex_unlock(&nbd->config_lock);
-- 
2.14.3

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

* [PATCH 5/7] nbd: clear_sock on netlink disconnect
  2018-05-16 18:51 [PATCH 1/7] block: fix MAINTAINERS email for nbd Josef Bacik
                   ` (2 preceding siblings ...)
  2018-05-16 18:51 ` [PATCH 4/7] nbd: use bd_set_size when updating disk size Josef Bacik
@ 2018-05-16 18:51 ` Josef Bacik
  2018-05-16 18:51 ` [PATCH 6/7] nbd: fix how we set bd_invalidated Josef Bacik
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Josef Bacik @ 2018-05-16 18:51 UTC (permalink / raw)
  To: axboe, nbd, linux-block, kernel-team; +Cc: Josef Bacik

From: Josef Bacik <jbacik@fb.com>

This is what the ioctl based nbd disconnect does as well.  Without this
the device will just sit there and wait for the connection to go away
(or IO to occur) before the device gets torn down.  Instead clear
everything up on our end so the configuration goes away as quickly as
possible.

Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 drivers/block/nbd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 64278f472efe..06725ce97593 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1768,6 +1768,7 @@ static int nbd_genl_disconnect(struct sk_buff *skb, struct genl_info *info)
 	}
 	mutex_lock(&nbd->config_lock);
 	nbd_disconnect(nbd);
+	nbd_clear_sock(nbd);
 	mutex_unlock(&nbd->config_lock);
 	if (test_and_clear_bit(NBD_HAS_CONFIG_REF,
 			       &nbd->config->runtime_flags))
-- 
2.14.3

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

* [PATCH 6/7] nbd: fix how we set bd_invalidated
  2018-05-16 18:51 [PATCH 1/7] block: fix MAINTAINERS email for nbd Josef Bacik
                   ` (3 preceding siblings ...)
  2018-05-16 18:51 ` [PATCH 5/7] nbd: clear_sock on netlink disconnect Josef Bacik
@ 2018-05-16 18:51 ` Josef Bacik
  2018-05-16 18:51 ` [PATCH 7/7] nbd: call nbd_bdev_reset instead of bd_set_size on disconnect Josef Bacik
  2018-05-16 18:56 ` [PATCH 1/7] block: fix MAINTAINERS email for nbd Jens Axboe
  6 siblings, 0 replies; 8+ messages in thread
From: Josef Bacik @ 2018-05-16 18:51 UTC (permalink / raw)
  To: axboe, nbd, linux-block, kernel-team; +Cc: Josef Bacik

From: Josef Bacik <jbacik@fb.com>

bd_invalidated is kind of a pain wrt partitions as it really only
triggers the partition rescan if it is set after bd_ops->open() runs, so
setting it when we reset the device isn't useful.  We also sporadically
would still have partitions left over in some disconnect cases, so fix
this by always setting bd_invalidated on open if there's no
configuration or if we've had a disconnect action happen, that way the
partition table gets invalidated and rescanned properly.

Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 drivers/block/nbd.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 06725ce97593..24788bd10c8b 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -964,10 +964,6 @@ static void nbd_bdev_reset(struct block_device *bdev)
 	if (bdev->bd_openers > 1)
 		return;
 	bd_set_size(bdev, 0);
-	if (max_part > 0) {
-		blkdev_reread_part(bdev);
-		bdev->bd_invalidated = 1;
-	}
 }
 
 static void nbd_parse_flags(struct nbd_device *nbd)
@@ -1282,6 +1278,9 @@ static int nbd_open(struct block_device *bdev, fmode_t mode)
 		refcount_set(&nbd->config_refs, 1);
 		refcount_inc(&nbd->refs);
 		mutex_unlock(&nbd->config_lock);
+		bdev->bd_invalidated = 1;
+	} else if (nbd_disconnected(nbd->config)) {
+		bdev->bd_invalidated = 1;
 	}
 out:
 	mutex_unlock(&nbd_index_mutex);
-- 
2.14.3

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

* [PATCH 7/7] nbd: call nbd_bdev_reset instead of bd_set_size on disconnect
  2018-05-16 18:51 [PATCH 1/7] block: fix MAINTAINERS email for nbd Josef Bacik
                   ` (4 preceding siblings ...)
  2018-05-16 18:51 ` [PATCH 6/7] nbd: fix how we set bd_invalidated Josef Bacik
@ 2018-05-16 18:51 ` Josef Bacik
  2018-05-16 18:56 ` [PATCH 1/7] block: fix MAINTAINERS email for nbd Jens Axboe
  6 siblings, 0 replies; 8+ messages in thread
From: Josef Bacik @ 2018-05-16 18:51 UTC (permalink / raw)
  To: axboe, nbd, linux-block, kernel-team; +Cc: Josef Bacik

From: Josef Bacik <jbacik@fb.com>

We need to make sure we don't just set the size of the bdev to 0 while
it's being used by a file system.  We have the appropriate check in
nbd_bdev_reset, simply use that helper instead.

Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 drivers/block/nbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 24788bd10c8b..abc0a815354f 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1127,7 +1127,7 @@ static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *b
 	if (ret)
 		sock_shutdown(nbd);
 	mutex_lock(&nbd->config_lock);
-	bd_set_size(bdev, 0);
+	nbd_bdev_reset(bdev);
 	/* user requested, ignore socket errors */
 	if (test_bit(NBD_DISCONNECT_REQUESTED, &config->runtime_flags))
 		ret = 0;
-- 
2.14.3

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

* Re: [PATCH 1/7] block: fix MAINTAINERS email for nbd
  2018-05-16 18:51 [PATCH 1/7] block: fix MAINTAINERS email for nbd Josef Bacik
                   ` (5 preceding siblings ...)
  2018-05-16 18:51 ` [PATCH 7/7] nbd: call nbd_bdev_reset instead of bd_set_size on disconnect Josef Bacik
@ 2018-05-16 18:56 ` Jens Axboe
  6 siblings, 0 replies; 8+ messages in thread
From: Jens Axboe @ 2018-05-16 18:56 UTC (permalink / raw)
  To: Josef Bacik, nbd, linux-block, kernel-team; +Cc: Josef Bacik

On 5/16/18 12:51 PM, Josef Bacik wrote:
> From: Josef Bacik <jbacik@fb.com>
> 
> I've been missing stuff because it's been going into my work email which
> is a black hole.  Update to the email I actually use so I stop missing
> patches and bug reports.

Thanks, applied 1-7 for 4.18.

-- 
Jens Axboe

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

end of thread, other threads:[~2018-05-16 18:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-16 18:51 [PATCH 1/7] block: fix MAINTAINERS email for nbd Josef Bacik
2018-05-16 18:51 ` [PATCH 2/7] nbd: fix nbd device deletion Josef Bacik
2018-05-16 18:51 ` [PATCH 3/7] nbd: update size when connected Josef Bacik
2018-05-16 18:51 ` [PATCH 4/7] nbd: use bd_set_size when updating disk size Josef Bacik
2018-05-16 18:51 ` [PATCH 5/7] nbd: clear_sock on netlink disconnect Josef Bacik
2018-05-16 18:51 ` [PATCH 6/7] nbd: fix how we set bd_invalidated Josef Bacik
2018-05-16 18:51 ` [PATCH 7/7] nbd: call nbd_bdev_reset instead of bd_set_size on disconnect Josef Bacik
2018-05-16 18:56 ` [PATCH 1/7] block: fix MAINTAINERS email for nbd Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).