All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mdadm: Deprecate the obsolete --auto-detect option
@ 2026-10-15 13:03 Masalkhi, Abd Alrhman
  2026-10-28  9:03 ` Mariusz Tkaczyk
  0 siblings, 1 reply; 5+ messages in thread
From: Masalkhi, Abd Alrhman @ 2026-10-15 13:03 UTC (permalink / raw)
  To: blazej.kucman@graidtech.com, mtkaczyk@kernel.org,
	ncroxon@redhat.com, xni@redhat.com, song@kernel.org,
	yukuai@kernel.org
  Cc: linux-raid@vger.kernel.org, Masalkhi, Abd Alrhman

From: Abd-Alrhman Masalkhi <abd.masalkhi@gatech.edu>

--auto-detect opened md0 (9:0) and issued the RAID_AUTORUN ioctl to ask
the kernel to start the arrays it had auto-detected. The kernel removed
this ioctl in commit d82fa81c2364 ("md: replace the RAID_AUTORUN ioctl
with a direct function call"). Before that, it worked only when md was
built into the kernel. Since then, md_ioctl() has rejected it with
ENOTTY, making --auto-detect ineffective on current kernels.

Remove autodetect(). Keep the option for now to avoid breaking existing
scripts, and print a warning message when it is used.

Signed-off-by: Abd-Alrhman Masalkhi <abd.masalkhi@gatech.edu>
---
 Manage.c | 13 -------------
 mdadm.c  |  2 +-
 mdadm.h  |  1 -
 3 files changed, 1 insertion(+), 15 deletions(-)

diff --git a/Manage.c b/Manage.c
index 40d52cfc..d38336a0 100644
--- a/Manage.c
+++ b/Manage.c
@@ -1738,19 +1738,6 @@ abort:
 	return !test && busy ? 2 : 1;
 }
 
-int autodetect(void)
-{
-	/* Open any md device, and issue the RAID_AUTORUN ioctl */
-	int rv = 1;
-	int fd = dev_open("9:0", O_RDONLY);
-	if (fd >= 0) {
-		if (ioctl(fd, RAID_AUTORUN, 0) == 0)
-			rv = 0;
-		close_fd(&fd);
-	}
-	return rv;
-}
-
 int Update_subarray(char *dev, char *subarray, enum update_opt update,
 		    struct mddev_ident *ident, int verbose)
 {
diff --git a/mdadm.c b/mdadm.c
index 2517b037..c4e234e3 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -1744,7 +1744,7 @@ int main(int argc, char *argv[])
 			rv = Incremental(devlist, &c, ss);
 		break;
 	case AUTODETECT:
-		autodetect();
+		pr_err("--auto-detect has no effect. It is deprecated and will be removed in future releases.\n");
 		break;
 	}
 	if (ss) {
diff --git a/mdadm.h b/mdadm.h
index deac7a56..985951d3 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1434,7 +1434,6 @@ extern int Manage_stop(char *devname, int fd, int quiet,
 extern int Manage_subdevs(char *devname, int fd,
 			  struct mddev_dev *devlist, int verbose, int test,
 			  enum update_opt update, int force);
-extern int autodetect(void);
 extern int Grow_Add_device(char *devname, int fd, char *newdev);
 extern int Grow_addbitmap(char *devname, int fd,
 			  struct context *c, struct shape *s);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mdadm: Deprecate the obsolete --auto-detect option
  2026-10-15 13:03 [PATCH] mdadm: Deprecate the obsolete --auto-detect option Masalkhi, Abd Alrhman
@ 2026-10-28  9:03 ` Mariusz Tkaczyk
  2026-10-28 12:52   ` Masalkhi, Abd Alrhman
  0 siblings, 1 reply; 5+ messages in thread
From: Mariusz Tkaczyk @ 2026-10-28  9:03 UTC (permalink / raw)
  To: Masalkhi, Abd Alrhman
  Cc: blazej.kucman@graidtech.com, ncroxon@redhat.com, xni@redhat.com,
	song@kernel.org, yukuai@kernel.org, linux-raid@vger.kernel.org

On Thu, 15 Oct 2026 13:03:59 +0000
"Masalkhi, Abd Alrhman" <abd.masalkhi@gatech.edu> wrote:

> From: Abd-Alrhman Masalkhi <abd.masalkhi@gatech.edu>
> 
> --auto-detect opened md0 (9:0) and issued the RAID_AUTORUN ioctl to
> ask the kernel to start the arrays it had auto-detected. The kernel
> removed this ioctl in commit d82fa81c2364 ("md: replace the
> RAID_AUTORUN ioctl with a direct function call"). Before that, it
> worked only when md was built into the kernel. Since then, md_ioctl()

Redhat still builds-in md into kernel so there is chance that someone
is using it.


> has rejected it with ENOTTY, making --auto-detect ineffective on
> current kernels.


Hello,
Do you mind to submit github PRs for mdadm patches?
https://github.com/md-raid-utilities/mdadm

mdadm community is the most active over the github today.

Indeed, it has been removed 6 years ago. The question is if 6 years is
enough to stop supporting the configurations with new mdadm and old
kernel. I think it is not enough.

I would do that at least 10 years after kernel part removed.

What can be done here is warning and improved error message saying that
"The option is deprecated and probably it is not supported with this
kernel". If you wish you can be more detailed and add validation
against kernel version but I have no hard feeling to that. It is minor
case, probably not used because no one ever complained about the removed
ioctl.

You can left some TODO message saying that after 2030y it can
removed- that would be helpful for future maintainers.

Thanks,
Mariusz

> 
> Remove autodetect(). Keep the option for now to avoid breaking
> existing scripts, and print a warning message when it is used.
> 
> Signed-off-by: Abd-Alrhman Masalkhi <abd.masalkhi@gatech.edu>
> ---
>  Manage.c | 13 -------------
>  mdadm.c  |  2 +-
>  mdadm.h  |  1 -
>  3 files changed, 1 insertion(+), 15 deletions(-)
> 
> diff --git a/Manage.c b/Manage.c
> index 40d52cfc..d38336a0 100644
> --- a/Manage.c
> +++ b/Manage.c
> @@ -1738,19 +1738,6 @@ abort:
>  	return !test && busy ? 2 : 1;
>  }
>  
> -int autodetect(void)
> -{
> -	/* Open any md device, and issue the RAID_AUTORUN ioctl */
> -	int rv = 1;
> -	int fd = dev_open("9:0", O_RDONLY);
> -	if (fd >= 0) {
> -		if (ioctl(fd, RAID_AUTORUN, 0) == 0)
> -			rv = 0;
> -		close_fd(&fd);
> -	}
> -	return rv;
> -}
> -
>  int Update_subarray(char *dev, char *subarray, enum update_opt
> update, struct mddev_ident *ident, int verbose)
>  {
> diff --git a/mdadm.c b/mdadm.c
> index 2517b037..c4e234e3 100644
> --- a/mdadm.c
> +++ b/mdadm.c
> @@ -1744,7 +1744,7 @@ int main(int argc, char *argv[])
>  			rv = Incremental(devlist, &c, ss);
>  		break;
>  	case AUTODETECT:
> -		autodetect();
> +		pr_err("--auto-detect has no effect. It is
> deprecated and will be removed in future releases.\n"); break;
>  	}
>  	if (ss) {
> diff --git a/mdadm.h b/mdadm.h
> index deac7a56..985951d3 100644
> --- a/mdadm.h
> +++ b/mdadm.h
> @@ -1434,7 +1434,6 @@ extern int Manage_stop(char *devname, int fd,
> int quiet, extern int Manage_subdevs(char *devname, int fd,
>  			  struct mddev_dev *devlist, int verbose,
> int test, enum update_opt update, int force);
> -extern int autodetect(void);
>  extern int Grow_Add_device(char *devname, int fd, char *newdev);
>  extern int Grow_addbitmap(char *devname, int fd,
>  			  struct context *c, struct shape *s);


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mdadm: Deprecate the obsolete --auto-detect option
  2026-10-28  9:03 ` Mariusz Tkaczyk
@ 2026-10-28 12:52   ` Masalkhi, Abd Alrhman
  2026-10-28 14:00     ` Mariusz Tkaczyk
  0 siblings, 1 reply; 5+ messages in thread
From: Masalkhi, Abd Alrhman @ 2026-10-28 12:52 UTC (permalink / raw)
  To: Mariusz Tkaczyk
  Cc: blazej.kucman@graidtech.com, ncroxon@redhat.com, xni@redhat.com,
	song@kernel.org, yukuai@kernel.org, linux-raid@vger.kernel.org

Hi Mariusz,

On Wed, Oct 28, 2026 at 10:03 +0100, Mariusz Tkaczyk wrote:
> On Thu, 15 Oct 2026 13:03:59 +0000
> "Masalkhi, Abd Alrhman" <abd.masalkhi@gatech.edu> wrote:
>
>> From: Abd-Alrhman Masalkhi <abd.masalkhi@gatech.edu>
>> 
>> --auto-detect opened md0 (9:0) and issued the RAID_AUTORUN ioctl to
>> ask the kernel to start the arrays it had auto-detected. The kernel
>> removed this ioctl in commit d82fa81c2364 ("md: replace the
>> RAID_AUTORUN ioctl with a direct function call"). Before that, it
>> worked only when md was built into the kernel. Since then, md_ioctl()
>
> Redhat still builds-in md into kernel so there is chance that someone
> is using it.
>
>
>> has rejected it with ENOTTY, making --auto-detect ineffective on
>> current kernels.
>
>
> Hello,
> Do you mind to submit github PRs for mdadm patches?
> https://github.com/md-raid-utilities/mdadm
>

Sure, I will submit the next version as a GitHub pull request.

One question, should I also send the RFC patches for updating mdadm to
use the new UAPI to the mailing list, or is submitting GitHub PRs
sufficient?

> mdadm community is the most active over the github today.
>
> Indeed, it has been removed 6 years ago. The question is if 6 years is
> enough to stop supporting the configurations with new mdadm and old
> kernel. I think it is not enough.
>
> I would do that at least 10 years after kernel part removed.
>
> What can be done here is warning and improved error message saying that
> "The option is deprecated and probably it is not supported with this
> kernel". If you wish you can be more detailed and add validation
> against kernel version but I have no hard feeling to that. It is minor
> case, probably not used because no one ever complained about the removed
> ioctl.
>
> You can left some TODO message saying that after 2030y it can
> removed- that would be helpful for future maintainers.
>

Thanks for the clarification. I will make the changes accordingly.

> Thanks,
> Mariusz
>
>> 
>> Remove autodetect(). Keep the option for now to avoid breaking
>> existing scripts, and print a warning message when it is used.
>> 
>> Signed-off-by: Abd-Alrhman Masalkhi <abd.masalkhi@gatech.edu>
>> ---
>>  Manage.c | 13 -------------
>>  mdadm.c  |  2 +-
>>  mdadm.h  |  1 -
>>  3 files changed, 1 insertion(+), 15 deletions(-)
>> 
>> diff --git a/Manage.c b/Manage.c
>> index 40d52cfc..d38336a0 100644
>> --- a/Manage.c
>> +++ b/Manage.c
>> @@ -1738,19 +1738,6 @@ abort:
>>  	return !test && busy ? 2 : 1;
>>  }
>>  
>> -int autodetect(void)
>> -{
>> -	/* Open any md device, and issue the RAID_AUTORUN ioctl */
>> -	int rv = 1;
>> -	int fd = dev_open("9:0", O_RDONLY);
>> -	if (fd >= 0) {
>> -		if (ioctl(fd, RAID_AUTORUN, 0) == 0)
>> -			rv = 0;
>> -		close_fd(&fd);
>> -	}
>> -	return rv;
>> -}
>> -
>>  int Update_subarray(char *dev, char *subarray, enum update_opt
>> update, struct mddev_ident *ident, int verbose)
>>  {
>> diff --git a/mdadm.c b/mdadm.c
>> index 2517b037..c4e234e3 100644
>> --- a/mdadm.c
>> +++ b/mdadm.c
>> @@ -1744,7 +1744,7 @@ int main(int argc, char *argv[])
>>  			rv = Incremental(devlist, &c, ss);
>>  		break;
>>  	case AUTODETECT:
>> -		autodetect();
>> +		pr_err("--auto-detect has no effect. It is
>> deprecated and will be removed in future releases.\n"); break;
>>  	}
>>  	if (ss) {
>> diff --git a/mdadm.h b/mdadm.h
>> index deac7a56..985951d3 100644
>> --- a/mdadm.h
>> +++ b/mdadm.h
>> @@ -1434,7 +1434,6 @@ extern int Manage_stop(char *devname, int fd,
>> int quiet, extern int Manage_subdevs(char *devname, int fd,
>>  			  struct mddev_dev *devlist, int verbose,
>> int test, enum update_opt update, int force);
>> -extern int autodetect(void);
>>  extern int Grow_Add_device(char *devname, int fd, char *newdev);
>>  extern int Grow_addbitmap(char *devname, int fd,
>>  			  struct context *c, struct shape *s);
>
>

-- 
Best Regards,
Abd-Alrhman

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mdadm: Deprecate the obsolete --auto-detect option
  2026-10-28 12:52   ` Masalkhi, Abd Alrhman
@ 2026-10-28 14:00     ` Mariusz Tkaczyk
  2026-10-28 16:37       ` Masalkhi, Abd Alrhman
  0 siblings, 1 reply; 5+ messages in thread
From: Mariusz Tkaczyk @ 2026-10-28 14:00 UTC (permalink / raw)
  To: Masalkhi, Abd Alrhman
  Cc: blazej.kucman@graidtech.com, ncroxon@redhat.com, xni@redhat.com,
	song@kernel.org, yukuai@kernel.org, linux-raid@vger.kernel.org

On Wed, 28 Oct 2026 12:52:30 +0000
"Masalkhi, Abd Alrhman" <abd.masalkhi@gatech.edu> wrote:

> Hi Mariusz,
> 
> On Wed, Oct 28, 2026 at 10:03 +0100, Mariusz Tkaczyk wrote:
> > On Thu, 15 Oct 2026 13:03:59 +0000
> > "Masalkhi, Abd Alrhman" <abd.masalkhi@gatech.edu> wrote:
> >  
> >> From: Abd-Alrhman Masalkhi <abd.masalkhi@gatech.edu>
> >> 
> >> --auto-detect opened md0 (9:0) and issued the RAID_AUTORUN ioctl to
> >> ask the kernel to start the arrays it had auto-detected. The kernel
> >> removed this ioctl in commit d82fa81c2364 ("md: replace the
> >> RAID_AUTORUN ioctl with a direct function call"). Before that, it
> >> worked only when md was built into the kernel. Since then,
> >> md_ioctl()  
> >
> > Redhat still builds-in md into kernel so there is chance that
> > someone is using it.
> >
> >  
> >> has rejected it with ENOTTY, making --auto-detect ineffective on
> >> current kernels.  
> >
> >
> > Hello,
> > Do you mind to submit github PRs for mdadm patches?
> > https://github.com/md-raid-utilities/mdadm
> >  
> 
> Sure, I will submit the next version as a GitHub pull request.
> 
> One question, should I also send the RFC patches for updating mdadm to
> use the new UAPI to the mailing list, or is submitting GitHub PRs
> sufficient?


In this particular case there is nothing interesting we are going to do
with kernel or any problem that needs to be coordinated with kernel.
Just take new UAPI and use it once is available so I don't think kernel
list messaging is needed.

I forgot to say, the problem you are challenging is very legacy. With
proposed change, we will not need to open the device and generate
unnecessary events (and problems) anymore! I'm glad to see someone
working on it.

Mariusz

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mdadm: Deprecate the obsolete --auto-detect option
  2026-10-28 14:00     ` Mariusz Tkaczyk
@ 2026-10-28 16:37       ` Masalkhi, Abd Alrhman
  0 siblings, 0 replies; 5+ messages in thread
From: Masalkhi, Abd Alrhman @ 2026-10-28 16:37 UTC (permalink / raw)
  To: Mariusz Tkaczyk
  Cc: blazej.kucman@graidtech.com, ncroxon@redhat.com, xni@redhat.com,
	song@kernel.org, yukuai@kernel.org, linux-raid@vger.kernel.org

Hi,

On Wed, Oct 28, 2026 at 15:00 +0100, Mariusz Tkaczyk wrote:
> On Wed, 28 Oct 2026 12:52:30 +0000
> "Masalkhi, Abd Alrhman" <abd.masalkhi@gatech.edu> wrote:
>
>> Hi Mariusz,
>> 
>> On Wed, Oct 28, 2026 at 10:03 +0100, Mariusz Tkaczyk wrote:
>> > On Thu, 15 Oct 2026 13:03:59 +0000
>> > "Masalkhi, Abd Alrhman" <abd.masalkhi@gatech.edu> wrote:
>> >  
>> >> From: Abd-Alrhman Masalkhi <abd.masalkhi@gatech.edu>
>> >> 
>> >> --auto-detect opened md0 (9:0) and issued the RAID_AUTORUN ioctl to
>> >> ask the kernel to start the arrays it had auto-detected. The kernel
>> >> removed this ioctl in commit d82fa81c2364 ("md: replace the
>> >> RAID_AUTORUN ioctl with a direct function call"). Before that, it
>> >> worked only when md was built into the kernel. Since then,
>> >> md_ioctl()  
>> >
>> > Redhat still builds-in md into kernel so there is chance that
>> > someone is using it.
>> >
>> >  
>> >> has rejected it with ENOTTY, making --auto-detect ineffective on
>> >> current kernels.  
>> >
>> >
>> > Hello,
>> > Do you mind to submit github PRs for mdadm patches?
>> > https://github.com/md-raid-utilities/mdadm
>> >  
>> 
>> Sure, I will submit the next version as a GitHub pull request.
>> 
>> One question, should I also send the RFC patches for updating mdadm to
>> use the new UAPI to the mailing list, or is submitting GitHub PRs
>> sufficient?
>
>
> In this particular case there is nothing interesting we are going to do
> with kernel or any problem that needs to be coordinated with kernel.
> Just take new UAPI and use it once is available so I don't think kernel
> list messaging is needed.
>
> I forgot to say, the problem you are challenging is very legacy. With
> proposed change, we will not need to open the device and generate
> unnecessary events (and problems) anymore! I'm glad to see someone
> working on it.
>

Yes, that is the end goal. I plan to do it in two phases. the first
one is to  but keep the array open as today, except for stop and
read-only and i will open the pull request today or tomorrow.

And the second is to stop opening the array entirely when the control
node is available. It is the harder part.  Much of mdadm is built around
the array fd, it is passed through most functions and used for sysfs
lookups and doing it separately keeps the first series reviewable.

> Mariusz
>

-- 
Best Regards,
Abd-Alrhman

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-10-28 16:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-15 13:03 [PATCH] mdadm: Deprecate the obsolete --auto-detect option Masalkhi, Abd Alrhman
2026-10-28  9:03 ` Mariusz Tkaczyk
2026-10-28 12:52   ` Masalkhi, Abd Alrhman
2026-10-28 14:00     ` Mariusz Tkaczyk
2026-10-28 16:37       ` Masalkhi, Abd Alrhman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.