diff options
author | via8 <viaviii.gp@gmail.com> | 2022-03-21 23:39:54 +0300 |
---|---|---|
committer | via8 <viaviii.gp@gmail.com> | 2022-10-13 14:05:46 +0300 |
commit | 9835770a81638047890b5d425b5e9003499693c0 (patch) | |
tree | 49bb642da52550cc768bf0a2ae48ea362ea128e2 | |
parent | dacea75f37a15e5c0e5bc6a32e042c75e73d0872 (diff) | |
download | sbdd-9835770a81638047890b5d425b5e9003499693c0.tar.gz sbdd-9835770a81638047890b5d425b5e9003499693c0.tar.bz2 sbdd-9835770a81638047890b5d425b5e9003499693c0.zip |
modifications
- zero memory on allocation
- fail bio on deletion
- remove exit timeout
-rw-r--r-- | sbdd.c | 15 |
1 files changed, 6 insertions, 9 deletions
@@ -17,7 +17,6 @@ #include <linux/kernel.h> #include <linux/module.h> #include <linux/vmalloc.h> -#include <linux/jiffies.h> #include <linux/moduleparam.h> #include <linux/spinlock_types.h> #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) { |