* [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel
@ 2024-08-14 7:10 Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 01/41] md/raid1: use md_bitmap_wait_behind_writes() in raid1_read_request() Yu Kuai
` (41 more replies)
0 siblings, 42 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
Changes in v2:
- add patch 1-8 to prevent dereference bitmap directly, and the last
patch to make bitmap structure internel.
- use plain function alls "bitmap_ops->xxx()" directly;
The background is that currently bitmap is using a global spin_lock,
cauing lock contention and huge IO performance degration for all raid
levels.
However, it's impossible to implement a new lock free bitmap with
current situation that md-bitmap exposes the internal implementation
with lots of exported apis. Hence bitmap_operations is invented, to
describe bitmap core implementation, and a new bitmap can be introduced
with a new bitmap_operations, we only need to switch to the new one
during initialization.
And with this we can build bitmap as kernel module, but that's not
our concern for now.
Noted I just compile this patchset, not tested yet.
Yu Kuai (41):
md/raid1: use md_bitmap_wait_behind_writes() in raid1_read_request()
md/md-bitmap: replace md_bitmap_status() with a new helper
md_bitmap_get_stats()
md: use new helper md_bitmap_get_stats() in update_array_info()
md/md-bitmap: add 'events_cleared' into struct md_bitmap_stats
md/md-bitmap: add 'sync_size' into struct md_bitmap_stats
md/md-bitmap: add 'file_pages' into struct md_bitmap_stats
md/md-bitmap: add 'behind_writes' and 'behind_wait' into struct
md_bitmap_stats
md/md-cluster: use helper md_bitmap_get_stats() to get pages in
resize_bitmaps()
md/md-bitmap: add a new helper md_bitmap_set_pages()
md/md-bitmap: introduce struct bitmap_operations
md/md-bitmap: simplify md_bitmap_create() + md_bitmap_load()
md/md-bitmap: merge md_bitmap_create() into bitmap_operations
md/md-bitmap: merge md_bitmap_load() into bitmap_operations
md/md-bitmap: merge md_bitmap_destroy() into bitmap_operations
md/md-bitmap: merge md_bitmap_flush() into bitmap_operations
md/md-bitmap: make md_bitmap_print_sb() internal
md/md-bitmap: merge md_bitmap_update_sb() into bitmap_operations
md/md-bitmap: merge md_bitmap_status() into bitmap_operations
md/md-bitmap: remove md_bitmap_setallbits()
md/md-bitmap: merge bitmap_write_all() into bitmap_operations
md/md-bitmap: merge md_bitmap_dirty_bits() into bitmap_operations
md/md-bitmap: merge md_bitmap_startwrite() into bitmap_operations
md/md-bitmap: merge md_bitmap_endwrite() into bitmap_operations
md/md-bitmap: merge md_bitmap_start_sync() into bitmap_operations
md/md-bitmap: remove the parameter 'aborted' for md_bitmap_end_sync()
md/md-bitmap: merge md_bitmap_end_sync() into bitmap_operations
md/md-bitmap: merge md_bitmap_close_sync() into bitmap_operations
md/md-bitmap: mrege md_bitmap_cond_end_sync() into bitmap_operations
md/md-bitmap: merge md_bitmap_sync_with_cluster() into
bitmap_operations
md/md-bitmap: merge md_bitmap_unplug_async() into md_bitmap_unplug()
md/md-bitmap: merge bitmap_unplug() into bitmap_operations
md/md-bitmap: merge md_bitmap_daemon_work() into bitmap_operations
md/md-bitmap: pass in mddev directly for md_bitmap_resize()
md/md-bitmap: merge md_bitmap_resize() into bitmap_operations
md/md-bitmap: merge get_bitmap_from_slot() into bitmap_operations
md/md-bitmap: merge md_bitmap_copy_from_slot() into struct
bitmap_operation.
md/md-bitmap: merge md_bitmap_set_pages() into struct
bitmap_operations
md/md-bitmap: merge md_bitmap_free() into bitmap_operations
md/md-bitmap: merge md_bitmap_wait_behind_writes() into
bitmap_operations
md/md-bitmap: merge md_bitmap_enabled() into bitmap_operations
md/md-bitmap: make in memory structure internal
drivers/md/dm-raid.c | 7 +-
drivers/md/md-bitmap.c | 561 +++++++++++++++++++++++++++++----------
drivers/md/md-bitmap.h | 272 ++++---------------
drivers/md/md-cluster.c | 79 +++---
drivers/md/md.c | 133 ++++++----
drivers/md/md.h | 3 +-
drivers/md/raid1-10.c | 9 +-
drivers/md/raid1.c | 78 +++---
drivers/md/raid10.c | 73 ++---
drivers/md/raid5-cache.c | 8 +-
drivers/md/raid5.c | 62 ++---
11 files changed, 731 insertions(+), 554 deletions(-)
--
2.39.2
^ permalink raw reply [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 01/41] md/raid1: use md_bitmap_wait_behind_writes() in raid1_read_request()
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 02/41] md/md-bitmap: replace md_bitmap_status() with a new helper md_bitmap_get_stats() Yu Kuai
` (40 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
Use the existed helper instead of open coding it to make the code cleaner.
There are no functional changes, and also avoid dereferencing bitmap
directly to prepare inventing a new bitmap.
Noted that this patch also export md_bitmap_wait_behind_writes(), which
is necessary for now, and the exported api will be removed in following
patches to convert bitmap apis into ops.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 1 +
drivers/md/raid1.c | 7 ++-----
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 08232d8dc815..08743dcc70f1 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1851,6 +1851,7 @@ void md_bitmap_wait_behind_writes(struct mddev *mddev)
atomic_read(&bitmap->behind_writes) == 0);
}
}
+EXPORT_SYMBOL_GPL(md_bitmap_wait_behind_writes);
void md_bitmap_destroy(struct mddev *mddev)
{
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 7acfe7c9dc8d..81fc100e7830 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1311,7 +1311,6 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,
struct r1conf *conf = mddev->private;
struct raid1_info *mirror;
struct bio *read_bio;
- struct bitmap *bitmap = mddev->bitmap;
const enum req_op op = bio_op(bio);
const blk_opf_t do_sync = bio->bi_opf & REQ_SYNC;
int max_sectors;
@@ -1377,15 +1376,13 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,
(unsigned long long)r1_bio->sector,
mirror->rdev->bdev);
- if (test_bit(WriteMostly, &mirror->rdev->flags) &&
- bitmap) {
+ if (test_bit(WriteMostly, &mirror->rdev->flags)) {
/*
* Reading from a write-mostly device must take care not to
* over-take any writes that are 'behind'
*/
mddev_add_trace_msg(mddev, "raid1 wait behind writes");
- wait_event(bitmap->behind_wait,
- atomic_read(&bitmap->behind_writes) == 0);
+ md_bitmap_wait_behind_writes(mddev);
}
if (max_sectors < bio_sectors(bio)) {
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 02/41] md/md-bitmap: replace md_bitmap_status() with a new helper md_bitmap_get_stats()
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 01/41] md/raid1: use md_bitmap_wait_behind_writes() in raid1_read_request() Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 03/41] md: use new helper md_bitmap_get_stats() in update_array_info() Yu Kuai
` (39 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
There are no functional changes, and the new helper will be used in
multiple places in following patches to avoid dereferencing bitmap
directly.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 25 ++++++-------------------
drivers/md/md-bitmap.h | 8 +++++++-
drivers/md/md.c | 25 ++++++++++++++++++++++++-
3 files changed, 37 insertions(+), 21 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 08743dcc70f1..8866c7122f79 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -2094,32 +2094,19 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
}
EXPORT_SYMBOL_GPL(md_bitmap_copy_from_slot);
-
-void md_bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
+int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
{
- unsigned long chunk_kb;
struct bitmap_counts *counts;
if (!bitmap)
- return;
+ return -ENOENT;
counts = &bitmap->counts;
+ stats->pages = counts->pages;
+ stats->missing_pages = counts->missing_pages;
+ stats->file = bitmap->storage.file;
- chunk_kb = bitmap->mddev->bitmap_info.chunksize >> 10;
- seq_printf(seq, "bitmap: %lu/%lu pages [%luKB], "
- "%lu%s chunk",
- counts->pages - counts->missing_pages,
- counts->pages,
- (counts->pages - counts->missing_pages)
- << (PAGE_SHIFT - 10),
- chunk_kb ? chunk_kb : bitmap->mddev->bitmap_info.chunksize,
- chunk_kb ? "KB" : "B");
- if (bitmap->storage.file) {
- seq_printf(seq, ", file: ");
- seq_file_path(seq, bitmap->storage.file, " \t\n");
- }
-
- seq_printf(seq, "\n");
+ return 0;
}
int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index bb9eb418780a..8fb52aacd5a1 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -234,6 +234,12 @@ struct bitmap {
int cluster_slot; /* Slot offset for clustered env */
};
+struct md_bitmap_stats {
+ unsigned long pages;
+ unsigned long missing_pages;
+ struct file *file;
+};
+
/* the bitmap API */
/* these are used only by md/bitmap */
@@ -244,7 +250,7 @@ void md_bitmap_destroy(struct mddev *mddev);
void md_bitmap_print_sb(struct bitmap *bitmap);
void md_bitmap_update_sb(struct bitmap *bitmap);
-void md_bitmap_status(struct seq_file *seq, struct bitmap *bitmap);
+int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats);
int md_bitmap_setallbits(struct bitmap *bitmap);
void md_bitmap_write_all(struct bitmap *bitmap);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index d3a837506a36..9cedb8578479 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -8370,6 +8370,29 @@ static void md_seq_stop(struct seq_file *seq, void *v)
spin_unlock(&all_mddevs_lock);
}
+static void md_bitmap_status(struct seq_file *seq, struct mddev *mddev)
+{
+ struct md_bitmap_stats stats;
+ unsigned long chunk_kb;
+ int err = md_bitmap_get_stats(mddev->bitmap, &stats);
+
+ if (err)
+ return;
+
+ chunk_kb = mddev->bitmap_info.chunksize >> 10;
+ seq_printf(seq, "bitmap: %lu/%lu pages [%luKB], %lu%s chunk",
+ stats.pages - stats.missing_pages, stats.pages,
+ (stats.pages - stats.missing_pages) << (PAGE_SHIFT - 10),
+ chunk_kb ? chunk_kb : mddev->bitmap_info.chunksize,
+ chunk_kb ? "KB" : "B");
+ if (stats.file) {
+ seq_puts(seq, ", file: ");
+ seq_file_path(seq, stats.file, " \t\n");
+ }
+
+ seq_putc(seq, '\n');
+}
+
static int md_seq_show(struct seq_file *seq, void *v)
{
struct mddev *mddev;
@@ -8453,7 +8476,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
} else
seq_printf(seq, "\n ");
- md_bitmap_status(seq, mddev->bitmap);
+ md_bitmap_status(seq, mddev);
seq_printf(seq, "\n");
}
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 03/41] md: use new helper md_bitmap_get_stats() in update_array_info()
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 01/41] md/raid1: use md_bitmap_wait_behind_writes() in raid1_read_request() Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 02/41] md/md-bitmap: replace md_bitmap_status() with a new helper md_bitmap_get_stats() Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 04/41] md/md-bitmap: add 'events_cleared' into struct md_bitmap_stats Yu Kuai
` (38 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
There are no functional changes, avoid dereferencing bitmap directly to
prepare inventing a new bitmap.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 9cedb8578479..27013059baa2 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -7577,15 +7577,17 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
if (rv)
md_bitmap_destroy(mddev);
} else {
- /* remove the bitmap */
- if (!mddev->bitmap) {
- rv = -ENOENT;
+ struct md_bitmap_stats stats;
+
+ rv = md_bitmap_get_stats(mddev->bitmap, &stats);
+ if (rv)
goto err;
- }
- if (mddev->bitmap->storage.file) {
+
+ if (stats.file) {
rv = -EINVAL;
goto err;
}
+
if (mddev->bitmap_info.nodes) {
/* hold PW on all the bitmap lock */
if (md_cluster_ops->lock_all_bitmaps(mddev) <= 0) {
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 04/41] md/md-bitmap: add 'events_cleared' into struct md_bitmap_stats
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (2 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 03/41] md: use new helper md_bitmap_get_stats() in update_array_info() Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 05/41] md/md-bitmap: add 'sync_size' " Yu Kuai
` (37 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
Also add a new helper to get events_cleared to avoid dereferencing
bitmap directly to prepare inventing a new bitmap.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 1 +
drivers/md/md-bitmap.h | 12 ++++++++++++
drivers/md/md.c | 4 ++--
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 8866c7122f79..8a2411040d2f 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -2105,6 +2105,7 @@ int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
stats->pages = counts->pages;
stats->missing_pages = counts->missing_pages;
stats->file = bitmap->storage.file;
+ stats->events_cleared = bitmap->events_cleared;
return 0;
}
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index 8fb52aacd5a1..c8527ba38dfc 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -238,6 +238,7 @@ struct md_bitmap_stats {
unsigned long pages;
unsigned long missing_pages;
struct file *file;
+ u64 events_cleared;
};
/* the bitmap API */
@@ -282,6 +283,17 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
void md_bitmap_free(struct bitmap *bitmap);
void md_bitmap_wait_behind_writes(struct mddev *mddev);
+static inline u64 md_bitmap_events_cleared(struct mddev *mddev)
+{
+ struct md_bitmap_stats stats;
+ int err = md_bitmap_get_stats(mddev->bitmap, &stats);
+
+ if (err)
+ return 0;
+
+ return stats.events_cleared;
+}
+
static inline bool md_bitmap_enabled(struct bitmap *bitmap)
{
return bitmap && bitmap->storage.filemap &&
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 27013059baa2..29ec6fe80ae8 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1464,7 +1464,7 @@ static int super_90_validate(struct mddev *mddev, struct md_rdev *freshest, stru
/* if adding to array with a bitmap, then we can accept an
* older device ... but not too old.
*/
- if (ev1 < mddev->bitmap->events_cleared)
+ if (ev1 < md_bitmap_events_cleared(mddev))
return 0;
if (ev1 < mddev->events)
set_bit(Bitmap_sync, &rdev->flags);
@@ -1991,7 +1991,7 @@ static int super_1_validate(struct mddev *mddev, struct md_rdev *freshest, struc
/* If adding to array with a bitmap, then we can accept an
* older device, but not too old.
*/
- if (ev1 < mddev->bitmap->events_cleared)
+ if (ev1 < md_bitmap_events_cleared(mddev))
return 0;
if (ev1 < mddev->events)
set_bit(Bitmap_sync, &rdev->flags);
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 05/41] md/md-bitmap: add 'sync_size' into struct md_bitmap_stats
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (3 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 04/41] md/md-bitmap: add 'events_cleared' into struct md_bitmap_stats Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 12:52 ` Mariusz Tkaczyk
2024-08-14 7:10 ` [PATCH RFC -next v2 06/41] md/md-bitmap: add 'file_pages' " Yu Kuai
` (36 subsequent siblings)
41 siblings, 1 reply; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
To avoid dereferencing bitmap directly in md-cluster to prepare
inventing a new bitmap.
BTW, also fix following checkpatch warnings:
WARNING: Deprecated use of 'kmap_atomic', prefer 'kmap_local_page' instead
WARNING: Deprecated use of 'kunmap_atomic', prefer 'kunmap_local' instead
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 6 ++++++
drivers/md/md-bitmap.h | 1 +
drivers/md/md-cluster.c | 25 +++++++++++++++----------
3 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 8a2411040d2f..9ff5ed250ba5 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -2096,11 +2096,16 @@ EXPORT_SYMBOL_GPL(md_bitmap_copy_from_slot);
int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
{
+ bitmap_super_t *sb;
struct bitmap_counts *counts;
if (!bitmap)
return -ENOENT;
+ sb = kmap_local_page(bitmap->storage.sb_page);
+ stats->sync_size = sb->sync_size;
+ kunmap_local(sb);
+
counts = &bitmap->counts;
stats->pages = counts->pages;
stats->missing_pages = counts->missing_pages;
@@ -2109,6 +2114,7 @@ int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
return 0;
}
+EXPORT_SYMBOL_GPL(md_bitmap_get_stats);
int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
int chunksize, int init)
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index c8527ba38dfc..1a7ad2cf9f75 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -237,6 +237,7 @@ struct bitmap {
struct md_bitmap_stats {
unsigned long pages;
unsigned long missing_pages;
+ unsigned long sync_size;
struct file *file;
u64 events_cleared;
};
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index 1d0db62f0351..9d87c215f094 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -1208,17 +1208,19 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
static int cluster_check_sync_size(struct mddev *mddev)
{
int i, rv;
- bitmap_super_t *sb;
unsigned long my_sync_size, sync_size = 0;
int node_num = mddev->bitmap_info.nodes;
int current_slot = md_cluster_ops->slot_number(mddev);
struct bitmap *bitmap = mddev->bitmap;
char str[64];
struct dlm_lock_resource *bm_lockres;
+ struct md_bitmap_stats stats;
- sb = kmap_atomic(bitmap->storage.sb_page);
- my_sync_size = sb->sync_size;
- kunmap_atomic(sb);
+ rv = md_bitmap_get_stats(bitmap, &stats);
+ if (rv)
+ return rv;
+
+ my_sync_size = stats.sync_size;
for (i = 0; i < node_num; i++) {
if (i == current_slot)
@@ -1247,15 +1249,18 @@ static int cluster_check_sync_size(struct mddev *mddev)
md_bitmap_update_sb(bitmap);
lockres_free(bm_lockres);
- sb = kmap_atomic(bitmap->storage.sb_page);
- if (sync_size == 0)
- sync_size = sb->sync_size;
- else if (sync_size != sb->sync_size) {
- kunmap_atomic(sb);
+ rv = md_bitmap_get_stats(bitmap, &stats);
+ if (rv) {
+ md_bitmap_free(bitmap);
+ return rv;
+ }
+
+ if (sync_size == 0) {
+ sync_size = stats.sync_size;
+ } else if (sync_size != stats.sync_size) {
md_bitmap_free(bitmap);
return -1;
}
- kunmap_atomic(sb);
md_bitmap_free(bitmap);
}
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 06/41] md/md-bitmap: add 'file_pages' into struct md_bitmap_stats
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (4 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 05/41] md/md-bitmap: add 'sync_size' " Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 07/41] md/md-bitmap: add 'behind_writes' and 'behind_wait' " Yu Kuai
` (35 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
There are no functional changes, avoid dereferencing bitmap directly to
prepare inventing a new bitmap.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 1 +
drivers/md/md-bitmap.h | 1 +
drivers/md/md.c | 12 ++++++++----
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 9ff5ed250ba5..cd304240aaa6 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -2109,6 +2109,7 @@ int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
counts = &bitmap->counts;
stats->pages = counts->pages;
stats->missing_pages = counts->missing_pages;
+ stats->file_pages = bitmap->storage.file_pages;
stats->file = bitmap->storage.file;
stats->events_cleared = bitmap->events_cleared;
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index 1a7ad2cf9f75..52ef4dae8f3e 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -237,6 +237,7 @@ struct bitmap {
struct md_bitmap_stats {
unsigned long pages;
unsigned long missing_pages;
+ unsigned long file_pages;
unsigned long sync_size;
struct file *file;
u64 events_cleared;
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 29ec6fe80ae8..628fa49170e1 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2323,7 +2323,10 @@ super_1_allow_new_offset(struct md_rdev *rdev,
unsigned long long new_offset)
{
/* All necessary checks on new >= old have been done */
- struct bitmap *bitmap;
+ struct bitmap *bitmap = rdev->mddev->bitmap;
+ struct md_bitmap_stats stats;
+ int err;
+
if (new_offset >= rdev->data_offset)
return 1;
@@ -2340,10 +2343,11 @@ super_1_allow_new_offset(struct md_rdev *rdev,
*/
if (rdev->sb_start + (32+4)*2 > new_offset)
return 0;
- bitmap = rdev->mddev->bitmap;
- if (bitmap && !rdev->mddev->bitmap_info.file &&
+
+ err = md_bitmap_get_stats(bitmap, &stats);
+ if (!err && !rdev->mddev->bitmap_info.file &&
rdev->sb_start + rdev->mddev->bitmap_info.offset +
- bitmap->storage.file_pages * (PAGE_SIZE>>9) > new_offset)
+ stats.file_pages * (PAGE_SIZE>>9) > new_offset)
return 0;
if (rdev->badblocks.sector + rdev->badblocks.size > new_offset)
return 0;
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 07/41] md/md-bitmap: add 'behind_writes' and 'behind_wait' into struct md_bitmap_stats
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (5 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 06/41] md/md-bitmap: add 'file_pages' " Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 08/41] md/md-cluster: use helper md_bitmap_get_stats() to get pages in resize_bitmaps() Yu Kuai
` (34 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
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 <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 2 ++
drivers/md/md-bitmap.h | 2 ++
drivers/md/raid1.c | 12 +++++++-----
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index cd304240aaa6..7dcb025207b8 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -2113,6 +2113,8 @@ int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
stats->file = bitmap->storage.file;
stats->events_cleared = bitmap->events_cleared;
+ stats->behind_writes = atomic_read(&bitmap->behind_writes);
+ stats->behind_wait = wq_has_sleeper(&bitmap->behind_wait);
return 0;
}
EXPORT_SYMBOL_GPL(md_bitmap_get_stats);
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index 52ef4dae8f3e..119644907f89 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -241,6 +241,8 @@ struct md_bitmap_stats {
unsigned long sync_size;
struct file *file;
u64 events_cleared;
+ int behind_writes;
+ bool behind_wait;
};
/* the bitmap API */
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 81fc100e7830..bfd2d63d1c59 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1603,16 +1603,18 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
continue;
if (first_clone) {
+ struct md_bitmap_stats stats;
+ int err = md_bitmap_get_stats(bitmap, &stats);
+
/* 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)) {
+ if (!err && write_behind &&
+ stats.behind_writes <
+ mddev->bitmap_info.max_write_behind &&
+ !stats.behind_wait)
alloc_behind_master_bio(r1_bio, bio);
- }
md_bitmap_startwrite(bitmap, r1_bio->sector, r1_bio->sectors,
test_bit(R1BIO_BehindIO, &r1_bio->state));
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 08/41] md/md-cluster: use helper md_bitmap_get_stats() to get pages in resize_bitmaps()
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (6 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 07/41] md/md-bitmap: add 'behind_writes' and 'behind_wait' " Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 09/41] md/md-bitmap: add a new helper md_bitmap_set_pages() Yu Kuai
` (33 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
Use the existed helper instead of open coding it, avoid dereferencing
bitmap directly to prepare inventing a new bitmap.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-cluster.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index 9d87c215f094..e4ad8efdc63b 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -1144,12 +1144,18 @@ static int update_bitmap_size(struct mddev *mddev, sector_t size)
static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsize)
{
struct bitmap_counts *counts;
- char str[64];
struct dlm_lock_resource *bm_lockres;
struct bitmap *bitmap = mddev->bitmap;
- unsigned long my_pages = bitmap->counts.pages;
+ struct md_bitmap_stats stats;
+ unsigned long my_pages;
+ char str[64];
int i, rv;
+ rv = md_bitmap_get_stats(bitmap, &stats);
+ if (rv)
+ return rv;
+
+ my_pages = stats.pages;
/*
* We need to ensure all the nodes can grow to a larger
* bitmap size before make the reshaping.
@@ -1170,6 +1176,9 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
}
counts = &bitmap->counts;
+ rv = md_bitmap_get_stats(bitmap, &stats);
+ if (rv)
+ goto out;
/*
* If we can hold the bitmap lock of one node then
* the slot is not occupied, update the pages.
@@ -1186,7 +1195,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
counts->pages = my_pages;
lockres_free(bm_lockres);
- if (my_pages != counts->pages)
+ if (my_pages != stats.pages)
/*
* Let's revert the bitmap size if one node
* can't resize bitmap
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 09/41] md/md-bitmap: add a new helper md_bitmap_set_pages()
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (7 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 08/41] md/md-cluster: use helper md_bitmap_get_stats() to get pages in resize_bitmaps() Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 10/41] md/md-bitmap: introduce struct bitmap_operations Yu Kuai
` (32 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
Currently md-cluster will set bitmap->counts.pages directly, add a
helper to do this to avoid dereferencing bitmap directly.
Noted that after this patch bitmap is not dereferenced directly anymore
and following patches will move the structure inside md-bitmap.c.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 6 ++++++
drivers/md/md-bitmap.h | 1 +
drivers/md/md-cluster.c | 4 +---
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 7dcb025207b8..ee3ed1e3daf9 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -2094,6 +2094,12 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
}
EXPORT_SYMBOL_GPL(md_bitmap_copy_from_slot);
+void md_bitmap_set_pages(struct bitmap *bitmap, unsigned long pages)
+{
+ bitmap->counts.pages = pages;
+}
+EXPORT_SYMBOL_GPL(md_bitmap_set_pages);
+
int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
{
bitmap_super_t *sb;
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index 119644907f89..cad1de79775f 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -284,6 +284,7 @@ int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot);
int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
sector_t *lo, sector_t *hi, bool clear_bits);
+void md_bitmap_set_pages(struct bitmap *bitmap, unsigned long pages);
void md_bitmap_free(struct bitmap *bitmap);
void md_bitmap_wait_behind_writes(struct mddev *mddev);
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index e4ad8efdc63b..1938eadb379b 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -1143,7 +1143,6 @@ static int update_bitmap_size(struct mddev *mddev, sector_t size)
static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsize)
{
- struct bitmap_counts *counts;
struct dlm_lock_resource *bm_lockres;
struct bitmap *bitmap = mddev->bitmap;
struct md_bitmap_stats stats;
@@ -1174,7 +1173,6 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
bitmap = NULL;
goto out;
}
- counts = &bitmap->counts;
rv = md_bitmap_get_stats(bitmap, &stats);
if (rv)
@@ -1192,7 +1190,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
bm_lockres->flags |= DLM_LKF_NOQUEUE;
rv = dlm_lock_sync(bm_lockres, DLM_LOCK_PW);
if (!rv)
- counts->pages = my_pages;
+ md_bitmap_set_pages(bitmap, my_pages);
lockres_free(bm_lockres);
if (my_pages != stats.pages)
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 10/41] md/md-bitmap: introduce struct bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (8 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 09/41] md/md-bitmap: add a new helper md_bitmap_set_pages() Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 11/41] md/md-bitmap: simplify md_bitmap_create() + md_bitmap_load() Yu Kuai
` (31 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
The structure is empty for now, and will be used in later patches to
merge in bitmap operations, so that bitmap implementation won't be
exposed.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 8 ++++++++
drivers/md/md-bitmap.h | 4 ++++
drivers/md/md.c | 1 +
drivers/md/md.h | 1 +
4 files changed, 14 insertions(+)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index ee3ed1e3daf9..eed3b930ade4 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -2711,3 +2711,11 @@ const struct attribute_group md_bitmap_group = {
.name = "bitmap",
.attrs = md_bitmap_attrs,
};
+
+static struct bitmap_operations bitmap_ops = {
+};
+
+void mddev_set_bitmap_ops(struct mddev *mddev)
+{
+ mddev->bitmap_ops = &bitmap_ops;
+}
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index cad1de79775f..a8a5d4804174 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -245,7 +245,11 @@ struct md_bitmap_stats {
bool behind_wait;
};
+struct bitmap_operations {
+};
+
/* the bitmap API */
+void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are used only by md/bitmap */
struct bitmap *md_bitmap_create(struct mddev *mddev, int slot);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 628fa49170e1..f67f2540fd6c 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -772,6 +772,7 @@ int mddev_init(struct mddev *mddev)
mddev->resync_min = 0;
mddev->resync_max = MaxSector;
mddev->level = LEVEL_NONE;
+ mddev_set_bitmap_ops(mddev);
INIT_WORK(&mddev->sync_work, md_start_sync);
INIT_WORK(&mddev->del_work, mddev_delayed_delete);
diff --git a/drivers/md/md.h b/drivers/md/md.h
index a0d6827dced9..e56193f71ab4 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -536,6 +536,7 @@ struct mddev {
int sync_checkers; /* # of threads checking writes_pending */
struct bitmap *bitmap; /* the bitmap for the device */
+ struct bitmap_operations *bitmap_ops;
struct {
struct file *file; /* the bitmap file */
loff_t offset; /* offset from superblock of
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 11/41] md/md-bitmap: simplify md_bitmap_create() + md_bitmap_load()
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (9 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 10/41] md/md-bitmap: introduce struct bitmap_operations Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-19 8:10 ` Su Yue
2024-08-14 7:10 ` [PATCH RFC -next v2 12/41] md/md-bitmap: merge md_bitmap_create() into bitmap_operations Yu Kuai
` (30 subsequent siblings)
41 siblings, 1 reply; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
Other than internal api get_bitmap_from_slot(), all other places will
set returned bitmap to mddev->bitmap. So move the setting of
mddev->bitmap into md_bitmap_create() to simplify code.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 23 +++++++++++++++--------
drivers/md/md-bitmap.h | 2 +-
drivers/md/md.c | 30 +++++++++---------------------
3 files changed, 25 insertions(+), 30 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index eed3b930ade4..75e58da9a1a5 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1879,7 +1879,7 @@ void md_bitmap_destroy(struct mddev *mddev)
* if this returns an error, bitmap_destroy must be called to do clean up
* once mddev->bitmap is set
*/
-struct bitmap *md_bitmap_create(struct mddev *mddev, int slot)
+static struct bitmap *bitmap_create(struct mddev *mddev, int slot)
{
struct bitmap *bitmap;
sector_t blocks = mddev->resync_max_sectors;
@@ -1966,6 +1966,17 @@ struct bitmap *md_bitmap_create(struct mddev *mddev, int slot)
return ERR_PTR(err);
}
+int md_bitmap_create(struct mddev *mddev, int slot)
+{
+ struct bitmap *bitmap = bitmap_create(mddev, slot);
+
+ if (IS_ERR(bitmap))
+ return PTR_ERR(bitmap);
+
+ mddev->bitmap = bitmap;
+ return 0;
+}
+
int md_bitmap_load(struct mddev *mddev)
{
int err = 0;
@@ -2030,7 +2041,7 @@ struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot)
int rv = 0;
struct bitmap *bitmap;
- bitmap = md_bitmap_create(mddev, slot);
+ bitmap = bitmap_create(mddev, slot);
if (IS_ERR(bitmap)) {
rv = PTR_ERR(bitmap);
return ERR_PTR(rv);
@@ -2381,7 +2392,6 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
} else {
/* No bitmap, OK to set a location */
long long offset;
- struct bitmap *bitmap;
if (strncmp(buf, "none", 4) == 0)
/* nothing to be done */;
@@ -2408,13 +2418,10 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
}
mddev->bitmap_info.offset = offset;
- bitmap = md_bitmap_create(mddev, -1);
- if (IS_ERR(bitmap)) {
- rv = PTR_ERR(bitmap);
+ rv = md_bitmap_create(mddev, -1);
+ if (rv)
goto out;
- }
- mddev->bitmap = bitmap;
rv = md_bitmap_load(mddev);
if (rv) {
mddev->bitmap_info.offset = 0;
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index a8a5d4804174..e187f9099f2e 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -252,7 +252,7 @@ struct bitmap_operations {
void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are used only by md/bitmap */
-struct bitmap *md_bitmap_create(struct mddev *mddev, int slot);
+int md_bitmap_create(struct mddev *mddev, int slot);
int md_bitmap_load(struct mddev *mddev);
void md_bitmap_flush(struct mddev *mddev);
void md_bitmap_destroy(struct mddev *mddev);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index f67f2540fd6c..6e130f6c2abd 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6211,16 +6211,10 @@ int md_run(struct mddev *mddev)
}
if (err == 0 && pers->sync_request &&
(mddev->bitmap_info.file || mddev->bitmap_info.offset)) {
- struct bitmap *bitmap;
-
- bitmap = md_bitmap_create(mddev, -1);
- if (IS_ERR(bitmap)) {
- err = PTR_ERR(bitmap);
+ err = md_bitmap_create(mddev, -1);
+ if (err)
pr_warn("%s: failed to create bitmap (%d)\n",
mdname(mddev), err);
- } else
- mddev->bitmap = bitmap;
-
}
if (err)
goto bitmap_abort;
@@ -7275,14 +7269,10 @@ static int set_bitmap_file(struct mddev *mddev, int fd)
err = 0;
if (mddev->pers) {
if (fd >= 0) {
- struct bitmap *bitmap;
-
- bitmap = md_bitmap_create(mddev, -1);
- if (!IS_ERR(bitmap)) {
- mddev->bitmap = bitmap;
+ err = md_bitmap_create(mddev, -1);
+ if (!err)
err = md_bitmap_load(mddev);
- } else
- err = PTR_ERR(bitmap);
+
if (err) {
md_bitmap_destroy(mddev);
fd = -1;
@@ -7291,6 +7281,7 @@ static int set_bitmap_file(struct mddev *mddev, int fd)
md_bitmap_destroy(mddev);
}
}
+
if (fd < 0) {
struct file *f = mddev->bitmap_info.file;
if (f) {
@@ -7559,7 +7550,6 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
goto err;
}
if (info->state & (1<<MD_SB_BITMAP_PRESENT)) {
- struct bitmap *bitmap;
/* add the bitmap */
if (mddev->bitmap) {
rv = -EEXIST;
@@ -7573,12 +7563,10 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
mddev->bitmap_info.default_offset;
mddev->bitmap_info.space =
mddev->bitmap_info.default_space;
- bitmap = md_bitmap_create(mddev, -1);
- if (!IS_ERR(bitmap)) {
- mddev->bitmap = bitmap;
+ rv = md_bitmap_create(mddev, -1);
+ if (!rv)
rv = md_bitmap_load(mddev);
- } else
- rv = PTR_ERR(bitmap);
+
if (rv)
md_bitmap_destroy(mddev);
} else {
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 12/41] md/md-bitmap: merge md_bitmap_create() into bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (10 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 11/41] md/md-bitmap: simplify md_bitmap_create() + md_bitmap_load() Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 13/41] md/md-bitmap: merge md_bitmap_load() " Yu Kuai
` (29 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
So that the implementation won't be exposed, and it'll be possible
to invent a new bitmap by replacing bitmap_operations.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 11 ++++++-----
drivers/md/md-bitmap.h | 2 +-
drivers/md/md.c | 6 +++---
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 75e58da9a1a5..9606bcafb834 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1879,7 +1879,7 @@ void md_bitmap_destroy(struct mddev *mddev)
* if this returns an error, bitmap_destroy must be called to do clean up
* once mddev->bitmap is set
*/
-static struct bitmap *bitmap_create(struct mddev *mddev, int slot)
+static struct bitmap *__bitmap_create(struct mddev *mddev, int slot)
{
struct bitmap *bitmap;
sector_t blocks = mddev->resync_max_sectors;
@@ -1966,9 +1966,9 @@ static struct bitmap *bitmap_create(struct mddev *mddev, int slot)
return ERR_PTR(err);
}
-int md_bitmap_create(struct mddev *mddev, int slot)
+static int bitmap_create(struct mddev *mddev, int slot)
{
- struct bitmap *bitmap = bitmap_create(mddev, slot);
+ struct bitmap *bitmap = __bitmap_create(mddev, slot);
if (IS_ERR(bitmap))
return PTR_ERR(bitmap);
@@ -2041,7 +2041,7 @@ struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot)
int rv = 0;
struct bitmap *bitmap;
- bitmap = bitmap_create(mddev, slot);
+ bitmap = __bitmap_create(mddev, slot);
if (IS_ERR(bitmap)) {
rv = PTR_ERR(bitmap);
return ERR_PTR(rv);
@@ -2418,7 +2418,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
}
mddev->bitmap_info.offset = offset;
- rv = md_bitmap_create(mddev, -1);
+ rv = bitmap_create(mddev, -1);
if (rv)
goto out;
@@ -2720,6 +2720,7 @@ const struct attribute_group md_bitmap_group = {
};
static struct bitmap_operations bitmap_ops = {
+ .create = bitmap_create,
};
void mddev_set_bitmap_ops(struct mddev *mddev)
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index e187f9099f2e..4b9c22b66e65 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -246,13 +246,13 @@ struct md_bitmap_stats {
};
struct bitmap_operations {
+ int (*create)(struct mddev *mddev, int slot);
};
/* the bitmap API */
void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are used only by md/bitmap */
-int md_bitmap_create(struct mddev *mddev, int slot);
int md_bitmap_load(struct mddev *mddev);
void md_bitmap_flush(struct mddev *mddev);
void md_bitmap_destroy(struct mddev *mddev);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 6e130f6c2abd..b32ab7ca7640 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6211,7 +6211,7 @@ int md_run(struct mddev *mddev)
}
if (err == 0 && pers->sync_request &&
(mddev->bitmap_info.file || mddev->bitmap_info.offset)) {
- err = md_bitmap_create(mddev, -1);
+ err = mddev->bitmap_ops->create(mddev, -1);
if (err)
pr_warn("%s: failed to create bitmap (%d)\n",
mdname(mddev), err);
@@ -7269,7 +7269,7 @@ static int set_bitmap_file(struct mddev *mddev, int fd)
err = 0;
if (mddev->pers) {
if (fd >= 0) {
- err = md_bitmap_create(mddev, -1);
+ err = mddev->bitmap_ops->create(mddev, -1);
if (!err)
err = md_bitmap_load(mddev);
@@ -7563,7 +7563,7 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
mddev->bitmap_info.default_offset;
mddev->bitmap_info.space =
mddev->bitmap_info.default_space;
- rv = md_bitmap_create(mddev, -1);
+ rv = mddev->bitmap_ops->create(mddev, -1);
if (!rv)
rv = md_bitmap_load(mddev);
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 13/41] md/md-bitmap: merge md_bitmap_load() into bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (11 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 12/41] md/md-bitmap: merge md_bitmap_create() into bitmap_operations Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 14/41] md/md-bitmap: merge md_bitmap_destroy() " Yu Kuai
` (28 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
So that the implementation won't be exposed, and it'll be possible
to invent a new bitmap by replacing bitmap_operations.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/dm-raid.c | 4 +++-
drivers/md/md-bitmap.c | 6 +++---
drivers/md/md-bitmap.h | 2 +-
drivers/md/md.c | 7 ++++---
4 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 0c3323e0adb2..c3e201fde4c5 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -3949,7 +3949,9 @@ static int __load_dirty_region_bitmap(struct raid_set *rs)
/* Try loading the bitmap unless "raid0", which does not have one */
if (!rs_is_raid0(rs) &&
!test_and_set_bit(RT_FLAG_RS_BITMAP_LOADED, &rs->runtime_flags)) {
- r = md_bitmap_load(&rs->md);
+ struct mddev *mddev = &rs->md;
+
+ r = mddev->bitmap_ops->load(mddev);
if (r)
DMERR("Failed to load bitmap");
}
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 9606bcafb834..0113a972e42d 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1977,7 +1977,7 @@ static int bitmap_create(struct mddev *mddev, int slot)
return 0;
}
-int md_bitmap_load(struct mddev *mddev)
+static int bitmap_load(struct mddev *mddev)
{
int err = 0;
sector_t start = 0;
@@ -2033,7 +2033,6 @@ int md_bitmap_load(struct mddev *mddev)
out:
return err;
}
-EXPORT_SYMBOL_GPL(md_bitmap_load);
/* caller need to free returned bitmap with md_bitmap_free() */
struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot)
@@ -2422,7 +2421,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
if (rv)
goto out;
- rv = md_bitmap_load(mddev);
+ rv = bitmap_load(mddev);
if (rv) {
mddev->bitmap_info.offset = 0;
md_bitmap_destroy(mddev);
@@ -2721,6 +2720,7 @@ const struct attribute_group md_bitmap_group = {
static struct bitmap_operations bitmap_ops = {
.create = bitmap_create,
+ .load = bitmap_load,
};
void mddev_set_bitmap_ops(struct mddev *mddev)
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index 4b9c22b66e65..ba912f5f3450 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -247,13 +247,13 @@ struct md_bitmap_stats {
struct bitmap_operations {
int (*create)(struct mddev *mddev, int slot);
+ int (*load)(struct mddev *mddev);
};
/* the bitmap API */
void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are used only by md/bitmap */
-int md_bitmap_load(struct mddev *mddev);
void md_bitmap_flush(struct mddev *mddev);
void md_bitmap_destroy(struct mddev *mddev);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index b32ab7ca7640..2fe25a6257e6 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6303,7 +6303,8 @@ int do_md_run(struct mddev *mddev)
err = md_run(mddev);
if (err)
goto out;
- err = md_bitmap_load(mddev);
+
+ err = mddev->bitmap_ops->load(mddev);
if (err) {
md_bitmap_destroy(mddev);
goto out;
@@ -7271,7 +7272,7 @@ static int set_bitmap_file(struct mddev *mddev, int fd)
if (fd >= 0) {
err = mddev->bitmap_ops->create(mddev, -1);
if (!err)
- err = md_bitmap_load(mddev);
+ err = mddev->bitmap_ops->load(mddev);
if (err) {
md_bitmap_destroy(mddev);
@@ -7565,7 +7566,7 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
mddev->bitmap_info.default_space;
rv = mddev->bitmap_ops->create(mddev, -1);
if (!rv)
- rv = md_bitmap_load(mddev);
+ rv = mddev->bitmap_ops->load(mddev);
if (rv)
md_bitmap_destroy(mddev);
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 14/41] md/md-bitmap: merge md_bitmap_destroy() into bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (12 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 13/41] md/md-bitmap: merge md_bitmap_load() " Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 15/41] md/md-bitmap: merge md_bitmap_flush() " Yu Kuai
` (27 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
So that the implementation won't be exposed, and it'll be possible
to invent a new bitmap by replacing bitmap_operations.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 7 ++++---
drivers/md/md-bitmap.h | 2 +-
drivers/md/md.c | 15 ++++++++-------
3 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 0113a972e42d..94cf3c6e96e3 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1853,7 +1853,7 @@ void md_bitmap_wait_behind_writes(struct mddev *mddev)
}
EXPORT_SYMBOL_GPL(md_bitmap_wait_behind_writes);
-void md_bitmap_destroy(struct mddev *mddev)
+static void bitmap_destroy(struct mddev *mddev)
{
struct bitmap *bitmap = mddev->bitmap;
@@ -2381,7 +2381,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
goto out;
}
- md_bitmap_destroy(mddev);
+ bitmap_destroy(mddev);
mddev->bitmap_info.offset = 0;
if (mddev->bitmap_info.file) {
struct file *f = mddev->bitmap_info.file;
@@ -2424,7 +2424,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
rv = bitmap_load(mddev);
if (rv) {
mddev->bitmap_info.offset = 0;
- md_bitmap_destroy(mddev);
+ bitmap_destroy(mddev);
goto out;
}
}
@@ -2721,6 +2721,7 @@ const struct attribute_group md_bitmap_group = {
static struct bitmap_operations bitmap_ops = {
.create = bitmap_create,
.load = bitmap_load,
+ .destroy = bitmap_destroy,
};
void mddev_set_bitmap_ops(struct mddev *mddev)
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index ba912f5f3450..9376bbeb4698 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -248,6 +248,7 @@ struct md_bitmap_stats {
struct bitmap_operations {
int (*create)(struct mddev *mddev, int slot);
int (*load)(struct mddev *mddev);
+ void (*destroy)(struct mddev *mddev);
};
/* the bitmap API */
@@ -255,7 +256,6 @@ void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are used only by md/bitmap */
void md_bitmap_flush(struct mddev *mddev);
-void md_bitmap_destroy(struct mddev *mddev);
void md_bitmap_print_sb(struct bitmap *bitmap);
void md_bitmap_update_sb(struct bitmap *bitmap);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 2fe25a6257e6..7aecd99d50e2 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6284,7 +6284,7 @@ int md_run(struct mddev *mddev)
pers->free(mddev, mddev->private);
mddev->private = NULL;
module_put(pers->owner);
- md_bitmap_destroy(mddev);
+ mddev->bitmap_ops->destroy(mddev);
abort:
bioset_exit(&mddev->io_clone_set);
exit_sync_set:
@@ -6306,7 +6306,7 @@ int do_md_run(struct mddev *mddev)
err = mddev->bitmap_ops->load(mddev);
if (err) {
- md_bitmap_destroy(mddev);
+ mddev->bitmap_ops->destroy(mddev);
goto out;
}
@@ -6492,7 +6492,8 @@ static void mddev_detach(struct mddev *mddev)
static void __md_stop(struct mddev *mddev)
{
struct md_personality *pers = mddev->pers;
- md_bitmap_destroy(mddev);
+
+ mddev->bitmap_ops->destroy(mddev);
mddev_detach(mddev);
spin_lock(&mddev->lock);
mddev->pers = NULL;
@@ -7275,11 +7276,11 @@ static int set_bitmap_file(struct mddev *mddev, int fd)
err = mddev->bitmap_ops->load(mddev);
if (err) {
- md_bitmap_destroy(mddev);
+ mddev->bitmap_ops->destroy(mddev);
fd = -1;
}
} else if (fd < 0) {
- md_bitmap_destroy(mddev);
+ mddev->bitmap_ops->destroy(mddev);
}
}
@@ -7569,7 +7570,7 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
rv = mddev->bitmap_ops->load(mddev);
if (rv)
- md_bitmap_destroy(mddev);
+ mddev->bitmap_ops->destroy(mddev);
} else {
struct md_bitmap_stats stats;
@@ -7596,7 +7597,7 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
module_put(md_cluster_mod);
mddev->safemode_delay = DEFAULT_SAFEMODE_DELAY;
}
- md_bitmap_destroy(mddev);
+ mddev->bitmap_ops->destroy(mddev);
mddev->bitmap_info.offset = 0;
}
}
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 15/41] md/md-bitmap: merge md_bitmap_flush() into bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (13 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 14/41] md/md-bitmap: merge md_bitmap_destroy() " Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 16/41] md/md-bitmap: make md_bitmap_print_sb() internal Yu Kuai
` (26 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
So that the implementation won't be exposed, and it'll be possible
to invent a new bitmap by replacing bitmap_operations.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 6 ++----
drivers/md/md-bitmap.h | 2 +-
drivers/md/md.c | 3 ++-
3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 94cf3c6e96e3..d1b43bce5953 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1773,10 +1773,7 @@ void md_bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long
}
}
-/*
- * flush out any pending updates
- */
-void md_bitmap_flush(struct mddev *mddev)
+static void bitmap_flush(struct mddev *mddev)
{
struct bitmap *bitmap = mddev->bitmap;
long sleep;
@@ -2722,6 +2719,7 @@ static struct bitmap_operations bitmap_ops = {
.create = bitmap_create,
.load = bitmap_load,
.destroy = bitmap_destroy,
+ .flush = bitmap_flush,
};
void mddev_set_bitmap_ops(struct mddev *mddev)
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index 9376bbeb4698..0212284c2b29 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -249,13 +249,13 @@ struct bitmap_operations {
int (*create)(struct mddev *mddev, int slot);
int (*load)(struct mddev *mddev);
void (*destroy)(struct mddev *mddev);
+ void (*flush)(struct mddev *mddev);
};
/* the bitmap API */
void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are used only by md/bitmap */
-void md_bitmap_flush(struct mddev *mddev);
void md_bitmap_print_sb(struct bitmap *bitmap);
void md_bitmap_update_sb(struct bitmap *bitmap);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 7aecd99d50e2..69d4b21c441e 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6450,7 +6450,8 @@ static void __md_stop_writes(struct mddev *mddev)
mddev->pers->quiesce(mddev, 1);
mddev->pers->quiesce(mddev, 0);
}
- md_bitmap_flush(mddev);
+
+ mddev->bitmap_ops->flush(mddev);
if (md_is_rdwr(mddev) &&
((!mddev->in_sync && !mddev_is_clustered(mddev)) ||
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 16/41] md/md-bitmap: make md_bitmap_print_sb() internal
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (14 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 15/41] md/md-bitmap: merge md_bitmap_flush() " Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 17/41] md/md-bitmap: merge md_bitmap_update_sb() into bitmap_operations Yu Kuai
` (25 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
md_bitmap_print_sb() is only used inside md-bitmap.c, hence make it
static, also rename it to bitmap_print_sb.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 5 ++---
drivers/md/md-bitmap.h | 1 -
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index d1b43bce5953..9d4bbcebb7b7 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -512,8 +512,7 @@ void md_bitmap_update_sb(struct bitmap *bitmap)
}
EXPORT_SYMBOL(md_bitmap_update_sb);
-/* print out the bitmap file superblock */
-void md_bitmap_print_sb(struct bitmap *bitmap)
+static void bitmap_print_sb(struct bitmap *bitmap)
{
bitmap_super_t *sb;
@@ -760,7 +759,7 @@ static int md_bitmap_read_sb(struct bitmap *bitmap)
bitmap->mddev->bitmap_info.space > sectors_reserved)
bitmap->mddev->bitmap_info.space = sectors_reserved;
} else {
- md_bitmap_print_sb(bitmap);
+ bitmap_print_sb(bitmap);
if (bitmap->cluster_slot < 0)
md_cluster_stop(bitmap->mddev);
}
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index 0212284c2b29..76bc90dccacc 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -257,7 +257,6 @@ void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are used only by md/bitmap */
-void md_bitmap_print_sb(struct bitmap *bitmap);
void md_bitmap_update_sb(struct bitmap *bitmap);
int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats);
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 17/41] md/md-bitmap: merge md_bitmap_update_sb() into bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (15 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 16/41] md/md-bitmap: make md_bitmap_print_sb() internal Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 18/41] md/md-bitmap: merge md_bitmap_status() " Yu Kuai
` (24 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
So that the implementation won't be exposed, and it'll be possible
to invent a new bitmap by replacing bitmap_operations.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 15 ++++++++-------
drivers/md/md-bitmap.h | 3 ++-
drivers/md/md-cluster.c | 2 +-
drivers/md/md.c | 4 ++--
4 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 9d4bbcebb7b7..9692acb8cb04 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -472,7 +472,7 @@ static void md_bitmap_wait_writes(struct bitmap *bitmap)
/* update the event counter and sync the superblock to disk */
-void md_bitmap_update_sb(struct bitmap *bitmap)
+static void bitmap_update_sb(struct bitmap *bitmap)
{
bitmap_super_t *sb;
@@ -510,7 +510,6 @@ void md_bitmap_update_sb(struct bitmap *bitmap)
write_sb_page(bitmap, bitmap->storage.sb_index,
bitmap->storage.sb_page, 1);
}
-EXPORT_SYMBOL(md_bitmap_update_sb);
static void bitmap_print_sb(struct bitmap *bitmap)
{
@@ -892,7 +891,7 @@ static void md_bitmap_file_unmap(struct bitmap_storage *store)
static void md_bitmap_file_kick(struct bitmap *bitmap)
{
if (!test_and_set_bit(BITMAP_STALE, &bitmap->flags)) {
- md_bitmap_update_sb(bitmap);
+ bitmap_update_sb(bitmap);
if (bitmap->storage.file) {
pr_warn("%s: kicking failed bitmap file %pD4 from array!\n",
@@ -1792,7 +1791,7 @@ static void bitmap_flush(struct mddev *mddev)
md_bitmap_daemon_work(mddev);
if (mddev->bitmap_info.external)
md_super_wait(mddev);
- md_bitmap_update_sb(bitmap);
+ bitmap_update_sb(bitmap);
}
/*
@@ -2022,7 +2021,7 @@ static int bitmap_load(struct mddev *mddev)
mddev_set_timeout(mddev, mddev->bitmap_info.daemon_sleep, true);
md_wakeup_thread(mddev->thread);
- md_bitmap_update_sb(bitmap);
+ bitmap_update_sb(bitmap);
if (test_bit(BITMAP_WRITE_ERROR, &bitmap->flags))
err = -EIO;
@@ -2083,7 +2082,7 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
}
if (clear_bits) {
- md_bitmap_update_sb(bitmap);
+ bitmap_update_sb(bitmap);
/* BITMAP_PAGE_PENDING is set, but bitmap_unplug needs
* BITMAP_PAGE_DIRTY or _NEEDWRITE to write ... */
for (i = 0; i < bitmap->storage.file_pages; i++)
@@ -2575,7 +2574,7 @@ backlog_store(struct mddev *mddev, const char *buf, size_t len)
mddev_create_serial_pool(mddev, rdev);
}
if (old_mwb != backlog)
- md_bitmap_update_sb(mddev->bitmap);
+ bitmap_update_sb(mddev->bitmap);
mddev_unlock_and_resume(mddev);
return len;
@@ -2719,6 +2718,8 @@ static struct bitmap_operations bitmap_ops = {
.load = bitmap_load,
.destroy = bitmap_destroy,
.flush = bitmap_flush,
+
+ .update_sb = bitmap_update_sb,
};
void mddev_set_bitmap_ops(struct mddev *mddev)
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index 76bc90dccacc..b2d4e71a478a 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -250,6 +250,8 @@ struct bitmap_operations {
int (*load)(struct mddev *mddev);
void (*destroy)(struct mddev *mddev);
void (*flush)(struct mddev *mddev);
+
+ void (*update_sb)(struct bitmap *bitmap);
};
/* the bitmap API */
@@ -257,7 +259,6 @@ void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are used only by md/bitmap */
-void md_bitmap_update_sb(struct bitmap *bitmap);
int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats);
int md_bitmap_setallbits(struct bitmap *bitmap);
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index 1938eadb379b..77111968e276 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -1253,7 +1253,7 @@ static int cluster_check_sync_size(struct mddev *mddev)
bm_lockres->flags |= DLM_LKF_NOQUEUE;
rv = dlm_lock_sync(bm_lockres, DLM_LOCK_PW);
if (!rv)
- md_bitmap_update_sb(bitmap);
+ mddev->bitmap_ops->update_sb(bitmap);
lockres_free(bm_lockres);
rv = md_bitmap_get_stats(bitmap, &stats);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 69d4b21c441e..ecfe957279e5 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2825,7 +2825,7 @@ void md_update_sb(struct mddev *mddev, int force_change)
mddev_add_trace_msg(mddev, "md md_update_sb");
rewrite:
- md_bitmap_update_sb(mddev->bitmap);
+ mddev->bitmap_ops->update_sb(mddev->bitmap);
rdev_for_each(rdev, mddev) {
if (rdev->sb_loaded != 1)
continue; /* no noise on spare devices */
@@ -9986,7 +9986,7 @@ static void check_sb_changes(struct mddev *mddev, struct md_rdev *rdev)
if (ret)
pr_info("md-cluster: resize failed\n");
else
- md_bitmap_update_sb(mddev->bitmap);
+ mddev->bitmap_ops->update_sb(mddev->bitmap);
}
/* Check for change of roles in the active devices */
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 18/41] md/md-bitmap: merge md_bitmap_status() into bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (16 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 17/41] md/md-bitmap: merge md_bitmap_update_sb() into bitmap_operations Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 19/41] md/md-bitmap: remove md_bitmap_setallbits() Yu Kuai
` (23 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
So that the implementation won't be exposed, and it'll be possible
to invent a new bitmap by replacing bitmap_operations.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 4 ++--
drivers/md/md-bitmap.h | 5 ++---
drivers/md/md-cluster.c | 8 ++++----
drivers/md/md.c | 6 +++---
drivers/md/raid1.c | 2 +-
5 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 9692acb8cb04..d4164f096d0c 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -2105,7 +2105,7 @@ void md_bitmap_set_pages(struct bitmap *bitmap, unsigned long pages)
}
EXPORT_SYMBOL_GPL(md_bitmap_set_pages);
-int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
+static int bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
{
bitmap_super_t *sb;
struct bitmap_counts *counts;
@@ -2128,7 +2128,6 @@ int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
stats->behind_wait = wq_has_sleeper(&bitmap->behind_wait);
return 0;
}
-EXPORT_SYMBOL_GPL(md_bitmap_get_stats);
int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
int chunksize, int init)
@@ -2720,6 +2719,7 @@ static struct bitmap_operations bitmap_ops = {
.flush = bitmap_flush,
.update_sb = bitmap_update_sb,
+ .get_stats = bitmap_get_stats,
};
void mddev_set_bitmap_ops(struct mddev *mddev)
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index b2d4e71a478a..5dc61df1aa40 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -252,6 +252,7 @@ struct bitmap_operations {
void (*flush)(struct mddev *mddev);
void (*update_sb)(struct bitmap *bitmap);
+ int (*get_stats)(struct bitmap *bitmap, struct md_bitmap_stats *stats);
};
/* the bitmap API */
@@ -259,8 +260,6 @@ void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are used only by md/bitmap */
-int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats);
-
int md_bitmap_setallbits(struct bitmap *bitmap);
void md_bitmap_write_all(struct bitmap *bitmap);
@@ -295,7 +294,7 @@ void md_bitmap_wait_behind_writes(struct mddev *mddev);
static inline u64 md_bitmap_events_cleared(struct mddev *mddev)
{
struct md_bitmap_stats stats;
- int err = md_bitmap_get_stats(mddev->bitmap, &stats);
+ int err = mddev->bitmap_ops->get_stats(mddev->bitmap, &stats);
if (err)
return 0;
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index 77111968e276..31108832dd9b 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -1150,7 +1150,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
char str[64];
int i, rv;
- rv = md_bitmap_get_stats(bitmap, &stats);
+ rv = mddev->bitmap_ops->get_stats(bitmap, &stats);
if (rv)
return rv;
@@ -1174,7 +1174,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
goto out;
}
- rv = md_bitmap_get_stats(bitmap, &stats);
+ rv = mddev->bitmap_ops->get_stats(bitmap, &stats);
if (rv)
goto out;
/*
@@ -1223,7 +1223,7 @@ static int cluster_check_sync_size(struct mddev *mddev)
struct dlm_lock_resource *bm_lockres;
struct md_bitmap_stats stats;
- rv = md_bitmap_get_stats(bitmap, &stats);
+ rv = mddev->bitmap_ops->get_stats(bitmap, &stats);
if (rv)
return rv;
@@ -1256,7 +1256,7 @@ static int cluster_check_sync_size(struct mddev *mddev)
mddev->bitmap_ops->update_sb(bitmap);
lockres_free(bm_lockres);
- rv = md_bitmap_get_stats(bitmap, &stats);
+ rv = mddev->bitmap_ops->get_stats(bitmap, &stats);
if (rv) {
md_bitmap_free(bitmap);
return rv;
diff --git a/drivers/md/md.c b/drivers/md/md.c
index ecfe957279e5..29dd6bc86f3f 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2345,7 +2345,7 @@ super_1_allow_new_offset(struct md_rdev *rdev,
if (rdev->sb_start + (32+4)*2 > new_offset)
return 0;
- err = md_bitmap_get_stats(bitmap, &stats);
+ err = rdev->mddev->bitmap_ops->get_stats(bitmap, &stats);
if (!err && !rdev->mddev->bitmap_info.file &&
rdev->sb_start + rdev->mddev->bitmap_info.offset +
stats.file_pages * (PAGE_SIZE>>9) > new_offset)
@@ -7575,7 +7575,7 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
} else {
struct md_bitmap_stats stats;
- rv = md_bitmap_get_stats(mddev->bitmap, &stats);
+ rv = mddev->bitmap_ops->get_stats(mddev->bitmap, &stats);
if (rv)
goto err;
@@ -8372,7 +8372,7 @@ static void md_bitmap_status(struct seq_file *seq, struct mddev *mddev)
{
struct md_bitmap_stats stats;
unsigned long chunk_kb;
- int err = md_bitmap_get_stats(mddev->bitmap, &stats);
+ int err = mddev->bitmap_ops->get_stats(mddev->bitmap, &stats);
if (err)
return;
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index bfd2d63d1c59..5e1a487bd4de 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1604,7 +1604,7 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
if (first_clone) {
struct md_bitmap_stats stats;
- int err = md_bitmap_get_stats(bitmap, &stats);
+ int err = mddev->bitmap_ops->get_stats(bitmap, &stats);
/* do behind I/O ?
* Not if there are too many, or cannot
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 19/41] md/md-bitmap: remove md_bitmap_setallbits()
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (17 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 18/41] md/md-bitmap: merge md_bitmap_status() " Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 20/41] md/md-bitmap: merge bitmap_write_all() into bitmap_operations Yu Kuai
` (22 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
md_bitmap_setallbits() is not used, hence can be removed.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index 5dc61df1aa40..b97c5df32848 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -260,7 +260,6 @@ void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are used only by md/bitmap */
-int md_bitmap_setallbits(struct bitmap *bitmap);
void md_bitmap_write_all(struct bitmap *bitmap);
void md_bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e);
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 20/41] md/md-bitmap: merge bitmap_write_all() into bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (18 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 19/41] md/md-bitmap: remove md_bitmap_setallbits() Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 21/41] md/md-bitmap: merge md_bitmap_dirty_bits() " Yu Kuai
` (21 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
So that the implementation won't be exposed, and it'll be possible
to invent a new bitmap by replacing bitmap_operations.
Also change the parameter from bitmap to mddev, to avoid access
bitmap outside md-bitmap.c as much as possible.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 14 +++++++-------
drivers/md/md-bitmap.h | 3 +--
drivers/md/md.c | 2 +-
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index d4164f096d0c..3b52fa59a36d 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1224,22 +1224,21 @@ static int md_bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
return ret;
}
-void md_bitmap_write_all(struct bitmap *bitmap)
+/* just flag bitmap pages as needing to be written. */
+static void bitmap_write_all(struct mddev *mddev)
{
- /* We don't actually write all bitmap blocks here,
- * just flag them as needing to be written
- */
int i;
+ struct bitmap *bitmap = mddev->bitmap;
if (!bitmap || !bitmap->storage.filemap)
return;
+
+ /* Only one copy, so nothing needed */
if (bitmap->storage.file)
- /* Only one copy, so nothing needed */
return;
for (i = 0; i < bitmap->storage.file_pages; i++)
- set_page_attr(bitmap, i,
- BITMAP_PAGE_NEEDWRITE);
+ set_page_attr(bitmap, i, BITMAP_PAGE_NEEDWRITE);
bitmap->allclean = 0;
}
@@ -2717,6 +2716,7 @@ static struct bitmap_operations bitmap_ops = {
.load = bitmap_load,
.destroy = bitmap_destroy,
.flush = bitmap_flush,
+ .write_all = bitmap_write_all,
.update_sb = bitmap_update_sb,
.get_stats = bitmap_get_stats,
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index b97c5df32848..70ca226036e1 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -250,6 +250,7 @@ struct bitmap_operations {
int (*load)(struct mddev *mddev);
void (*destroy)(struct mddev *mddev);
void (*flush)(struct mddev *mddev);
+ void (*write_all)(struct mddev *mddev);
void (*update_sb)(struct bitmap *bitmap);
int (*get_stats)(struct bitmap *bitmap, struct md_bitmap_stats *stats);
@@ -260,8 +261,6 @@ void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are used only by md/bitmap */
-void md_bitmap_write_all(struct bitmap *bitmap);
-
void md_bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e);
/* these are exported */
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 29dd6bc86f3f..bddc0ceb169a 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -9527,7 +9527,7 @@ static void md_start_sync(struct work_struct *ws)
* stored on all devices. So make sure all bitmap pages get written.
*/
if (spares)
- md_bitmap_write_all(mddev->bitmap);
+ mddev->bitmap_ops->write_all(mddev);
name = test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) ?
"reshape" : "resync";
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 21/41] md/md-bitmap: merge md_bitmap_dirty_bits() into bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (19 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 20/41] md/md-bitmap: merge bitmap_write_all() into bitmap_operations Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 22/41] md/md-bitmap: merge md_bitmap_startwrite() " Yu Kuai
` (20 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
So that the implementation won't be exposed, and it'll be possible
to invent a new bitmap by replacing bitmap_operations.
Also change the parameter from bitmap to mddev, to avoid access
bitmap outside md-bitmap.c as much as possible.
And while we're here, also fix coding style for bitmap_store().
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 9 ++++++++-
drivers/md/md-bitmap.h | 6 ++----
drivers/md/md.c | 14 ++++++++++----
3 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 3b52fa59a36d..01f2370b991c 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1753,12 +1753,18 @@ static void md_bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, in
}
/* dirty the memory and file bits for bitmap chunks "s" to "e" */
-void md_bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e)
+static void bitmap_dirty_bits(struct mddev *mddev, unsigned long s,
+ unsigned long e)
{
unsigned long chunk;
+ struct bitmap *bitmap = mddev->bitmap;
+
+ if (!bitmap)
+ return;
for (chunk = s; chunk <= e; chunk++) {
sector_t sec = (sector_t)chunk << bitmap->counts.chunkshift;
+
md_bitmap_set_memory_bits(bitmap, sec, 1);
md_bitmap_file_set_bit(bitmap, sec);
if (sec < bitmap->mddev->recovery_cp)
@@ -2717,6 +2723,7 @@ static struct bitmap_operations bitmap_ops = {
.destroy = bitmap_destroy,
.flush = bitmap_flush,
.write_all = bitmap_write_all,
+ .dirty_bits = bitmap_dirty_bits,
.update_sb = bitmap_update_sb,
.get_stats = bitmap_get_stats,
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index 70ca226036e1..fded46433bcb 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -251,6 +251,8 @@ struct bitmap_operations {
void (*destroy)(struct mddev *mddev);
void (*flush)(struct mddev *mddev);
void (*write_all)(struct mddev *mddev);
+ void (*dirty_bits)(struct mddev *mddev, unsigned long s,
+ unsigned long e);
void (*update_sb)(struct bitmap *bitmap);
int (*get_stats)(struct bitmap *bitmap, struct md_bitmap_stats *stats);
@@ -259,10 +261,6 @@ struct bitmap_operations {
/* the bitmap API */
void mddev_set_bitmap_ops(struct mddev *mddev);
-/* these are used only by md/bitmap */
-
-void md_bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e);
-
/* these are exported */
int md_bitmap_startwrite(struct bitmap *bitmap, sector_t offset,
unsigned long sectors, int behind);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index bddc0ceb169a..1e1d3db56bb9 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -4685,14 +4685,20 @@ bitmap_store(struct mddev *mddev, const char *buf, size_t len)
/* buf should be <chunk> <chunk> ... or <chunk>-<chunk> ... (range) */
while (*buf) {
chunk = end_chunk = simple_strtoul(buf, &end, 0);
- if (buf == end) break;
+ if (buf == end)
+ break;
+
if (*end == '-') { /* range */
buf = end + 1;
end_chunk = simple_strtoul(buf, &end, 0);
- if (buf == end) break;
+ if (buf == end)
+ break;
}
- if (*end && !isspace(*end)) break;
- md_bitmap_dirty_bits(mddev->bitmap, chunk, end_chunk);
+
+ if (*end && !isspace(*end))
+ break;
+
+ mddev->bitmap_ops->dirty_bits(mddev, chunk, end_chunk);
buf = skip_spaces(end);
}
md_bitmap_unplug(mddev->bitmap); /* flush the bits to disk */
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 22/41] md/md-bitmap: merge md_bitmap_startwrite() into bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (20 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 21/41] md/md-bitmap: merge md_bitmap_dirty_bits() " Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 23/41] md/md-bitmap: merge md_bitmap_endwrite() " Yu Kuai
` (19 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
So that the implementation won't be exposed, and it'll be possible
to invent a new bitmap by replacing bitmap_operations.
Also change the parameter from bitmap to mddev, to avoid access
bitmap outside md-bitmap.c as much as possible. And change the type
of 'behind' from int to bool.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 8 ++++++--
drivers/md/md-bitmap.h | 5 +++--
drivers/md/raid1.c | 5 +++--
drivers/md/raid10.c | 3 ++-
drivers/md/raid5.c | 13 +++++--------
5 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 01f2370b991c..1387d5bbf8a1 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1458,8 +1458,11 @@ __acquires(bitmap->lock)
&(bitmap->bp[page].map[pageoff]);
}
-int md_bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors, int behind)
+static int bitmap_startwrite(struct mddev *mddev, sector_t offset,
+ unsigned long sectors, bool behind)
{
+ struct bitmap *bitmap = mddev->bitmap;
+
if (!bitmap)
return 0;
@@ -1520,7 +1523,6 @@ int md_bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long s
}
return 0;
}
-EXPORT_SYMBOL(md_bitmap_startwrite);
void md_bitmap_endwrite(struct bitmap *bitmap, sector_t offset,
unsigned long sectors, int success, int behind)
@@ -2725,6 +2727,8 @@ static struct bitmap_operations bitmap_ops = {
.write_all = bitmap_write_all,
.dirty_bits = bitmap_dirty_bits,
+ .startwrite = bitmap_startwrite,
+
.update_sb = bitmap_update_sb,
.get_stats = bitmap_get_stats,
};
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index fded46433bcb..cc76b4a69a31 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -254,6 +254,9 @@ struct bitmap_operations {
void (*dirty_bits)(struct mddev *mddev, unsigned long s,
unsigned long e);
+ int (*startwrite)(struct mddev *mddev, sector_t offset,
+ unsigned long sectors, bool behind);
+
void (*update_sb)(struct bitmap *bitmap);
int (*get_stats)(struct bitmap *bitmap, struct md_bitmap_stats *stats);
};
@@ -262,8 +265,6 @@ struct bitmap_operations {
void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are exported */
-int md_bitmap_startwrite(struct bitmap *bitmap, sector_t offset,
- unsigned long sectors, int behind);
void md_bitmap_endwrite(struct bitmap *bitmap, sector_t offset,
unsigned long sectors, int success, int behind);
int md_bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int degraded);
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 5e1a487bd4de..e07b3a0427cb 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1616,8 +1616,9 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
!stats.behind_wait)
alloc_behind_master_bio(r1_bio, bio);
- md_bitmap_startwrite(bitmap, r1_bio->sector, r1_bio->sectors,
- test_bit(R1BIO_BehindIO, &r1_bio->state));
+ mddev->bitmap_ops->startwrite(mddev, r1_bio->sector,
+ r1_bio->sectors,
+ test_bit(R1BIO_BehindIO, &r1_bio->state));
first_clone = 0;
}
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 2a9c4ee982e0..96de2d68c913 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1492,7 +1492,8 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio,
md_account_bio(mddev, &bio);
r10_bio->master_bio = bio;
atomic_set(&r10_bio->remaining, 1);
- md_bitmap_startwrite(mddev->bitmap, r10_bio->sector, r10_bio->sectors, 0);
+ mddev->bitmap_ops->startwrite(mddev, r10_bio->sector, r10_bio->sectors,
+ false);
for (i = 0; i < conf->copies; i++) {
if (r10_bio->devs[i].bio)
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index c14cf2410365..c24036d1e6da 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3563,8 +3563,8 @@ static void __add_stripe_bio(struct stripe_head *sh, struct bio *bi,
*/
set_bit(STRIPE_BITMAP_PENDING, &sh->state);
spin_unlock_irq(&sh->stripe_lock);
- md_bitmap_startwrite(conf->mddev->bitmap, sh->sector,
- RAID5_STRIPE_SECTORS(conf), 0);
+ conf->mddev->bitmap_ops->startwrite(conf->mddev, sh->sector,
+ RAID5_STRIPE_SECTORS(conf), false);
spin_lock_irq(&sh->stripe_lock);
clear_bit(STRIPE_BITMAP_PENDING, &sh->state);
if (!sh->batch_head) {
@@ -5788,13 +5788,10 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi)
}
spin_unlock_irq(&sh->stripe_lock);
if (conf->mddev->bitmap) {
- for (d = 0;
- d < conf->raid_disks - conf->max_degraded;
+ for (d = 0; d < conf->raid_disks - conf->max_degraded;
d++)
- md_bitmap_startwrite(mddev->bitmap,
- sh->sector,
- RAID5_STRIPE_SECTORS(conf),
- 0);
+ mddev->bitmap_ops->startwrite(mddev, sh->sector,
+ RAID5_STRIPE_SECTORS(conf), false);
sh->bm_seq = conf->seq_flush + 1;
set_bit(STRIPE_BIT_DELAY, &sh->state);
}
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 23/41] md/md-bitmap: merge md_bitmap_endwrite() into bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (21 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 22/41] md/md-bitmap: merge md_bitmap_startwrite() " Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 24/41] md/md-bitmap: merge md_bitmap_start_sync() " Yu Kuai
` (18 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
So that the implementation won't be exposed, and it'll be possible
to invent a new bitmap by replacing bitmap_operations.
Also change the parameter from bitmap to mddev, to avoid access
bitmap outside md-bitmap.c as much as possible. And change the type
of 'success' and behind' from int to bool.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 9 ++++++---
drivers/md/md-bitmap.h | 4 ++--
drivers/md/raid1.c | 12 +++++++-----
drivers/md/raid10.c | 11 ++++++-----
drivers/md/raid5-cache.c | 8 ++++----
drivers/md/raid5.c | 18 ++++++++++--------
6 files changed, 35 insertions(+), 27 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 1387d5bbf8a1..8da6e889d5f1 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1524,11 +1524,14 @@ static int bitmap_startwrite(struct mddev *mddev, sector_t offset,
return 0;
}
-void md_bitmap_endwrite(struct bitmap *bitmap, sector_t offset,
- unsigned long sectors, int success, int behind)
+static void bitmap_endwrite(struct mddev *mddev, sector_t offset,
+ unsigned long sectors, bool success, bool behind)
{
+ struct bitmap *bitmap = mddev->bitmap;
+
if (!bitmap)
return;
+
if (behind) {
if (atomic_dec_and_test(&bitmap->behind_writes))
wake_up(&bitmap->behind_wait);
@@ -1575,7 +1578,6 @@ void md_bitmap_endwrite(struct bitmap *bitmap, sector_t offset,
sectors = 0;
}
}
-EXPORT_SYMBOL(md_bitmap_endwrite);
static int __bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks,
int degraded)
@@ -2728,6 +2730,7 @@ static struct bitmap_operations bitmap_ops = {
.dirty_bits = bitmap_dirty_bits,
.startwrite = bitmap_startwrite,
+ .endwrite = bitmap_endwrite,
.update_sb = bitmap_update_sb,
.get_stats = bitmap_get_stats,
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index cc76b4a69a31..223dc5d6f4e4 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -256,6 +256,8 @@ struct bitmap_operations {
int (*startwrite)(struct mddev *mddev, sector_t offset,
unsigned long sectors, bool behind);
+ void (*endwrite)(struct mddev *mddev, sector_t offset,
+ unsigned long sectors, bool success, bool behind);
void (*update_sb)(struct bitmap *bitmap);
int (*get_stats)(struct bitmap *bitmap, struct md_bitmap_stats *stats);
@@ -265,8 +267,6 @@ struct bitmap_operations {
void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are exported */
-void md_bitmap_endwrite(struct bitmap *bitmap, sector_t offset,
- unsigned long sectors, int success, int behind);
int md_bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int degraded);
void md_bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int aborted);
void md_bitmap_close_sync(struct bitmap *bitmap);
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index e07b3a0427cb..aeee09965817 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -411,18 +411,20 @@ static void raid1_end_read_request(struct bio *bio)
static void close_write(struct r1bio *r1_bio)
{
+ struct mddev *mddev = r1_bio->mddev;
+
/* it really is the end of this request */
if (test_bit(R1BIO_BehindIO, &r1_bio->state)) {
bio_free_pages(r1_bio->behind_master_bio);
bio_put(r1_bio->behind_master_bio);
r1_bio->behind_master_bio = NULL;
}
+
/* clear the bitmap if all writes complete successfully */
- md_bitmap_endwrite(r1_bio->mddev->bitmap, r1_bio->sector,
- r1_bio->sectors,
- !test_bit(R1BIO_Degraded, &r1_bio->state),
- test_bit(R1BIO_BehindIO, &r1_bio->state));
- md_write_end(r1_bio->mddev);
+ mddev->bitmap_ops->endwrite(mddev, r1_bio->sector, r1_bio->sectors,
+ !test_bit(R1BIO_Degraded, &r1_bio->state),
+ test_bit(R1BIO_BehindIO, &r1_bio->state));
+ md_write_end(mddev);
}
static void r1_bio_write_done(struct r1bio *r1_bio)
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 96de2d68c913..52f29b907ab6 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -426,12 +426,13 @@ static void raid10_end_read_request(struct bio *bio)
static void close_write(struct r10bio *r10_bio)
{
+ struct mddev *mddev = r10_bio->mddev;
+
/* clear the bitmap if all writes complete successfully */
- md_bitmap_endwrite(r10_bio->mddev->bitmap, r10_bio->sector,
- r10_bio->sectors,
- !test_bit(R10BIO_Degraded, &r10_bio->state),
- 0);
- md_write_end(r10_bio->mddev);
+ mddev->bitmap_ops->endwrite(mddev, r10_bio->sector, r10_bio->sectors,
+ !test_bit(R10BIO_Degraded, &r10_bio->state),
+ false);
+ md_write_end(mddev);
}
static void one_write_done(struct r10bio *r10_bio)
diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c
index 874874fe4fa1..23f2cbcf1a6c 100644
--- a/drivers/md/raid5-cache.c
+++ b/drivers/md/raid5-cache.c
@@ -313,10 +313,10 @@ void r5c_handle_cached_data_endio(struct r5conf *conf,
if (sh->dev[i].written) {
set_bit(R5_UPTODATE, &sh->dev[i].flags);
r5c_return_dev_pending_writes(conf, &sh->dev[i]);
- md_bitmap_endwrite(conf->mddev->bitmap, sh->sector,
- RAID5_STRIPE_SECTORS(conf),
- !test_bit(STRIPE_DEGRADED, &sh->state),
- 0);
+ conf->mddev->bitmap_ops->endwrite(conf->mddev,
+ sh->sector, RAID5_STRIPE_SECTORS(conf),
+ !test_bit(STRIPE_DEGRADED, &sh->state),
+ false);
}
}
}
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index c24036d1e6da..93d582b9f922 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3663,8 +3663,9 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
bi = nextbi;
}
if (bitmap_end)
- md_bitmap_endwrite(conf->mddev->bitmap, sh->sector,
- RAID5_STRIPE_SECTORS(conf), 0, 0);
+ conf->mddev->bitmap_ops->endwrite(conf->mddev,
+ sh->sector, RAID5_STRIPE_SECTORS(conf),
+ false, false);
bitmap_end = 0;
/* and fail all 'written' */
bi = sh->dev[i].written;
@@ -3709,8 +3710,9 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
}
}
if (bitmap_end)
- md_bitmap_endwrite(conf->mddev->bitmap, sh->sector,
- RAID5_STRIPE_SECTORS(conf), 0, 0);
+ conf->mddev->bitmap_ops->endwrite(conf->mddev,
+ sh->sector, RAID5_STRIPE_SECTORS(conf),
+ false, false);
/* If we were in the middle of a write the parity block might
* still be locked - so just clear all R5_LOCKED flags
*/
@@ -4059,10 +4061,10 @@ static void handle_stripe_clean_event(struct r5conf *conf,
bio_endio(wbi);
wbi = wbi2;
}
- md_bitmap_endwrite(conf->mddev->bitmap, sh->sector,
- RAID5_STRIPE_SECTORS(conf),
- !test_bit(STRIPE_DEGRADED, &sh->state),
- 0);
+ conf->mddev->bitmap_ops->endwrite(conf->mddev,
+ sh->sector, RAID5_STRIPE_SECTORS(conf),
+ !test_bit(STRIPE_DEGRADED, &sh->state),
+ false);
if (head_sh->batch_head) {
sh = list_first_entry(&sh->batch_list,
struct stripe_head,
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 24/41] md/md-bitmap: merge md_bitmap_start_sync() into bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (22 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 23/41] md/md-bitmap: merge md_bitmap_endwrite() " Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 25/41] md/md-bitmap: remove the parameter 'aborted' for md_bitmap_end_sync() Yu Kuai
` (17 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
So that the implementation won't be exposed, and it'll be possible
to invent a new bitmap by replacing bitmap_operations.
Also change the parameter from bitmap to mddev, to avoid access
bitmap outside md-bitmap.c as much as possible.
Also fix lots of code style.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 36 ++++++++++++++++++++----------------
drivers/md/md-bitmap.h | 3 ++-
drivers/md/raid1.c | 10 +++++-----
drivers/md/raid10.c | 22 ++++++++++++----------
drivers/md/raid5.c | 10 ++++++----
5 files changed, 45 insertions(+), 36 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 8da6e889d5f1..e42a0433e926 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1579,24 +1579,26 @@ static void bitmap_endwrite(struct mddev *mddev, sector_t offset,
}
}
-static int __bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks,
- int degraded)
+static bool __bitmap_start_sync(struct bitmap *bitmap, sector_t offset,
+ sector_t *blocks, bool degraded)
{
bitmap_counter_t *bmc;
- int rv;
+ bool rv;
+
if (bitmap == NULL) {/* FIXME or bitmap set as 'failed' */
*blocks = 1024;
- return 1; /* always resync if no bitmap */
+ return true; /* always resync if no bitmap */
}
spin_lock_irq(&bitmap->counts.lock);
+
+ rv = false;
bmc = md_bitmap_get_counter(&bitmap->counts, offset, blocks, 0);
- rv = 0;
if (bmc) {
/* locked */
- if (RESYNC(*bmc))
- rv = 1;
- else if (NEEDED(*bmc)) {
- rv = 1;
+ if (RESYNC(*bmc)) {
+ rv = true;
+ } else if (NEEDED(*bmc)) {
+ rv = true;
if (!degraded) { /* don't set/clear bits if degraded */
*bmc |= RESYNC_MASK;
*bmc &= ~NEEDED_MASK;
@@ -1604,11 +1606,12 @@ static int __bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t
}
}
spin_unlock_irq(&bitmap->counts.lock);
+
return rv;
}
-int md_bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks,
- int degraded)
+static bool bitmap_start_sync(struct mddev *mddev, sector_t offset,
+ sector_t *blocks, bool degraded)
{
/* bitmap_start_sync must always report on multiples of whole
* pages, otherwise resync (which is very PAGE_SIZE based) will
@@ -1617,19 +1620,19 @@ int md_bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t *block
* At least PAGE_SIZE>>9 blocks are covered.
* Return the 'or' of the result.
*/
- int rv = 0;
+ bool rv = false;
sector_t blocks1;
*blocks = 0;
while (*blocks < (PAGE_SIZE>>9)) {
- rv |= __bitmap_start_sync(bitmap, offset,
+ rv |= __bitmap_start_sync(mddev->bitmap, offset,
&blocks1, degraded);
offset += blocks1;
*blocks += blocks1;
}
+
return rv;
}
-EXPORT_SYMBOL(md_bitmap_start_sync);
void md_bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int aborted)
{
@@ -1723,7 +1726,7 @@ void md_bitmap_sync_with_cluster(struct mddev *mddev,
WARN((blocks > new_lo) && old_lo, "alignment is not correct for lo\n");
for (sector = old_hi; sector < new_hi; ) {
- md_bitmap_start_sync(bitmap, sector, &blocks, 0);
+ bitmap_start_sync(mddev, sector, &blocks, false);
sector += blocks;
}
WARN((blocks > new_hi) && old_hi, "alignment is not correct for hi\n");
@@ -2005,7 +2008,7 @@ static int bitmap_load(struct mddev *mddev)
*/
while (sector < mddev->resync_max_sectors) {
sector_t blocks;
- md_bitmap_start_sync(bitmap, sector, &blocks, 0);
+ bitmap_start_sync(mddev, sector, &blocks, false);
sector += blocks;
}
md_bitmap_close_sync(bitmap);
@@ -2731,6 +2734,7 @@ static struct bitmap_operations bitmap_ops = {
.startwrite = bitmap_startwrite,
.endwrite = bitmap_endwrite,
+ .start_sync = bitmap_start_sync,
.update_sb = bitmap_update_sb,
.get_stats = bitmap_get_stats,
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index 223dc5d6f4e4..6fba3ff2f949 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -258,6 +258,8 @@ struct bitmap_operations {
unsigned long sectors, bool behind);
void (*endwrite)(struct mddev *mddev, sector_t offset,
unsigned long sectors, bool success, bool behind);
+ bool (*start_sync)(struct mddev *mddev, sector_t offset,
+ sector_t *blocks, bool degraded);
void (*update_sb)(struct bitmap *bitmap);
int (*get_stats)(struct bitmap *bitmap, struct md_bitmap_stats *stats);
@@ -267,7 +269,6 @@ struct bitmap_operations {
void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are exported */
-int md_bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int degraded);
void md_bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int aborted);
void md_bitmap_close_sync(struct bitmap *bitmap);
void md_bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, bool force);
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index aeee09965817..555b56d15d92 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2767,7 +2767,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
int wonly = -1;
int write_targets = 0, read_targets = 0;
sector_t sync_blocks;
- int still_degraded = 0;
+ bool still_degraded = false;
int good_sectors = RESYNC_SECTORS;
int min_bad = 0; /* number of sectors that are bad in all devices */
int idx = sector_to_idx(sector_nr);
@@ -2809,7 +2809,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
/* before building a request, check if we can skip these blocks..
* This call the bitmap_start_sync doesn't actually record anything
*/
- if (!md_bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 1) &&
+ if (!mddev->bitmap_ops->start_sync(mddev, sector_nr, &sync_blocks, true) &&
!conf->fullsync && !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) {
/* We can skip this block, and probably several more */
*skipped = 1;
@@ -2860,7 +2860,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
if (rdev == NULL ||
test_bit(Faulty, &rdev->flags)) {
if (i < conf->raid_disks)
- still_degraded = 1;
+ still_degraded = true;
} else if (!test_bit(In_sync, &rdev->flags)) {
bio->bi_opf = REQ_OP_WRITE;
bio->bi_end_io = end_sync_write;
@@ -2984,8 +2984,8 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
if (len == 0)
break;
if (sync_blocks == 0) {
- if (!md_bitmap_start_sync(mddev->bitmap, sector_nr,
- &sync_blocks, still_degraded) &&
+ if (!mddev->bitmap_ops->start_sync(mddev, sector_nr,
+ &sync_blocks, still_degraded) &&
!conf->fullsync &&
!test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery))
break;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 52f29b907ab6..2ab641166c8c 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -3289,10 +3289,10 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
r10_bio = NULL;
for (i = 0 ; i < conf->geo.raid_disks; i++) {
- int still_degraded;
+ bool still_degraded;
struct r10bio *rb2;
sector_t sect;
- int must_sync;
+ bool must_sync;
int any_working;
struct raid10_info *mirror = &conf->mirrors[i];
struct md_rdev *mrdev, *mreplace;
@@ -3309,7 +3309,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
if (!mrdev && !mreplace)
continue;
- still_degraded = 0;
+ still_degraded = false;
/* want to reconstruct this device */
rb2 = r10_bio;
sect = raid10_find_virt(conf, sector_nr, i);
@@ -3322,8 +3322,9 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
* we only need to recover the block if it is set in
* the bitmap
*/
- must_sync = md_bitmap_start_sync(mddev->bitmap, sect,
- &sync_blocks, 1);
+ must_sync = mddev->bitmap_ops->start_sync(mddev, sect,
+ &sync_blocks,
+ true);
if (sync_blocks < max_sync)
max_sync = sync_blocks;
if (!must_sync &&
@@ -3361,13 +3362,13 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
struct md_rdev *rdev = conf->mirrors[j].rdev;
if (rdev == NULL || test_bit(Faulty, &rdev->flags)) {
- still_degraded = 1;
+ still_degraded = false;
break;
}
}
- must_sync = md_bitmap_start_sync(mddev->bitmap, sect,
- &sync_blocks, still_degraded);
+ must_sync = mddev->bitmap_ops->start_sync(mddev, sect,
+ &sync_blocks, still_degraded);
any_working = 0;
for (j=0; j<conf->copies;j++) {
@@ -3544,8 +3545,9 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
mddev_is_clustered(mddev) &&
(sector_nr + 2 * RESYNC_SECTORS > conf->cluster_sync_high));
- if (!md_bitmap_start_sync(mddev->bitmap, sector_nr,
- &sync_blocks, mddev->degraded) &&
+ if (!mddev->bitmap_ops->start_sync(mddev, sector_nr,
+ &sync_blocks,
+ mddev->degraded) &&
!conf->fullsync && !test_bit(MD_RECOVERY_REQUESTED,
&mddev->recovery)) {
/* We can skip this block */
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 93d582b9f922..313904dd6555 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -6485,7 +6485,7 @@ static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_n
struct r5conf *conf = mddev->private;
struct stripe_head *sh;
sector_t sync_blocks;
- int still_degraded = 0;
+ bool still_degraded = false;
int i;
if (sector_nr >= max_sector) {
@@ -6530,7 +6530,8 @@ static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_n
}
if (!test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery) &&
!conf->fullsync &&
- !md_bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 1) &&
+ !mddev->bitmap_ops->start_sync(mddev, sector_nr, &sync_blocks,
+ true) &&
sync_blocks >= RAID5_STRIPE_SECTORS(conf)) {
/* we can skip this block, and probably more */
do_div(sync_blocks, RAID5_STRIPE_SECTORS(conf));
@@ -6558,10 +6559,11 @@ static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_n
struct md_rdev *rdev = conf->disks[i].rdev;
if (rdev == NULL || test_bit(Faulty, &rdev->flags))
- still_degraded = 1;
+ still_degraded = true;
}
- md_bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, still_degraded);
+ mddev->bitmap_ops->start_sync(mddev, sector_nr, &sync_blocks,
+ still_degraded);
set_bit(STRIPE_SYNC_REQUESTED, &sh->state);
set_bit(STRIPE_HANDLE, &sh->state);
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 25/41] md/md-bitmap: remove the parameter 'aborted' for md_bitmap_end_sync()
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (23 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 24/41] md/md-bitmap: merge md_bitmap_start_sync() " Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 26/41] md/md-bitmap: merge md_bitmap_end_sync() into bitmap_operations Yu Kuai
` (16 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
For internal callers, aborted are always set to false, while for
external callers, aborted are always set to true.
Hence there is no need to always pass in true for exported api.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 15 +++++++++++----
drivers/md/md-bitmap.h | 3 ++-
drivers/md/raid1.c | 4 ++--
drivers/md/raid10.c | 4 ++--
drivers/md/raid5.c | 2 +-
5 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index e42a0433e926..c18ce8e4ea72 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1634,7 +1634,8 @@ static bool bitmap_start_sync(struct mddev *mddev, sector_t offset,
return rv;
}
-void md_bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int aborted)
+static void __bitmap_end_sync(struct bitmap *bitmap, sector_t offset,
+ sector_t *blocks, bool aborted)
{
bitmap_counter_t *bmc;
unsigned long flags;
@@ -1663,6 +1664,12 @@ void md_bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks
unlock:
spin_unlock_irqrestore(&bitmap->counts.lock, flags);
}
+
+void md_bitmap_end_sync(struct bitmap *bitmap, sector_t offset,
+ sector_t *blocks)
+{
+ __bitmap_end_sync(bitmap, offset, blocks, true);
+}
EXPORT_SYMBOL(md_bitmap_end_sync);
void md_bitmap_close_sync(struct bitmap *bitmap)
@@ -1676,7 +1683,7 @@ void md_bitmap_close_sync(struct bitmap *bitmap)
if (!bitmap)
return;
while (sector < bitmap->mddev->resync_max_sectors) {
- md_bitmap_end_sync(bitmap, sector, &blocks, 0);
+ __bitmap_end_sync(bitmap, sector, &blocks, false);
sector += blocks;
}
}
@@ -1704,7 +1711,7 @@ void md_bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, bool force)
sector &= ~((1ULL << bitmap->counts.chunkshift) - 1);
s = 0;
while (s < sector && s < bitmap->mddev->resync_max_sectors) {
- md_bitmap_end_sync(bitmap, s, &blocks, 0);
+ __bitmap_end_sync(bitmap, s, &blocks, false);
s += blocks;
}
bitmap->last_end_sync = jiffies;
@@ -1720,7 +1727,7 @@ void md_bitmap_sync_with_cluster(struct mddev *mddev,
sector_t sector, blocks = 0;
for (sector = old_lo; sector < new_lo; ) {
- md_bitmap_end_sync(bitmap, sector, &blocks, 0);
+ __bitmap_end_sync(bitmap, sector, &blocks, false);
sector += blocks;
}
WARN((blocks > new_lo) && old_lo, "alignment is not correct for lo\n");
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index 6fba3ff2f949..68324757da5a 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -269,7 +269,8 @@ struct bitmap_operations {
void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are exported */
-void md_bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, int aborted);
+void md_bitmap_end_sync(struct bitmap *bitmap, sector_t offset,
+ sector_t *blocks);
void md_bitmap_close_sync(struct bitmap *bitmap);
void md_bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, bool force);
void md_bitmap_sync_with_cluster(struct mddev *mddev,
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 555b56d15d92..1be06a476acf 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2038,7 +2038,7 @@ static void abort_sync_write(struct mddev *mddev, struct r1bio *r1_bio)
/* make sure these bits don't get cleared. */
do {
- md_bitmap_end_sync(mddev->bitmap, s, &sync_blocks, 1);
+ md_bitmap_end_sync(mddev->bitmap, s, &sync_blocks);
s += sync_blocks;
sectors_to_go -= sync_blocks;
} while (sectors_to_go > 0);
@@ -2785,7 +2785,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
*/
if (mddev->curr_resync < max_sector) /* aborted */
md_bitmap_end_sync(mddev->bitmap, mddev->curr_resync,
- &sync_blocks, 1);
+ &sync_blocks);
else /* completed sync */
conf->fullsync = 0;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 2ab641166c8c..821219dc973e 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -3195,12 +3195,12 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
if (mddev->curr_resync < max_sector) { /* aborted */
if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery))
md_bitmap_end_sync(mddev->bitmap, mddev->curr_resync,
- &sync_blocks, 1);
+ &sync_blocks);
else for (i = 0; i < conf->geo.raid_disks; i++) {
sector_t sect =
raid10_find_virt(conf, mddev->curr_resync, i);
md_bitmap_end_sync(mddev->bitmap, sect,
- &sync_blocks, 1);
+ &sync_blocks);
}
} else {
/* completed sync */
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 313904dd6555..3e9fed1e1153 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -6498,7 +6498,7 @@ static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_n
if (mddev->curr_resync < max_sector) /* aborted */
md_bitmap_end_sync(mddev->bitmap, mddev->curr_resync,
- &sync_blocks, 1);
+ &sync_blocks);
else /* completed sync */
conf->fullsync = 0;
md_bitmap_close_sync(mddev->bitmap);
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 26/41] md/md-bitmap: merge md_bitmap_end_sync() into bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (24 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 25/41] md/md-bitmap: remove the parameter 'aborted' for md_bitmap_end_sync() Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 27/41] md/md-bitmap: merge md_bitmap_close_sync() " Yu Kuai
` (15 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
So that the implementation won't be exposed, and it'll be possible
to invent a new bitmap by replacing bitmap_operations.
Also change the parameter from bitmap to mddev, to avoid access
bitmap outside md-bitmap.c as much as possible.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 8 ++++----
drivers/md/md-bitmap.h | 3 +--
drivers/md/raid1.c | 6 +++---
drivers/md/raid10.c | 10 ++++++----
drivers/md/raid5.c | 4 ++--
5 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index c18ce8e4ea72..b3649f1d1200 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1665,12 +1665,11 @@ static void __bitmap_end_sync(struct bitmap *bitmap, sector_t offset,
spin_unlock_irqrestore(&bitmap->counts.lock, flags);
}
-void md_bitmap_end_sync(struct bitmap *bitmap, sector_t offset,
- sector_t *blocks)
+static void bitmap_end_sync(struct mddev *mddev, sector_t offset,
+ sector_t *blocks)
{
- __bitmap_end_sync(bitmap, offset, blocks, true);
+ __bitmap_end_sync(mddev->bitmap, offset, blocks, true);
}
-EXPORT_SYMBOL(md_bitmap_end_sync);
void md_bitmap_close_sync(struct bitmap *bitmap)
{
@@ -2742,6 +2741,7 @@ static struct bitmap_operations bitmap_ops = {
.startwrite = bitmap_startwrite,
.endwrite = bitmap_endwrite,
.start_sync = bitmap_start_sync,
+ .end_sync = bitmap_end_sync,
.update_sb = bitmap_update_sb,
.get_stats = bitmap_get_stats,
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index 68324757da5a..ff0ca61147e9 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -260,6 +260,7 @@ struct bitmap_operations {
unsigned long sectors, bool success, bool behind);
bool (*start_sync)(struct mddev *mddev, sector_t offset,
sector_t *blocks, bool degraded);
+ void (*end_sync)(struct mddev *mddev, sector_t offset, sector_t *blocks);
void (*update_sb)(struct bitmap *bitmap);
int (*get_stats)(struct bitmap *bitmap, struct md_bitmap_stats *stats);
@@ -269,8 +270,6 @@ struct bitmap_operations {
void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are exported */
-void md_bitmap_end_sync(struct bitmap *bitmap, sector_t offset,
- sector_t *blocks);
void md_bitmap_close_sync(struct bitmap *bitmap);
void md_bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, bool force);
void md_bitmap_sync_with_cluster(struct mddev *mddev,
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 1be06a476acf..e7e9e52db795 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2038,7 +2038,7 @@ static void abort_sync_write(struct mddev *mddev, struct r1bio *r1_bio)
/* make sure these bits don't get cleared. */
do {
- md_bitmap_end_sync(mddev->bitmap, s, &sync_blocks);
+ mddev->bitmap_ops->end_sync(mddev, s, &sync_blocks);
s += sync_blocks;
sectors_to_go -= sync_blocks;
} while (sectors_to_go > 0);
@@ -2784,8 +2784,8 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
* We can find the current addess in mddev->curr_resync
*/
if (mddev->curr_resync < max_sector) /* aborted */
- md_bitmap_end_sync(mddev->bitmap, mddev->curr_resync,
- &sync_blocks);
+ mddev->bitmap_ops->end_sync(mddev, mddev->curr_resync,
+ &sync_blocks);
else /* completed sync */
conf->fullsync = 0;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 821219dc973e..694522fb5584 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -3194,13 +3194,15 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
if (mddev->curr_resync < max_sector) { /* aborted */
if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery))
- md_bitmap_end_sync(mddev->bitmap, mddev->curr_resync,
- &sync_blocks);
+ mddev->bitmap_ops->end_sync(mddev,
+ mddev->curr_resync,
+ &sync_blocks);
else for (i = 0; i < conf->geo.raid_disks; i++) {
sector_t sect =
raid10_find_virt(conf, mddev->curr_resync, i);
- md_bitmap_end_sync(mddev->bitmap, sect,
- &sync_blocks);
+
+ mddev->bitmap_ops->end_sync(mddev, sect,
+ &sync_blocks);
}
} else {
/* completed sync */
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 3e9fed1e1153..89ae149bf28e 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -6497,8 +6497,8 @@ static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_n
}
if (mddev->curr_resync < max_sector) /* aborted */
- md_bitmap_end_sync(mddev->bitmap, mddev->curr_resync,
- &sync_blocks);
+ mddev->bitmap_ops->end_sync(mddev, mddev->curr_resync,
+ &sync_blocks);
else /* completed sync */
conf->fullsync = 0;
md_bitmap_close_sync(mddev->bitmap);
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 27/41] md/md-bitmap: merge md_bitmap_close_sync() into bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (25 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 26/41] md/md-bitmap: merge md_bitmap_end_sync() into bitmap_operations Yu Kuai
@ 2024-08-14 7:10 ` Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 28/41] md/md-bitmap: mrege md_bitmap_cond_end_sync() " Yu Kuai
` (14 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:10 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
So that the implementation won't be exposed, and it'll be possible
to invent a new bitmap by replacing bitmap_operations.
Also change the parameter from bitmap to mddev, to avoid access
bitmap outside md-bitmap.c as much as possible.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 9 ++++++---
drivers/md/md-bitmap.h | 2 +-
drivers/md/raid1.c | 2 +-
drivers/md/raid10.c | 2 +-
drivers/md/raid5.c | 2 +-
5 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index b3649f1d1200..ed814bcb1933 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1671,7 +1671,7 @@ static void bitmap_end_sync(struct mddev *mddev, sector_t offset,
__bitmap_end_sync(mddev->bitmap, offset, blocks, true);
}
-void md_bitmap_close_sync(struct bitmap *bitmap)
+static void bitmap_close_sync(struct mddev *mddev)
{
/* Sync has finished, and any bitmap chunks that weren't synced
* properly have been aborted. It remains to us to clear the
@@ -1679,14 +1679,16 @@ void md_bitmap_close_sync(struct bitmap *bitmap)
*/
sector_t sector = 0;
sector_t blocks;
+ struct bitmap *bitmap = mddev->bitmap;
+
if (!bitmap)
return;
+
while (sector < bitmap->mddev->resync_max_sectors) {
__bitmap_end_sync(bitmap, sector, &blocks, false);
sector += blocks;
}
}
-EXPORT_SYMBOL(md_bitmap_close_sync);
void md_bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, bool force)
{
@@ -2017,7 +2019,7 @@ static int bitmap_load(struct mddev *mddev)
bitmap_start_sync(mddev, sector, &blocks, false);
sector += blocks;
}
- md_bitmap_close_sync(bitmap);
+ bitmap_close_sync(mddev);
if (mddev->degraded == 0
|| bitmap->events_cleared == mddev->events)
@@ -2742,6 +2744,7 @@ static struct bitmap_operations bitmap_ops = {
.endwrite = bitmap_endwrite,
.start_sync = bitmap_start_sync,
.end_sync = bitmap_end_sync,
+ .close_sync = bitmap_close_sync,
.update_sb = bitmap_update_sb,
.get_stats = bitmap_get_stats,
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index ff0ca61147e9..47e157d9f6be 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -261,6 +261,7 @@ struct bitmap_operations {
bool (*start_sync)(struct mddev *mddev, sector_t offset,
sector_t *blocks, bool degraded);
void (*end_sync)(struct mddev *mddev, sector_t offset, sector_t *blocks);
+ void (*close_sync)(struct mddev *mddev);
void (*update_sb)(struct bitmap *bitmap);
int (*get_stats)(struct bitmap *bitmap, struct md_bitmap_stats *stats);
@@ -270,7 +271,6 @@ struct bitmap_operations {
void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are exported */
-void md_bitmap_close_sync(struct bitmap *bitmap);
void md_bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, bool force);
void md_bitmap_sync_with_cluster(struct mddev *mddev,
sector_t old_lo, sector_t old_hi,
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index e7e9e52db795..fffd94119f0a 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2789,7 +2789,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
else /* completed sync */
conf->fullsync = 0;
- md_bitmap_close_sync(mddev->bitmap);
+ mddev->bitmap_ops->close_sync(mddev);
close_sync(conf);
if (mddev_is_clustered(mddev)) {
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 694522fb5584..10df08394ebb 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -3222,7 +3222,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
}
conf->fullsync = 0;
}
- md_bitmap_close_sync(mddev->bitmap);
+ mddev->bitmap_ops->close_sync(mddev);
close_sync(conf);
*skipped = 1;
return sectors_skipped;
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 89ae149bf28e..d2b8d2517abf 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -6501,7 +6501,7 @@ static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_n
&sync_blocks);
else /* completed sync */
conf->fullsync = 0;
- md_bitmap_close_sync(mddev->bitmap);
+ mddev->bitmap_ops->close_sync(mddev);
return 0;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 28/41] md/md-bitmap: mrege md_bitmap_cond_end_sync() into bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (26 preceding siblings ...)
2024-08-14 7:10 ` [PATCH RFC -next v2 27/41] md/md-bitmap: merge md_bitmap_close_sync() " Yu Kuai
@ 2024-08-14 7:11 ` Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 29/41] md/md-bitmap: merge md_bitmap_sync_with_cluster() " Yu Kuai
` (13 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:11 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
So that the implementation won't be exposed, and it'll be possible
to invent a new bitmap by replacing bitmap_operations.
Also change the parameter from bitmap to mddev, to avoid access
bitmap outside md-bitmap.c as much as possible.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 6 ++++--
drivers/md/md-bitmap.h | 2 +-
drivers/md/raid1.c | 6 +++---
drivers/md/raid10.c | 2 +-
drivers/md/raid5.c | 2 +-
5 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index ed814bcb1933..b92b8f997fc8 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1690,10 +1690,12 @@ static void bitmap_close_sync(struct mddev *mddev)
}
}
-void md_bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, bool force)
+static void bitmap_cond_end_sync(struct mddev *mddev, sector_t sector,
+ bool force)
{
sector_t s = 0;
sector_t blocks;
+ struct bitmap *bitmap = mddev->bitmap;
if (!bitmap)
return;
@@ -1718,7 +1720,6 @@ void md_bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, bool force)
bitmap->last_end_sync = jiffies;
sysfs_notify_dirent_safe(bitmap->mddev->sysfs_completed);
}
-EXPORT_SYMBOL(md_bitmap_cond_end_sync);
void md_bitmap_sync_with_cluster(struct mddev *mddev,
sector_t old_lo, sector_t old_hi,
@@ -2744,6 +2745,7 @@ static struct bitmap_operations bitmap_ops = {
.endwrite = bitmap_endwrite,
.start_sync = bitmap_start_sync,
.end_sync = bitmap_end_sync,
+ .cond_end_sync = bitmap_cond_end_sync,
.close_sync = bitmap_close_sync,
.update_sb = bitmap_update_sb,
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index 47e157d9f6be..34c70abe8795 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -261,6 +261,7 @@ struct bitmap_operations {
bool (*start_sync)(struct mddev *mddev, sector_t offset,
sector_t *blocks, bool degraded);
void (*end_sync)(struct mddev *mddev, sector_t offset, sector_t *blocks);
+ void (*cond_end_sync)(struct mddev *mddev, sector_t sector, bool force);
void (*close_sync)(struct mddev *mddev);
void (*update_sb)(struct bitmap *bitmap);
@@ -271,7 +272,6 @@ struct bitmap_operations {
void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are exported */
-void md_bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector, bool force);
void md_bitmap_sync_with_cluster(struct mddev *mddev,
sector_t old_lo, sector_t old_hi,
sector_t new_lo, sector_t new_hi);
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index fffd94119f0a..869226752a63 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2827,9 +2827,9 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
* sector_nr + two times RESYNC_SECTORS
*/
- md_bitmap_cond_end_sync(mddev->bitmap, sector_nr,
- mddev_is_clustered(mddev) && (sector_nr + 2 * RESYNC_SECTORS > conf->cluster_sync_high));
-
+ mddev->bitmap_ops->cond_end_sync(mddev, sector_nr,
+ mddev_is_clustered(mddev) &&
+ (sector_nr + 2 * RESYNC_SECTORS > conf->cluster_sync_high));
if (raise_barrier(conf, sector_nr))
return 0;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 10df08394ebb..45bcda686def 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -3543,7 +3543,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
* safety reason, which ensures curr_resync_completed is
* updated in bitmap_cond_end_sync.
*/
- md_bitmap_cond_end_sync(mddev->bitmap, sector_nr,
+ mddev->bitmap_ops->cond_end_sync(mddev, sector_nr,
mddev_is_clustered(mddev) &&
(sector_nr + 2 * RESYNC_SECTORS > conf->cluster_sync_high));
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index d2b8d2517abf..87b8d19ab601 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -6540,7 +6540,7 @@ static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_n
return sync_blocks * RAID5_STRIPE_SECTORS(conf);
}
- md_bitmap_cond_end_sync(mddev->bitmap, sector_nr, false);
+ mddev->bitmap_ops->cond_end_sync(mddev, sector_nr, false);
sh = raid5_get_active_stripe(conf, NULL, sector_nr,
R5_GAS_NOBLOCK);
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 29/41] md/md-bitmap: merge md_bitmap_sync_with_cluster() into bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (27 preceding siblings ...)
2024-08-14 7:11 ` [PATCH RFC -next v2 28/41] md/md-bitmap: mrege md_bitmap_cond_end_sync() " Yu Kuai
@ 2024-08-14 7:11 ` Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 30/41] md/md-bitmap: merge md_bitmap_unplug_async() into md_bitmap_unplug() Yu Kuai
` (12 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:11 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
So that the implementation won't be exposed, and it'll be possible
to invent a new bitmap by replacing bitmap_operations.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 9 +++++----
drivers/md/md-bitmap.h | 8 ++++----
drivers/md/md-cluster.c | 4 ++--
3 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index b92b8f997fc8..a9bf9ad71ba6 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1721,9 +1721,9 @@ static void bitmap_cond_end_sync(struct mddev *mddev, sector_t sector,
sysfs_notify_dirent_safe(bitmap->mddev->sysfs_completed);
}
-void md_bitmap_sync_with_cluster(struct mddev *mddev,
- sector_t old_lo, sector_t old_hi,
- sector_t new_lo, sector_t new_hi)
+static void bitmap_sync_with_cluster(struct mddev *mddev,
+ sector_t old_lo, sector_t old_hi,
+ sector_t new_lo, sector_t new_hi)
{
struct bitmap *bitmap = mddev->bitmap;
sector_t sector, blocks = 0;
@@ -1740,7 +1740,6 @@ void md_bitmap_sync_with_cluster(struct mddev *mddev,
}
WARN((blocks > new_hi) && old_hi, "alignment is not correct for hi\n");
}
-EXPORT_SYMBOL(md_bitmap_sync_with_cluster);
static void md_bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int needed)
{
@@ -2750,6 +2749,8 @@ static struct bitmap_operations bitmap_ops = {
.update_sb = bitmap_update_sb,
.get_stats = bitmap_get_stats,
+
+ .sync_with_cluster = bitmap_sync_with_cluster,
};
void mddev_set_bitmap_ops(struct mddev *mddev)
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index 34c70abe8795..d933b603fce9 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -266,16 +266,16 @@ struct bitmap_operations {
void (*update_sb)(struct bitmap *bitmap);
int (*get_stats)(struct bitmap *bitmap, struct md_bitmap_stats *stats);
+
+ void (*sync_with_cluster)(struct mddev *mddev,
+ sector_t old_lo, sector_t old_hi,
+ sector_t new_lo, sector_t new_hi);
};
/* the bitmap API */
void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are exported */
-void md_bitmap_sync_with_cluster(struct mddev *mddev,
- sector_t old_lo, sector_t old_hi,
- sector_t new_lo, sector_t new_hi);
-
void md_bitmap_unplug(struct bitmap *bitmap);
void md_bitmap_unplug_async(struct bitmap *bitmap);
void md_bitmap_daemon_work(struct mddev *mddev);
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index 31108832dd9b..b36b9f449f9d 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -497,8 +497,8 @@ static void process_suspend_info(struct mddev *mddev,
* we don't want to trigger lots of WARN.
*/
if (sb && !(le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE))
- md_bitmap_sync_with_cluster(mddev, cinfo->sync_low,
- cinfo->sync_hi, lo, hi);
+ mddev->bitmap_ops->sync_with_cluster(mddev, cinfo->sync_low,
+ cinfo->sync_hi, lo, hi);
cinfo->sync_low = lo;
cinfo->sync_hi = hi;
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 30/41] md/md-bitmap: merge md_bitmap_unplug_async() into md_bitmap_unplug()
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (28 preceding siblings ...)
2024-08-14 7:11 ` [PATCH RFC -next v2 29/41] md/md-bitmap: merge md_bitmap_sync_with_cluster() " Yu Kuai
@ 2024-08-14 7:11 ` Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 31/41] md/md-bitmap: merge bitmap_unplug() into bitmap_operations Yu Kuai
` (11 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:11 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
Add a parameter 'bool sync' to distinguish them, and
md_bitmap_unplug_async() won't be exported anymore, hence
bitmap_operations only need one op to cover them.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 28 ++++++++++++++++++++--------
drivers/md/md-bitmap.h | 3 +--
drivers/md/md.c | 2 +-
drivers/md/raid1-10.c | 7 ++-----
drivers/md/raid1.c | 2 +-
drivers/md/raid10.c | 4 ++--
drivers/md/raid5.c | 2 +-
7 files changed, 28 insertions(+), 20 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index a9bf9ad71ba6..13aafe7e3ba8 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1026,7 +1026,7 @@ static int md_bitmap_file_test_bit(struct bitmap *bitmap, sector_t block)
/* 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 */
-void md_bitmap_unplug(struct bitmap *bitmap)
+static void __bitmap_unplug(struct bitmap *bitmap)
{
unsigned long i;
int dirty, need_write;
@@ -1058,7 +1058,6 @@ void md_bitmap_unplug(struct bitmap *bitmap)
if (test_bit(BITMAP_WRITE_ERROR, &bitmap->flags))
md_bitmap_file_kick(bitmap);
}
-EXPORT_SYMBOL(md_bitmap_unplug);
struct bitmap_unplug_work {
struct work_struct work;
@@ -1071,11 +1070,11 @@ static void md_bitmap_unplug_fn(struct work_struct *work)
struct bitmap_unplug_work *unplug_work =
container_of(work, struct bitmap_unplug_work, work);
- md_bitmap_unplug(unplug_work->bitmap);
+ __bitmap_unplug(unplug_work->bitmap);
complete(unplug_work->done);
}
-void md_bitmap_unplug_async(struct bitmap *bitmap)
+static void bitmap_unplug_async(struct bitmap *bitmap)
{
DECLARE_COMPLETION_ONSTACK(done);
struct bitmap_unplug_work unplug_work;
@@ -1087,7 +1086,20 @@ void md_bitmap_unplug_async(struct bitmap *bitmap)
queue_work(md_bitmap_wq, &unplug_work.work);
wait_for_completion(&done);
}
-EXPORT_SYMBOL(md_bitmap_unplug_async);
+
+void md_bitmap_unplug(struct mddev *mddev, bool sync)
+{
+ struct bitmap *bitmap = mddev->bitmap;
+
+ if (!bitmap)
+ return;
+
+ if (sync)
+ __bitmap_unplug(bitmap);
+ else
+ bitmap_unplug_async(bitmap);
+}
+EXPORT_SYMBOL_GPL(md_bitmap_unplug);
static void md_bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int needed);
@@ -2108,9 +2120,9 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
for (i = 0; i < bitmap->storage.file_pages; i++)
if (test_page_attr(bitmap, i, BITMAP_PAGE_PENDING))
set_page_attr(bitmap, i, BITMAP_PAGE_NEEDWRITE);
- md_bitmap_unplug(bitmap);
+ __bitmap_unplug(bitmap);
}
- md_bitmap_unplug(mddev->bitmap);
+ __bitmap_unplug(mddev->bitmap);
*low = lo;
*high = hi;
md_bitmap_free(bitmap);
@@ -2348,7 +2360,7 @@ int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
spin_unlock_irq(&bitmap->counts.lock);
if (!init) {
- md_bitmap_unplug(bitmap);
+ __bitmap_unplug(bitmap);
bitmap->mddev->pers->quiesce(bitmap->mddev, 0);
}
ret = 0;
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index d933b603fce9..ae6ba558e48a 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -276,8 +276,7 @@ struct bitmap_operations {
void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are exported */
-void md_bitmap_unplug(struct bitmap *bitmap);
-void md_bitmap_unplug_async(struct bitmap *bitmap);
+void md_bitmap_unplug(struct mddev *mddev, bool sync);
void md_bitmap_daemon_work(struct mddev *mddev);
int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 1e1d3db56bb9..f15784b31b98 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -4701,7 +4701,7 @@ bitmap_store(struct mddev *mddev, const char *buf, size_t len)
mddev->bitmap_ops->dirty_bits(mddev, chunk, end_chunk);
buf = skip_spaces(end);
}
- md_bitmap_unplug(mddev->bitmap); /* flush the bits to disk */
+ md_bitmap_unplug(mddev, true); /* flush the bits to disk */
out:
mddev_unlock(mddev);
return len;
diff --git a/drivers/md/raid1-10.c b/drivers/md/raid1-10.c
index 2ea1710a3b70..45b30f08f3a5 100644
--- a/drivers/md/raid1-10.c
+++ b/drivers/md/raid1-10.c
@@ -166,12 +166,9 @@ static inline bool raid1_add_bio_to_plug(struct mddev *mddev, struct bio *bio,
* while current io submission must wait for bitmap io to be done. In order to
* avoid such deadlock, submit bitmap io asynchronously.
*/
-static inline void raid1_prepare_flush_writes(struct bitmap *bitmap)
+static inline void raid1_prepare_flush_writes(struct mddev *mddev)
{
- if (current->bio_list)
- md_bitmap_unplug_async(bitmap);
- else
- md_bitmap_unplug(bitmap);
+ md_bitmap_unplug(mddev, current->bio_list == NULL);
}
/*
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 869226752a63..3dedb7fd74c4 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -896,7 +896,7 @@ static void wake_up_barrier(struct r1conf *conf)
static void flush_bio_list(struct r1conf *conf, struct bio *bio)
{
/* flush any pending bitmap writes to disk before proceeding w/ I/O */
- raid1_prepare_flush_writes(conf->mddev->bitmap);
+ raid1_prepare_flush_writes(conf->mddev);
wake_up_barrier(conf);
while (bio) { /* submit pending writes */
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 45bcda686def..085a85945a42 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -885,7 +885,7 @@ static void flush_pending_writes(struct r10conf *conf)
__set_current_state(TASK_RUNNING);
blk_start_plug(&plug);
- raid1_prepare_flush_writes(conf->mddev->bitmap);
+ raid1_prepare_flush_writes(conf->mddev);
wake_up(&conf->wait_barrier);
while (bio) { /* submit pending writes */
@@ -1101,7 +1101,7 @@ static void raid10_unplug(struct blk_plug_cb *cb, bool from_schedule)
/* we aren't scheduling, so we can do the write-out directly. */
bio = bio_list_get(&plug->pending);
- raid1_prepare_flush_writes(mddev->bitmap);
+ raid1_prepare_flush_writes(mddev);
wake_up_barrier(conf);
while (bio) { /* submit pending writes */
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 87b8d19ab601..e98061c01b44 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -6768,7 +6768,7 @@ static void raid5d(struct md_thread *thread)
/* Now is a good time to flush some bitmap updates */
conf->seq_flush++;
spin_unlock_irq(&conf->device_lock);
- md_bitmap_unplug(mddev->bitmap);
+ md_bitmap_unplug(mddev, true);
spin_lock_irq(&conf->device_lock);
conf->seq_write = conf->seq_flush;
activate_bit_delay(conf, conf->temp_inactive_list);
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 31/41] md/md-bitmap: merge bitmap_unplug() into bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (29 preceding siblings ...)
2024-08-14 7:11 ` [PATCH RFC -next v2 30/41] md/md-bitmap: merge md_bitmap_unplug_async() into md_bitmap_unplug() Yu Kuai
@ 2024-08-14 7:11 ` Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 32/41] md/md-bitmap: merge md_bitmap_daemon_work() " Yu Kuai
` (10 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:11 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
So that the implementation won't be exposed, and it'll be possible
to invent a new bitmap by replacing bitmap_operations.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 4 ++--
drivers/md/md-bitmap.h | 2 +-
drivers/md/md.c | 2 +-
drivers/md/raid1-10.c | 2 +-
drivers/md/raid5.c | 2 +-
5 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 13aafe7e3ba8..ec85d7f2eeee 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1087,7 +1087,7 @@ static void bitmap_unplug_async(struct bitmap *bitmap)
wait_for_completion(&done);
}
-void md_bitmap_unplug(struct mddev *mddev, bool sync)
+static void bitmap_unplug(struct mddev *mddev, bool sync)
{
struct bitmap *bitmap = mddev->bitmap;
@@ -1099,7 +1099,6 @@ void md_bitmap_unplug(struct mddev *mddev, bool sync)
else
bitmap_unplug_async(bitmap);
}
-EXPORT_SYMBOL_GPL(md_bitmap_unplug);
static void md_bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int needed);
@@ -2751,6 +2750,7 @@ static struct bitmap_operations bitmap_ops = {
.flush = bitmap_flush,
.write_all = bitmap_write_all,
.dirty_bits = bitmap_dirty_bits,
+ .unplug = bitmap_unplug,
.startwrite = bitmap_startwrite,
.endwrite = bitmap_endwrite,
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index ae6ba558e48a..eaaaab51701e 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -253,6 +253,7 @@ struct bitmap_operations {
void (*write_all)(struct mddev *mddev);
void (*dirty_bits)(struct mddev *mddev, unsigned long s,
unsigned long e);
+ void (*unplug)(struct mddev *mddev, bool sync);
int (*startwrite)(struct mddev *mddev, sector_t offset,
unsigned long sectors, bool behind);
@@ -276,7 +277,6 @@ struct bitmap_operations {
void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are exported */
-void md_bitmap_unplug(struct mddev *mddev, bool sync);
void md_bitmap_daemon_work(struct mddev *mddev);
int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
diff --git a/drivers/md/md.c b/drivers/md/md.c
index f15784b31b98..6d621c28cea0 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -4701,7 +4701,7 @@ bitmap_store(struct mddev *mddev, const char *buf, size_t len)
mddev->bitmap_ops->dirty_bits(mddev, chunk, end_chunk);
buf = skip_spaces(end);
}
- md_bitmap_unplug(mddev, true); /* flush the bits to disk */
+ mddev->bitmap_ops->unplug(mddev, true); /* flush the bits to disk */
out:
mddev_unlock(mddev);
return len;
diff --git a/drivers/md/raid1-10.c b/drivers/md/raid1-10.c
index 45b30f08f3a5..e8207513eb1b 100644
--- a/drivers/md/raid1-10.c
+++ b/drivers/md/raid1-10.c
@@ -168,7 +168,7 @@ static inline bool raid1_add_bio_to_plug(struct mddev *mddev, struct bio *bio,
*/
static inline void raid1_prepare_flush_writes(struct mddev *mddev)
{
- md_bitmap_unplug(mddev, current->bio_list == NULL);
+ mddev->bitmap_ops->unplug(mddev, current->bio_list == NULL);
}
/*
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index e98061c01b44..91b610d11c6a 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -6768,7 +6768,7 @@ static void raid5d(struct md_thread *thread)
/* Now is a good time to flush some bitmap updates */
conf->seq_flush++;
spin_unlock_irq(&conf->device_lock);
- md_bitmap_unplug(mddev, true);
+ mddev->bitmap_ops->unplug(mddev, true);
spin_lock_irq(&conf->device_lock);
conf->seq_write = conf->seq_flush;
activate_bit_delay(conf, conf->temp_inactive_list);
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 32/41] md/md-bitmap: merge md_bitmap_daemon_work() into bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (30 preceding siblings ...)
2024-08-14 7:11 ` [PATCH RFC -next v2 31/41] md/md-bitmap: merge bitmap_unplug() into bitmap_operations Yu Kuai
@ 2024-08-14 7:11 ` Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 33/41] md/md-bitmap: pass in mddev directly for md_bitmap_resize() Yu Kuai
` (9 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:11 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
So that the implementation won't be exposed, and it'll be possible
to invent a new bitmap by replacing bitmap_operations.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 9 +++++----
drivers/md/md-bitmap.h | 2 +-
drivers/md/md.c | 2 +-
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index ec85d7f2eeee..a1f57f751b55 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1298,7 +1298,7 @@ static void mddev_set_timeout(struct mddev *mddev, unsigned long timeout,
* bitmap daemon -- periodically wakes up to clean bits and flush pages
* out to disk
*/
-void md_bitmap_daemon_work(struct mddev *mddev)
+static void bitmap_daemon_work(struct mddev *mddev)
{
struct bitmap *bitmap;
unsigned long j;
@@ -1815,11 +1815,11 @@ static void bitmap_flush(struct mddev *mddev)
*/
sleep = mddev->bitmap_info.daemon_sleep * 2;
bitmap->daemon_lastrun -= sleep;
- md_bitmap_daemon_work(mddev);
+ bitmap_daemon_work(mddev);
bitmap->daemon_lastrun -= sleep;
- md_bitmap_daemon_work(mddev);
+ bitmap_daemon_work(mddev);
bitmap->daemon_lastrun -= sleep;
- md_bitmap_daemon_work(mddev);
+ bitmap_daemon_work(mddev);
if (mddev->bitmap_info.external)
md_super_wait(mddev);
bitmap_update_sb(bitmap);
@@ -2751,6 +2751,7 @@ static struct bitmap_operations bitmap_ops = {
.write_all = bitmap_write_all,
.dirty_bits = bitmap_dirty_bits,
.unplug = bitmap_unplug,
+ .daemon_work = bitmap_daemon_work,
.startwrite = bitmap_startwrite,
.endwrite = bitmap_endwrite,
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index eaaaab51701e..b4c3e4faf288 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -254,6 +254,7 @@ struct bitmap_operations {
void (*dirty_bits)(struct mddev *mddev, unsigned long s,
unsigned long e);
void (*unplug)(struct mddev *mddev, bool sync);
+ void (*daemon_work)(struct mddev *mddev);
int (*startwrite)(struct mddev *mddev, sector_t offset,
unsigned long sectors, bool behind);
@@ -277,7 +278,6 @@ struct bitmap_operations {
void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are exported */
-void md_bitmap_daemon_work(struct mddev *mddev);
int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
int chunksize, int init);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 6d621c28cea0..4bdfe23a565d 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -9621,7 +9621,7 @@ static void unregister_sync_thread(struct mddev *mddev)
void md_check_recovery(struct mddev *mddev)
{
if (mddev->bitmap)
- md_bitmap_daemon_work(mddev);
+ mddev->bitmap_ops->daemon_work(mddev);
if (signal_pending(current)) {
if (mddev->pers->sync_request && !mddev->external) {
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 33/41] md/md-bitmap: pass in mddev directly for md_bitmap_resize()
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (31 preceding siblings ...)
2024-08-14 7:11 ` [PATCH RFC -next v2 32/41] md/md-bitmap: merge md_bitmap_daemon_work() " Yu Kuai
@ 2024-08-14 7:11 ` Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 34/41] md/md-bitmap: merge md_bitmap_resize() into bitmap_operations Yu Kuai
` (8 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:11 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
And move the condition "if (mddev->bitmap)" into md_bitmap_resize() as
well, on the one hand make code cleaner, on the other hand try not to
access bitmap directly.
Since we are here, also change the parameter 'init' from int to bool.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/dm-raid.c | 2 +-
drivers/md/md-bitmap.c | 10 +++++++---
drivers/md/md-bitmap.h | 4 ++--
drivers/md/md-cluster.c | 4 ++--
drivers/md/raid1.c | 12 +++++++-----
drivers/md/raid10.c | 17 +++++++++--------
drivers/md/raid5.c | 11 ++++++-----
7 files changed, 34 insertions(+), 26 deletions(-)
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index c3e201fde4c5..cc071fcd7a04 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -4068,7 +4068,7 @@ static int raid_preresume(struct dm_target *ti)
mddev->bitmap_info.chunksize != to_bytes(rs->requested_bitmap_chunk_sectors)))) {
int chunksize = to_bytes(rs->requested_bitmap_chunk_sectors) ?: mddev->bitmap_info.chunksize;
- r = md_bitmap_resize(mddev->bitmap, mddev->dev_sectors, chunksize, 0);
+ r = md_bitmap_resize(mddev, mddev->dev_sectors, chunksize, false);
if (r)
DMERR("Failed to resize bitmap");
}
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index a1f57f751b55..04f32f18e734 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1975,7 +1975,7 @@ static struct bitmap *__bitmap_create(struct mddev *mddev, int slot)
goto error;
bitmap->daemon_lastrun = jiffies;
- err = md_bitmap_resize(bitmap, blocks, mddev->bitmap_info.chunksize, 1);
+ err = md_bitmap_resize(mddev, blocks, mddev->bitmap_info.chunksize, true);
if (err)
goto error;
@@ -2160,8 +2160,8 @@ static int bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats
return 0;
}
-int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
- int chunksize, int init)
+int md_bitmap_resize(struct mddev *mddev, sector_t blocks, int chunksize,
+ bool init)
{
/* If chunk_size is 0, choose an appropriate chunk size.
* Then possibly allocate new storage space.
@@ -2182,6 +2182,10 @@ int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
int ret = 0;
long pages;
struct bitmap_page *new_bp;
+ struct bitmap *bitmap = mddev->bitmap;
+
+ if (!bitmap)
+ return 0;
if (bitmap->storage.file && !init) {
pr_info("md: cannot resize file-based bitmap\n");
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index b4c3e4faf288..ffb6e027dfff 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -279,8 +279,8 @@ void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are exported */
-int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
- int chunksize, int init);
+int md_bitmap_resize(struct mddev *mddev, sector_t blocks, int chunksize,
+ bool init);
struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot);
int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
sector_t *lo, sector_t *hi, bool clear_bits);
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index b36b9f449f9d..d0f9ff7bd663 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -628,8 +628,8 @@ static int process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg)
break;
case BITMAP_RESIZE:
if (le64_to_cpu(msg->high) != mddev->pers->size(mddev, 0, 0))
- ret = md_bitmap_resize(mddev->bitmap,
- le64_to_cpu(msg->high), 0, 0);
+ ret = md_bitmap_resize(mddev, le64_to_cpu(msg->high), 0,
+ false);
break;
default:
ret = -1;
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 3dedb7fd74c4..ba5df105d735 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -3309,14 +3309,16 @@ static int raid1_resize(struct mddev *mddev, sector_t sectors)
* worth it.
*/
sector_t newsize = raid1_size(mddev, sectors, 0);
+ int ret;
+
if (mddev->external_size &&
mddev->array_sectors > newsize)
return -EINVAL;
- if (mddev->bitmap) {
- int ret = md_bitmap_resize(mddev->bitmap, newsize, 0, 0);
- if (ret)
- return ret;
- }
+
+ ret = md_bitmap_resize(mddev, newsize, 0, false);
+ if (ret)
+ return ret;
+
md_set_array_sectors(mddev, newsize);
if (sectors > mddev->dev_sectors &&
mddev->recovery_cp > mddev->dev_sectors) {
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 085a85945a42..343c9bcc3104 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -4196,6 +4196,7 @@ static int raid10_resize(struct mddev *mddev, sector_t sectors)
*/
struct r10conf *conf = mddev->private;
sector_t oldsize, size;
+ int ret;
if (mddev->reshape_position != MaxSector)
return -EBUSY;
@@ -4208,11 +4209,11 @@ static int raid10_resize(struct mddev *mddev, sector_t sectors)
if (mddev->external_size &&
mddev->array_sectors > size)
return -EINVAL;
- if (mddev->bitmap) {
- int ret = md_bitmap_resize(mddev->bitmap, size, 0, 0);
- if (ret)
- return ret;
- }
+
+ ret = md_bitmap_resize(mddev, size, 0, false);
+ if (ret)
+ return ret;
+
md_set_array_sectors(mddev, size);
if (sectors > mddev->dev_sectors &&
mddev->recovery_cp > oldsize) {
@@ -4478,7 +4479,7 @@ static int raid10_start_reshape(struct mddev *mddev)
newsize = raid10_size(mddev, 0, conf->geo.raid_disks);
if (!mddev_is_clustered(mddev)) {
- ret = md_bitmap_resize(mddev->bitmap, newsize, 0, 0);
+ ret = md_bitmap_resize(mddev, newsize, 0, false);
if (ret)
goto abort;
else
@@ -4500,13 +4501,13 @@ static int raid10_start_reshape(struct mddev *mddev)
MD_FEATURE_RESHAPE_ACTIVE)) || (oldsize == newsize))
goto out;
- ret = md_bitmap_resize(mddev->bitmap, newsize, 0, 0);
+ ret = md_bitmap_resize(mddev, newsize, 0, false);
if (ret)
goto abort;
ret = md_cluster_ops->resize_bitmaps(mddev, newsize, oldsize);
if (ret) {
- md_bitmap_resize(mddev->bitmap, oldsize, 0, 0);
+ md_bitmap_resize(mddev, oldsize, 0, false);
goto abort;
}
}
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 91b610d11c6a..47c89f7b1dfe 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -8313,6 +8313,7 @@ static int raid5_resize(struct mddev *mddev, sector_t sectors)
*/
sector_t newsize;
struct r5conf *conf = mddev->private;
+ int ret;
if (raid5_has_log(conf) || raid5_has_ppl(conf))
return -EINVAL;
@@ -8321,11 +8322,11 @@ static int raid5_resize(struct mddev *mddev, sector_t sectors)
if (mddev->external_size &&
mddev->array_sectors > newsize)
return -EINVAL;
- if (mddev->bitmap) {
- int ret = md_bitmap_resize(mddev->bitmap, sectors, 0, 0);
- if (ret)
- return ret;
- }
+
+ ret = md_bitmap_resize(mddev, sectors, 0, false);
+ if (ret)
+ return ret;
+
md_set_array_sectors(mddev, newsize);
if (sectors > mddev->dev_sectors &&
mddev->recovery_cp > mddev->dev_sectors) {
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 34/41] md/md-bitmap: merge md_bitmap_resize() into bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (32 preceding siblings ...)
2024-08-14 7:11 ` [PATCH RFC -next v2 33/41] md/md-bitmap: pass in mddev directly for md_bitmap_resize() Yu Kuai
@ 2024-08-14 7:11 ` Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 35/41] md/md-bitmap: merge get_bitmap_from_slot() " Yu Kuai
` (7 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:11 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
So that the implementation won't be exposed, and it'll be possible
to invent a new bitmap by replacing bitmap_operations.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/dm-raid.c | 3 ++-
drivers/md/md-bitmap.c | 11 +++++++----
drivers/md/md-bitmap.h | 5 +++--
drivers/md/md-cluster.c | 5 +++--
drivers/md/raid1.c | 2 +-
drivers/md/raid10.c | 10 +++++-----
drivers/md/raid5.c | 2 +-
7 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index cc071fcd7a04..63682d27fc8d 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -4068,7 +4068,8 @@ static int raid_preresume(struct dm_target *ti)
mddev->bitmap_info.chunksize != to_bytes(rs->requested_bitmap_chunk_sectors)))) {
int chunksize = to_bytes(rs->requested_bitmap_chunk_sectors) ?: mddev->bitmap_info.chunksize;
- r = md_bitmap_resize(mddev, mddev->dev_sectors, chunksize, false);
+ r = mddev->bitmap_ops->resize(mddev, mddev->dev_sectors,
+ chunksize, false);
if (r)
DMERR("Failed to resize bitmap");
}
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 04f32f18e734..4dc48055b18f 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -32,6 +32,9 @@
#include "md.h"
#include "md-bitmap.h"
+static int bitmap_resize(struct mddev *mddev, sector_t blocks, int chunksize,
+ bool init);
+
static inline char *bmname(struct bitmap *bitmap)
{
return bitmap->mddev ? mdname(bitmap->mddev) : "mdX";
@@ -1975,7 +1978,7 @@ static struct bitmap *__bitmap_create(struct mddev *mddev, int slot)
goto error;
bitmap->daemon_lastrun = jiffies;
- err = md_bitmap_resize(mddev, blocks, mddev->bitmap_info.chunksize, true);
+ err = bitmap_resize(mddev, blocks, mddev->bitmap_info.chunksize, true);
if (err)
goto error;
@@ -2160,8 +2163,8 @@ static int bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats
return 0;
}
-int md_bitmap_resize(struct mddev *mddev, sector_t blocks, int chunksize,
- bool init)
+static int bitmap_resize(struct mddev *mddev, sector_t blocks, int chunksize,
+ bool init)
{
/* If chunk_size is 0, choose an appropriate chunk size.
* Then possibly allocate new storage space.
@@ -2370,7 +2373,6 @@ int md_bitmap_resize(struct mddev *mddev, sector_t blocks, int chunksize,
err:
return ret;
}
-EXPORT_SYMBOL_GPL(md_bitmap_resize);
static ssize_t
location_show(struct mddev *mddev, char *page)
@@ -2749,6 +2751,7 @@ const struct attribute_group md_bitmap_group = {
static struct bitmap_operations bitmap_ops = {
.create = bitmap_create,
+ .resize = bitmap_resize,
.load = bitmap_load,
.destroy = bitmap_destroy,
.flush = bitmap_flush,
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index ffb6e027dfff..64ab063734c9 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -247,6 +247,9 @@ struct md_bitmap_stats {
struct bitmap_operations {
int (*create)(struct mddev *mddev, int slot);
+ int (*resize)(struct mddev *mddev, sector_t blocks, int chunksize,
+ bool init);
+
int (*load)(struct mddev *mddev);
void (*destroy)(struct mddev *mddev);
void (*flush)(struct mddev *mddev);
@@ -279,8 +282,6 @@ void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are exported */
-int md_bitmap_resize(struct mddev *mddev, sector_t blocks, int chunksize,
- bool init);
struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot);
int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
sector_t *lo, sector_t *hi, bool clear_bits);
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index d0f9ff7bd663..2250bd6dddb7 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -628,8 +628,9 @@ static int process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg)
break;
case BITMAP_RESIZE:
if (le64_to_cpu(msg->high) != mddev->pers->size(mddev, 0, 0))
- ret = md_bitmap_resize(mddev, le64_to_cpu(msg->high), 0,
- false);
+ ret = mddev->bitmap_ops->resize(mddev,
+ le64_to_cpu(msg->high),
+ 0, false);
break;
default:
ret = -1;
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index ba5df105d735..e285f01e3ef6 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -3315,7 +3315,7 @@ static int raid1_resize(struct mddev *mddev, sector_t sectors)
mddev->array_sectors > newsize)
return -EINVAL;
- ret = md_bitmap_resize(mddev, newsize, 0, false);
+ ret = mddev->bitmap_ops->resize(mddev, newsize, 0, false);
if (ret)
return ret;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 343c9bcc3104..a1e25c250d46 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -4210,7 +4210,7 @@ static int raid10_resize(struct mddev *mddev, sector_t sectors)
mddev->array_sectors > size)
return -EINVAL;
- ret = md_bitmap_resize(mddev, size, 0, false);
+ ret = mddev->bitmap_ops->resize(mddev, size, 0, false);
if (ret)
return ret;
@@ -4479,7 +4479,7 @@ static int raid10_start_reshape(struct mddev *mddev)
newsize = raid10_size(mddev, 0, conf->geo.raid_disks);
if (!mddev_is_clustered(mddev)) {
- ret = md_bitmap_resize(mddev, newsize, 0, false);
+ ret = mddev->bitmap_ops->resize(mddev, newsize, 0, false);
if (ret)
goto abort;
else
@@ -4494,20 +4494,20 @@ static int raid10_start_reshape(struct mddev *mddev)
/*
* some node is already performing reshape, and no need to
- * call md_bitmap_resize again since it should be called when
+ * call bitmap_ops->resize again since it should be called when
* receiving BITMAP_RESIZE msg
*/
if ((sb && (le32_to_cpu(sb->feature_map) &
MD_FEATURE_RESHAPE_ACTIVE)) || (oldsize == newsize))
goto out;
- ret = md_bitmap_resize(mddev, newsize, 0, false);
+ ret = mddev->bitmap_ops->resize(mddev, newsize, 0, false);
if (ret)
goto abort;
ret = md_cluster_ops->resize_bitmaps(mddev, newsize, oldsize);
if (ret) {
- md_bitmap_resize(mddev, oldsize, 0, false);
+ mddev->bitmap_ops->resize(mddev, oldsize, 0, false);
goto abort;
}
}
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 47c89f7b1dfe..c84a7e0263cd 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -8323,7 +8323,7 @@ static int raid5_resize(struct mddev *mddev, sector_t sectors)
mddev->array_sectors > newsize)
return -EINVAL;
- ret = md_bitmap_resize(mddev, sectors, 0, false);
+ ret = mddev->bitmap_ops->resize(mddev, sectors, 0, false);
if (ret)
return ret;
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 35/41] md/md-bitmap: merge get_bitmap_from_slot() into bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (33 preceding siblings ...)
2024-08-14 7:11 ` [PATCH RFC -next v2 34/41] md/md-bitmap: merge md_bitmap_resize() into bitmap_operations Yu Kuai
@ 2024-08-14 7:11 ` Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 36/41] md/md-bitmap: merge md_bitmap_copy_from_slot() into struct bitmap_operation Yu Kuai
` (6 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:11 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
So that the implementation won't be exposed, and it'll be possible
to invent a new bitmap by replacing bitmap_operations.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 6 +++---
drivers/md/md-bitmap.h | 2 +-
drivers/md/md-cluster.c | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 4dc48055b18f..a89119438aa2 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -2064,7 +2064,7 @@ static int bitmap_load(struct mddev *mddev)
}
/* caller need to free returned bitmap with md_bitmap_free() */
-struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot)
+static struct bitmap *bitmap_get_from_slot(struct mddev *mddev, int slot)
{
int rv = 0;
struct bitmap *bitmap;
@@ -2083,7 +2083,6 @@ struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot)
return bitmap;
}
-EXPORT_SYMBOL(get_bitmap_from_slot);
/* Loads the bitmap associated with slot and copies the resync information
* to our bitmap
@@ -2096,7 +2095,7 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
struct bitmap_counts *counts;
struct bitmap *bitmap;
- bitmap = get_bitmap_from_slot(mddev, slot);
+ bitmap = bitmap_get_from_slot(mddev, slot);
if (IS_ERR(bitmap)) {
pr_err("%s can't get bitmap from slot %d\n", __func__, slot);
return -1;
@@ -2771,6 +2770,7 @@ static struct bitmap_operations bitmap_ops = {
.get_stats = bitmap_get_stats,
.sync_with_cluster = bitmap_sync_with_cluster,
+ .get_from_slot = bitmap_get_from_slot,
};
void mddev_set_bitmap_ops(struct mddev *mddev)
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index 64ab063734c9..cbd25b9aa145 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -275,6 +275,7 @@ struct bitmap_operations {
void (*sync_with_cluster)(struct mddev *mddev,
sector_t old_lo, sector_t old_hi,
sector_t new_lo, sector_t new_hi);
+ struct bitmap *(*get_from_slot)(struct mddev *mddev, int slot);
};
/* the bitmap API */
@@ -282,7 +283,6 @@ void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are exported */
-struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot);
int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
sector_t *lo, sector_t *hi, bool clear_bits);
void md_bitmap_set_pages(struct bitmap *bitmap, unsigned long pages);
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index 2250bd6dddb7..bfc7003547b9 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -1168,7 +1168,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
if (i == md_cluster_ops->slot_number(mddev))
continue;
- bitmap = get_bitmap_from_slot(mddev, i);
+ bitmap = mddev->bitmap_ops->get_from_slot(mddev, i);
if (IS_ERR(bitmap)) {
pr_err("can't get bitmap from slot %d\n", i);
bitmap = NULL;
@@ -1234,7 +1234,7 @@ static int cluster_check_sync_size(struct mddev *mddev)
if (i == current_slot)
continue;
- bitmap = get_bitmap_from_slot(mddev, i);
+ bitmap = mddev->bitmap_ops->get_from_slot(mddev, i);
if (IS_ERR(bitmap)) {
pr_err("can't get bitmap from slot %d\n", i);
return -1;
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 36/41] md/md-bitmap: merge md_bitmap_copy_from_slot() into struct bitmap_operation.
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (34 preceding siblings ...)
2024-08-14 7:11 ` [PATCH RFC -next v2 35/41] md/md-bitmap: merge get_bitmap_from_slot() " Yu Kuai
@ 2024-08-14 7:11 ` Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 37/41] md/md-bitmap: merge md_bitmap_set_pages() into struct bitmap_operations Yu Kuai
` (5 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:11 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
So that the implementation won't be exposed, and it'll be possible
to invent a new bitmap by replacing bitmap_operations.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 6 +++---
drivers/md/md-bitmap.h | 4 ++--
drivers/md/md-cluster.c | 6 +++---
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index a89119438aa2..5d04b32ce088 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -2087,8 +2087,8 @@ static struct bitmap *bitmap_get_from_slot(struct mddev *mddev, int slot)
/* Loads the bitmap associated with slot and copies the resync information
* to our bitmap
*/
-int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
- sector_t *low, sector_t *high, bool clear_bits)
+static int bitmap_copy_from_slot(struct mddev *mddev, int slot, sector_t *low,
+ sector_t *high, bool clear_bits)
{
int rv = 0, i, j;
sector_t block, lo = 0, hi = 0;
@@ -2130,7 +2130,6 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
return rv;
}
-EXPORT_SYMBOL_GPL(md_bitmap_copy_from_slot);
void md_bitmap_set_pages(struct bitmap *bitmap, unsigned long pages)
{
@@ -2771,6 +2770,7 @@ static struct bitmap_operations bitmap_ops = {
.sync_with_cluster = bitmap_sync_with_cluster,
.get_from_slot = bitmap_get_from_slot,
+ .copy_from_slot = bitmap_copy_from_slot,
};
void mddev_set_bitmap_ops(struct mddev *mddev)
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index cbd25b9aa145..1dbc78b9172b 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -276,6 +276,8 @@ struct bitmap_operations {
sector_t old_lo, sector_t old_hi,
sector_t new_lo, sector_t new_hi);
struct bitmap *(*get_from_slot)(struct mddev *mddev, int slot);
+ int (*copy_from_slot)(struct mddev *mddev, int slot, sector_t *lo,
+ sector_t *hi, bool clear_bits);
};
/* the bitmap API */
@@ -283,8 +285,6 @@ void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are exported */
-int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
- sector_t *lo, sector_t *hi, bool clear_bits);
void md_bitmap_set_pages(struct bitmap *bitmap, unsigned long pages);
void md_bitmap_free(struct bitmap *bitmap);
void md_bitmap_wait_behind_writes(struct mddev *mddev);
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index bfc7003547b9..201a4b12c2fe 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -317,7 +317,7 @@ static void recover_bitmaps(struct md_thread *thread)
str, ret);
goto clear_bit;
}
- ret = md_bitmap_copy_from_slot(mddev, slot, &lo, &hi, true);
+ ret = mddev->bitmap_ops->copy_from_slot(mddev, slot, &lo, &hi, true);
if (ret) {
pr_err("md-cluster: Could not copy data from bitmap %d\n", slot);
goto clear_bit;
@@ -857,7 +857,7 @@ static int gather_all_resync_info(struct mddev *mddev, int total_slots)
}
/* Read the disk bitmap sb and check if it needs recovery */
- ret = md_bitmap_copy_from_slot(mddev, i, &lo, &hi, false);
+ ret = mddev->bitmap_ops->copy_from_slot(mddev, i, &lo, &hi, false);
if (ret) {
pr_warn("md-cluster: Could not gather bitmaps from slot %d", i);
lockres_free(bm_lockres);
@@ -1598,7 +1598,7 @@ static int gather_bitmaps(struct md_rdev *rdev)
for (sn = 0; sn < mddev->bitmap_info.nodes; sn++) {
if (sn == (cinfo->slot_number - 1))
continue;
- err = md_bitmap_copy_from_slot(mddev, sn, &lo, &hi, false);
+ err = mddev->bitmap_ops->copy_from_slot(mddev, sn, &lo, &hi, false);
if (err) {
pr_warn("md-cluster: Could not gather bitmaps from slot %d", sn);
goto out;
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 37/41] md/md-bitmap: merge md_bitmap_set_pages() into struct bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (35 preceding siblings ...)
2024-08-14 7:11 ` [PATCH RFC -next v2 36/41] md/md-bitmap: merge md_bitmap_copy_from_slot() into struct bitmap_operation Yu Kuai
@ 2024-08-14 7:11 ` Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 38/41] md/md-bitmap: merge md_bitmap_free() into bitmap_operations Yu Kuai
` (4 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:11 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
o that the implementation won't be exposed, and it'll be possible
o invent a new bitmap by replacing bitmap_operations.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 4 ++--
drivers/md/md-bitmap.h | 2 +-
drivers/md/md-cluster.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 5d04b32ce088..f53e3a62c4e2 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -2131,11 +2131,10 @@ static int bitmap_copy_from_slot(struct mddev *mddev, int slot, sector_t *low,
return rv;
}
-void md_bitmap_set_pages(struct bitmap *bitmap, unsigned long pages)
+static void bitmap_set_pages(struct bitmap *bitmap, unsigned long pages)
{
bitmap->counts.pages = pages;
}
-EXPORT_SYMBOL_GPL(md_bitmap_set_pages);
static int bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
{
@@ -2771,6 +2770,7 @@ static struct bitmap_operations bitmap_ops = {
.sync_with_cluster = bitmap_sync_with_cluster,
.get_from_slot = bitmap_get_from_slot,
.copy_from_slot = bitmap_copy_from_slot,
+ .set_pages = bitmap_set_pages,
};
void mddev_set_bitmap_ops(struct mddev *mddev)
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index 1dbc78b9172b..d5bbadc1f6fd 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -278,6 +278,7 @@ struct bitmap_operations {
struct bitmap *(*get_from_slot)(struct mddev *mddev, int slot);
int (*copy_from_slot)(struct mddev *mddev, int slot, sector_t *lo,
sector_t *hi, bool clear_bits);
+ void (*set_pages)(struct bitmap *bitmap, unsigned long pages);
};
/* the bitmap API */
@@ -285,7 +286,6 @@ void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are exported */
-void md_bitmap_set_pages(struct bitmap *bitmap, unsigned long pages);
void md_bitmap_free(struct bitmap *bitmap);
void md_bitmap_wait_behind_writes(struct mddev *mddev);
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index 201a4b12c2fe..64a4ccbe68c0 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -1191,7 +1191,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
bm_lockres->flags |= DLM_LKF_NOQUEUE;
rv = dlm_lock_sync(bm_lockres, DLM_LOCK_PW);
if (!rv)
- md_bitmap_set_pages(bitmap, my_pages);
+ mddev->bitmap_ops->set_pages(bitmap, my_pages);
lockres_free(bm_lockres);
if (my_pages != stats.pages)
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 38/41] md/md-bitmap: merge md_bitmap_free() into bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (36 preceding siblings ...)
2024-08-14 7:11 ` [PATCH RFC -next v2 37/41] md/md-bitmap: merge md_bitmap_set_pages() into struct bitmap_operations Yu Kuai
@ 2024-08-14 7:11 ` Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 39/41] md/md-bitmap: merge md_bitmap_wait_behind_writes() " Yu Kuai
` (3 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:11 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
So that the implementation won't be exposed, and it'll be possible
o invent a new bitmap by replacing bitmap_operations.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 7 ++-----
drivers/md/md-bitmap.h | 3 +--
drivers/md/md-cluster.c | 12 ++++++------
3 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index f53e3a62c4e2..eb7c5e552acf 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1828,10 +1828,7 @@ static void bitmap_flush(struct mddev *mddev)
bitmap_update_sb(bitmap);
}
-/*
- * free memory that was allocated
- */
-void md_bitmap_free(struct bitmap *bitmap)
+static void md_bitmap_free(struct bitmap *bitmap)
{
unsigned long k, pages;
struct bitmap_page *bp;
@@ -1865,7 +1862,6 @@ void md_bitmap_free(struct bitmap *bitmap)
kfree(bp);
kfree(bitmap);
}
-EXPORT_SYMBOL(md_bitmap_free);
void md_bitmap_wait_behind_writes(struct mddev *mddev)
{
@@ -2771,6 +2767,7 @@ static struct bitmap_operations bitmap_ops = {
.get_from_slot = bitmap_get_from_slot,
.copy_from_slot = bitmap_copy_from_slot,
.set_pages = bitmap_set_pages,
+ .free = md_bitmap_free,
};
void mddev_set_bitmap_ops(struct mddev *mddev)
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index d5bbadc1f6fd..d0037665a4dc 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -279,14 +279,13 @@ struct bitmap_operations {
int (*copy_from_slot)(struct mddev *mddev, int slot, sector_t *lo,
sector_t *hi, bool clear_bits);
void (*set_pages)(struct bitmap *bitmap, unsigned long pages);
+ void (*free)(struct bitmap *bitmap);
};
/* the bitmap API */
void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are exported */
-
-void md_bitmap_free(struct bitmap *bitmap);
void md_bitmap_wait_behind_writes(struct mddev *mddev);
static inline u64 md_bitmap_events_cleared(struct mddev *mddev)
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index 64a4ccbe68c0..da94f7251da7 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -1200,12 +1200,12 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
* can't resize bitmap
*/
goto out;
- md_bitmap_free(bitmap);
+ mddev->bitmap_ops->free(bitmap);
}
return 0;
out:
- md_bitmap_free(bitmap);
+ mddev->bitmap_ops->free(bitmap);
update_bitmap_size(mddev, oldsize);
return -1;
}
@@ -1248,7 +1248,7 @@ static int cluster_check_sync_size(struct mddev *mddev)
bm_lockres = lockres_init(mddev, str, NULL, 1);
if (!bm_lockres) {
pr_err("md-cluster: Cannot initialize %s\n", str);
- md_bitmap_free(bitmap);
+ mddev->bitmap_ops->free(bitmap);
return -1;
}
bm_lockres->flags |= DLM_LKF_NOQUEUE;
@@ -1259,17 +1259,17 @@ static int cluster_check_sync_size(struct mddev *mddev)
rv = mddev->bitmap_ops->get_stats(bitmap, &stats);
if (rv) {
- md_bitmap_free(bitmap);
+ mddev->bitmap_ops->free(bitmap);
return rv;
}
if (sync_size == 0) {
sync_size = stats.sync_size;
} else if (sync_size != stats.sync_size) {
- md_bitmap_free(bitmap);
+ mddev->bitmap_ops->free(bitmap);
return -1;
}
- md_bitmap_free(bitmap);
+ mddev->bitmap_ops->free(bitmap);
}
return (my_sync_size == sync_size) ? 0 : -1;
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 39/41] md/md-bitmap: merge md_bitmap_wait_behind_writes() into bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (37 preceding siblings ...)
2024-08-14 7:11 ` [PATCH RFC -next v2 38/41] md/md-bitmap: merge md_bitmap_free() into bitmap_operations Yu Kuai
@ 2024-08-14 7:11 ` Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 40/41] md/md-bitmap: merge md_bitmap_enabled() " Yu Kuai
` (2 subsequent siblings)
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:11 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
So that the implementation won't be exposed, and it'll be possible
to invent a new bitmap by replacing bitmap_operations.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 6 +++---
drivers/md/md-bitmap.h | 4 +---
drivers/md/md.c | 2 +-
drivers/md/raid1.c | 2 +-
4 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index eb7c5e552acf..c6826cb28ed2 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1863,7 +1863,7 @@ static void md_bitmap_free(struct bitmap *bitmap)
kfree(bitmap);
}
-void md_bitmap_wait_behind_writes(struct mddev *mddev)
+static void bitmap_wait_behind_writes(struct mddev *mddev)
{
struct bitmap *bitmap = mddev->bitmap;
@@ -1876,7 +1876,6 @@ void md_bitmap_wait_behind_writes(struct mddev *mddev)
atomic_read(&bitmap->behind_writes) == 0);
}
}
-EXPORT_SYMBOL_GPL(md_bitmap_wait_behind_writes);
static void bitmap_destroy(struct mddev *mddev)
{
@@ -1885,7 +1884,7 @@ static void bitmap_destroy(struct mddev *mddev)
if (!bitmap) /* there was no bitmap */
return;
- md_bitmap_wait_behind_writes(mddev);
+ bitmap_wait_behind_writes(mddev);
if (!mddev->serialize_policy)
mddev_destroy_serial_pool(mddev, NULL);
@@ -2752,6 +2751,7 @@ static struct bitmap_operations bitmap_ops = {
.dirty_bits = bitmap_dirty_bits,
.unplug = bitmap_unplug,
.daemon_work = bitmap_daemon_work,
+ .wait_behind_writes = bitmap_wait_behind_writes,
.startwrite = bitmap_startwrite,
.endwrite = bitmap_endwrite,
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index d0037665a4dc..b232ac57c0dc 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -258,6 +258,7 @@ struct bitmap_operations {
unsigned long e);
void (*unplug)(struct mddev *mddev, bool sync);
void (*daemon_work)(struct mddev *mddev);
+ void (*wait_behind_writes)(struct mddev *mddev);
int (*startwrite)(struct mddev *mddev, sector_t offset,
unsigned long sectors, bool behind);
@@ -285,9 +286,6 @@ struct bitmap_operations {
/* the bitmap API */
void mddev_set_bitmap_ops(struct mddev *mddev);
-/* these are exported */
-void md_bitmap_wait_behind_writes(struct mddev *mddev);
-
static inline u64 md_bitmap_events_cleared(struct mddev *mddev)
{
struct md_bitmap_stats stats;
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 4bdfe23a565d..6800888152d0 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6484,7 +6484,7 @@ EXPORT_SYMBOL_GPL(md_stop_writes);
static void mddev_detach(struct mddev *mddev)
{
- md_bitmap_wait_behind_writes(mddev);
+ mddev->bitmap_ops->wait_behind_writes(mddev);
if (mddev->pers && mddev->pers->quiesce && !is_md_suspended(mddev)) {
mddev->pers->quiesce(mddev, 1);
mddev->pers->quiesce(mddev, 0);
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index e285f01e3ef6..17b1965fec56 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1384,7 +1384,7 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,
* over-take any writes that are 'behind'
*/
mddev_add_trace_msg(mddev, "raid1 wait behind writes");
- md_bitmap_wait_behind_writes(mddev);
+ mddev->bitmap_ops->wait_behind_writes(mddev);
}
if (max_sectors < bio_sectors(bio)) {
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 40/41] md/md-bitmap: merge md_bitmap_enabled() into bitmap_operations
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (38 preceding siblings ...)
2024-08-14 7:11 ` [PATCH RFC -next v2 39/41] md/md-bitmap: merge md_bitmap_wait_behind_writes() " Yu Kuai
@ 2024-08-14 7:11 ` Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 41/41] md/md-bitmap: make in memory structure internal Yu Kuai
2024-08-19 8:18 ` [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Su Yue
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:11 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
So that the implementation won't be exposed, and it'll be possible
to invent a new bitmap by replacing bitmap_operations.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 19 ++++++++++++++++++-
drivers/md/md-bitmap.h | 8 +-------
drivers/md/raid1-10.c | 2 +-
3 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index c6826cb28ed2..8b9f0560f02f 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -40,6 +40,22 @@ static inline char *bmname(struct bitmap *bitmap)
return bitmap->mddev ? mdname(bitmap->mddev) : "mdX";
}
+static bool __bitmap_enabled(struct bitmap *bitmap)
+{
+ return bitmap->storage.filemap &&
+ !test_bit(BITMAP_STALE, &bitmap->flags);
+}
+
+static bool bitmap_enabled(struct mddev *mddev)
+{
+ struct bitmap *bitmap = mddev->bitmap;
+
+ if (!bitmap)
+ return false;
+
+ return __bitmap_enabled(bitmap);
+}
+
/*
* check a page and, if necessary, allocate it (or hijack it if the alloc fails)
*
@@ -1035,7 +1051,7 @@ static void __bitmap_unplug(struct bitmap *bitmap)
int dirty, need_write;
int writing = 0;
- if (!md_bitmap_enabled(bitmap))
+ if (!__bitmap_enabled(bitmap))
return;
/* look at each page to see if there are any set bits that need to be
@@ -2742,6 +2758,7 @@ const struct attribute_group md_bitmap_group = {
};
static struct bitmap_operations bitmap_ops = {
+ .enabled = bitmap_enabled,
.create = bitmap_create,
.resize = bitmap_resize,
.load = bitmap_load,
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index b232ac57c0dc..364e00833aef 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -246,6 +246,7 @@ struct md_bitmap_stats {
};
struct bitmap_operations {
+ bool (*enabled)(struct mddev *mddev);
int (*create)(struct mddev *mddev, int slot);
int (*resize)(struct mddev *mddev, sector_t blocks, int chunksize,
bool init);
@@ -297,12 +298,5 @@ static inline u64 md_bitmap_events_cleared(struct mddev *mddev)
return stats.events_cleared;
}
-static inline bool md_bitmap_enabled(struct bitmap *bitmap)
-{
- return bitmap && bitmap->storage.filemap &&
- !test_bit(BITMAP_STALE, &bitmap->flags);
-}
-
#endif
-
#endif
diff --git a/drivers/md/raid1-10.c b/drivers/md/raid1-10.c
index e8207513eb1b..4378d3250bd7 100644
--- a/drivers/md/raid1-10.c
+++ b/drivers/md/raid1-10.c
@@ -140,7 +140,7 @@ static inline bool raid1_add_bio_to_plug(struct mddev *mddev, struct bio *bio,
* 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)) {
+ if (!mddev->bitmap_ops->enabled(mddev)) {
raid1_submit_write(bio);
return true;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* [PATCH RFC -next v2 41/41] md/md-bitmap: make in memory structure internal
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (39 preceding siblings ...)
2024-08-14 7:11 ` [PATCH RFC -next v2 40/41] md/md-bitmap: merge md_bitmap_enabled() " Yu Kuai
@ 2024-08-14 7:11 ` Yu Kuai
2024-08-19 8:18 ` [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Su Yue
41 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-14 7:11 UTC (permalink / raw)
To: mariusz.tkaczyk, hch, song
Cc: linux-kernel, linux-raid, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
Now that struct btimap_page and bitmap is not used external anymore,
move them from md-bitmap.h to md-bitmap.c.(expect that dm-raid is still
using define marco 'COUNTER_MAX').
Also fix some checkpatch warnings.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md-bitmap.c | 247 ++++++++++++++++++++++++++++++++++++----
drivers/md/md-bitmap.h | 189 +-----------------------------
drivers/md/md-cluster.c | 4 +-
drivers/md/md.c | 2 +-
drivers/md/md.h | 2 +-
drivers/md/raid1.c | 6 +-
6 files changed, 237 insertions(+), 213 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 8b9f0560f02f..0aee595f5c79 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -32,6 +32,186 @@
#include "md.h"
#include "md-bitmap.h"
+#define BITMAP_MAJOR_LO 3
+/* version 4 insists the bitmap is in little-endian order
+ * with version 3, it is host-endian which is non-portable
+ * Version 5 is currently set only for clustered devices
+ */
+#define BITMAP_MAJOR_HI 4
+#define BITMAP_MAJOR_CLUSTERED 5
+#define BITMAP_MAJOR_HOSTENDIAN 3
+
+/*
+ * in-memory bitmap:
+ *
+ * Use 16 bit block counters to track pending writes to each "chunk".
+ * The 2 high order bits are special-purpose, the first is a flag indicating
+ * whether a resync is needed. The second is a flag indicating whether a
+ * resync is active.
+ * This means that the counter is actually 14 bits:
+ *
+ * +--------+--------+------------------------------------------------+
+ * | resync | resync | counter |
+ * | needed | active | |
+ * | (0-1) | (0-1) | (0-16383) |
+ * +--------+--------+------------------------------------------------+
+ *
+ * The "resync needed" bit is set when:
+ * a '1' bit is read from storage at startup.
+ * a write request fails on some drives
+ * a resync is aborted on a chunk with 'resync active' set
+ * It is cleared (and resync-active set) when a resync starts across all drives
+ * of the chunk.
+ *
+ *
+ * The "resync active" bit is set when:
+ * a resync is started on all drives, and resync_needed is set.
+ * resync_needed will be cleared (as long as resync_active wasn't already set).
+ * It is cleared when a resync completes.
+ *
+ * The counter counts pending write requests, plus the on-disk bit.
+ * When the counter is '1' and the resync bits are clear, the on-disk
+ * bit can be cleared as well, thus setting the counter to 0.
+ * When we set a bit, or in the counter (to start a write), if the fields is
+ * 0, we first set the disk bit and set the counter to 1.
+ *
+ * If the counter is 0, the on-disk bit is clear and the stripe is clean
+ * Anything that dirties the stripe pushes the counter to 2 (at least)
+ * and sets the on-disk bit (lazily).
+ * If a periodic sweep find the counter at 2, it is decremented to 1.
+ * If the sweep find the counter at 1, the on-disk bit is cleared and the
+ * counter goes to zero.
+ *
+ * Also, we'll hijack the "map" pointer itself and use it as two 16 bit block
+ * counters as a fallback when "page" memory cannot be allocated:
+ *
+ * Normal case (page memory allocated):
+ *
+ * page pointer (32-bit)
+ *
+ * [ ] ------+
+ * |
+ * +-------> [ ][ ]..[ ] (4096 byte page == 2048 counters)
+ * c1 c2 c2048
+ *
+ * Hijacked case (page memory allocation failed):
+ *
+ * hijacked page pointer (32-bit)
+ *
+ * [ ][ ] (no page memory allocated)
+ * counter #1 (16-bit) counter #2 (16-bit)
+ *
+ */
+
+#define PAGE_BITS (PAGE_SIZE << 3)
+#define PAGE_BIT_SHIFT (PAGE_SHIFT + 3)
+
+#define NEEDED(x) (((bitmap_counter_t) x) & NEEDED_MASK)
+#define RESYNC(x) (((bitmap_counter_t) x) & RESYNC_MASK)
+#define COUNTER(x) (((bitmap_counter_t) x) & COUNTER_MAX)
+
+/* how many counters per page? */
+#define PAGE_COUNTER_RATIO (PAGE_BITS / COUNTER_BITS)
+/* same, except a shift value for more efficient bitops */
+#define PAGE_COUNTER_SHIFT (PAGE_BIT_SHIFT - COUNTER_BIT_SHIFT)
+/* same, except a mask value for more efficient bitops */
+#define PAGE_COUNTER_MASK (PAGE_COUNTER_RATIO - 1)
+
+#define BITMAP_BLOCK_SHIFT 9
+
+/*
+ * bitmap structures:
+ */
+
+/* the in-memory bitmap is represented by bitmap_pages */
+struct bitmap_page {
+ /*
+ * map points to the actual memory page
+ */
+ char *map;
+ /*
+ * in emergencies (when map cannot be alloced), hijack the map
+ * pointer and use it as two counters itself
+ */
+ unsigned int hijacked:1;
+ /*
+ * If any counter in this page is '1' or '2' - and so could be
+ * cleared then that page is marked as 'pending'
+ */
+ unsigned int pending:1;
+ /*
+ * count of dirty bits on the page
+ */
+ unsigned int count:30;
+};
+
+/* the main bitmap structure - one per mddev */
+struct bitmap {
+
+ struct bitmap_counts {
+ spinlock_t lock;
+ struct bitmap_page *bp;
+ /* total number of pages in the bitmap */
+ unsigned long pages;
+ /* number of pages not yet allocated */
+ unsigned long missing_pages;
+ /* chunksize = 2^chunkshift (for bitops) */
+ unsigned long chunkshift;
+ /* total number of data chunks for the array */
+ unsigned long chunks;
+ } counts;
+
+ struct mddev *mddev; /* the md device that the bitmap is for */
+
+ __u64 events_cleared;
+ int need_sync;
+
+ struct bitmap_storage {
+ /* backing disk file */
+ struct file *file;
+ /* cached copy of the bitmap file superblock */
+ struct page *sb_page;
+ unsigned long sb_index;
+ /* list of cache pages for the file */
+ struct page **filemap;
+ /* attributes associated filemap pages */
+ unsigned long *filemap_attr;
+ /* number of pages in the file */
+ unsigned long file_pages;
+ /* total bytes in the bitmap */
+ unsigned long bytes;
+ } storage;
+
+ unsigned long flags;
+
+ int allclean;
+
+ atomic_t behind_writes;
+ /* highest actual value at runtime */
+ unsigned long behind_writes_used;
+
+ /*
+ * the bitmap daemon - periodically wakes up and sweeps the bitmap
+ * file, cleaning up bits and flushing out pages to disk as necessary
+ */
+ unsigned long daemon_lastrun; /* jiffies of last run */
+ /*
+ * when we lasted called end_sync to update bitmap with resync
+ * progress.
+ */
+ unsigned long last_end_sync;
+
+ /* pending writes to the bitmap file */
+ atomic_t pending_writes;
+ wait_queue_head_t write_wait;
+ wait_queue_head_t overflow_wait;
+ wait_queue_head_t behind_wait;
+
+ struct kernfs_node *sysfs_can_clear;
+ /* slot offset for clustered env */
+ int cluster_slot;
+};
+
static int bitmap_resize(struct mddev *mddev, sector_t blocks, int chunksize,
bool init);
@@ -491,9 +671,10 @@ static void md_bitmap_wait_writes(struct bitmap *bitmap)
/* update the event counter and sync the superblock to disk */
-static void bitmap_update_sb(struct bitmap *bitmap)
+static void bitmap_update_sb(void *data)
{
bitmap_super_t *sb;
+ struct bitmap *bitmap = data;
if (!bitmap || !bitmap->mddev) /* no bitmap for this array */
return;
@@ -1844,10 +2025,11 @@ static void bitmap_flush(struct mddev *mddev)
bitmap_update_sb(bitmap);
}
-static void md_bitmap_free(struct bitmap *bitmap)
+static void md_bitmap_free(void *data)
{
unsigned long k, pages;
struct bitmap_page *bp;
+ struct bitmap *bitmap = data;
if (!bitmap) /* there was no bitmap */
return;
@@ -2075,7 +2257,7 @@ static int bitmap_load(struct mddev *mddev)
}
/* caller need to free returned bitmap with md_bitmap_free() */
-static struct bitmap *bitmap_get_from_slot(struct mddev *mddev, int slot)
+static void *bitmap_get_from_slot(struct mddev *mddev, int slot)
{
int rv = 0;
struct bitmap *bitmap;
@@ -2142,15 +2324,18 @@ static int bitmap_copy_from_slot(struct mddev *mddev, int slot, sector_t *low,
return rv;
}
-static void bitmap_set_pages(struct bitmap *bitmap, unsigned long pages)
+static void bitmap_set_pages(void *data, unsigned long pages)
{
+ struct bitmap *bitmap = data;
+
bitmap->counts.pages = pages;
}
-static int bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
+static int bitmap_get_stats(void *data, struct md_bitmap_stats *stats)
{
bitmap_super_t *sb;
struct bitmap_counts *counts;
+ struct bitmap *bitmap = data;
if (!bitmap)
return -ENOENT;
@@ -2499,6 +2684,7 @@ space_show(struct mddev *mddev, char *page)
static ssize_t
space_store(struct mddev *mddev, const char *buf, size_t len)
{
+ struct bitmap *bitmap;
unsigned long sectors;
int rv;
@@ -2509,8 +2695,8 @@ space_store(struct mddev *mddev, const char *buf, size_t len)
if (sectors == 0)
return -EINVAL;
- if (mddev->bitmap &&
- sectors < (mddev->bitmap->storage.bytes + 511) >> 9)
+ bitmap = mddev->bitmap;
+ if (bitmap && sectors < (bitmap->storage.bytes + 511) >> 9)
return -EFBIG; /* Bitmap is too big for this small space */
/* could make sure it isn't too big, but that isn't really
@@ -2687,10 +2873,13 @@ __ATTR(metadata, S_IRUGO|S_IWUSR, metadata_show, metadata_store);
static ssize_t can_clear_show(struct mddev *mddev, char *page)
{
int len;
+ struct bitmap *bitmap;
+
spin_lock(&mddev->lock);
- if (mddev->bitmap)
- len = sprintf(page, "%s\n", (mddev->bitmap->need_sync ?
- "false" : "true"));
+ bitmap = mddev->bitmap;
+ if (bitmap)
+ len = sprintf(page, "%s\n", (bitmap->need_sync ? "false" :
+ "true"));
else
len = sprintf(page, "\n");
spin_unlock(&mddev->lock);
@@ -2699,17 +2888,24 @@ static ssize_t can_clear_show(struct mddev *mddev, char *page)
static ssize_t can_clear_store(struct mddev *mddev, const char *buf, size_t len)
{
- if (mddev->bitmap == NULL)
+ struct bitmap *bitmap = mddev->bitmap;
+
+ if (!bitmap)
return -ENOENT;
- if (strncmp(buf, "false", 5) == 0)
- mddev->bitmap->need_sync = 1;
- else if (strncmp(buf, "true", 4) == 0) {
+
+ if (strncmp(buf, "false", 5) == 0) {
+ bitmap->need_sync = 1;
+ return len;
+ }
+
+ if (strncmp(buf, "true", 4) == 0) {
if (mddev->degraded)
return -EBUSY;
- mddev->bitmap->need_sync = 0;
- } else
- return -EINVAL;
- return len;
+ bitmap->need_sync = 0;
+ return len;
+ }
+
+ return -EINVAL;
}
static struct md_sysfs_entry bitmap_can_clear =
@@ -2719,21 +2915,26 @@ static ssize_t
behind_writes_used_show(struct mddev *mddev, char *page)
{
ssize_t ret;
+ struct bitmap *bitmap;
+
spin_lock(&mddev->lock);
- if (mddev->bitmap == NULL)
+ bitmap = mddev->bitmap;
+ if (!bitmap)
ret = sprintf(page, "0\n");
else
- ret = sprintf(page, "%lu\n",
- mddev->bitmap->behind_writes_used);
+ ret = sprintf(page, "%lu\n", bitmap->behind_writes_used);
spin_unlock(&mddev->lock);
+
return ret;
}
static ssize_t
behind_writes_used_reset(struct mddev *mddev, const char *buf, size_t len)
{
- if (mddev->bitmap)
- mddev->bitmap->behind_writes_used = 0;
+ struct bitmap *bitmap = mddev->bitmap;
+
+ if (bitmap)
+ bitmap->behind_writes_used = 0;
return len;
}
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index 364e00833aef..06c46b4e58f4 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -7,81 +7,7 @@
#ifndef BITMAP_H
#define BITMAP_H 1
-#define BITMAP_MAJOR_LO 3
-/* version 4 insists the bitmap is in little-endian order
- * with version 3, it is host-endian which is non-portable
- * Version 5 is currently set only for clustered devices
- */
-#define BITMAP_MAJOR_HI 4
-#define BITMAP_MAJOR_CLUSTERED 5
-#define BITMAP_MAJOR_HOSTENDIAN 3
-
-/*
- * in-memory bitmap:
- *
- * Use 16 bit block counters to track pending writes to each "chunk".
- * The 2 high order bits are special-purpose, the first is a flag indicating
- * whether a resync is needed. The second is a flag indicating whether a
- * resync is active.
- * This means that the counter is actually 14 bits:
- *
- * +--------+--------+------------------------------------------------+
- * | resync | resync | counter |
- * | needed | active | |
- * | (0-1) | (0-1) | (0-16383) |
- * +--------+--------+------------------------------------------------+
- *
- * The "resync needed" bit is set when:
- * a '1' bit is read from storage at startup.
- * a write request fails on some drives
- * a resync is aborted on a chunk with 'resync active' set
- * It is cleared (and resync-active set) when a resync starts across all drives
- * of the chunk.
- *
- *
- * The "resync active" bit is set when:
- * a resync is started on all drives, and resync_needed is set.
- * resync_needed will be cleared (as long as resync_active wasn't already set).
- * It is cleared when a resync completes.
- *
- * The counter counts pending write requests, plus the on-disk bit.
- * When the counter is '1' and the resync bits are clear, the on-disk
- * bit can be cleared as well, thus setting the counter to 0.
- * When we set a bit, or in the counter (to start a write), if the fields is
- * 0, we first set the disk bit and set the counter to 1.
- *
- * If the counter is 0, the on-disk bit is clear and the stripe is clean
- * Anything that dirties the stripe pushes the counter to 2 (at least)
- * and sets the on-disk bit (lazily).
- * If a periodic sweep find the counter at 2, it is decremented to 1.
- * If the sweep find the counter at 1, the on-disk bit is cleared and the
- * counter goes to zero.
- *
- * Also, we'll hijack the "map" pointer itself and use it as two 16 bit block
- * counters as a fallback when "page" memory cannot be allocated:
- *
- * Normal case (page memory allocated):
- *
- * page pointer (32-bit)
- *
- * [ ] ------+
- * |
- * +-------> [ ][ ]..[ ] (4096 byte page == 2048 counters)
- * c1 c2 c2048
- *
- * Hijacked case (page memory allocation failed):
- *
- * hijacked page pointer (32-bit)
- *
- * [ ][ ] (no page memory allocated)
- * counter #1 (16-bit) counter #2 (16-bit)
- *
- */
-
-#ifdef __KERNEL__
-
-#define PAGE_BITS (PAGE_SIZE << 3)
-#define PAGE_BIT_SHIFT (PAGE_SHIFT + 3)
+#define BITMAP_MAGIC 0x6d746962
typedef __u16 bitmap_counter_t;
#define COUNTER_BITS 16
@@ -91,26 +17,6 @@ typedef __u16 bitmap_counter_t;
#define NEEDED_MASK ((bitmap_counter_t) (1 << (COUNTER_BITS - 1)))
#define RESYNC_MASK ((bitmap_counter_t) (1 << (COUNTER_BITS - 2)))
#define COUNTER_MAX ((bitmap_counter_t) RESYNC_MASK - 1)
-#define NEEDED(x) (((bitmap_counter_t) x) & NEEDED_MASK)
-#define RESYNC(x) (((bitmap_counter_t) x) & RESYNC_MASK)
-#define COUNTER(x) (((bitmap_counter_t) x) & COUNTER_MAX)
-
-/* how many counters per page? */
-#define PAGE_COUNTER_RATIO (PAGE_BITS / COUNTER_BITS)
-/* same, except a shift value for more efficient bitops */
-#define PAGE_COUNTER_SHIFT (PAGE_BIT_SHIFT - COUNTER_BIT_SHIFT)
-/* same, except a mask value for more efficient bitops */
-#define PAGE_COUNTER_MASK (PAGE_COUNTER_RATIO - 1)
-
-#define BITMAP_BLOCK_SHIFT 9
-
-#endif
-
-/*
- * bitmap structures:
- */
-
-#define BITMAP_MAGIC 0x6d746962
/* use these for bitmap->flags and bitmap->sb->state bit-fields */
enum bitmap_state {
@@ -152,88 +58,6 @@ typedef struct bitmap_super_s {
* devices. For raid10 it is the size of the array.
*/
-#ifdef __KERNEL__
-
-/* the in-memory bitmap is represented by bitmap_pages */
-struct bitmap_page {
- /*
- * map points to the actual memory page
- */
- char *map;
- /*
- * in emergencies (when map cannot be alloced), hijack the map
- * pointer and use it as two counters itself
- */
- unsigned int hijacked:1;
- /*
- * If any counter in this page is '1' or '2' - and so could be
- * cleared then that page is marked as 'pending'
- */
- unsigned int pending:1;
- /*
- * count of dirty bits on the page
- */
- unsigned int count:30;
-};
-
-/* the main bitmap structure - one per mddev */
-struct bitmap {
-
- struct bitmap_counts {
- spinlock_t lock;
- struct bitmap_page *bp;
- unsigned long pages; /* total number of pages
- * in the bitmap */
- unsigned long missing_pages; /* number of pages
- * not yet allocated */
- unsigned long chunkshift; /* chunksize = 2^chunkshift
- * (for bitops) */
- unsigned long chunks; /* Total number of data
- * chunks for the array */
- } counts;
-
- struct mddev *mddev; /* the md device that the bitmap is for */
-
- __u64 events_cleared;
- int need_sync;
-
- struct bitmap_storage {
- struct file *file; /* backing disk file */
- struct page *sb_page; /* cached copy of the bitmap
- * file superblock */
- unsigned long sb_index;
- struct page **filemap; /* list of cache pages for
- * the file */
- unsigned long *filemap_attr; /* attributes associated
- * w/ filemap pages */
- unsigned long file_pages; /* number of pages in the file*/
- unsigned long bytes; /* total bytes in the bitmap */
- } storage;
-
- unsigned long flags;
-
- int allclean;
-
- atomic_t behind_writes;
- unsigned long behind_writes_used; /* highest actual value at runtime */
-
- /*
- * the bitmap daemon - periodically wakes up and sweeps the bitmap
- * file, cleaning up bits and flushing out pages to disk as necessary
- */
- unsigned long daemon_lastrun; /* jiffies of last run */
- unsigned long last_end_sync; /* when we lasted called end_sync to
- * update bitmap with resync progress */
-
- atomic_t pending_writes; /* pending writes to the bitmap file */
- wait_queue_head_t write_wait;
- wait_queue_head_t overflow_wait;
- wait_queue_head_t behind_wait;
-
- struct kernfs_node *sysfs_can_clear;
- int cluster_slot; /* Slot offset for clustered env */
-};
-
struct md_bitmap_stats {
unsigned long pages;
unsigned long missing_pages;
@@ -271,17 +95,17 @@ struct bitmap_operations {
void (*cond_end_sync)(struct mddev *mddev, sector_t sector, bool force);
void (*close_sync)(struct mddev *mddev);
- void (*update_sb)(struct bitmap *bitmap);
- int (*get_stats)(struct bitmap *bitmap, struct md_bitmap_stats *stats);
+ void (*update_sb)(void *data);
+ int (*get_stats)(void *data, struct md_bitmap_stats *stats);
void (*sync_with_cluster)(struct mddev *mddev,
sector_t old_lo, sector_t old_hi,
sector_t new_lo, sector_t new_hi);
- struct bitmap *(*get_from_slot)(struct mddev *mddev, int slot);
+ void *(*get_from_slot)(struct mddev *mddev, int slot);
int (*copy_from_slot)(struct mddev *mddev, int slot, sector_t *lo,
sector_t *hi, bool clear_bits);
- void (*set_pages)(struct bitmap *bitmap, unsigned long pages);
- void (*free)(struct bitmap *bitmap);
+ void (*set_pages)(void *data, unsigned long pages);
+ void (*free)(void *data);
};
/* the bitmap API */
@@ -299,4 +123,3 @@ static inline u64 md_bitmap_events_cleared(struct mddev *mddev)
}
#endif
-#endif
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index da94f7251da7..eadefa24b8cc 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -1145,7 +1145,7 @@ static int update_bitmap_size(struct mddev *mddev, sector_t size)
static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsize)
{
struct dlm_lock_resource *bm_lockres;
- struct bitmap *bitmap = mddev->bitmap;
+ void *bitmap = mddev->bitmap;
struct md_bitmap_stats stats;
unsigned long my_pages;
char str[64];
@@ -1219,7 +1219,7 @@ static int cluster_check_sync_size(struct mddev *mddev)
unsigned long my_sync_size, sync_size = 0;
int node_num = mddev->bitmap_info.nodes;
int current_slot = md_cluster_ops->slot_number(mddev);
- struct bitmap *bitmap = mddev->bitmap;
+ void *bitmap = mddev->bitmap;
char str[64];
struct dlm_lock_resource *bm_lockres;
struct md_bitmap_stats stats;
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 6800888152d0..3ba45c41dc0e 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2324,7 +2324,7 @@ super_1_allow_new_offset(struct md_rdev *rdev,
unsigned long long new_offset)
{
/* All necessary checks on new >= old have been done */
- struct bitmap *bitmap = rdev->mddev->bitmap;
+ void *bitmap = rdev->mddev->bitmap;
struct md_bitmap_stats stats;
int err;
diff --git a/drivers/md/md.h b/drivers/md/md.h
index e56193f71ab4..1c6a5f41adca 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -535,7 +535,7 @@ struct mddev {
struct percpu_ref writes_pending;
int sync_checkers; /* # of threads checking writes_pending */
- struct bitmap *bitmap; /* the bitmap for the device */
+ void *bitmap; /* the bitmap for the device */
struct bitmap_operations *bitmap_ops;
struct {
struct file *file; /* the bitmap file */
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 17b1965fec56..6651d44d8605 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1425,7 +1425,6 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
struct r1conf *conf = mddev->private;
struct r1bio *r1_bio;
int i, disks;
- struct bitmap *bitmap = mddev->bitmap;
unsigned long flags;
struct md_rdev *blocked_rdev;
int first_clone;
@@ -1578,7 +1577,7 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
* at a time and thus needs a new bio that can fit the whole payload
* this bio in page sized chunks.
*/
- if (write_behind && bitmap)
+ if (write_behind && mddev->bitmap)
max_sectors = min_t(int, max_sectors,
BIO_MAX_VECS * (PAGE_SIZE >> 9));
if (max_sectors < bio_sectors(bio)) {
@@ -1606,7 +1605,8 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
if (first_clone) {
struct md_bitmap_stats stats;
- int err = mddev->bitmap_ops->get_stats(bitmap, &stats);
+ int err = mddev->bitmap_ops->get_stats(mddev->bitmap,
+ &stats);
/* do behind I/O ?
* Not if there are too many, or cannot
--
2.39.2
^ permalink raw reply related [flat|nested] 47+ messages in thread
* Re: [PATCH RFC -next v2 05/41] md/md-bitmap: add 'sync_size' into struct md_bitmap_stats
2024-08-14 7:10 ` [PATCH RFC -next v2 05/41] md/md-bitmap: add 'sync_size' " Yu Kuai
@ 2024-08-14 12:52 ` Mariusz Tkaczyk
0 siblings, 0 replies; 47+ messages in thread
From: Mariusz Tkaczyk @ 2024-08-14 12:52 UTC (permalink / raw)
To: Yu Kuai; +Cc: hch, song, linux-kernel, linux-raid, yukuai3, yi.zhang, yangerkun
On Wed, 14 Aug 2024 15:10:37 +0800
Yu Kuai <yukuai1@huaweicloud.com> wrote:
> From: Yu Kuai <yukuai3@huawei.com>
>
> To avoid dereferencing bitmap directly in md-cluster to prepare
> inventing a new bitmap.
>
> BTW, also fix following checkpatch warnings:
>
> WARNING: Deprecated use of 'kmap_atomic', prefer 'kmap_local_page' instead
> WARNING: Deprecated use of 'kunmap_atomic', prefer 'kunmap_local' instead
>
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
> drivers/md/md-bitmap.c | 6 ++++++
> drivers/md/md-bitmap.h | 1 +
> drivers/md/md-cluster.c | 25 +++++++++++++++----------
> 3 files changed, 22 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
> index 8a2411040d2f..9ff5ed250ba5 100644
> --- a/drivers/md/md-bitmap.c
> +++ b/drivers/md/md-bitmap.c
> @@ -2096,11 +2096,16 @@ EXPORT_SYMBOL_GPL(md_bitmap_copy_from_slot);
>
> int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
> {
> + bitmap_super_t *sb;
> struct bitmap_counts *counts;
Hi Kuai,
Use reversed christmas tree convention if possible :)
> diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
> index c8527ba38dfc..1a7ad2cf9f75 100644
> --- a/drivers/md/md-bitmap.h
> +++ b/drivers/md/md-bitmap.h
> @@ -237,6 +237,7 @@ struct bitmap {
> struct md_bitmap_stats {
> unsigned long pages;
> unsigned long missing_pages;
> + unsigned long sync_size;
Same here.
Anyway, LGTM.
Mariusz
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH RFC -next v2 11/41] md/md-bitmap: simplify md_bitmap_create() + md_bitmap_load()
2024-08-14 7:10 ` [PATCH RFC -next v2 11/41] md/md-bitmap: simplify md_bitmap_create() + md_bitmap_load() Yu Kuai
@ 2024-08-19 8:10 ` Su Yue
2024-08-19 11:06 ` Yu Kuai
0 siblings, 1 reply; 47+ messages in thread
From: Su Yue @ 2024-08-19 8:10 UTC (permalink / raw)
To: Yu Kuai
Cc: mariusz.tkaczyk, hch, song, linux-kernel, linux-raid, yukuai3,
yi.zhang, yangerkun
On Wed 14 Aug 2024 at 15:10, Yu Kuai <yukuai1@huaweicloud.com>
wrote:
> From: Yu Kuai <yukuai3@huawei.com>
>
> Other than internal api get_bitmap_from_slot(), all other places
> will
> set returned bitmap to mddev->bitmap. So move the setting of
> mddev->bitmap into md_bitmap_create() to simplify code.
>
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
> drivers/md/md-bitmap.c | 23 +++++++++++++++--------
> drivers/md/md-bitmap.h | 2 +-
> drivers/md/md.c | 30 +++++++++---------------------
> 3 files changed, 25 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
> index eed3b930ade4..75e58da9a1a5 100644
> --- a/drivers/md/md-bitmap.c
> +++ b/drivers/md/md-bitmap.c
> @@ -1879,7 +1879,7 @@ void md_bitmap_destroy(struct mddev
> *mddev)
> * if this returns an error, bitmap_destroy must be called to
> do clean up
> * once mddev->bitmap is set
> */
> -struct bitmap *md_bitmap_create(struct mddev *mddev, int slot)
> +static struct bitmap *bitmap_create(struct mddev *mddev, int
> slot)
> {
> struct bitmap *bitmap;
> sector_t blocks = mddev->resync_max_sectors;
> @@ -1966,6 +1966,17 @@ struct bitmap *md_bitmap_create(struct
> mddev *mddev, int slot)
> return ERR_PTR(err);
> }
>
> +int md_bitmap_create(struct mddev *mddev, int slot)
>
NIT: We have two functions named md_bitmap_create() now. The
static
one will be renamed to __md_bitmap_create in next patch. Better to
rename
in this patch.
--
Su
> +{
> + struct bitmap *bitmap = bitmap_create(mddev, slot);
> +
> + if (IS_ERR(bitmap))
> + return PTR_ERR(bitmap);
> +
> + mddev->bitmap = bitmap;
> + return 0;
> +}
> +
> int md_bitmap_load(struct mddev *mddev)
> {
> int err = 0;
> @@ -2030,7 +2041,7 @@ struct bitmap *get_bitmap_from_slot(struct
> mddev *mddev, int slot)
> int rv = 0;
> struct bitmap *bitmap;
>
> - bitmap = md_bitmap_create(mddev, slot);
> + bitmap = bitmap_create(mddev, slot);
> if (IS_ERR(bitmap)) {
> rv = PTR_ERR(bitmap);
> return ERR_PTR(rv);
> @@ -2381,7 +2392,6 @@ location_store(struct mddev *mddev, const
> char *buf, size_t len)
> } else {
> /* No bitmap, OK to set a location */
> long long offset;
> - struct bitmap *bitmap;
>
> if (strncmp(buf, "none", 4) == 0)
> /* nothing to be done */;
> @@ -2408,13 +2418,10 @@ location_store(struct mddev *mddev,
> const char *buf, size_t len)
> }
>
> mddev->bitmap_info.offset = offset;
> - bitmap = md_bitmap_create(mddev, -1);
> - if (IS_ERR(bitmap)) {
> - rv = PTR_ERR(bitmap);
> + rv = md_bitmap_create(mddev, -1);
> + if (rv)
> goto out;
> - }
>
> - mddev->bitmap = bitmap;
> rv = md_bitmap_load(mddev);
> if (rv) {
> mddev->bitmap_info.offset = 0;
> diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
> index a8a5d4804174..e187f9099f2e 100644
> --- a/drivers/md/md-bitmap.h
> +++ b/drivers/md/md-bitmap.h
> @@ -252,7 +252,7 @@ struct bitmap_operations {
> void mddev_set_bitmap_ops(struct mddev *mddev);
>
> /* these are used only by md/bitmap */
> -struct bitmap *md_bitmap_create(struct mddev *mddev, int slot);
> +int md_bitmap_create(struct mddev *mddev, int slot);
> int md_bitmap_load(struct mddev *mddev);
> void md_bitmap_flush(struct mddev *mddev);
> void md_bitmap_destroy(struct mddev *mddev);
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index f67f2540fd6c..6e130f6c2abd 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -6211,16 +6211,10 @@ int md_run(struct mddev *mddev)
> }
> if (err == 0 && pers->sync_request &&
> (mddev->bitmap_info.file || mddev->bitmap_info.offset)) {
> - struct bitmap *bitmap;
> -
> - bitmap = md_bitmap_create(mddev, -1);
> - if (IS_ERR(bitmap)) {
> - err = PTR_ERR(bitmap);
> + err = md_bitmap_create(mddev, -1);
> + if (err)
> pr_warn("%s: failed to create bitmap (%d)\n",
> mdname(mddev), err);
> - } else
> - mddev->bitmap = bitmap;
> -
> }
> if (err)
> goto bitmap_abort;
> @@ -7275,14 +7269,10 @@ static int set_bitmap_file(struct mddev
> *mddev, int fd)
> err = 0;
> if (mddev->pers) {
> if (fd >= 0) {
> - struct bitmap *bitmap;
> -
> - bitmap = md_bitmap_create(mddev, -1);
> - if (!IS_ERR(bitmap)) {
> - mddev->bitmap = bitmap;
> + err = md_bitmap_create(mddev, -1);
> + if (!err)
> err = md_bitmap_load(mddev);
> - } else
> - err = PTR_ERR(bitmap);
> +
> if (err) {
> md_bitmap_destroy(mddev);
> fd = -1;
> @@ -7291,6 +7281,7 @@ static int set_bitmap_file(struct mddev
> *mddev, int fd)
> md_bitmap_destroy(mddev);
> }
> }
> +
> if (fd < 0) {
> struct file *f = mddev->bitmap_info.file;
> if (f) {
> @@ -7559,7 +7550,6 @@ static int update_array_info(struct mddev
> *mddev, mdu_array_info_t *info)
> goto err;
> }
> if (info->state & (1<<MD_SB_BITMAP_PRESENT)) {
> - struct bitmap *bitmap;
> /* add the bitmap */
> if (mddev->bitmap) {
> rv = -EEXIST;
> @@ -7573,12 +7563,10 @@ static int update_array_info(struct
> mddev *mddev, mdu_array_info_t *info)
> mddev->bitmap_info.default_offset;
> mddev->bitmap_info.space =
> mddev->bitmap_info.default_space;
> - bitmap = md_bitmap_create(mddev, -1);
> - if (!IS_ERR(bitmap)) {
> - mddev->bitmap = bitmap;
> + rv = md_bitmap_create(mddev, -1);
> + if (!rv)
> rv = md_bitmap_load(mddev);
> - } else
> - rv = PTR_ERR(bitmap);
> +
> if (rv)
> md_bitmap_destroy(mddev);
> } else {
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
` (40 preceding siblings ...)
2024-08-14 7:11 ` [PATCH RFC -next v2 41/41] md/md-bitmap: make in memory structure internal Yu Kuai
@ 2024-08-19 8:18 ` Su Yue
2024-08-19 11:13 ` Yu Kuai
41 siblings, 1 reply; 47+ messages in thread
From: Su Yue @ 2024-08-19 8:18 UTC (permalink / raw)
To: Yu Kuai
Cc: mariusz.tkaczyk, hch, song, linux-kernel, linux-raid, yukuai3,
yi.zhang, yangerkun
On Wed 14 Aug 2024 at 15:10, Yu Kuai <yukuai1@huaweicloud.com>
wrote:
> From: Yu Kuai <yukuai3@huawei.com>
>
> Changes in v2:
> - add patch 1-8 to prevent dereference bitmap directly, and the
> last
> patch to make bitmap structure internel.
> - use plain function alls "bitmap_ops->xxx()" directly;
>
> The background is that currently bitmap is using a global
> spin_lock,
> cauing lock contention and huge IO performance degration for all
> raid
> levels.
>
> However, it's impossible to implement a new lock free bitmap
> with
> current situation that md-bitmap exposes the internal
> implementation
> with lots of exported apis. Hence bitmap_operations is invented,
> to
> describe bitmap core implementation, and a new bitmap can be
> introduced
> with a new bitmap_operations, we only need to switch to the new
> one
> during initialization.
>
Is the new bitmap in plan?
>
> And with this we can build bitmap as kernel module, but that's
> not
> our concern for now.
>
> Noted I just compile this patchset, not tested yet.
>
I've looked through the patchset almostly. The changes are quite
straightforward. IMO, it's good timing to test it and drop RFC in
next
version.
> Yu Kuai (41):
> md/raid1: use md_bitmap_wait_behind_writes() in
> raid1_read_request()
> md/md-bitmap: replace md_bitmap_status() with a new helper
> md_bitmap_get_stats()
> md: use new helper md_bitmap_get_stats() in
> update_array_info()
> md/md-bitmap: add 'events_cleared' into struct md_bitmap_stats
> md/md-bitmap: add 'sync_size' into struct md_bitmap_stats
> md/md-bitmap: add 'file_pages' into struct md_bitmap_stats
> md/md-bitmap: add 'behind_writes' and 'behind_wait' into
> struct
> md_bitmap_stats
> md/md-cluster: use helper md_bitmap_get_stats() to get pages
> in
> resize_bitmaps()
> md/md-bitmap: add a new helper md_bitmap_set_pages()
> md/md-bitmap: introduce struct bitmap_operations
> md/md-bitmap: simplify md_bitmap_create() + md_bitmap_load()
> md/md-bitmap: merge md_bitmap_create() into bitmap_operations
> md/md-bitmap: merge md_bitmap_load() into bitmap_operations
> md/md-bitmap: merge md_bitmap_destroy() into bitmap_operations
> md/md-bitmap: merge md_bitmap_flush() into bitmap_operations
> md/md-bitmap: make md_bitmap_print_sb() internal
> md/md-bitmap: merge md_bitmap_update_sb() into
> bitmap_operations
> md/md-bitmap: merge md_bitmap_status() into bitmap_operations
> md/md-bitmap: remove md_bitmap_setallbits()
> md/md-bitmap: merge bitmap_write_all() into bitmap_operations
> md/md-bitmap: merge md_bitmap_dirty_bits() into
> bitmap_operations
> md/md-bitmap: merge md_bitmap_startwrite() into
> bitmap_operations
> md/md-bitmap: merge md_bitmap_endwrite() into
> bitmap_operations
> md/md-bitmap: merge md_bitmap_start_sync() into
> bitmap_operations
> md/md-bitmap: remove the parameter 'aborted' for
> md_bitmap_end_sync()
> md/md-bitmap: merge md_bitmap_end_sync() into
> bitmap_operations
> md/md-bitmap: merge md_bitmap_close_sync() into
> bitmap_operations
> md/md-bitmap: mrege md_bitmap_cond_end_sync() into
> bitmap_operations
> md/md-bitmap: merge md_bitmap_sync_with_cluster() into
> bitmap_operations
> md/md-bitmap: merge md_bitmap_unplug_async() into
> md_bitmap_unplug()
> md/md-bitmap: merge bitmap_unplug() into bitmap_operations
> md/md-bitmap: merge md_bitmap_daemon_work() into
> bitmap_operations
> md/md-bitmap: pass in mddev directly for md_bitmap_resize()
> md/md-bitmap: merge md_bitmap_resize() into bitmap_operations
> md/md-bitmap: merge get_bitmap_from_slot() into
> bitmap_operations
> md/md-bitmap: merge md_bitmap_copy_from_slot() into struct
> bitmap_operation.
> md/md-bitmap: merge md_bitmap_set_pages() into struct
> bitmap_operations
> md/md-bitmap: merge md_bitmap_free() into bitmap_operations
> md/md-bitmap: merge md_bitmap_wait_behind_writes() into
> bitmap_operations
> md/md-bitmap: merge md_bitmap_enabled() into bitmap_operations
> md/md-bitmap: make in memory structure internal
>
> drivers/md/dm-raid.c | 7 +-
> drivers/md/md-bitmap.c | 561
> +++++++++++++++++++++++++++++----------
> drivers/md/md-bitmap.h | 272 ++++---------------
> drivers/md/md-cluster.c | 79 +++---
> drivers/md/md.c | 133 ++++++----
> drivers/md/md.h | 3 +-
> drivers/md/raid1-10.c | 9 +-
> drivers/md/raid1.c | 78 +++---
> drivers/md/raid10.c | 73 ++---
> drivers/md/raid5-cache.c | 8 +-
> drivers/md/raid5.c | 62 ++---
> 11 files changed, 731 insertions(+), 554 deletions(-)
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH RFC -next v2 11/41] md/md-bitmap: simplify md_bitmap_create() + md_bitmap_load()
2024-08-19 8:10 ` Su Yue
@ 2024-08-19 11:06 ` Yu Kuai
0 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-19 11:06 UTC (permalink / raw)
To: Su Yue, Yu Kuai
Cc: mariusz.tkaczyk, hch, song, linux-kernel, linux-raid, yi.zhang,
yangerkun, yukuai (C)
Hi,
在 2024/08/19 16:10, Su Yue 写道:
>
> On Wed 14 Aug 2024 at 15:10, Yu Kuai <yukuai1@huaweicloud.com> wrote:
>
>> From: Yu Kuai <yukuai3@huawei.com>
>>
>> Other than internal api get_bitmap_from_slot(), all other places will
>> set returned bitmap to mddev->bitmap. So move the setting of
>> mddev->bitmap into md_bitmap_create() to simplify code.
>>
>> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
>> ---
>> drivers/md/md-bitmap.c | 23 +++++++++++++++--------
>> drivers/md/md-bitmap.h | 2 +-
>> drivers/md/md.c | 30 +++++++++---------------------
>> 3 files changed, 25 insertions(+), 30 deletions(-)
>>
>> diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
>> index eed3b930ade4..75e58da9a1a5 100644
>> --- a/drivers/md/md-bitmap.c
>> +++ b/drivers/md/md-bitmap.c
>> @@ -1879,7 +1879,7 @@ void md_bitmap_destroy(struct mddev *mddev)
>> * if this returns an error, bitmap_destroy must be called to do
>> clean up
>> * once mddev->bitmap is set
>> */
>> -struct bitmap *md_bitmap_create(struct mddev *mddev, int slot)
>> +static struct bitmap *bitmap_create(struct mddev *mddev, int slot)
>> {
>> struct bitmap *bitmap;
>> sector_t blocks = mddev->resync_max_sectors;
>> @@ -1966,6 +1966,17 @@ struct bitmap *md_bitmap_create(struct mddev
>> *mddev, int slot)
>> return ERR_PTR(err);
>> }
>>
>> +int md_bitmap_create(struct mddev *mddev, int slot)
>>
> NIT: We have two functions named md_bitmap_create() now. The static
> one will be renamed to __md_bitmap_create in next patch. Better to rename
> in this patch.
The static is renamed to bitmap_create() in this patch. And in the next
patch, the static is renamed to __bitmap_create() while the exported one
is renamed to bitmap_create().
I'll rename the static one to __bitmap_create() directly.
Thanks!
Kuai
>
> --
> Su
>
>> +{
>> + struct bitmap *bitmap = bitmap_create(mddev, slot);
>> +
>> + if (IS_ERR(bitmap))
>> + return PTR_ERR(bitmap);
>> +
>> + mddev->bitmap = bitmap;
>> + return 0;
>> +}
>> +
>> int md_bitmap_load(struct mddev *mddev)
>> {
>> int err = 0;
>> @@ -2030,7 +2041,7 @@ struct bitmap *get_bitmap_from_slot(struct mddev
>> *mddev, int slot)
>> int rv = 0;
>> struct bitmap *bitmap;
>>
>> - bitmap = md_bitmap_create(mddev, slot);
>> + bitmap = bitmap_create(mddev, slot);
>> if (IS_ERR(bitmap)) {
>> rv = PTR_ERR(bitmap);
>> return ERR_PTR(rv);
>> @@ -2381,7 +2392,6 @@ location_store(struct mddev *mddev, const char
>> *buf, size_t len)
>> } else {
>> /* No bitmap, OK to set a location */
>> long long offset;
>> - struct bitmap *bitmap;
>>
>> if (strncmp(buf, "none", 4) == 0)
>> /* nothing to be done */;
>> @@ -2408,13 +2418,10 @@ location_store(struct mddev *mddev, const char
>> *buf, size_t len)
>> }
>>
>> mddev->bitmap_info.offset = offset;
>> - bitmap = md_bitmap_create(mddev, -1);
>> - if (IS_ERR(bitmap)) {
>> - rv = PTR_ERR(bitmap);
>> + rv = md_bitmap_create(mddev, -1);
>> + if (rv)
>> goto out;
>> - }
>>
>> - mddev->bitmap = bitmap;
>> rv = md_bitmap_load(mddev);
>> if (rv) {
>> mddev->bitmap_info.offset = 0;
>> diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
>> index a8a5d4804174..e187f9099f2e 100644
>> --- a/drivers/md/md-bitmap.h
>> +++ b/drivers/md/md-bitmap.h
>> @@ -252,7 +252,7 @@ struct bitmap_operations {
>> void mddev_set_bitmap_ops(struct mddev *mddev);
>>
>> /* these are used only by md/bitmap */
>> -struct bitmap *md_bitmap_create(struct mddev *mddev, int slot);
>> +int md_bitmap_create(struct mddev *mddev, int slot);
>> int md_bitmap_load(struct mddev *mddev);
>> void md_bitmap_flush(struct mddev *mddev);
>> void md_bitmap_destroy(struct mddev *mddev);
>> diff --git a/drivers/md/md.c b/drivers/md/md.c
>> index f67f2540fd6c..6e130f6c2abd 100644
>> --- a/drivers/md/md.c
>> +++ b/drivers/md/md.c
>> @@ -6211,16 +6211,10 @@ int md_run(struct mddev *mddev)
>> }
>> if (err == 0 && pers->sync_request &&
>> (mddev->bitmap_info.file || mddev->bitmap_info.offset)) {
>> - struct bitmap *bitmap;
>> -
>> - bitmap = md_bitmap_create(mddev, -1);
>> - if (IS_ERR(bitmap)) {
>> - err = PTR_ERR(bitmap);
>> + err = md_bitmap_create(mddev, -1);
>> + if (err)
>> pr_warn("%s: failed to create bitmap (%d)\n",
>> mdname(mddev), err);
>> - } else
>> - mddev->bitmap = bitmap;
>> -
>> }
>> if (err)
>> goto bitmap_abort;
>> @@ -7275,14 +7269,10 @@ static int set_bitmap_file(struct mddev
>> *mddev, int fd)
>> err = 0;
>> if (mddev->pers) {
>> if (fd >= 0) {
>> - struct bitmap *bitmap;
>> -
>> - bitmap = md_bitmap_create(mddev, -1);
>> - if (!IS_ERR(bitmap)) {
>> - mddev->bitmap = bitmap;
>> + err = md_bitmap_create(mddev, -1);
>> + if (!err)
>> err = md_bitmap_load(mddev);
>> - } else
>> - err = PTR_ERR(bitmap);
>> +
>> if (err) {
>> md_bitmap_destroy(mddev);
>> fd = -1;
>> @@ -7291,6 +7281,7 @@ static int set_bitmap_file(struct mddev *mddev,
>> int fd)
>> md_bitmap_destroy(mddev);
>> }
>> }
>> +
>> if (fd < 0) {
>> struct file *f = mddev->bitmap_info.file;
>> if (f) {
>> @@ -7559,7 +7550,6 @@ static int update_array_info(struct mddev
>> *mddev, mdu_array_info_t *info)
>> goto err;
>> }
>> if (info->state & (1<<MD_SB_BITMAP_PRESENT)) {
>> - struct bitmap *bitmap;
>> /* add the bitmap */
>> if (mddev->bitmap) {
>> rv = -EEXIST;
>> @@ -7573,12 +7563,10 @@ static int update_array_info(struct mddev
>> *mddev, mdu_array_info_t *info)
>> mddev->bitmap_info.default_offset;
>> mddev->bitmap_info.space =
>> mddev->bitmap_info.default_space;
>> - bitmap = md_bitmap_create(mddev, -1);
>> - if (!IS_ERR(bitmap)) {
>> - mddev->bitmap = bitmap;
>> + rv = md_bitmap_create(mddev, -1);
>> + if (!rv)
>> rv = md_bitmap_load(mddev);
>> - } else
>> - rv = PTR_ERR(bitmap);
>> +
>> if (rv)
>> md_bitmap_destroy(mddev);
>> } else {
> .
>
^ permalink raw reply [flat|nested] 47+ messages in thread
* Re: [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel
2024-08-19 8:18 ` [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Su Yue
@ 2024-08-19 11:13 ` Yu Kuai
0 siblings, 0 replies; 47+ messages in thread
From: Yu Kuai @ 2024-08-19 11:13 UTC (permalink / raw)
To: Su Yue, Yu Kuai
Cc: mariusz.tkaczyk, hch, song, linux-kernel, linux-raid, yi.zhang,
yangerkun, yukuai (C)
Hi,
在 2024/08/19 16:18, Su Yue 写道:
>
> On Wed 14 Aug 2024 at 15:10, Yu Kuai <yukuai1@huaweicloud.com> wrote:
>
>> From: Yu Kuai <yukuai3@huawei.com>
>>
>> Changes in v2:
>> - add patch 1-8 to prevent dereference bitmap directly, and the last
>> patch to make bitmap structure internel.
>> - use plain function alls "bitmap_ops->xxx()" directly;
>>
>> The background is that currently bitmap is using a global spin_lock,
>> cauing lock contention and huge IO performance degration for all raid
>> levels.
>>
>> However, it's impossible to implement a new lock free bitmap with
>> current situation that md-bitmap exposes the internal implementation
>> with lots of exported apis. Hence bitmap_operations is invented, to
>> describe bitmap core implementation, and a new bitmap can be introduced
>> with a new bitmap_operations, we only need to switch to the new one
>> during initialization.
>>
> Is the new bitmap in plan?
Yes, I'm working on this now in my spare time, based on this set.
>>
>> And with this we can build bitmap as kernel module, but that's not
>> our concern for now.
>>
>> Noted I just compile this patchset, not tested yet.
>>
>
> I've looked through the patchset almostly. The changes are quite
> straightforward. IMO, it's good timing to test it and drop RFC in next
> version.
I'm testing now, however, I met some problem that's likely related to
the mdadm tests, not this set. I'll send the formal version soon.
Thansk for the review!
Kuai
>
>> Yu Kuai (41):
>> md/raid1: use md_bitmap_wait_behind_writes() in raid1_read_request()
>> md/md-bitmap: replace md_bitmap_status() with a new helper
>> md_bitmap_get_stats()
>> md: use new helper md_bitmap_get_stats() in update_array_info()
>> md/md-bitmap: add 'events_cleared' into struct md_bitmap_stats
>> md/md-bitmap: add 'sync_size' into struct md_bitmap_stats
>> md/md-bitmap: add 'file_pages' into struct md_bitmap_stats
>> md/md-bitmap: add 'behind_writes' and 'behind_wait' into struct
>> md_bitmap_stats
>> md/md-cluster: use helper md_bitmap_get_stats() to get pages in
>> resize_bitmaps()
>> md/md-bitmap: add a new helper md_bitmap_set_pages()
>> md/md-bitmap: introduce struct bitmap_operations
>> md/md-bitmap: simplify md_bitmap_create() + md_bitmap_load()
>> md/md-bitmap: merge md_bitmap_create() into bitmap_operations
>> md/md-bitmap: merge md_bitmap_load() into bitmap_operations
>> md/md-bitmap: merge md_bitmap_destroy() into bitmap_operations
>> md/md-bitmap: merge md_bitmap_flush() into bitmap_operations
>> md/md-bitmap: make md_bitmap_print_sb() internal
>> md/md-bitmap: merge md_bitmap_update_sb() into bitmap_operations
>> md/md-bitmap: merge md_bitmap_status() into bitmap_operations
>> md/md-bitmap: remove md_bitmap_setallbits()
>> md/md-bitmap: merge bitmap_write_all() into bitmap_operations
>> md/md-bitmap: merge md_bitmap_dirty_bits() into bitmap_operations
>> md/md-bitmap: merge md_bitmap_startwrite() into bitmap_operations
>> md/md-bitmap: merge md_bitmap_endwrite() into bitmap_operations
>> md/md-bitmap: merge md_bitmap_start_sync() into bitmap_operations
>> md/md-bitmap: remove the parameter 'aborted' for md_bitmap_end_sync()
>> md/md-bitmap: merge md_bitmap_end_sync() into bitmap_operations
>> md/md-bitmap: merge md_bitmap_close_sync() into bitmap_operations
>> md/md-bitmap: mrege md_bitmap_cond_end_sync() into bitmap_operations
>> md/md-bitmap: merge md_bitmap_sync_with_cluster() into
>> bitmap_operations
>> md/md-bitmap: merge md_bitmap_unplug_async() into md_bitmap_unplug()
>> md/md-bitmap: merge bitmap_unplug() into bitmap_operations
>> md/md-bitmap: merge md_bitmap_daemon_work() into bitmap_operations
>> md/md-bitmap: pass in mddev directly for md_bitmap_resize()
>> md/md-bitmap: merge md_bitmap_resize() into bitmap_operations
>> md/md-bitmap: merge get_bitmap_from_slot() into bitmap_operations
>> md/md-bitmap: merge md_bitmap_copy_from_slot() into struct
>> bitmap_operation.
>> md/md-bitmap: merge md_bitmap_set_pages() into struct
>> bitmap_operations
>> md/md-bitmap: merge md_bitmap_free() into bitmap_operations
>> md/md-bitmap: merge md_bitmap_wait_behind_writes() into
>> bitmap_operations
>> md/md-bitmap: merge md_bitmap_enabled() into bitmap_operations
>> md/md-bitmap: make in memory structure internal
>>
>> drivers/md/dm-raid.c | 7 +-
>> drivers/md/md-bitmap.c | 561 +++++++++++++++++++++++++++++----------
>> drivers/md/md-bitmap.h | 272 ++++---------------
>> drivers/md/md-cluster.c | 79 +++---
>> drivers/md/md.c | 133 ++++++----
>> drivers/md/md.h | 3 +-
>> drivers/md/raid1-10.c | 9 +-
>> drivers/md/raid1.c | 78 +++---
>> drivers/md/raid10.c | 73 ++---
>> drivers/md/raid5-cache.c | 8 +-
>> drivers/md/raid5.c | 62 ++---
>> 11 files changed, 731 insertions(+), 554 deletions(-)
> .
>
^ permalink raw reply [flat|nested] 47+ messages in thread
end of thread, other threads:[~2024-08-19 11:13 UTC | newest]
Thread overview: 47+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-14 7:10 [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 01/41] md/raid1: use md_bitmap_wait_behind_writes() in raid1_read_request() Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 02/41] md/md-bitmap: replace md_bitmap_status() with a new helper md_bitmap_get_stats() Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 03/41] md: use new helper md_bitmap_get_stats() in update_array_info() Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 04/41] md/md-bitmap: add 'events_cleared' into struct md_bitmap_stats Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 05/41] md/md-bitmap: add 'sync_size' " Yu Kuai
2024-08-14 12:52 ` Mariusz Tkaczyk
2024-08-14 7:10 ` [PATCH RFC -next v2 06/41] md/md-bitmap: add 'file_pages' " Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 07/41] md/md-bitmap: add 'behind_writes' and 'behind_wait' " Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 08/41] md/md-cluster: use helper md_bitmap_get_stats() to get pages in resize_bitmaps() Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 09/41] md/md-bitmap: add a new helper md_bitmap_set_pages() Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 10/41] md/md-bitmap: introduce struct bitmap_operations Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 11/41] md/md-bitmap: simplify md_bitmap_create() + md_bitmap_load() Yu Kuai
2024-08-19 8:10 ` Su Yue
2024-08-19 11:06 ` Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 12/41] md/md-bitmap: merge md_bitmap_create() into bitmap_operations Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 13/41] md/md-bitmap: merge md_bitmap_load() " Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 14/41] md/md-bitmap: merge md_bitmap_destroy() " Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 15/41] md/md-bitmap: merge md_bitmap_flush() " Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 16/41] md/md-bitmap: make md_bitmap_print_sb() internal Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 17/41] md/md-bitmap: merge md_bitmap_update_sb() into bitmap_operations Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 18/41] md/md-bitmap: merge md_bitmap_status() " Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 19/41] md/md-bitmap: remove md_bitmap_setallbits() Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 20/41] md/md-bitmap: merge bitmap_write_all() into bitmap_operations Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 21/41] md/md-bitmap: merge md_bitmap_dirty_bits() " Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 22/41] md/md-bitmap: merge md_bitmap_startwrite() " Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 23/41] md/md-bitmap: merge md_bitmap_endwrite() " Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 24/41] md/md-bitmap: merge md_bitmap_start_sync() " Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 25/41] md/md-bitmap: remove the parameter 'aborted' for md_bitmap_end_sync() Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 26/41] md/md-bitmap: merge md_bitmap_end_sync() into bitmap_operations Yu Kuai
2024-08-14 7:10 ` [PATCH RFC -next v2 27/41] md/md-bitmap: merge md_bitmap_close_sync() " Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 28/41] md/md-bitmap: mrege md_bitmap_cond_end_sync() " Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 29/41] md/md-bitmap: merge md_bitmap_sync_with_cluster() " Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 30/41] md/md-bitmap: merge md_bitmap_unplug_async() into md_bitmap_unplug() Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 31/41] md/md-bitmap: merge bitmap_unplug() into bitmap_operations Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 32/41] md/md-bitmap: merge md_bitmap_daemon_work() " Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 33/41] md/md-bitmap: pass in mddev directly for md_bitmap_resize() Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 34/41] md/md-bitmap: merge md_bitmap_resize() into bitmap_operations Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 35/41] md/md-bitmap: merge get_bitmap_from_slot() " Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 36/41] md/md-bitmap: merge md_bitmap_copy_from_slot() into struct bitmap_operation Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 37/41] md/md-bitmap: merge md_bitmap_set_pages() into struct bitmap_operations Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 38/41] md/md-bitmap: merge md_bitmap_free() into bitmap_operations Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 39/41] md/md-bitmap: merge md_bitmap_wait_behind_writes() " Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 40/41] md/md-bitmap: merge md_bitmap_enabled() " Yu Kuai
2024-08-14 7:11 ` [PATCH RFC -next v2 41/41] md/md-bitmap: make in memory structure internal Yu Kuai
2024-08-19 8:18 ` [PATCH RFC -next v2 00/41] md/md-bitmap: introduce bitmap_operations and make structure internel Su Yue
2024-08-19 11:13 ` Yu Kuai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).