public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <chaitanyak@nvidia.com>
To: Josef Bacik <josef@toxicpanda.com>
Cc: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	"bvanassche@acm.org" <bvanassche@acm.org>
Subject: Re: Nullblk configfs oddities
Date: Mon, 18 Apr 2022 22:15:27 +0000	[thread overview]
Message-ID: <0e405b48-4ca1-5821-a289-fa683f7e5ce0@nvidia.com> (raw)
In-Reply-To: <CAEzrpqeHrrqqn7056Le8nmf+VbUugxXV2QjZeQTraW1dwJHviA@mail.gmail.com>

>> when you load module with default module parameter it will create a
>> default device with no memory backed mode, that will not be visible in
>> the configfs.
>>
>> So you need to load the module with nr_devices=0 that will prevent the
>> null_blk to create the default device which is not memory backed and not
>> present in the configfs:-
>>
> 
> Yup I know what it's doing, I'm raising this as it's weird and took me
> a bit to work out what was happening, and it annoyed me.  It's not
> anything I can't work around, but the UX kinda sucks.  Thanks,
> 
> Josef

hmmm, how about a following patch, this will create memory backed
default devices at the time of loading the module ?

# git diff
diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index c441a4972064..d45c2f3f5692 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -148,7 +148,7 @@ static const struct kernel_param_ops 
null_queue_mode_param_ops = {
  device_param_cb(queue_mode, &null_queue_mode_param_ops, &g_queue_mode, 
0444);
  MODULE_PARM_DESC(queue_mode, "Block interface to use 
(0=bio,1=rq,2=multiqueue)");

-static int g_gb = 250;
+static int g_gb = 1;
  module_param_named(gb, g_gb, int, 0444);
  MODULE_PARM_DESC(gb, "Size in GB");

@@ -168,6 +168,10 @@ static bool g_blocking;
  module_param_named(blocking, g_blocking, bool, 0444);
  MODULE_PARM_DESC(blocking, "Register as a blocking blk-mq driver device");

+static bool g_memory_backed;
+module_param_named(memory_backed, g_memory_backed, bool, 0444);
+MODULE_PARM_DESC(memory_backed, "memory backed device, default:false");
+
  static bool shared_tags;
  module_param(shared_tags, bool, 0444);
  MODULE_PARM_DESC(shared_tags, "Share tag set between devices for blk-mq");
@@ -657,6 +661,8 @@ static struct nullb_device *null_alloc_dev(void)
         dev->zone_max_open = g_zone_max_open;
         dev->zone_max_active = g_zone_max_active;
         dev->virt_boundary = g_virt_boundary;
+       dev->memory_backed = g_memory_backed;
+
         return dev;
  }


This passed the fio verification test when loaded with newly added 
module parameter memory_backed=1:-

+ modprobe -r null_blk
+ modprobe null_blk
+ tree config/
config/
└── nullb
     └── features

1 directory, 1 file
+ lsblk
+ grep null
nullb0  250:0    0    1G  0 disk
+ fio fio/verify.fio --filename=/dev/nullb0 --output=/tmp/fio.log
verify: bad header offset 668917760, wanted 0 at file /dev/nullb0 offset 
0, length 4096 (requested block: offset=0, length=4096)
verify: bad header offset 746139648, wanted 4096 at file /dev/nullb0 
offset 4096, length 4096 (requested block: offset=4096, length=4096)
verify: bad header offset 705691648, wanted 8192 at file /dev/nullb0 
offset 8192, length 4096 (requested block: offset=8192, length=4096)
verify: bad header offset 363917312, wanted 12288 at file /dev/nullb0 
offset 12288, length 4096 (requested block: offset=12288, length=4096)
+ grep err= /tmp/fio.log
write-and-verify: (groupid=0, jobs=1): err=84 (file:io_u.c:2141, 
func=io_u_queued_complete, error=Invalid or incomplete multibyte or wide 
character): pid=21015: Mon Apr 18 15:14:36 2022
+ modprobe -r null_blk
+ modprobe -r null_blk
+ modprobe null_blk memory_backed=1
+ tree config/
config/
└── nullb
     └── features

1 directory, 1 file
+ lsblk
+ grep null
nullb0  250:0    0    1G  0 disk
+ fio fio/verify.fio --filename=/dev/nullb0 --output=/tmp/fio.log
+ grep err= /tmp/fio.log
write-and-verify: (groupid=0, jobs=1): err= 0: pid=21025: Mon Apr 18 
15:14:38 2022
+ modprobe -r null_blk


-ck

  reply	other threads:[~2022-04-18 22:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-18 21:38 Nullblk configfs oddities Josef Bacik
2022-04-18 21:54 ` Chaitanya Kulkarni
2022-04-18 22:02   ` Josef Bacik
2022-04-18 22:15     ` Chaitanya Kulkarni [this message]
2022-04-18 22:14   ` Jens Axboe
2022-04-18 22:21     ` Chaitanya Kulkarni
2022-04-18 22:24       ` Jens Axboe
2022-04-18 22:28         ` Josef Bacik
2022-04-19  4:23         ` Damien Le Moal
2022-04-19 14:49           ` Bart Van Assche
2022-05-03 20:20           ` Josef Bacik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0e405b48-4ca1-5821-a289-fa683f7e5ce0@nvidia.com \
    --to=chaitanyak@nvidia.com \
    --cc=bvanassche@acm.org \
    --cc=josef@toxicpanda.com \
    --cc=linux-block@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox