aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvia8 <viaviii.gp@gmail.com>2022-03-21 23:39:54 +0300
committervia8 <viaviii.gp@gmail.com>2022-10-13 14:05:46 +0300
commit9835770a81638047890b5d425b5e9003499693c0 (patch)
tree49bb642da52550cc768bf0a2ae48ea362ea128e2
parentdacea75f37a15e5c0e5bc6a32e042c75e73d0872 (diff)
downloadsbdd-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.c15
1 files 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 <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) {