Initial DDF support code.
Create a ddf array by naming the device /dev/ddf* or specifying metadata 'ddf'. If ddf is specified with no level, assume a container (indeed, anything else would be wrong). **Need to use text_Version to set external metadata... More ddf support Load a ddf container. Now --examine /dev/ddf works. super-ddf: fix compile warning From: Dan Williams <dan.j.williams@intel.com> super-ddf.c:723: format %lu expects type long unsigned int, but argument 3 has type unsigned int Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
parent
d03373f1de
commit
a322f70c41
8
Create.c
8
Create.c
|
@ -92,6 +92,14 @@ int Create(struct supertype *st, char *mddev, int mdfd,
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
if (level == UnSet) {
|
||||
/* "ddf" metadata only supports one level - should possibly
|
||||
* push this into metadata handler??
|
||||
*/
|
||||
if (st && st->ss == &super_ddf)
|
||||
level = LEVEL_CONTAINER;
|
||||
}
|
||||
|
||||
if (level == UnSet) {
|
||||
fprintf(stderr,
|
||||
Name ": a RAID level is needed to create an array.\n");
|
||||
|
|
11
Makefile
11
Makefile
|
@ -69,18 +69,19 @@ MAN8DIR = $(MANDIR)/man8
|
|||
OBJS = mdadm.o config.o mdstat.o ReadMe.o util.o Manage.o Assemble.o Build.o \
|
||||
Create.o Detail.o Examine.o Grow.o Monitor.o dlink.o Kill.o Query.o \
|
||||
Incremental.o \
|
||||
mdopen.o super0.o super1.o bitmap.o restripe.o sysfs.o sha1.o \
|
||||
mapfile.o crc32.o
|
||||
mdopen.o super0.o super1.o super-ddf.o bitmap.o restripe.o sysfs.o \
|
||||
sha1.o mapfile.o crc32.o
|
||||
SRCS = mdadm.c config.c mdstat.c ReadMe.c util.c Manage.c Assemble.c Build.c \
|
||||
Create.c Detail.c Examine.c Grow.c Monitor.c dlink.c Kill.c Query.c \
|
||||
Incremental.c \
|
||||
mdopen.c super0.c super1.c bitmap.c restripe.c sysfs.c sha1.c \
|
||||
mapfile.c crc32.c
|
||||
mdopen.c super0.c super1.c super-ddf.c bitmap.c restripe.c sysfs.c \
|
||||
sha1.c mapfile.c crc32.c
|
||||
|
||||
STATICSRC = pwgr.c
|
||||
STATICOBJS = pwgr.o
|
||||
|
||||
ASSEMBLE_SRCS := mdassemble.c Assemble.c Manage.c config.c dlink.c util.c super0.c super1.c sha1.c
|
||||
ASSEMBLE_SRCS := mdassemble.c Assemble.c Manage.c config.c dlink.c util.c \
|
||||
super0.c super1.c super-ddf.c sha1.c crc32.c
|
||||
ASSEMBLE_FLAGS:= $(CFLAGS) -DMDASSEMBLE
|
||||
ifdef MDASSEMBLE_AUTO
|
||||
ASSEMBLE_SRCS += mdopen.c mdstat.c
|
||||
|
|
35
TODO
35
TODO
|
@ -1,3 +1,38 @@
|
|||
- add 'name' field to metadata type and use it.
|
||||
- use validate_geometry more
|
||||
- metadata should be able to check/reject bitmap stuff.
|
||||
|
||||
DDF:
|
||||
Three new metadata types:
|
||||
ddf - used only to create a container.
|
||||
ddf-bvd - used to create an array in a container
|
||||
ddf-svd - used to create a secondary array from bvds.
|
||||
|
||||
Usage:
|
||||
mdadm -C /dev/ddf1 /dev/sd[abcdef]
|
||||
mdadm -C /dev/md1 -e ddf /dev/sd[a-f]
|
||||
mdadm -C /dev/md1 -l container /dev/sd[a-f]
|
||||
|
||||
Each of these create a new ddf container using all those
|
||||
devices. The name 'ddf*' signals that ddf metadata should be used.
|
||||
'-e ddf' only supports one level - 'container'. 'container' is only
|
||||
supported by ddf.
|
||||
|
||||
mdadm -C /dev/md1 -l0 -n4 /dev/ddf1 # or maybe not ???
|
||||
mdadm -C /dev/md1 -l1 -n2 /dev/sda /dev/sdb
|
||||
If exactly one device is given, and it is a container, we select
|
||||
devices from that container.
|
||||
If devices are given that are already in use, they must be in use by
|
||||
a container, and the array is created in the container.
|
||||
If devices given are bvds, we slip under the hood to make
|
||||
the svd arrays.
|
||||
|
||||
mdadm -A /dev/ddf ......
|
||||
base drives make a container. Anything in that container is started
|
||||
auto-read-only.
|
||||
if /dev/ddf is already assembled, we assemble bvds and svds inside it.
|
||||
|
||||
|
||||
2005-dec-20
|
||||
Want an incremental assembly mode to work nicely with udev.
|
||||
Core usage would be something like
|
||||
|
|
4
mdadm.h
4
mdadm.h
|
@ -380,7 +380,7 @@ extern struct superswitch {
|
|||
char *text_version;
|
||||
int swapuuid; /* true if uuid is bigending rather than hostendian */
|
||||
int external;
|
||||
} super0, super1, *superlist[];
|
||||
} super0, super1, super_ddf, super_ddf_bvd, super_ddf_svd, *superlist[];
|
||||
|
||||
struct supertype {
|
||||
struct superswitch *ss;
|
||||
|
@ -546,6 +546,7 @@ extern char DefaultConfFile[];
|
|||
extern int open_mddev(char *dev, int autof);
|
||||
extern int open_mddev_devnum(char *devname, int devnum, char *name,
|
||||
char *chosen_name, int parts);
|
||||
extern int open_container(int fd);
|
||||
|
||||
|
||||
#define LEVEL_MULTIPATH (-4)
|
||||
|
@ -554,6 +555,7 @@ extern int open_mddev_devnum(char *devname, int devnum, char *name,
|
|||
|
||||
/* kernel module doesn't know about these */
|
||||
#define LEVEL_CONTAINER (-100)
|
||||
#define LEVEL_UNSUPPORTED (-200)
|
||||
|
||||
|
||||
/* faulty stuff */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
52
util.c
52
util.c
|
@ -31,6 +31,7 @@
|
|||
#include "md_p.h"
|
||||
#include <sys/utsname.h>
|
||||
#include <ctype.h>
|
||||
#include <dirent.h>
|
||||
|
||||
/*
|
||||
* following taken from linux/blkpg.h because they aren't
|
||||
|
@ -759,7 +760,7 @@ int dev_open(char *dev, int flags)
|
|||
return fd;
|
||||
}
|
||||
|
||||
struct superswitch *superlist[] = { &super0, &super1, NULL };
|
||||
struct superswitch *superlist[] = { &super0, &super1, &super_ddf, NULL };
|
||||
|
||||
#if !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO)
|
||||
struct supertype *super_by_fd(int fd)
|
||||
|
@ -908,6 +909,55 @@ void get_one_disk(int mdfd, mdu_array_info_t *ainf, mdu_disk_info_t *disk)
|
|||
return;
|
||||
}
|
||||
|
||||
int open_container(int fd)
|
||||
{
|
||||
/* 'fd' is a block device. Find out if it is in use
|
||||
* by a container, and return an open fd on that container.
|
||||
*/
|
||||
char path[256];
|
||||
char *e;
|
||||
DIR *dir;
|
||||
struct dirent *de;
|
||||
int dfd, n;
|
||||
char buf[200];
|
||||
int major, minor;
|
||||
struct stat st;
|
||||
|
||||
if (fstat(fd, &st) != 0)
|
||||
return -1;
|
||||
sprintf(path, "/sys/dev/block/%d:%d/holders",
|
||||
(int)major(st.st_rdev), (int)minor(st.st_rdev));
|
||||
e = path + strlen(path);
|
||||
|
||||
dir = opendir(path);
|
||||
if (!dir)
|
||||
return -1;
|
||||
while ((de = readdir(dir))) {
|
||||
if (de->d_ino == 0)
|
||||
continue;
|
||||
if (de->d_name[0] == '.')
|
||||
continue;
|
||||
sprintf(e, "/%s/dev", de->d_name);
|
||||
dfd = open(path, O_RDONLY);
|
||||
if (dfd < 0)
|
||||
continue;
|
||||
n = read(dfd, buf, sizeof(buf));
|
||||
close(dfd);
|
||||
if (n <= 0 || n >= sizeof(buf))
|
||||
continue;
|
||||
buf[n] = 0;
|
||||
if (sscanf(buf, "%d:%d", &major, &minor) != 2)
|
||||
continue;
|
||||
sprintf(buf, "%d:%d", major, minor);
|
||||
dfd = dev_open(buf, O_RDONLY);
|
||||
if (dfd >= 0) {
|
||||
closedir(dir);
|
||||
return dfd;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef __TINYC__
|
||||
/* tinyc doesn't optimize this check in ioctl.h out ... */
|
||||
unsigned int __invalid_size_argument_for_IOC = 0;
|
||||
|
|
Loading…
Reference in New Issue