lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240814071113.346781-7-yukuai1@huaweicloud.com>
Date: Wed, 14 Aug 2024 15:10:38 +0800
From: Yu Kuai <yukuai1@...weicloud.com>
To: mariusz.tkaczyk@...ux.intel.com,
	hch@...radead.org,
	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 RFC -next v2 06/41] 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 |  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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ