* [PATCH 2/3] tcm/iblock: Add UNMAP / Block DISCARD support
@ 2010-09-27 22:51 Nicholas A. Bellinger
0 siblings, 0 replies; only message in thread
From: Nicholas A. Bellinger @ 2010-09-27 22:51 UTC (permalink / raw)
To: linux-scsi, linux-kernel
Cc: Christoph Hellwig, Martin K. Petersen, Douglas Gilbert,
Jens Axboe, FUJITA Tomonori, Mike Christie, Hannes Reinecke,
James Bottomley, Konrad Rzeszutek Wilk, Boaz Harrosh,
Richard Sharpe, Nicholas Bellinger
From: Nicholas Bellinger <nab@linux-iscsi.org>
This patch adds UNMAP emulation support using Block layer DISCARD in iblock_emulate_scsi_cdb()
-> transport_generic_unmap(). This includes the use of blk_queue_discard() in
iblock_create_virtdevice() to determine when to set DEV_ATTRIB(dev)->emulate_tpe=1 to
signal to TCM Core to perform the necessary control CDB emulation for TPE=1 / UNMAP.
Signed-off-by: Nicholas A. Bellinger <nab@linux-iscsi.org>
---
drivers/target/target_core_iblock.c | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index 1b148f5..089f353 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -221,6 +221,16 @@ static struct se_device *iblock_create_virtdevice(
*/
if (__iblock_do_sync_cache(dev) == 0)
ib_dev->ibd_flags |= IBDF_BDEV_ISSUE_FLUSH;
+ /*
+ * 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(bdev_get_queue(bd))) {
+ DEV_ATTRIB(dev)->emulate_tpe = 1;
+ printk(KERN_INFO "IBLOCK: Enabling BLOCK Discard"
+ " and TPE=1 emulation\n");
+ }
return dev;
@@ -446,8 +456,10 @@ static int iblock_emulate_read_cap16(struct se_task *task)
static int iblock_emulate_scsi_cdb(struct se_task *task)
{
- int ret;
+ struct iblock_dev *ibd = (struct iblock_dev *) task->se_dev->dev_ptr;
+ struct block_device *bd = ibd->ibd_bd;
struct se_cmd *cmd = TASK_CMD(task);
+ int ret;
switch (T_TASK(cmd)->t_task_cdb[0]) {
case INQUIRY:
@@ -490,6 +502,11 @@ static int iblock_emulate_scsi_cdb(struct se_task *task)
if (ret < 0)
return ret;
break;
+ case UNMAP:
+ ret = transport_generic_unmap(cmd, bd);
+ if (ret < 0)
+ return ret;
+ break;
case ALLOW_MEDIUM_REMOVAL:
case ERASE:
case REZERO_UNIT:
--
1.5.6.5
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2010-09-27 22:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-27 22:51 [PATCH 2/3] tcm/iblock: Add UNMAP / Block DISCARD support Nicholas A. Bellinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).