aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid1.c
diff options
context:
space:
mode:
authorYu Kuai <[email protected]>2024-08-26 07:44:18 +0000
committerSong Liu <[email protected]>2024-08-27 17:14:15 +0000
commita0e7744a460ba5ca91f8d6fc4a696ee345b5baa9 (patch)
tree2703bfdb1b04af7b391ca85a4d8369f3be482921 /drivers/md/raid1.c
parentmd/md-bitmap: add 'file_pages' into struct md_bitmap_stats (diff)
downloadkernel-a0e7744a460ba5ca91f8d6fc4a696ee345b5baa9.tar.gz
kernel-a0e7744a460ba5ca91f8d6fc4a696ee345b5baa9.zip
md/md-bitmap: add 'behind_writes' and 'behind_wait' into struct md_bitmap_stats
There are no functional changes, avoid dereferencing bitmap directly to prepare inventing a new bitmap. Also fix following checkpatch warning by using wq_has_sleeper(). WARNING: waitqueue_active without comment Signed-off-by: Yu Kuai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Song Liu <[email protected]>
Diffstat (limited to 'drivers/md/raid1.c')
-rw-r--r--drivers/md/raid1.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 18aaa7247bba..b6c4e44f9b4b 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1590,16 +1590,19 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
continue;
if (first_clone) {
+ unsigned long max_write_behind =
+ mddev->bitmap_info.max_write_behind;
+ struct md_bitmap_stats stats;
+ int err;
+
/* do behind I/O ?
* Not if there are too many, or cannot
* allocate memory, or a reader on WriteMostly
* is waiting for behind writes to flush */
- if (bitmap && write_behind &&
- (atomic_read(&bitmap->behind_writes)
- < mddev->bitmap_info.max_write_behind) &&
- !waitqueue_active(&bitmap->behind_wait)) {
+ err = md_bitmap_get_stats(bitmap, &stats);
+ if (!err && write_behind && !stats.behind_wait &&
+ stats.behind_writes < max_write_behind)
alloc_behind_master_bio(r1_bio, bio);
- }
md_bitmap_startwrite(bitmap, r1_bio->sector, r1_bio->sectors,
test_bit(R1BIO_BehindIO, &r1_bio->state));