From 9835770a81638047890b5d425b5e9003499693c0 Mon Sep 17 00:00:00 2001 From: via8 Date: Mon, 21 Mar 2022 23:39:54 +0300 Subject: modifications - zero memory on allocation - fail bio on deletion - remove exit timeout --- sbdd.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/sbdd.c b/sbdd.c index f06bcb0..ab2e51d 100644 --- a/sbdd.c +++ b/sbdd.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #ifdef BLK_MQ_MODE @@ -133,8 +132,11 @@ static void sbdd_xfer_bio(struct bio *bio) static blk_qc_t sbdd_make_request(struct request_queue *q, struct bio *bio) { - if (atomic_read(&__sbdd.deleting)) + if (atomic_read(&__sbdd.deleting)) { + pr_err("unable to process bio while deleting\n"); + bio_io_error(bio); return BLK_STS_IOERR; + } atomic_inc(&__sbdd.refs_cnt); @@ -176,7 +178,7 @@ static int sbdd_create(void) __sbdd.capacity = (sector_t)__sbdd_capacity_mib * SBDD_MIB_SECTORS; pr_info("allocating data\n"); - __sbdd.data = vmalloc(__sbdd.capacity << SBDD_SECTOR_SHIFT); + __sbdd.data = vzalloc(__sbdd.capacity << SBDD_SECTOR_SHIFT); if (!__sbdd.data) { pr_err("unable to alloc data\n"); return -ENOMEM; @@ -256,12 +258,7 @@ static void sbdd_delete(void) { atomic_set(&__sbdd.deleting, 1); - if (!wait_event_timeout(__sbdd.exitwait, - !atomic_read(&__sbdd.refs_cnt), - msecs_to_jiffies(1000))) { - pr_err("call sbdd_delete() failed, timed out\n"); - return; - } + wait_event(__sbdd.exitwait, !atomic_read(&__sbdd.refs_cnt)); /* gd will be removed only after the last reference put */ if (__sbdd.gd) { -- cgit v1.2.3-18-g5258