[PATCH 2/2] target/iblock: Delayed bios for active I/O shutdown testing

From: Nicholas Bellinger
Date: Thu Feb 09 2017 - 23:56:01 EST


Signed-off-by: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx>
---
drivers/target/target_core_iblock.c | 21 +++++++++++++++++++++
drivers/target/target_core_iblock.h | 2 ++
2 files changed, 23 insertions(+)

diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index ce1321a..deef231 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -297,6 +297,19 @@ static void iblock_complete_cmd(struct se_cmd *cmd)
kfree(ibr);
}

+static void iblock_delayed_work(struct work_struct *work)
+{
+ struct iblock_req *ibr = container_of(work,
+ struct iblock_req, delayed_work.work);
+ struct bio *bio = ibr->bio;
+ struct se_cmd *cmd = bio->bi_private;
+
+ printk("iblock_delayed_work: cmd: %p\n", cmd);
+
+ bio_put(bio);
+ iblock_complete_cmd(cmd);
+}
+
static void iblock_bio_done(struct bio *bio)
{
struct se_cmd *cmd = bio->bi_private;
@@ -311,6 +324,14 @@ static void iblock_bio_done(struct bio *bio)
smp_mb__after_atomic();
}

+ if (cmd->data_direction == DMA_TO_DEVICE) {
+ ibr->bio = bio;
+ INIT_DELAYED_WORK(&ibr->delayed_work, iblock_delayed_work);
+ schedule_delayed_work(&ibr->delayed_work, 60 * HZ);
+ printk("Queued ibr->delayed_work ! :-)\n");
+ return;
+ }
+
bio_put(bio);

iblock_complete_cmd(cmd);
diff --git a/drivers/target/target_core_iblock.h b/drivers/target/target_core_iblock.h
index 9cc3843..122b415 100644
--- a/drivers/target/target_core_iblock.h
+++ b/drivers/target/target_core_iblock.h
@@ -14,6 +14,8 @@
struct iblock_req {
refcount_t pending;
atomic_t ib_bio_err_cnt;
+ struct delayed_work delayed_work;
+ struct bio *bio;
} ____cacheline_aligned;

#define IBDF_HAS_UDEV_PATH 0x01
--
1.9.1


--=-mAJjcxyyMXpcSErrgYWS--