summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>2024-10-07 14:20:17 +0200
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>2024-11-05 13:36:43 +0100
commit119cdcad049e0464bfdd9ab19e2fd8cb4f9a82d6 (patch)
tree95dea358d25a8fdea7acabdfae6911eed7bb82f2
parentReadMe: Fix stylistic issues (diff)
downloadmdadm-119cdcad049e0464bfdd9ab19e2fd8cb4f9a82d6.tar.xz
mdadm-119cdcad049e0464bfdd9ab19e2fd8cb4f9a82d6.zip
mdadm: drop auto= support
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>
-rw-r--r--Assemble.c3
-rw-r--r--Build.c3
-rw-r--r--Create.c2
-rw-r--r--Incremental.c21
-rw-r--r--ReadMe.c4
-rw-r--r--config.c57
-rw-r--r--mdadm.8.in61
-rw-r--r--mdadm.c36
-rw-r--r--mdadm.conf.5.in32
-rw-r--r--mdadm.h7
-rw-r--r--mdopen.c183
-rw-r--r--util.c36
12 files changed, 60 insertions, 385 deletions
diff --git a/Assemble.c b/Assemble.c
index d3dbfbc6..87d1ae04 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -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 052b1bc2..6f63d3f3 100644
--- 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;
diff --git a/Create.c b/Create.c
index 1640f21e..140a7098 100644
--- 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;
diff --git a/Incremental.c b/Incremental.c
index 8c915783..5e59b6d1 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -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)) {
diff --git a/ReadMe.c b/ReadMe.c
index 7f1baa7a..6cc5547d 100644
--- 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"
diff --git a/config.c b/config.c
index 022fb2a0..3359504d 100644
--- 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);
diff --git a/mdadm.8.in b/mdadm.8.in
index 43d6fe05..12e7eb1a 100644
--- a/mdadm.8.in
+++ b/mdadm.8.in
@@ -969,63 +969,6 @@ 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.
@@ -1169,10 +1112,6 @@ 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
an array has an
diff --git a/mdadm.c b/mdadm.c
index 83051a1b..8cb4ba66 100644
--- 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;
diff --git a/mdadm.conf.5.in b/mdadm.conf.5.in
index 97862fdb..dd407a0a 100644
--- a/mdadm.conf.5.in
+++ b/mdadm.conf.5.in
@@ -185,27 +185,6 @@ 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
found. When assembling the array,
@@ -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 0f40af93..5aa50854 100644
--- 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
diff --git a/mdopen.c b/mdopen.c
index 8587524b..3532c758 100644
--- a/mdopen.c
+++ b/mdopen.c
@@ -29,82 +29,6 @@
#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 f05392a2..a120c985 100644
--- 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;