All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: axboe@kernel.dk, nbd@other.debian.org,
	linux-block@vger.kernel.org, kernel-team@fb.com,
	alex@iss-integration.com
Cc: Josef Bacik <jbacik@fb.com>, stable@vger.kernel.org
Subject: [PATCH 3/3] nbd: use bd_set_size when updating disk size
Date: Fri, 13 Apr 2018 12:03:34 -0400	[thread overview]
Message-ID: <20180413160334.5496-3-josef@toxicpanda.com> (raw)
In-Reply-To: <20180413160334.5496-1-josef@toxicpanda.com>

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 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 1520383b12f6..61dd95aa47fa 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -231,9 +231,15 @@ 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) {
+		bd_set_size(bdev, config->bytesize);
+		bdput(bdev);
+	}
 	kobject_uevent(&nbd_to_dev(nbd)->kobj, KOBJ_CHANGE);
 }
 
@@ -1111,7 +1117,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

  parent reply	other threads:[~2018-04-13 16:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-13 16:03 [PATCH 1/3] nbd: del_gendisk after we cleanup the queue Josef Bacik
2018-04-13 16:03 ` [PATCH 2/3] nbd: update size when connected Josef Bacik
2018-04-14  3:02   ` Alex Gorbachev
2018-04-13 16:03 ` Josef Bacik [this message]
2018-04-14  3:01   ` [PATCH 3/3] nbd: use bd_set_size when updating disk size Alex Gorbachev
2018-04-13 16:16 ` [PATCH 1/3] nbd: del_gendisk after we cleanup the queue Bart Van Assche
2018-04-13 16:16   ` Bart Van Assche
2018-04-13 16:21   ` Josef Bacik
2018-04-13 16:25     ` Bart Van Assche
2018-04-13 16:25       ` Bart Van Assche
2018-04-14  3:03 ` Alex Gorbachev

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=20180413160334.5496-3-josef@toxicpanda.com \
    --to=josef@toxicpanda.com \
    --cc=alex@iss-integration.com \
    --cc=axboe@kernel.dk \
    --cc=jbacik@fb.com \
    --cc=kernel-team@fb.com \
    --cc=linux-block@vger.kernel.org \
    --cc=nbd@other.debian.org \
    --cc=stable@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.