]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
md/raid1-10: submit write io directly if bitmap is not enabled
authorYu Kuai <yukuai3@huawei.com>
Mon, 29 May 2023 13:11:03 +0000 (21:11 +0800)
committerRoxana Nicolescu <roxana.nicolescu@canonical.com>
Mon, 2 Oct 2023 15:19:30 +0000 (17:19 +0200)
BugLink: https://bugs.launchpad.net/bugs/2034469
[ Upstream commit 7db922bae3abdf0a1db81ef7228cc0b996a0c1e3 ]

Commit 6cce3b23f6f8 ("[PATCH] md: write intent bitmap support for raid10")
add bitmap support, and it changed that write io is submitted through
daemon thread because bitmap need to be updated before write io. And
later, plug is used to fix performance regression because all the write io
will go to demon thread, which means io can't be issued concurrently.

However, if bitmap is not enabled, the write io should not go to daemon
thread in the first place, and plug is not needed as well.

Fixes: 6cce3b23f6f8 ("[PATCH] md: write intent bitmap support for raid10")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230529131106.2123367-5-yukuai1@huaweicloud.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/md/md-bitmap.c
drivers/md/md-bitmap.h
drivers/md/raid1-10.c

index 9640741e8d369fca8f4da2af25163f4569ca5cde..8bbeeec70905c8f4bcf94e21f8379cd3555a8ec9 100644 (file)
@@ -993,7 +993,6 @@ static int md_bitmap_file_test_bit(struct bitmap *bitmap, sector_t block)
        return set;
 }
 
-
 /* this gets called when the md device is ready to unplug its underlying
  * (slave) device queues -- before we let any writes go down, we need to
  * sync the dirty pages of the bitmap file to disk */
@@ -1003,8 +1002,7 @@ void md_bitmap_unplug(struct bitmap *bitmap)
        int dirty, need_write;
        int writing = 0;
 
-       if (!bitmap || !bitmap->storage.filemap ||
-           test_bit(BITMAP_STALE, &bitmap->flags))
+       if (!md_bitmap_enabled(bitmap))
                return;
 
        /* look at each page to see if there are any set bits that need to be
index cfd7395de8fd36c779092617c23ad6d36fad7bea..3a4750952b3a7ec48c50002d38011ef4b16bda7c 100644 (file)
@@ -273,6 +273,13 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
                             sector_t *lo, sector_t *hi, bool clear_bits);
 void md_bitmap_free(struct bitmap *bitmap);
 void md_bitmap_wait_behind_writes(struct mddev *mddev);
+
+static inline bool md_bitmap_enabled(struct bitmap *bitmap)
+{
+       return bitmap && bitmap->storage.filemap &&
+              !test_bit(BITMAP_STALE, &bitmap->flags);
+}
+
 #endif
 
 #endif
index 506299bd55cb6edb74b208d5408ceb324051369d..73cc3cb9154d8cf62429fd7ad889a7be469b58b1 100644 (file)
@@ -131,9 +131,18 @@ static inline bool raid1_add_bio_to_plug(struct mddev *mddev, struct bio *bio,
                                      blk_plug_cb_fn unplug)
 {
        struct raid1_plug_cb *plug = NULL;
-       struct blk_plug_cb *cb = blk_check_plugged(unplug, mddev,
-                                                  sizeof(*plug));
+       struct blk_plug_cb *cb;
+
+       /*
+        * If bitmap is not enabled, it's safe to submit the io directly, and
+        * this can get optimal performance.
+        */
+       if (!md_bitmap_enabled(mddev->bitmap)) {
+               raid1_submit_write(bio);
+               return true;
+       }
 
+       cb = blk_check_plugged(unplug, mddev, sizeof(*plug));
        if (!cb)
                return false;