Blob Blame History Raw
From a2e9262477843712dcfb5a9b53b0180b240bda36 Mon Sep 17 00:00:00 2001
From: David Disseldorp <ddiss@suse.de>
Date: Thu, 2 Nov 2017 18:02:27 +0100
Subject: [PATCH 3/3] target/rbd: use target_configure_unmap_from_queue()
 helper
Patch-mainline: Not yet, SES clustered LIO/RBD
References: bsc#1064320

All other block-queue based backstores have been converted to use this
new helper function. Change RBD to do the same.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Acked-by: Luis Henriques <lhenriques@suse.com>

---
 drivers/target/target_core_rbd.c | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/drivers/target/target_core_rbd.c b/drivers/target/target_core_rbd.c
index 2410ab9ac039..7c0afad3a53c 100644
--- a/drivers/target/target_core_rbd.c
+++ b/drivers/target/target_core_rbd.c
@@ -114,26 +114,10 @@ static int tcm_rbd_configure_device(struct se_device *dev)
 	dev->dev_attrib.hw_max_sectors = queue_max_hw_sectors(q);
 	dev->dev_attrib.hw_queue_depth = q->nr_requests;
 
-	/*
-	 * Check if the underlying struct block_device request_queue supports
-	 * the QUEUE_FLAG_DISCARD bit for UNMAP/WRITE_SAME in SCSI + TRIM
-	 * in ATA and we need to set TPE=1
-	 */
-	if (blk_queue_discard(q)) {
-		dev->dev_attrib.max_unmap_lba_count =
-				q->limits.max_discard_sectors;
-
-		/*
-		 * Currently hardcoded to 1 in Linux/SCSI code..
-		 */
-		dev->dev_attrib.max_unmap_block_desc_count = 1;
-		dev->dev_attrib.unmap_granularity =
-				q->limits.discard_granularity >> 9;
-		dev->dev_attrib.unmap_granularity_alignment =
-				q->limits.discard_alignment;
+	if (target_configure_unmap_from_queue(&dev->dev_attrib, q))
+		pr_debug("RBD: BLOCK Discard support available,"
+			 " disabled by default\n");
 
-		pr_debug("TCM RBD: BLOCK Discard support available disabled by default\n");
-	}
 	/*
 	 * Enable write same emulation for RBD and use 0xFFFF as
 	 * the smaller WRITE_SAME(10) only has a two-byte block count.
-- 
2.13.6