Skip to content

Commit 92f93c3

Browse files
Christoph Hellwigaxboe
authored andcommitted
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>
1 parent ee4bf64 commit 92f93c3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/block/nbd.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,11 @@ static void nbd_size_clear(struct nbd_device *nbd)
299299
static void nbd_size_update(struct nbd_device *nbd)
300300
{
301301
struct nbd_config *config = nbd->config;
302-
struct block_device *bdev = bdget_disk(nbd->disk, 0);
303302
sector_t nr_sectors = config->bytesize >> 9;
303+
struct block_device *bdev;
304+
305+
if (!nbd->task_recv)
306+
return;
304307

305308
if (config->flags & NBD_FLAG_SEND_TRIM) {
306309
nbd->disk->queue->limits.discard_granularity = config->blksize;
@@ -309,7 +312,9 @@ static void nbd_size_update(struct nbd_device *nbd)
309312
}
310313
blk_queue_logical_block_size(nbd->disk->queue, config->blksize);
311314
blk_queue_physical_block_size(nbd->disk->queue, config->blksize);
315+
312316
set_capacity(nbd->disk, nr_sectors);
317+
bdev = bdget_disk(nbd->disk, 0);
313318
if (bdev) {
314319
if (bdev->bd_disk)
315320
bd_set_nr_sectors(bdev, nr_sectors);
@@ -326,8 +331,7 @@ static void nbd_size_set(struct nbd_device *nbd, loff_t blocksize,
326331
struct nbd_config *config = nbd->config;
327332
config->blksize = blocksize;
328333
config->bytesize = blocksize * nr_blocks;
329-
if (nbd->task_recv != NULL)
330-
nbd_size_update(nbd);
334+
nbd_size_update(nbd);
331335
}
332336

333337
static void nbd_complete_rq(struct request *req)

0 commit comments

Comments
 (0)