]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm: drop auto= support
authorMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Mon, 7 Oct 2024 12:20:17 +0000 (14:20 +0200)
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Tue, 5 Nov 2024 12:36:43 +0000 (13:36 +0100)
According to author (and what was described in man):
"With mdadm 3.0, device creation is normally left up to udev so this is
option is unlikely to be needed"
This was a workaround for kernel 2.6 family issues (partitionable and
non-partitionable arrays hell) and I believe we are far away from it now.

I'm not aware of any usage of it, hence it is removed.

Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
12 files changed:
Assemble.c
Build.c
Create.c
Incremental.c
ReadMe.c
config.c
mdadm.8.in
mdadm.c
mdadm.conf.5.in
mdadm.h
mdopen.c
util.c

index d3dbfbc6d79f83865a0deae7c9f4c1f253dc4285..87d1ae048fcfaf060cab50a37f6d1e4167ed0252 100644 (file)
@@ -1573,8 +1573,7 @@ try_again:
                        /* Ignore 'host:' prefix of name */
                        name = strchr(name, ':')+1;
 
-               mdfd = create_mddev(mddev, name, ident->autof, trustworthy,
-                                   chosen_name, 0);
+               mdfd = create_mddev(mddev, name, trustworthy, chosen_name, 0);
        }
        if (mdfd < 0) {
                st->ss->free_super(st);
diff --git a/Build.c b/Build.c
index 052b1bc25877e64f9fdf89ab25625d0273100282..6f63d3f39845272768b2fe463be4f29f1d6fbadb 100644 (file)
--- a/Build.c
+++ b/Build.c
@@ -75,8 +75,7 @@ int Build(struct mddev_ident *ident, struct mddev_dev *devlist, struct shape *s,
 
        /* We need to create the device.  It can have no name. */
        map_lock(&map);
-       mdfd = create_mddev(ident->devname, NULL, c->autof, LOCAL,
-                           chosen_name, 0);
+       mdfd = create_mddev(ident->devname, NULL, LOCAL, chosen_name, 0);
        if (mdfd < 0) {
                map_unlock(&map);
                return 1;
index 1640f21e9a6a6ee72e04bcc961ea2646c288483b..140a70988c5f9afd63bb45222c483d024ae920c4 100644 (file)
--- a/Create.c
+++ b/Create.c
@@ -1045,7 +1045,7 @@ int Create(struct supertype *st, struct mddev_ident *ident, int subdevs,
 
        /* We need to create the device */
        map_lock(&map);
-       mdfd = create_mddev(ident->devname, ident->name, c->autof, LOCAL, chosen_name, 1);
+       mdfd = create_mddev(ident->devname, ident->name, LOCAL, chosen_name, 1);
        if (mdfd < 0) {
                map_unlock(&map);
                return 1;
index 8c915783486221ca91e4d55a5b4c4feb3f073867..5e59b6d144c0a1aca580f5db294ebecd3e6ce199 100644 (file)
@@ -107,8 +107,6 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
        char *devname = devlist->devname;
        int journal_device_missing = 0;
 
-       struct createinfo *ci = conf_get_create_info();
-
        if (!stat_is_blkdev(devname, &rdev))
                return rv;
        dfd = dev_open(devname, O_RDONLY);
@@ -234,16 +232,6 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
        if (trustworthy == LOCAL_ANY)
                trustworthy = LOCAL;
 
-       /* There are three possible sources for 'autof':  command line,
-        * ARRAY line in mdadm.conf, or CREATE line in mdadm.conf.
-        * ARRAY takes precedence, then command line, then
-        * CREATE.
-        */
-       if (match && match->autof)
-               c->autof = match->autof;
-       if (c->autof == 0)
-               c->autof = ci->autof;
-
        name_to_use = info.name;
        if (name_to_use[0] == 0 && is_container(info.array.level)) {
                name_to_use = info.text_version;
@@ -297,8 +285,8 @@ int Incremental(struct mddev_dev *devlist, struct context *c,
                        goto out;
 
                /* Couldn't find an existing array, maybe make a new one */
-               mdfd = create_mddev(match ? match->devname : NULL,
-                                   name_to_use, c->autof, trustworthy, chosen_name, 0);
+               mdfd = create_mddev(match ? match->devname : NULL, name_to_use, trustworthy,
+                                   chosen_name, 0);
 
                if (mdfd < 0)
                        goto out_unlock;
@@ -1607,10 +1595,7 @@ static int Incremental_container(struct supertype *st, char *devname,
                        if (match)
                                trustworthy = LOCAL;
 
-                       mdfd = create_mddev(match ? match->devname : NULL,
-                                           ra->name,
-                                           c->autof,
-                                           trustworthy,
+                       mdfd = create_mddev(match ? match->devname : NULL, ra->name, trustworthy,
                                            chosen_name, 0);
 
                        if (!is_fd_valid(mdfd)) {
index 7f1baa7a9077f6a612599df707825f19677dd5b5..6cc5547dc4ff33c090c4606a2d169d2336301705 100644 (file)
--- a/ReadMe.c
+++ b/ReadMe.c
@@ -132,7 +132,7 @@ struct option long_options[] = {
        {"spare-disks", 1, 0, 'x'},
        {"spare-devices", 1, 0, 'x'},
        {"size", 1, 0, 'z'},
-       {"auto", 1, 0, Auto},
+       {"auto", 1, 0, Auto}, /* Deprecated, left for backward compatibility */
        {"assume-clean", 0, 0, AssumeClean },
        {"write-zeroes", 0, 0, WriteZeroes },
        {"metadata", 1, 0, 'e'}, /* superblock format */
@@ -578,7 +578,7 @@ char Help_config[] =
 "\n"
 " Other configuration lines include:\n"
 "  mailaddr, mailfrom, program, monitordelay    used for --monitor mode\n"
-"  create, auto                                 used when creating device names in /dev\n"
+"  create,                                      used when creating device names in /dev\n"
 "  homehost, homecluster, policy, part-policy   used to guide policy in various\n"
 "                                               situations\n"
 "\n"
index 022fb2a0f59846137bd4198f3192bfb60648d9ac..3359504d201b4cfc07cc4c2fde1e798ab5917557 100644 (file)
--- a/config.c
+++ b/config.c
@@ -171,7 +171,6 @@ inline void ident_init(struct mddev_ident *ident)
        assert(ident);
 
        ident->assembled = false;
-       ident->autof = 0;
        ident->bitmap_fd = -1;
        ident->bitmap_file = NULL;
        ident->container = NULL;
@@ -397,7 +396,6 @@ struct mddev_dev *load_containers(void)
 }
 
 struct createinfo createinfo = {
-       .autof = 2, /* by default, create devices with standard names */
        .names = 0, /* By default, stick with numbered md devices. */
        .bblist = 1, /* Use a bad block list by default */
 #ifdef DEBIAN
@@ -408,52 +406,6 @@ struct createinfo createinfo = {
 #endif
 };
 
-int parse_auto(char *str, char *msg, int config)
-{
-       int autof;
-       if (str == NULL || *str == 0)
-               autof = 2;
-       else if (strcasecmp(str, "no") == 0)
-               autof = 1;
-       else if (strcasecmp(str, "yes") == 0)
-               autof = 2;
-       else if (strcasecmp(str, "md") == 0)
-               autof = config ? 5:3;
-       else {
-               /* There might be digits, and maybe a hypen, at the end */
-               char *e = str + strlen(str);
-               int num = 4;
-               int len;
-               while (e > str && isdigit(e[-1]))
-                       e--;
-               if (*e) {
-                       num = atoi(e);
-                       if (num <= 0)
-                               num = 1;
-               }
-               if (e > str && e[-1] == '-')
-                       e--;
-               len = e - str;
-               if ((len == 2 && strncasecmp(str, "md", 2) == 0)) {
-                       autof = config ? 5 : 3;
-               } else if ((len == 3 && strncasecmp(str, "yes", 3) == 0)) {
-                       autof = 2;
-               } else if ((len == 3 && strncasecmp(str, "mdp", 3) == 0)) {
-                       autof = config ? 6 : 4;
-               } else if ((len == 1 && strncasecmp(str, "p", 1) == 0) ||
-                          (len >= 4 && strncasecmp(str, "part", 4) == 0)) {
-                       autof = 6;
-               } else {
-                       pr_err("%s arg of \"%s\" unrecognised: use no,yes,md,mdp,part\n"
-                               "        optionally followed by a number.\n",
-                               msg, str);
-                       exit(2);
-               }
-               autof |= num << 3;
-       }
-       return autof;
-}
-
 static void createline(char *line)
 {
        char *w;
@@ -461,7 +413,8 @@ static void createline(char *line)
 
        for (w = dl_next(line); w != line; w = dl_next(w)) {
                if (strncasecmp(w, "auto=", 5) == 0)
-                       createinfo.autof = parse_auto(w + 5, "auto=", 1);
+                       /* auto is no supported now, ignore it silently */
+                       continue;
                else if (strncasecmp(w, "owner=", 6) == 0) {
                        if (w[6] == 0) {
                                pr_err("missing owner name\n");
@@ -630,9 +583,9 @@ void arrayline(char *line)
                        if (!mis.st)
                                pr_err("metadata format %s unknown, ignored.\n",
                                       w + 9);
-               } else if (strncasecmp(w, "auto=", 5) == 0 ) {
-                       /* whether to create device special files as needed */
-                       mis.autof = parse_auto(w + 5, "auto type", 0);
+               } else if (strncasecmp(w, "auto=", 5) == 0) {
+                       /* Ignore for backward compatibility */
+                       continue;
                } else if (strncasecmp(w, "member=", 7) == 0) {
                        /* subarray within a container */
                        mis.member = xstrdup(w + 7);
index 43d6fe05f49fc8f1302f3d71dfbcdec340678829..12e7eb1ab1e6c4a5024f33303f30fda8a81f9c89 100644 (file)
@@ -968,63 +968,6 @@ rather than read-write as normal.  No writes will be allowed to the
 array, and no resync, recovery, or reshape will be started. It works with
 Create, Assemble, Manage and Misc mode.
 
-.TP
-.BR \-a ", " "\-\-auto{=yes,md,mdp,part,p}{NN}"
-Instruct mdadm how to create the device file if needed, possibly allocating
-an unused minor number.  "md" causes a non-partitionable array
-to be used (though since Linux 2.6.28, these array devices are in fact
-partitionable).  "mdp", "part" or "p" causes a partitionable array (2.6 and
-later) to be used.  "yes" requires the named md device to have
-a 'standard' format, and the type and minor number will be determined
-from this.  With mdadm 3.0, device creation is normally left up to
-.I udev
-so this option is unlikely to be needed.
-See DEVICE NAMES below.
-
-The argument can also come immediately after
-"\-a".  e.g. "\-ap".
-
-If
-.B \-\-auto
-is not given on the command line or in the config file, then
-the default will be
-.BR \-\-auto=yes .
-
-If
-.B \-\-scan
-is also given, then any
-.I auto=
-entries in the config file will override the
-.B \-\-auto
-instruction given on the command line.
-
-For partitionable arrays,
-.I mdadm
-will create the device file for the whole array and for the first 4
-partitions.  A different number of partitions can be specified at the
-end of this option (e.g.
-.BR \-\-auto=p7 ).
-If the device name ends with a digit, the partition names add a 'p',
-and a number, e.g.
-.IR /dev/md/home1p3 .
-If there is no trailing digit, then the partition names just have a
-number added, e.g.
-.IR /dev/md/scratch3 .
-
-If the md device name is in a 'standard' format as described in DEVICE
-NAMES, then it will be created, if necessary, with the appropriate
-device number based on that name.  If the device name is not in one of these
-formats, then an unused device number will be allocated.  The device
-number will be considered unused if there is no active array for that
-number, and there is no entry in /dev for that number and with a
-non-standard name.  Names that are not in 'standard' format are only
-allowed in "/dev/md/".
-
-This is meaningful with
-.B \-\-create
-or
-.BR \-\-build .
-
 .TP
 .BR \-a ", " "\-\-add"
 This option can be used in Grow mode in two cases.
@@ -1168,10 +1111,6 @@ are present.  This is only needed with
 and can be used if the physical connections to devices are
 not as reliable as you would like.
 
-.TP
-.BR \-a ", " "\-\-auto{=no,yes,md,mdp,part}"
-See this option under Create and Build options.
-
 .TP
 .BR \-b ", " \-\-bitmap=
 Specify the bitmap file that was given when the array was created.  If
diff --git a/mdadm.c b/mdadm.c
index 83051a1b8f0161fe06402ae41a48fecb72edbaf6..8cb4ba66ac202398bfeeb864e54a87460303c590 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -106,16 +106,6 @@ int main(int argc, char *argv[])
        mdu_array_info_t array;
        int devs_found = 0;
        int grow_continue = 0;
-       /* autof indicates whether and how to create device node.
-        * bottom 3 bits are style.  Rest (when shifted) are number of parts
-        * 0  - unset
-        * 1  - don't create (no)
-        * 2  - if is_standard, then create (yes)
-        * 3  - create as 'md' - reject is_standard mdp (md)
-        * 4  - create as 'mdp' - reject is_standard md (mdp)
-        * 5  - default to md if not is_standard (md in config file)
-        * 6  - default to mdp if not is_standard (part, or mdp in config file)
-        */
        struct context c = {
                .require_homehost = 1,
        };
@@ -704,8 +694,8 @@ int main(int argc, char *argv[])
                case O(INCREMENTAL,'a'):
                case O(INCREMENTAL,Auto):
                case O(ASSEMBLE,'a'):
-               case O(ASSEMBLE,Auto): /* auto-creation of device node */
-                       c.autof = parse_auto(optarg, "--auto flag", 0);
+               case O(ASSEMBLE, Auto): /* auto-creation of device node - deprecated */
+                       pr_info("--auto is deprecated and will be removed in future releases.\n");
                        continue;
                case O(BUILD,'f'): /* force honouring '-n 1' */
                case O(BUILD,Force): /* force honouring '-n 1' */
@@ -1318,10 +1308,6 @@ int main(int argc, char *argv[])
                if (ident_set_devname(&ident, devlist->devname) != MDADM_STATUS_SUCCESS)
                        exit(1);
 
-               if ((int)ident.super_minor == -2 && c.autof) {
-                       pr_err("--super-minor=dev is incompatible with --auto\n");
-                       exit(2);
-               }
                if (mode == MANAGE || mode == GROW) {
                        mdfd = open_mddev(ident.devname, 1);
                        if (mdfd < 0)
@@ -1403,8 +1389,6 @@ int main(int argc, char *argv[])
                exit(1);
        }
 
-       ident.autof = c.autof;
-
        if (c.scan && c.verbose < 2)
                /* --scan implied --brief unless -vv */
                c.brief = 1;
@@ -1456,8 +1440,6 @@ int main(int argc, char *argv[])
                                if (mdfd >= 0)
                                        close(mdfd);
                        } else {
-                               if (array_ident->autof == 0)
-                                       array_ident->autof = c.autof;
                                rv |= Assemble(ss, ident.devname, array_ident, NULL, &c);
                        }
                } else if (!c.scan)
@@ -1479,10 +1461,7 @@ int main(int argc, char *argv[])
                                        rv |= 1;
                                        continue;
                                }
-                               if (array_ident->autof == 0)
-                                       array_ident->autof = c.autof;
-                               rv |= Assemble(ss, dv->devname, array_ident,
-                                              NULL, &c);
+                               rv |= Assemble(ss, dv->devname, array_ident, NULL, &c);
                        }
                } else {
                        if (c.update) {
@@ -1748,11 +1727,10 @@ static int scan_assemble(struct supertype *ss,
                pr_err("No devices listed in conf file were found.\n");
                return 1;
        }
-       for (a = array_list; a; a = a->next) {
+
+       for (a = array_list; a; a = a->next)
                a->assembled = 0;
-               if (a->autof == 0)
-                       a->autof = c->autof;
-       }
+
        if (map_lock(&map))
                pr_err("failed to get exclusive lock on mapfile\n");
        do {
@@ -1784,7 +1762,7 @@ static int scan_assemble(struct supertype *ss,
                 */
                int rv2;
                int acnt;
-               ident->autof = c->autof;
+
                do {
                        struct mddev_dev *devlist = conf_get_devs();
                        acnt = 0;
index 97862fdb220d6ab5c8ed29eb97c235ee3cf788e8..dd407a0a1572cd932a66f7d76e6d120fc0c90cae 100644 (file)
@@ -184,27 +184,6 @@ will, when monitoring the arrays, move a spare drive from one array in
 a group to another array in that group if the first array had a failed
 or missing drive but no spare.
 
-.TP
-.B auto=
-This option is rarely needed with mdadm-3.0, particularly if use with
-the Linux kernel v2.6.28 or later.
-It tells
-.I mdadm
-whether to use partitionable array or non-partitionable arrays and,
-in the absence of
-.IR udev ,
-how many partition devices to create.  From 2.6.28 all md array
-devices are partitionable, hence this option is not needed.
-
-The value of this option can be "yes" or "md" to indicate that a
-traditional, non-partitionable md array should be created, or "mdp",
-"part" or "partition" to indicate that a partitionable md array (only
-available in linux 2.6 and later) should be used.  This later set can
-also have a number appended to indicate how many partitions to create
-device files for, e.g.
-.BR auto=mdp5 .
-The default is 4.
-
 .TP
 .B bitmap=
 The option specifies a file in which a write-intent bitmap should be
@@ -314,17 +293,6 @@ defaults (root/wheel or root/disk).
 .B mode=
 An octal file mode such as 0660 can be given to override the default
 of 0600.
-.TP
-.B auto=
-This corresponds to the
-.B \-\-auto
-flag to mdadm.  Give
-.BR yes ,
-.BR md ,
-.BR mdp ,
-.B part
-\(em possibly followed by a number of partitions \(em to indicate how
-missing device entries should be created.
 
 .TP
 .B metadata=
diff --git a/mdadm.h b/mdadm.h
index 0f40af933cf152fbac3f7f6d6e57621ca65fc5ef..5aa50854a250a3d156e34817762b49cde7f5b832 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -639,7 +639,6 @@ struct mddev_ident {
        int raid_disks;
        int spare_disks;
        struct supertype *st;
-       int     autof;          /* 1 for normal, 2 for partitioned */
        char    *spare_group;
        char    *bitmap_file;
        int     bitmap_fd;
@@ -674,7 +673,6 @@ struct context {
        enum    update_opt update;
        int     scan;
        int     SparcAdjust;
-       int     autof;
        int     delay;
        int     freeze_reshape;
        char    *backup_file;
@@ -1760,8 +1758,6 @@ extern char *human_size(long long bytes);
 extern char *human_size_brief(long long bytes, int prefix);
 extern void print_r10_layout(int layout);
 
-extern char *find_free_devnm(int use_partitions);
-
 extern void put_md_name(char *name);
 extern char *devid2kname(dev_t devid);
 extern char *devid2devnm(dev_t devid);
@@ -1770,8 +1766,7 @@ extern char *get_md_name(char *devnm);
 
 extern char DefaultConfFile[];
 
-extern int create_mddev(char *dev, char *name, int autof, int trustworthy,
-                       char *chosen, int block_udev);
+extern int create_mddev(char *dev, char *name, int trustworthy, char *chosen, int block_udev);
 /* values for 'trustworthy' */
 #define        LOCAL   1
 #define        LOCAL_ANY 10
index 8587524b09b832e34ac379b0ba2d988d1f778779..3532c758ace1fd8092a8ee2f5f778f9dfae64138 100644 (file)
--- a/mdopen.c
+++ b/mdopen.c
 
 #include <ctype.h>
 
-void make_parts(char *dev, int cnt)
-{
-       /* make 'cnt' partition devices for 'dev'
-        * If dev is a device name we use the
-        *  major/minor from dev and add 1..cnt
-        * If it is a symlink, we make similar symlinks.
-        * If dev ends with a digit, we add "p%d" else "%d"
-        * If the name exists, we use it's owner/mode,
-        * else that of dev
-        */
-       struct stat stb;
-       int major_num;
-       int minor_num;
-       int odig;
-       int i;
-       int nlen = strlen(dev) + 20;
-       char *name;
-       int dig = isdigit(dev[strlen(dev)-1]);
-       char orig[1001];
-       char sym[1024];
-       int err;
-
-       if (cnt == 0)
-               cnt = 4;
-       if (lstat(dev, &stb)!= 0)
-               return;
-
-       if (S_ISBLK(stb.st_mode)) {
-               major_num = major(stb.st_rdev);
-               minor_num = minor(stb.st_rdev);
-               odig = -1;
-       } else if (S_ISLNK(stb.st_mode)) {
-               int len;
-
-               len = readlink(dev, orig, sizeof(orig));
-               if (len < 0 || len >= (int)sizeof(orig))
-                       return;
-               orig[len] = 0;
-               odig = isdigit(orig[len-1]);
-               major_num = -1;
-               minor_num = -1;
-       } else
-               return;
-       name = xmalloc(nlen);
-       for (i = 1; i <= cnt ; i++) {
-               struct stat stb2;
-               snprintf(name, nlen, "%s%s%d", dev, dig?"p":"", i);
-               if (stat(name, &stb2) == 0) {
-                       if (!S_ISBLK(stb2.st_mode) || !S_ISBLK(stb.st_mode))
-                               continue;
-                       if (stb2.st_rdev == makedev(major_num, minor_num+i))
-                               continue;
-                       unlink(name);
-               } else {
-                       stb2 = stb;
-               }
-               if (S_ISBLK(stb.st_mode)) {
-                       if (mknod(name, S_IFBLK | 0600,
-                                 makedev(major_num, minor_num+i)))
-                               perror("mknod");
-                       if (chown(name, stb2.st_uid, stb2.st_gid))
-                               perror("chown");
-                       if (chmod(name, stb2.st_mode & 07777))
-                               perror("chmod");
-                       err = 0;
-               } else {
-                       snprintf(sym, sizeof(sym), "%s%s%d", orig, odig?"p":"", i);
-                       err = symlink(sym, name);
-               }
-
-               if (err == 0 && stat(name, &stb2) == 0)
-                       add_dev(name, &stb2, 0, NULL);
-       }
-       free(name);
-}
-
 int create_named_array(char *devnm)
 {
        int fd;
@@ -131,6 +55,35 @@ int create_named_array(char *devnm)
        return 1;
 }
 
+char *find_free_devnm(void)
+{
+       static char devnm[MD_NAME_MAX];
+       int devnum;
+
+       for (devnum = 127; devnum != 128; devnum = devnum ? devnum - 1 : 511) {
+               sprintf(devnm, "md%d", devnum);
+
+               if (mddev_busy(devnm))
+                       continue;
+
+               if (!conf_name_is_free(devnm))
+                       continue;
+
+               if (!udev_is_available()) {
+                       /* make sure it is new to /dev too*/
+                       dev_t devid = devnm2devid(devnm);
+
+                       if (devid && map_dev(major(devid), minor(devid), 0))
+                               continue;
+               }
+
+               break;
+       }
+       if (devnum == 128)
+               return NULL;
+       return devnm;
+}
+
 /*
  * We need a new md device to assemble/build/create an array.
  * 'dev' is a name given us by the user (command line or mdadm.conf)
@@ -165,15 +118,13 @@ int create_named_array(char *devnm)
  * When we create devices, we use uid/gid/umask from config file.
  */
 
-int create_mddev(char *dev, char *name, int autof, int trustworthy,
+int create_mddev(char *dev, char *name, int trustworthy,
                 char *chosen, int block_udev)
 {
        int mdfd;
        struct stat stb;
        int num = -1;
-       int use_mdp = -1;
        struct createinfo *ci = conf_get_create_info();
-       int parts;
        char *cname;
        char devname[37];
        char devnm[32];
@@ -185,12 +136,6 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
        if (chosen == NULL)
                chosen = cbuf;
 
-       if (autof == 0)
-               autof = ci->autof;
-
-       parts = autof >> 3;
-       autof &= 7;
-
        strcpy(chosen, DEV_MD_DIR);
        cname = chosen + strlen(chosen);
 
@@ -212,12 +157,9 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
                                        dev, dev+5);
                                return -1;
                        }
-                       if (strcmp(cname, "md") == 0)
-                               use_mdp = 0;
-                       else
-                               use_mdp = 1;
+
                        /* recreate name: /dev/md/0 or /dev/md/d0 */
-                       sprintf(cname, "%s%d", use_mdp?"d":"", num);
+                       sprintf(cname, "%d", num);
                } else
                        strcpy(cname, dev);
 
@@ -246,10 +188,6 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
                                ep = sp;
                        if (ep == sp || *ep || num < 0)
                                num = -1;
-                       else if (cname[0] == 'd')
-                               use_mdp = 1;
-                       else
-                               use_mdp = 0;
                }
        }
 
@@ -257,18 +195,11 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
        /* named 'METADATA' cannot use 'mdp'. */
        if (name && name[0] == 0)
                name = NULL;
-       if (name && trustworthy == METADATA && use_mdp == 1) {
+       if (name && trustworthy == METADATA) {
                pr_err("%s is not allowed for a %s container. Consider /dev/md%d.\n", dev, name, num);
                return -1;
        }
-       if (name && trustworthy == METADATA)
-               use_mdp = 0;
-       if (use_mdp == -1) {
-               if (autof == 4 || autof == 6)
-                       use_mdp = 1;
-               else
-                       use_mdp = 0;
-       }
+
        if (num < 0 && trustworthy == LOCAL && name) {
                /* if name is numeric, possibly prefixed by
                 * 'md' or '/dev/md', use that for num
@@ -285,7 +216,7 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
                if (ep == n2 || *ep)
                        num = -1;
                else {
-                       sprintf(devnm, "md%s%d", use_mdp ? "_d":"", num);
+                       sprintf(devnm, "md%d", num);
                        if (mddev_busy(devnm))
                                num = -1;
                }
@@ -357,14 +288,15 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
        if (devnm[0] == 0) {
                if (num < 0) {
                        /* need to choose a free number. */
-                       char *_devnm = find_free_devnm(use_mdp);
-                       if (_devnm == NULL) {
+                       char *_devnm = find_free_devnm();
+
+                       if (!_devnm) {
                                pr_err("No avail md devices - aborting\n");
                                return -1;
                        }
                        strcpy(devnm, _devnm);
                } else {
-                       sprintf(devnm, "%s%d", use_mdp?"md_d":"md", num);
+                       sprintf(devnm, "md%d", num);
                        if (mddev_busy(devnm)) {
                                pr_err("%s is already in use.\n",
                                       dev);
@@ -415,8 +347,6 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
                        }
                        add_dev(devname, &stb, 0, NULL);
                }
-               if (use_mdp == 1)
-                       make_parts(devname, parts);
 
                if (strcmp(chosen, devname) != 0) {
                        if (mkdir(DEV_NUM_PREF, 0700) == 0) {
@@ -446,8 +376,6 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
                        } else if (symlink(devname, chosen) != 0)
                                pr_err("failed to create %s: %s\n",
                                        chosen, strerror(errno));
-                       if (use_mdp && strcmp(chosen, devname) != 0)
-                               make_parts(chosen, parts);
                }
        }
        mdfd = open_dev_excl(devnm);
@@ -499,36 +427,3 @@ int is_mddev(char *dev)
 
        return 0;
 }
-
-char *find_free_devnm(int use_partitions)
-{
-       static char devnm[32];
-       int devnum;
-       for (devnum = 127; devnum != 128;
-            devnum = devnum ? devnum-1 : (1<<9)-1) {
-
-               if (use_partitions)
-                       sprintf(devnm, "md_d%d", devnum);
-               else
-                       sprintf(devnm, "md%d", devnum);
-               if (mddev_busy(devnm))
-                       continue;
-               if (!conf_name_is_free(devnm))
-                       continue;
-               if (!udev_is_available()) {
-                       /* make sure it is new to /dev too, at least as a
-                        * non-standard */
-                       dev_t devid = devnm2devid(devnm);
-                       if (devid) {
-                               char *dn = map_dev(major(devid),
-                                                  minor(devid), 0);
-                               if (dn && ! is_standard(dn, NULL))
-                                       continue;
-                       }
-               }
-               break;
-       }
-       if (devnum == 128)
-               return NULL;
-       return devnm;
-}
diff --git a/util.c b/util.c
index f05392a2ddd243141956bd9329af99c7de5ac1db..a120c985d870af0a7c26a075afaa33982248e1f3 100644 (file)
--- a/util.c
+++ b/util.c
@@ -760,42 +760,6 @@ bad_option:
        return 0;
 }
 
-int is_standard(char *dev, int *nump)
-{
-       /* tests if dev is a "standard" md dev name.
-        * i.e if the last component is "/dNN" or "/mdNN",
-        * where NN is a string of digits
-        * Returns 1 if a partitionable standard,
-        *   -1 if non-partitonable,
-        *   0 if not a standard name.
-        */
-       char *d = strrchr(dev, '/');
-       int type = 0;
-       int num;
-       if (!d)
-               return 0;
-       if (strncmp(d, "/d",2) == 0)
-               d += 2, type = 1; /* /dev/md/dN{pM} */
-       else if (strncmp(d, "/md_d", 5) == 0)
-               d += 5, type = 1; /* /dev/md_dN{pM} */
-       else if (strncmp(d, "/md", 3) == 0)
-               d += 3, type = -1; /* /dev/mdN */
-       else if (d-dev > 3 && strncmp(d-2, "md/", 3) == 0)
-               d += 1, type = -1; /* /dev/md/N */
-       else
-               return 0;
-       if (!*d)
-               return 0;
-       num = atoi(d);
-       while (isdigit(*d))
-               d++;
-       if (*d)
-               return 0;
-       if (nump) *nump = num;
-
-       return type;
-}
-
 unsigned long calc_csum(void *super, int bytes)
 {
        unsigned long long newcsum = 0;