Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1291271

[PATCH v2 4/4] nbd: Move flag parsing to a function

From Markus Pargmann <mpa@pengutronix.de>
Newsgroups linux.kernel
Subject [PATCH v2 4/4] nbd: Move flag parsing to a function
Date 2015-12-14 16:20 +0100
Message-ID <qFD4T-7Rv-43@gated-at.bofh.it> (permalink)
References <qFD4S-7Rv-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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 <mpa@pengutronix.de>
---
 drivers/block/nbd.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index a1fa356e4cbf..81a9be7d176c 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -641,6 +641,18 @@ static void nbd_bdev_reset(struct block_device *bdev)
 	}
 }
 
+static void nbd_parse_flags(struct nbd_device *nbd, struct block_device *bdev)
+{
+	if (nbd->flags & NBD_FLAG_READ_ONLY)
+		set_device_ro(bdev, true);
+	if (nbd->flags & NBD_FLAG_SEND_TRIM)
+		queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, nbd->disk->queue);
+	if (nbd->flags & NBD_FLAG_SEND_FLUSH)
+		blk_queue_flush(nbd->disk->queue, REQ_FLUSH);
+	else
+		blk_queue_flush(nbd->disk->queue, 0);
+}
+
 static int nbd_dev_dbg_init(struct nbd_device *nbd);
 static void nbd_dev_dbg_close(struct nbd_device *nbd);
 
@@ -742,15 +754,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
 
 		mutex_unlock(&nbd->tx_lock);
 
-		if (nbd->flags & NBD_FLAG_READ_ONLY)
-			set_device_ro(bdev, true);
-		if (nbd->flags & NBD_FLAG_SEND_TRIM)
-			queue_flag_set_unlocked(QUEUE_FLAG_DISCARD,
-				nbd->disk->queue);
-		if (nbd->flags & NBD_FLAG_SEND_FLUSH)
-			blk_queue_flush(nbd->disk->queue, REQ_FLUSH);
-		else
-			blk_queue_flush(nbd->disk->queue, 0);
+		nbd_parse_flags(nbd, bdev);
 
 		thread = kthread_run(nbd_thread_send, nbd, "%s",
 				     nbd_name(nbd));
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/4] nbd: Remove signal usage Markus Pargmann <mpa@pengutronix.de> - 2015-12-14 16:20 +0100
  [PATCH v2 1/4] nbd: Remove signal usage Markus Pargmann <mpa@pengutronix.de> - 2015-12-14 16:20 +0100
  [PATCH v2 2/4] nbd: Timeouts are not user requested disconnects Markus Pargmann <mpa@pengutronix.de> - 2015-12-14 16:20 +0100
  [PATCH v2 3/4] nbd: Cleanup reset of nbd and bdev after a disconnect Markus Pargmann <mpa@pengutronix.de> - 2015-12-14 16:20 +0100
  [PATCH v2 4/4] nbd: Move flag parsing to a function Markus Pargmann <mpa@pengutronix.de> - 2015-12-14 16:20 +0100

csiph-web