diff options
author | Christoph Hellwig <hch@lst.de> | 2020-11-16 15:56:58 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-11-16 08:34:14 -0700 |
commit | 92f93c3a1bf9dc73181dc6566497d16b690cb576 (patch) | |
tree | aefc6de70544d3fe33f2704f233d84c13085c0b9 /drivers/block/nbd.c | |
parent | ee4bf648635055d2b76afadaf34236c8b2d852a7 (diff) | |
download | linux-stable-92f93c3a1bf9dc73181dc6566497d16b690cb576.tar.gz linux-stable-92f93c3a1bf9dc73181dc6566497d16b690cb576.tar.bz2 linux-stable-92f93c3a1bf9dc73181dc6566497d16b690cb576.zip |
nbd: move the task_recv check into nbd_size_update
nbd_size_update is about to acquire a few more callers, so lift the check
into the function.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block/nbd.c')
-rw-r--r-- | drivers/block/nbd.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index a9a0b49ff161..48054051e281 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -299,8 +299,11 @@ 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); sector_t nr_sectors = config->bytesize >> 9; + struct block_device *bdev; + + if (!nbd->task_recv) + return; if (config->flags & NBD_FLAG_SEND_TRIM) { nbd->disk->queue->limits.discard_granularity = config->blksize; @@ -309,7 +312,9 @@ static void nbd_size_update(struct nbd_device *nbd) } blk_queue_logical_block_size(nbd->disk->queue, config->blksize); blk_queue_physical_block_size(nbd->disk->queue, config->blksize); + set_capacity(nbd->disk, nr_sectors); + bdev = bdget_disk(nbd->disk, 0); if (bdev) { if (bdev->bd_disk) bd_set_nr_sectors(bdev, nr_sectors); @@ -326,8 +331,7 @@ 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); + nbd_size_update(nbd); } static void nbd_complete_rq(struct request *req) |