All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <kch@nvidia.com>
To: <linux-block@vger.kernel.org>
Cc: <axboe@kernel.dk>, <ming.lei@redhat.com>, <damien.lemoal@wdc.com>,
	<jiangguoqing@kylinos.cn>, <shinichiro.kawasaki@wdc.com>,
	Chaitanya Kulkarni <kch@nvidia.com>
Subject: [PATCH 0/4] blk-lib: cleanup bdev_get_queue()
Date: Mon, 14 Feb 2022 02:08:55 -0800	[thread overview]
Message-ID: <20220214100859.9400-1-kch@nvidia.com> (raw)

Hi,

Based on the comment in the include/linux/blkdev.h:bdev_get_queue()
the return value of the function will never be NULL. This patch series
removes those checks present in the blk-lib.c, also removes the not
needed local variable pointer to request_queue from the write_zeroes
helpers.

Below is the test log for  discard (__blkdev_issue_disacrd()) and
write-zeroes (__blkdev_issue_write_zeroes/__blkdev_issue_zero_pages()).

-ck

Chaitanya Kulkarni (4):
  blk-lib: don't check bdev_get_queue() NULL check
  blk-lib: don't check bdev_get_queue() NULL check
  blk-lib: don't check bdev_get_queue() NULL check
  blk-lib: don't check bdev_get_queue() NULL check

 block/blk-lib.c | 14 --------------
 1 file changed, 14 deletions(-)

1. Execute discard (__blkdev_issue_disacrd()) and write-zeroes
   (__blkdev_issue_write_zeroes, __blkdev_issue_zero_pages())

root@dev linux-block (for-next) # sh test-discard-wz.sh 
+ modprobe -r null_blk
+ modprobe null_blk
+ blkdiscard -o 0 -l 40960 /dev/nullb0
+ dmesg -c
[ 1749.411466] null_blk: module loaded
*[ 1749.425918] __blkdev_issue_discard 82 sector 0 nr_sects 80*
+ blkdiscard -z -o 0 -l 40960 /dev/nullb0
+ dmesg -c
*[ 1749.443746] __blkdev_issue_zero_pages 289 sector 0 nr_sects 80*
+ modprobe -r null_blk
+ modprobe null_blk write_zeroes=1
+ blkdiscard -z -o 0 -l 40960 /dev/nullb0
+ dmesg -c
[ 1749.532618] null_blk: module loaded
*[ 1749.542257] __blkdev_issue_write_zeroes 242 sector 0 nr_sects 80*
+ modprobe -r null_blk
+ set +x

2. Debug patch to test disacrd and write-zeroes on the
   null_blk:
root@dev linux-block (for-next) # git diff 
diff --git a/block/blk-lib.c b/block/blk-lib.c
index fc6ea52e7482..a0e7891cae60 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -79,6 +79,8 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
 
                WARN_ON_ONCE((req_sects << 9) > UINT_MAX);
 
+               pr_info("%s %d sector %llu nr_sects %llu\n",
+                               __func__, __LINE__, sector, nr_sects);
                bio = blk_next_bio(bio, bdev, 0, op, gfp_mask);
                bio->bi_iter.bi_sector = sector;
                bio->bi_iter.bi_size = req_sects << 9;
@@ -237,6 +239,8 @@ static int __blkdev_issue_write_zeroes(struct block_device *bdev,
                return -EOPNOTSUPP;
 
        while (nr_sects) {
+               pr_info("%s %d sector %llu nr_sects %llu\n",
+                               __func__, __LINE__, sector, nr_sects);
                bio = blk_next_bio(bio, bdev, 0, REQ_OP_WRITE_ZEROES, gfp_mask);
                bio->bi_iter.bi_sector = sector;
                if (flags & BLKDEV_ZERO_NOUNMAP)
@@ -282,6 +286,8 @@ static int __blkdev_issue_zero_pages(struct block_device *bdev,
                return -EPERM;
 
        while (nr_sects != 0) {
+               pr_info("%s %d sector %llu nr_sects %llu\n",
+                               __func__, __LINE__, sector, nr_sects);
                bio = blk_next_bio(bio, bdev, __blkdev_sectors_to_bio_pages(nr_sects),
                                   REQ_OP_WRITE, gfp_mask);
                bio->bi_iter.bi_sector = sector;
diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index 13004beb48ca..584ac0519c3e 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -84,6 +84,9 @@ static bool g_virt_boundary = false;
 module_param_named(virt_boundary, g_virt_boundary, bool, 0444);
 MODULE_PARM_DESC(virt_boundary, "Require a virtual boundary for the device. Default: False");
 
+static bool g_write_zeroes = false;
+module_param_named(write_zeroes, g_write_zeroes, bool, 0444);
+
 static int g_no_sched;
 module_param_named(no_sched, g_no_sched, int, 0444);
 MODULE_PARM_DESC(no_sched, "No io scheduler");
@@ -1755,25 +1758,12 @@ static void null_del_dev(struct nullb *nullb)
 
 static void null_config_discard(struct nullb *nullb)
 {
-       if (nullb->dev->discard == false)
-               return;
-
-       if (!nullb->dev->memory_backed) {
-               nullb->dev->discard = false;
-               pr_info("discard option is ignored without memory backing\n");
-               return;
-       }
-
-       if (nullb->dev->zoned) {
-               nullb->dev->discard = false;
-               pr_info("discard option is ignored in zoned mode\n");
-               return;
-       }
-
        nullb->q->limits.discard_granularity = nullb->dev->blocksize;
        nullb->q->limits.discard_alignment = nullb->dev->blocksize;
        blk_queue_max_discard_sectors(nullb->q, UINT_MAX >> 9);
        blk_queue_flag_set(QUEUE_FLAG_DISCARD, nullb->q);
+       if (g_write_zeroes)
+               blk_queue_max_write_zeroes_sectors(nullb->q, UINT_MAX >> 9);
 }
 


-- 
2.29.0


             reply	other threads:[~2022-02-14 10:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-14 10:08 Chaitanya Kulkarni [this message]
2022-02-14 10:08 ` [PATCH 1/4] blk-lib: don't check bdev_get_queue() NULL check Chaitanya Kulkarni
2022-02-14 10:08 ` [PATCH 2/4] " Chaitanya Kulkarni
2022-02-14 10:08 ` [PATCH 3/4] " Chaitanya Kulkarni
2022-02-14 10:08 ` [PATCH 4/4] " Chaitanya Kulkarni
2022-02-14 10:19 ` [PATCH 0/4] blk-lib: cleanup bdev_get_queue() Chaitanya Kulkarni
2022-02-14 13:45   ` Jens Axboe

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=20220214100859.9400-1-kch@nvidia.com \
    --to=kch@nvidia.com \
    --cc=axboe@kernel.dk \
    --cc=damien.lemoal@wdc.com \
    --cc=jiangguoqing@kylinos.cn \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=shinichiro.kawasaki@wdc.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.