From: Abd-Alrhman Masalkhi <abd.masalkhi@gmail.com>
To: song@kernel.org, yukuai@fygo.io, chengzhihao1@huawei.com,
magiclinan@didiglobal.com, xiao@kernel.org
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
Abd-Alrhman Masalkhi <abd.masalkhi@gmail.com>
Subject: [RFC PATCH v2 3/4] md: use struct mdu_array_info64 for SET_ARRAY_INFO
Date: Thu, 1 Oct 2026 12:56:10 +0000 [thread overview]
Message-ID: <20261001125611.943731-4-abd.masalkhi@gmail.com> (raw)
In-Reply-To: <20261001125611.943731-1-abd.masalkhi@gmail.com>
The md control device passes array information as struct
mdu_array_info64. Make md_set_array_info() and update_array_info()
take the new struct mdu_array_info64, so that the md control device
and the old SET_ARRAY_INFO ioctl can share them.
md_set_array_info() no longer checks for a negative major_version:
the field is unsigned now, and the existing check against the size
of super_types still rejects such values.
md_setup_drive() uses a struct mdu_array_info64 directly.
Signed-off-by: Abd-Alrhman Masalkhi <abd.masalkhi@gmail.com>
---
drivers/md/md-autodetect.c | 2 +-
drivers/md/md.c | 37 +++++++++++++++++++++++++++++++------
drivers/md/md.h | 4 ++--
3 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/drivers/md/md-autodetect.c b/drivers/md/md-autodetect.c
index 9ba061f1a628..227cd4a688a5 100644
--- a/drivers/md/md-autodetect.c
+++ b/drivers/md/md-autodetect.c
@@ -124,7 +124,7 @@ static void __init md_setup_drive(struct md_setup_args *args)
{
char *devname = args->device_names;
dev_t devices[MD_SB_DISKS + 1], mdev;
- struct mdu_array_info_s ainfo = { };
+ struct mdu_array_info64 ainfo = { };
struct mddev *mddev;
int err = 0, i;
char name[16];
diff --git a/drivers/md/md.c b/drivers/md/md.c
index be1634ae1d09..63b9468285b0 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -7904,12 +7904,11 @@ static int set_bitmap_file(struct mddev *mddev, int fd)
* The minor and patch _version numbers are also kept incase the
* super_block handler wishes to interpret them.
*/
-int md_set_array_info(struct mddev *mddev, struct mdu_array_info_s *info)
+int md_set_array_info(struct mddev *mddev, struct mdu_array_info64 *info)
{
if (info->raid_disks == 0) {
/* just setting version number for superblock loading */
- if (info->major_version < 0 ||
- info->major_version >= ARRAY_SIZE(super_types) ||
+ if (info->major_version >= ARRAY_SIZE(super_types) ||
super_types[info->major_version].name == NULL) {
/* maybe try to auto-load a module? */
pr_warn("md: superblock version %d not known\n",
@@ -8101,7 +8100,7 @@ static void put_cluster_ops(struct mddev *mddev)
* Any differences that cannot be handled will cause an error.
* Normally, only one change can be managed at a time.
*/
-static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
+static int update_array_info(struct mddev *mddev, struct mdu_array_info64 *info)
{
int rv = 0;
int cnt = 0;
@@ -8315,9 +8314,33 @@ static void convert_to_disk_info64(struct mdu_disk_info64 *info64,
info64->state = info->state;
}
+static void convert_to_array_info64(struct mdu_array_info64 *info64,
+ mdu_array_info_t *info)
+{
+ info64->major_version = info->major_version;
+ info64->minor_version = info->minor_version;
+ info64->patch_version = info->patch_version;
+ info64->level = info->level;
+ info64->ctime = info->ctime;
+ info64->size = info->size;
+ info64->nr_disks = info->nr_disks;
+ info64->raid_disks = info->raid_disks;
+ info64->md_minor = info->md_minor;
+ info64->not_persistent = info->not_persistent;
+ info64->utime = info->utime;
+ info64->state = info->state;
+ info64->active_disks = info->active_disks;
+ info64->working_disks = info->working_disks;
+ info64->failed_disks = info->failed_disks;
+ info64->spare_disks = info->spare_disks;
+ info64->layout = info->layout;
+ info64->chunk_size = info->chunk_size;
+}
+
static int __md_set_array_info(struct mddev *mddev, void __user *argp)
{
mdu_array_info_t info;
+ struct mdu_array_info64 info64 = {0};
int err;
if (!argp)
@@ -8325,8 +8348,10 @@ static int __md_set_array_info(struct mddev *mddev, void __user *argp)
else if (copy_from_user(&info, argp, sizeof(info)))
return -EFAULT;
+ convert_to_array_info64(&info64, &info);
+
if (mddev->pers) {
- err = update_array_info(mddev, &info);
+ err = update_array_info(mddev, &info64);
if (err)
pr_warn("md: couldn't update array info. %d\n", err);
return err;
@@ -8342,7 +8367,7 @@ static int __md_set_array_info(struct mddev *mddev, void __user *argp)
return -EBUSY;
}
- err = md_set_array_info(mddev, &info);
+ err = md_set_array_info(mddev, &info64);
if (err)
pr_warn("md: couldn't set array info. %d\n", err);
diff --git a/drivers/md/md.h b/drivers/md/md.h
index a84c8b97fa2c..27de34a8bdf9 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -1042,12 +1042,12 @@ static inline void mddev_unlock_and_resume(struct mddev *mddev)
mddev_resume(mddev);
}
-struct mdu_array_info_s;
+struct mdu_array_info64;
struct mdu_disk_info64;
extern int mdp_major;
void md_autostart_arrays(int part);
-int md_set_array_info(struct mddev *mddev, struct mdu_array_info_s *info);
+int md_set_array_info(struct mddev *mddev, struct mdu_array_info64 *info);
int md_add_new_disk(struct mddev *mddev, struct mdu_disk_info64 *info);
int do_md_run(struct mddev *mddev);
#define MDDEV_STACK_INTEGRITY (1u << 0)
--
2.43.0
next prev parent reply other threads:[~2026-10-01 12:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 12:56 [RFC PATCH v2 0/4] md: add a control device for array management Abd-Alrhman Masalkhi
2026-10-01 12:56 ` [RFC PATCH v2 1/4] md: add uapi definitions for the md control device Abd-Alrhman Masalkhi
2026-10-01 12:56 ` [RFC PATCH v2 2/4] md: pass struct mdu_disk_info64 to md_add_new_disk() Abd-Alrhman Masalkhi
2026-10-01 12:56 ` Abd-Alrhman Masalkhi [this message]
2026-10-01 12:56 ` [RFC PATCH v2 4/4] md: add a control device for array management Abd-Alrhman Masalkhi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261001125611.943731-4-abd.masalkhi@gmail.com \
--to=abd.masalkhi@gmail.com \
--cc=chengzhihao1@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=magiclinan@didiglobal.com \
--cc=song@kernel.org \
--cc=xiao@kernel.org \
--cc=yukuai@fygo.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®