Skip to content

Commit d02cf53

Browse files
author
Markus Pargmann
committed
nbd: Move flag parsing to a function
nbd changes properties of the blockdevice depending on flags that were received. This patch moves this flag parsing into a separate function nbd_parse_flags(). Signed-off-by: Markus Pargmann <[email protected]>
1 parent 0e4f0f6 commit d02cf53

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

drivers/block/nbd.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,18 @@ static void nbd_bdev_reset(struct block_device *bdev)
641641
}
642642
}
643643

644+
static void nbd_parse_flags(struct nbd_device *nbd, struct block_device *bdev)
645+
{
646+
if (nbd->flags & NBD_FLAG_READ_ONLY)
647+
set_device_ro(bdev, true);
648+
if (nbd->flags & NBD_FLAG_SEND_TRIM)
649+
queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, nbd->disk->queue);
650+
if (nbd->flags & NBD_FLAG_SEND_FLUSH)
651+
blk_queue_flush(nbd->disk->queue, REQ_FLUSH);
652+
else
653+
blk_queue_flush(nbd->disk->queue, 0);
654+
}
655+
644656
static int nbd_dev_dbg_init(struct nbd_device *nbd);
645657
static void nbd_dev_dbg_close(struct nbd_device *nbd);
646658

@@ -742,15 +754,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
742754

743755
mutex_unlock(&nbd->tx_lock);
744756

745-
if (nbd->flags & NBD_FLAG_READ_ONLY)
746-
set_device_ro(bdev, true);
747-
if (nbd->flags & NBD_FLAG_SEND_TRIM)
748-
queue_flag_set_unlocked(QUEUE_FLAG_DISCARD,
749-
nbd->disk->queue);
750-
if (nbd->flags & NBD_FLAG_SEND_FLUSH)
751-
blk_queue_flush(nbd->disk->queue, REQ_FLUSH);
752-
else
753-
blk_queue_flush(nbd->disk->queue, 0);
757+
nbd_parse_flags(nbd, bdev);
754758

755759
thread = kthread_run(nbd_thread_send, nbd, "%s",
756760
nbd_name(nbd));

0 commit comments

Comments
 (0)