mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yu Kuai <yukuai1@huaweicloud.com>
To: Yu Kuai <yukuai1@huaweicloud.com>, Christoph Hellwig <hch@lst.de>
Cc: xni@redhat.com, colyli@kernel.org, agk@redhat.com,
	snitzer@kernel.org, mpatocka@redhat.com, song@kernel.org,
	linux-kernel@vger.kernel.org, dm-devel@lists.linux.dev,
	linux-raid@vger.kernel.org, yi.zhang@huawei.com,
	yangerkun@huawei.com, johnny.chenyi@huawei.com,
	"yukuai (C)" <yukuai3@huawei.com>
Subject: Re: [PATCH RFC md-6.16 v3 15/19] md/md-llbitmap: implement APIs to dirty bits and clear bits
Date: Tue, 13 May 2025 14:32:04 +0800	[thread overview]
Message-ID: <03f64fc7-4e57-2f32-bffc-04836a9df790@huaweicloud.com> (raw)
In-Reply-To: <69dc5ab6-542d-dcc2-f4ec-0a6a8e49b937@huaweicloud.com>

Hi,

在 2025/05/12 21:36, Yu Kuai 写道:
> Hi,
> 
> 在 2025/05/12 21:30, Christoph Hellwig 写道:
>> On Mon, May 12, 2025 at 03:26:41PM +0200, Christoph Hellwig wrote:
>>>> 1) bitmap bio must be done before this bio can be issued;
>>>> 2) bitmap bio will be added to current->bio_list, and wait for this bio
>>>> to be issued;
>>>>
>>>> Do you have a better sulution to this problem?
>>>
>>> A bew block layer API that bypasses bio_list maybe?  I.e. export
>>> __submit_bio with a better name and a kerneldoc detailing the narrow
>>> use case.
>>
>> That won't work as we'd miss a lot of checks, cgroup handling, etc.
>>
>> But maybe a flag to skip the recursion avoidance?
> 
> I think this can work, and this can also improve performance. I'll look
> into this.

So, I did a quick test with old internal bitmap and make sure following
patch can work.

However, for bitmap file case, bio is issued from submit_bh(), I'll have
to change buffer_head code and I'm not sure if we want to do that.

Thanks,
Kuai

diff --git a/block/blk-core.c b/block/blk-core.c
index b862c66018f2..66ced5769694 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -745,7 +745,7 @@ void submit_bio_noacct_nocheck(struct bio *bio)
          * to collect a list of requests submited by a ->submit_bio 
method while
          * it is active, and then process them after it returned.
          */
-       if (current->bio_list)
+       if (current->bio_list && !bio_flagged(bio, BIO_STACKED_META))
                 bio_list_add(&current->bio_list[0], bio);
         else if (!bdev_test_flag(bio->bi_bdev, BD_HAS_SUBMIT_BIO))
                 __submit_bio_noacct_mq(bio);
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 431a3ab2e449..e0cb210a4ea4 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1257,35 +1257,6 @@ static void __bitmap_unplug(struct bitmap *bitmap)
                 md_bitmap_file_kick(bitmap);
  }

-struct bitmap_unplug_work {
-       struct work_struct work;
-       struct bitmap *bitmap;
-       struct completion *done;
-};
-
-static void md_bitmap_unplug_fn(struct work_struct *work)
-{
-       struct bitmap_unplug_work *unplug_work =
-               container_of(work, struct bitmap_unplug_work, work);
-
-       __bitmap_unplug(unplug_work->bitmap);
-       complete(unplug_work->done);
-}
-
-static void bitmap_unplug_async(struct bitmap *bitmap)
-{
-       DECLARE_COMPLETION_ONSTACK(done);
-       struct bitmap_unplug_work unplug_work;
-
-       INIT_WORK_ONSTACK(&unplug_work.work, md_bitmap_unplug_fn);
-       unplug_work.bitmap = bitmap;
-       unplug_work.done = &done;
-
-       queue_work(md_bitmap_wq, &unplug_work.work);
-       wait_for_completion(&done);
-       destroy_work_on_stack(&unplug_work.work);
-}
-
  static void bitmap_unplug(struct mddev *mddev, bool sync)
  {
         struct bitmap *bitmap = mddev->bitmap;
@@ -1293,10 +1264,7 @@ static void bitmap_unplug(struct mddev *mddev, 
bool sync)
         if (!bitmap)
                 return;

-       if (sync)
-               __bitmap_unplug(bitmap);
-       else
-               bitmap_unplug_async(bitmap);
+       __bitmap_unplug(bitmap);
  }

  static void md_bitmap_set_memory_bits(struct bitmap *bitmap, sector_t 
offset, int needed);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 32b997dfe6f4..179eabd6e038 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1050,6 +1050,7 @@ void md_super_write(struct mddev *mddev, struct 
md_rdev *rdev,
         __bio_add_page(bio, page, size, 0);
         bio->bi_private = rdev;
         bio->bi_end_io = super_written;
+       bio_set_flag(bio, BIO_STACKED_META);

         if (test_bit(MD_FAILFAST_SUPPORTED, &mddev->flags) &&
             test_bit(FailFast, &rdev->flags) &&
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index f38425338c3f..88164cdae6aa 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -300,6 +300,7 @@ enum {
         BIO_REMAPPED,
         BIO_ZONE_WRITE_PLUGGING, /* bio handled through zone write 
plugging */
         BIO_EMULATES_ZONE_APPEND, /* bio emulates a zone append 
operation */
+       BIO_STACKED_META,       /* bio is metadata from stacked device */
         BIO_FLAG_LAST
  };

> 
> Thanks,
> Kuai
> 
>>
>> .
>>
> 
> .
> 


  reply	other threads:[~2025-05-13  6:32 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-12  1:19 [PATCH RFC md-6.16 v3 00/19] md: introduce a new lockless bitmap Yu Kuai
2025-05-12  1:19 ` [PATCH RFC md-6.16 v3 01/19] md/md-bitmap: add {start, end}_discard in bitmap_operations Yu Kuai
2025-05-12  4:39   ` Christoph Hellwig
2025-05-12  1:19 ` [PATCH RFC md-6.16 v3 02/19] md: support discard for bitmap ops Yu Kuai
2025-05-12  4:41   ` Christoph Hellwig
2025-05-12  6:05     ` Yu Kuai
2025-05-12  6:12       ` Christoph Hellwig
2025-05-12  6:22         ` Yu Kuai
2025-05-12  1:19 ` [PATCH RFC md-6.16 v3 03/19] md/md-bitmap: remove parameter slot from bitmap_create() Yu Kuai
2025-05-12  4:41   ` Christoph Hellwig
2025-05-12  1:19 ` [PATCH RFC md-6.16 v3 04/19] md: add a new sysfs api bitmap_version Yu Kuai
2025-05-12  4:51   ` Christoph Hellwig
2025-05-12  6:12     ` Yu Kuai
2025-05-12  1:19 ` [PATCH RFC md-6.16 v3 05/19] md: delay registration of bitmap_ops until creating bitmap Yu Kuai
2025-05-12  4:53   ` Christoph Hellwig
2025-05-12  6:25     ` Yu Kuai
2025-05-12  1:19 ` [PATCH RFC md-6.16 v3 06/19] md: add a new parameter 'offset' to md_super_write() Yu Kuai
2025-05-12  4:55   ` Christoph Hellwig
2025-05-12  6:32     ` Yu Kuai
2025-05-12  6:39       ` Christoph Hellwig
2025-05-12  1:19 ` [PATCH RFC md-6.16 v3 07/19] md/md-bitmap: add a new helper skip_sync_blocks() in bitmap_operations Yu Kuai
2025-05-12  4:56   ` Christoph Hellwig
2025-05-22  2:44   ` Xiao Ni
2025-05-12  1:19 ` [PATCH RFC md-6.16 v3 08/19] md/md-bitmap: add a new helper blocks_synced() " Yu Kuai
2025-05-12  4:57   ` Christoph Hellwig
2025-05-12  1:19 ` [PATCH RFC md-6.16 v3 09/19] md: add a new recovery_flag MD_RECOVERY_LAZY_RECOVER Yu Kuai
2025-05-12  4:57   ` Christoph Hellwig
2025-05-12  1:19 ` [PATCH RFC md-6.16 v3 10/19] md/md-llbitmap: add data structure definition and comments Yu Kuai
2025-05-12  5:09   ` Christoph Hellwig
2025-05-12  8:05     ` Yu Kuai
2025-05-12 13:24       ` Christoph Hellwig
2025-05-12  1:19 ` [PATCH RFC md-6.16 v3 11/19] md/md-llbitmap: implement bitmap IO Yu Kuai
2025-05-12  5:15   ` Christoph Hellwig
2025-05-12  8:15     ` Yu Kuai
2025-05-12 13:25       ` Christoph Hellwig
2025-05-12  1:19 ` [PATCH RFC md-6.16 v3 12/19] md/md-llbitmap: implement bit state machine Yu Kuai
2025-05-12  1:19 ` [PATCH RFC md-6.16 v3 13/19] md/md-llbitmap: implement APIs for page level dirty bits synchronization Yu Kuai
2025-05-12  1:19 ` [PATCH RFC md-6.16 v3 14/19] md/md-llbitmap: implement APIs to mange bitmap lifetime Yu Kuai
2025-05-12  1:19 ` [PATCH RFC md-6.16 v3 15/19] md/md-llbitmap: implement APIs to dirty bits and clear bits Yu Kuai
2025-05-12  5:17   ` Christoph Hellwig
2025-05-12  8:23     ` Yu Kuai
2025-05-12 13:26       ` Christoph Hellwig
2025-05-12 13:30         ` Christoph Hellwig
2025-05-12 13:36           ` Yu Kuai
2025-05-13  6:32             ` Yu Kuai [this message]
2025-05-13  6:48               ` Christoph Hellwig
2025-05-13  7:14                 ` Yu Kuai
2025-05-13  7:43                   ` Christoph Hellwig
2025-05-13  9:32                     ` Yu Kuai
2025-05-14  5:17                       ` Christoph Hellwig
2025-05-15 13:38                         ` Yu Kuai
2025-05-12  1:19 ` [PATCH RFC md-6.16 v3 16/19] md/md-llbitmap: implement APIs for sync_thread Yu Kuai
2025-05-12  1:19 ` [PATCH RFC md-6.16 v3 17/19] md/md-llbitmap: implement all bitmap operations Yu Kuai
2025-05-12  5:18   ` Christoph Hellwig
2025-05-12  8:28     ` Yu Kuai
2025-05-12  1:19 ` [PATCH RFC md-6.16 v3 18/19] md/md-llbitmap: implement sysfs APIs Yu Kuai
2025-05-12  1:19 ` [PATCH RFC md-6.16 v3 19/19] md/md-llbitmap: add Kconfig Yu Kuai
2025-05-12  5:19   ` Christoph Hellwig
2025-05-12  8:30     ` Yu Kuai
2025-05-12  5:21 ` [PATCH RFC md-6.16 v3 00/19] md: introduce a new lockless bitmap Christoph Hellwig
2025-05-12  8:40   ` Yu Kuai
2025-05-12 13:27     ` Christoph Hellwig
2025-05-12 13:41       ` Yu Kuai

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=03f64fc7-4e57-2f32-bffc-04836a9df790@huaweicloud.com \
    --to=yukuai1@huaweicloud.com \
    --cc=agk@redhat.com \
    --cc=colyli@kernel.org \
    --cc=dm-devel@lists.linux.dev \
    --cc=hch@lst.de \
    --cc=johnny.chenyi@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=snitzer@kernel.org \
    --cc=song@kernel.org \
    --cc=xni@redhat.com \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai3@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®