[PATCH 6/8] null_blk: allow memory-backed write-zeroes-bio

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds support for memory backed REQ_OP_WRITE_ZEROES
operations for the null_blk bio mode.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@xxxxxxx>
---
 drivers/block/null_blk_main.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
index d463bde001b6..30cb90553167 100644
--- a/drivers/block/null_blk_main.c
+++ b/drivers/block/null_blk_main.c
@@ -1147,6 +1147,7 @@ static int null_handle_rq(struct nullb_cmd *cmd)
 
 static int null_handle_bio(struct nullb_cmd *cmd)
 {
+	unsigned int blk_bio_bytes = bio_sectors(cmd->bio) << SECTOR_SHIFT;
 	struct bio *bio = cmd->bio;
 	struct nullb *nullb = cmd->nq->dev->nullb;
 	int err;
@@ -1157,10 +1158,15 @@ static int null_handle_bio(struct nullb_cmd *cmd)
 
 	sector = bio->bi_iter.bi_sector;
 
-	if (bio_op(bio) == REQ_OP_DISCARD) {
-		null_handle_discard(nullb, sector,
-			bio_sectors(bio) << SECTOR_SHIFT);
+	switch (bio_op(bio)) {
+	case REQ_OP_DISCARD:
+		null_handle_discard(nullb, sector, blk_bio_bytes);
+		return 0;
+	case REQ_OP_WRITE_ZEROES:
+		null_handle_write_zeroes(nullb, sector, blk_bio_bytes);
 		return 0;
+	default:
+		break;
 	}
 
 	spin_lock_irq(&nullb->lock);
-- 
2.17.0




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux