[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240826074452.1490072-8-yukuai1@huaweicloud.com>
Date: Mon, 26 Aug 2024 15:44:17 +0800
From: Yu Kuai <yukuai1@...weicloud.com>
To: mariusz.tkaczyk@...ux.intel.com,
xni@...hat.com,
song@...nel.org
Cc: linux-kernel@...r.kernel.org,
linux-raid@...r.kernel.org,
yukuai3@...wei.com,
yukuai1@...weicloud.com,
yi.zhang@...wei.com,
yangerkun@...wei.com
Subject: [PATCH md-6.12 v2 07/42] md/md-bitmap: add 'file_pages' into struct md_bitmap_stats
From: Yu Kuai <yukuai3@...wei.com>
There are no functional changes, avoid dereferencing bitmap directly to
prepare inventing a new bitmap.
Signed-off-by: Yu Kuai <yukuai3@...wei.com>
---
drivers/md/md-bitmap.c | 7 +++++--
drivers/md/md-bitmap.h | 1 +
drivers/md/md.c | 17 +++++++++++------
3 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 33812543d984..ba83b99d6185 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -2096,6 +2096,7 @@ EXPORT_SYMBOL_GPL(md_bitmap_copy_from_slot);
int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
{
+ struct bitmap_storage *storage;
struct bitmap_counts *counts;
bitmap_super_t *sb;
@@ -2110,9 +2111,11 @@ int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
stats->missing_pages = counts->missing_pages;
stats->pages = counts->pages;
- stats->events_cleared = bitmap->events_cleared;
- stats->file = bitmap->storage.file;
+ storage = &bitmap->storage;
+ stats->file_pages = storage->file_pages;
+ stats->file = storage->file;
+ stats->events_cleared = bitmap->events_cleared;
return 0;
}
EXPORT_SYMBOL_GPL(md_bitmap_get_stats);
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index a43a75575769..870125670087 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -237,6 +237,7 @@ struct bitmap {
struct md_bitmap_stats {
u64 events_cleared;
unsigned long missing_pages;
+ unsigned long file_pages;
unsigned long sync_size;
unsigned long pages;
struct file *file;
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 5e1dd3009092..53e10dc28f72 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2335,7 +2335,6 @@ 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;
if (new_offset >= rdev->data_offset)
return 1;
@@ -2352,11 +2351,17 @@ 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 &&
- rdev->sb_start + rdev->mddev->bitmap_info.offset +
- bitmap->storage.file_pages * (PAGE_SIZE>>9) > new_offset)
- return 0;
+
+ if (!rdev->mddev->bitmap_info.file) {
+ struct md_bitmap_stats stats;
+ int err;
+
+ err = md_bitmap_get_stats(rdev->mddev->bitmap, &stats);
+ if (!err && rdev->sb_start + rdev->mddev->bitmap_info.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
Powered by blists - more mailing lists