Skip to content

Commit 7db922b

Browse files
YuKuai-huaweiliu-song-6
authored andcommitted
md/raid1-10: submit write io directly if bitmap is not enabled
Commit 6cce3b2 ("[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: 6cce3b2 ("[PATCH] md: write intent bitmap support for raid10") Signed-off-by: Yu Kuai <[email protected]> Signed-off-by: Song Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 8295efb commit 7db922b

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

drivers/md/md-bitmap.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,6 @@ static int md_bitmap_file_test_bit(struct bitmap *bitmap, sector_t block)
10161016
return set;
10171017
}
10181018

1019-
10201019
/* this gets called when the md device is ready to unplug its underlying
10211020
* (slave) device queues -- before we let any writes go down, we need to
10221021
* sync the dirty pages of the bitmap file to disk */
@@ -1026,8 +1025,7 @@ void md_bitmap_unplug(struct bitmap *bitmap)
10261025
int dirty, need_write;
10271026
int writing = 0;
10281027

1029-
if (!bitmap || !bitmap->storage.filemap ||
1030-
test_bit(BITMAP_STALE, &bitmap->flags))
1028+
if (!md_bitmap_enabled(bitmap))
10311029
return;
10321030

10331031
/* look at each page to see if there are any set bits that need to be

drivers/md/md-bitmap.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,13 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
273273
sector_t *lo, sector_t *hi, bool clear_bits);
274274
void md_bitmap_free(struct bitmap *bitmap);
275275
void md_bitmap_wait_behind_writes(struct mddev *mddev);
276+
277+
static inline bool md_bitmap_enabled(struct bitmap *bitmap)
278+
{
279+
return bitmap && bitmap->storage.filemap &&
280+
!test_bit(BITMAP_STALE, &bitmap->flags);
281+
}
282+
276283
#endif
277284

278285
#endif

drivers/md/raid1-10.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,18 @@ static inline bool raid1_add_bio_to_plug(struct mddev *mddev, struct bio *bio,
132132
blk_plug_cb_fn unplug)
133133
{
134134
struct raid1_plug_cb *plug = NULL;
135-
struct blk_plug_cb *cb = blk_check_plugged(unplug, mddev,
136-
sizeof(*plug));
135+
struct blk_plug_cb *cb;
136+
137+
/*
138+
* If bitmap is not enabled, it's safe to submit the io directly, and
139+
* this can get optimal performance.
140+
*/
141+
if (!md_bitmap_enabled(mddev->bitmap)) {
142+
raid1_submit_write(bio);
143+
return true;
144+
}
137145

146+
cb = blk_check_plugged(unplug, mddev, sizeof(*plug));
138147
if (!cb)
139148
return false;
140149

0 commit comments

Comments
 (0)