FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Device-mapper Development

 
 
LinkBack Thread Tools
 
Old 06-20-2008, 09:52 PM
 
Default dmraid ./configure ./configure.in include/dmra ...

CVSROOT: /cvs/dm
Module name: dmraid
Changes by: heinzm@sourceware.org 2008-06-20 21:52:19

Modified files:
. : configure configure.in
include/dmraid : display.h dmraid.h format.h lib_context.h
list.h locking.h metadata.h misc.h reconfig.h
lib : .export.sym version.h
lib/activate : activate.c devmapper.c
lib/datastruct : byteorder.h
lib/device : ata.c ata.h dev-io.h scan.c scsi.c scsi.h
lib/display : display.c
lib/format : format.c register.h
lib/format/ataraid: asr.c asr.h hpt37x.c hpt37x.h hpt45x.c
hpt45x.h isw.c isw.h jm.c jm.h lsi.c lsi.h
nv.c nv.h pdc.c pdc.h sil.c sil.h via.c
via.h
lib/format/ddf : ddf1.c ddf1.h ddf1_crc.c ddf1_cvt.c ddf1_cvt.h
ddf1_dump.c ddf1_lib.c ddf1_lib.h
lib/format/partition: dos.c dos.h
lib/format/template: template.c template.h
lib/locking : locking.c
lib/log : log.c
lib/metadata : log_ops.c metadata.c reconfig.c
lib/misc : file.c init.c lib_context.c misc.c workaround.c
lib/mm : dbg_malloc.c
man : dmraid.8
tools : VERSION commands.c commands.h dmraid.c
toollib.c toollib.h

Log message:
Intel Software RAID create/delete/spare/rebuild support

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/configure.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/configure.in.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/include/dmraid/display.h.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/include/dmraid/dmraid.h.diff?cvsroot=dm&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/include/dmraid/format.h.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/include/dmraid/lib_context.h.diff?cvsroot=dm&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/include/dmraid/list.h.diff?cvsroot=dm&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/include/dmraid/locking.h.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/include/dmraid/metadata.h.diff?cvsroot=dm&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/include/dmraid/misc.h.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/include/dmraid/reconfig.h.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/.export.sym.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/version.h.diff?cvsroot=dm&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/activate/activate.c.diff?cvsroot=dm&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/activate/devmapper.c.diff?cvsroot=dm&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/datastruct/byteorder.h.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/device/ata.c.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/device/ata.h.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/device/dev-io.h.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/device/scan.c.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/device/scsi.c.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/device/scsi.h.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/display/display.c.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/format.c.diff?cvsroot=dm&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/register.h.diff?cvsroot=dm&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ataraid/asr.c.diff?cvsroot=dm&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ataraid/asr.h.diff?cvsroot=dm&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ataraid/hpt37x.c.diff?cvsroot=dm&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ataraid/hpt37x.h.diff?cvsroot=dm&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ataraid/hpt45x.c.diff?cvsroot=dm&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ataraid/hpt45x.h.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ataraid/isw.c.diff?cvsroot=dm&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ataraid/isw.h.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ataraid/jm.c.diff?cvsroot=dm&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ataraid/jm.h.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ataraid/lsi.c.diff?cvsroot=dm&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ataraid/lsi.h.diff?cvsroot=dm&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ataraid/nv.c.diff?cvsroot=dm&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ataraid/nv.h.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ataraid/pdc.c.diff?cvsroot=dm&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ataraid/pdc.h.diff?cvsroot=dm&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ataraid/sil.c.diff?cvsroot=dm&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ataraid/sil.h.diff?cvsroot=dm&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ataraid/via.c.diff?cvsroot=dm&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ataraid/via.h.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ddf/ddf1.c.diff?cvsroot=dm&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ddf/ddf1.h.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ddf/ddf1_crc.c.diff?cvsroot=dm&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ddf/ddf1_cvt.c.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ddf/ddf1_cvt.h.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ddf/ddf1_dump.c.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ddf/ddf1_lib.c.diff?cvsroot=dm&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ddf/ddf1_lib.h.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/partition/dos.c.diff?cvsroot=dm&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/partition/dos.h.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/template/template.c.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/template/template.h.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/locking/locking.c.diff?cvsroot=dm&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/log/log.c.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/metadata/log_ops.c.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/metadata/metadata.c.diff?cvsroot=dm&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/metadata/reconfig.c.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/misc/file.c.diff?cvsroot=dm&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/misc/init.c.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/misc/lib_context.c.diff?cvsroot=dm&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/misc/misc.c.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/misc/workaround.c.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/mm/dbg_malloc.c.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/man/dmraid.8.diff?cvsroot=dm&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/tools/VERSION.diff?cvsroot=dm&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/tools/commands.c.diff?cvsroot=dm&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/tools/commands.h.diff?cvsroot=dm&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/tools/dmraid.c.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/tools/toollib.c.diff?cvsroot=dm&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/tools/toollib.h.diff?cvsroot=dm&r1=1.1&r2=1.2

--- dmraid/configure 2008/02/22 16:50:38 1.1
+++ dmraid/configure 2008/06/20 21:52:15 1.2
@@ -854,8 +854,10 @@
--enable-jobs=NUM Number of jobs to run simultaneously
--enable-libselinux Use this to link the tools to libselinux
--enable-libsepol Use this to link the tools to libsepol
- --enable-mini Use this to create a minimal binrary suitable
+ --enable-mini Use this to create a minimal binary suitable
for early boot environments
+ --enable-led Use this to enable LED support
+ --enable-intel_led Use this to enable Intel LED support
--disable-native_log Disable native metadata logging. Default is enabled
--enable-static_link Use this to link the tools to the dmraid and devmapper
libraries statically. Default is dynamic linking
@@ -4513,6 +4515,22 @@
DMRAID_MINI=no
fi;

+# Check whether --enable-led or --disable-led was given.
+if test "${enable_led+set}" = set; then
+ enableval="$enable_led"
+ DMRAID_LED=$enableval
+else
+ DMRAID_LED=no
+fi;
+
+# Check whether --enable-intel_led or --disable-intel_led was given.
+if test "${enable_intel_led+set}" = set; then
+ enableval="$enable_intel_led"
+ DMRAID_INTEL_LED=$enableval
+else
+ DMRAID_INTEL_LED=no
+fi;
+
echo $ac_n "checking whether to disable native metadata logging""... $ac_c" 1>&6
# Check whether --enable-native_log or --disable-native_log was given.
if test "${enable_native_log+set}" = set; then
@@ -4577,6 +4595,14 @@
fi
fi

+if test x$DMRAID_LED = xyes; then
+ CFLAGS="$CFLAGS -DDMRAID_LED"
+fi
+
+if test x$DMRAID_INTEL_LED = xyes; then
+ CFLAGS="$CFLAGS -DDMRAID_LED -DDMRAID_INTEL_LED"
+fi
+
if test x$DEBUG = xyes; then
FLAVOUR="${FLAVOUR}debug "
fi
--- dmraid/configure.in 2008/02/22 16:50:38 1.1
+++ dmraid/configure.in 2008/06/20 21:52:15 1.2
@@ -107,9 +107,15 @@
AC_ARG_ENABLE(libsepol, [ --enable-libsepol Use this to link the tools to libsepol ], LIBSEPOL=$enableval, LIBSEPOL=no)

dnl Enables mini binary
-AC_ARG_ENABLE(mini, [ --enable-mini Use this to create a minimal binrary suitable
+AC_ARG_ENABLE(mini, [ --enable-mini Use this to create a minimal binary suitable
for early boot environments], DMRAID_MINI=$enableval, DMRAID_MINI=no)

+dnl Enables LED support
+AC_ARG_ENABLE(led, [ --enable-led Use this to enable LED support], DMRAID_LED=$enableval, DMRAID_LED=no)
+
+dnl Enables Intel LED support
+AC_ARG_ENABLE(intel_led, [ --enable-intel_led Use this to enable Intel LED support], DMRAID_INTEL_LED=$enableval, DMRAID_INTEL_LED=no)
+
echo $ac_n "checking whether to disable native metadata logging""... $ac_c" 1>&6
dnl Disable native metadata logging
AC_ARG_ENABLE(native_log, [ --disable-native_log Disable native metadata logging. Default is enabled],
@@ -155,6 +161,14 @@
fi
fi

+if test x$DMRAID_LED = xyes; then
+ CFLAGS="$CFLAGS -DDMRAID_LED"
+fi
+
+if test x$DMRAID_INTEL_LED = xyes; then
+ CFLAGS="$CFLAGS -DDMRAID_LED -DDMRAID_INTEL_LED"
+fi
+
if test x$DEBUG = xyes; then
FLAVOUR="${FLAVOUR}debug "
fi
--- dmraid/include/dmraid/display.h 2008/02/22 16:57:35 1.1
+++ dmraid/include/dmraid/display.h 2008/06/20 21:52:16 1.2
@@ -9,15 +9,15 @@
#define _DISPLAY_H_

enum dev_type {
- DEVICE = 0x01, /* ALL devices */
- RAID = 0x02, /* RAID devices */
- NATIVE = 0x04, /* Native metadata of RAID devices */
- SET = 0x08, /* RAID sets */
+ DEVICE = 0x01, /* ALL devices */
+ RAID = 0x02, /* RAID devices */
+ NATIVE = 0x04, /* Native metadata of RAID devices */
+ SET = 0x08, /* RAID sets */
};

enum active_type {
- D_ALL = 0x01, /* All devices */
- D_ACTIVE = 0x02, /* Active devices only */
+ D_ALL = 0x01, /* All devices */
+ D_ACTIVE = 0x02, /* Active devices only */
D_INACTIVE = 0x04, /* Inactive devices only */
};

--- dmraid/include/dmraid/dmraid.h 2008/02/22 17:04:35 1.2
+++ dmraid/include/dmraid/dmraid.h 2008/06/20 21:52:16 1.3
@@ -1,7 +1,10 @@
/*
- * Copyright (C) 2004,2005 Heinz Mauelshagen, Red Hat GmbH.
+ * Copyright (C) 2004-2008 Heinz Mauelshagen, Red Hat GmbH.
* All rights reserved.
*
+ * Copyright (C) 2007 Intel Corporation. All rights reserved.
+ * November, 2007 - additions for Create, Delete, Rebuild & Raid 10.
+ *
* See file LICENSE at the top of this source tree for license information.
*/

@@ -56,7 +59,7 @@
*/
extern const char *get_set_type(struct lib_context *lc, void *rs);
extern const char *get_set_name(struct lib_context *lc, void *rs);
-extern int group_set(struct lib_context *lc, char *name);
+extern int group_set(struct lib_context *lc, char **name);
extern char *libdmraid_make_table(struct lib_context *lc, struct raid_set *rs);

enum activate_type {
@@ -65,8 +68,8 @@
};

extern void process_sets(struct lib_context *lc,
- int (*func)(struct lib_context *lc, void *rs, int arg),
- int arg, enum set_type type);
+ int (*func) (struct lib_context * lc, void *rs,
+ int arg), int arg, enum set_type type);
extern int change_set(struct lib_context *lc, enum activate_type what,
void *rs);

--- dmraid/include/dmraid/format.h 2008/02/22 16:57:35 1.1
+++ dmraid/include/dmraid/format.h 2008/06/20 21:52:16 1.2
@@ -1,6 +1,9 @@
/*
- * Copyright (C) 2004,2005 Heinz Mauelshagen, Red Hat GmbH.
+ * Copyright (C) 2004-2008 Heinz Mauelshagen, Red Hat GmbH.
* All rights reserved.
+ *
+ * Copyright (C) 2007 Intel Corporation. All rights reserved.
+ * November, 2007 - additions for Create, Delete, Rebuild & Raid 10.
*
* See file LICENSE at the top of this source tree for license information.
*/
@@ -40,7 +43,7 @@
struct event_rd {
struct raid_set *rs;
struct raid_dev *rd;
- enum rd_action action;
+ enum rd_action action;
};

/*
@@ -51,10 +54,46 @@
*/
struct event_handlers {
/* Handle IO error */
- int (*io)(struct lib_context *lc, struct event_io *e_io);
+ int (*io) (struct lib_context * lc, struct event_io * e_io);

/* Handle RAID device add/remove. */
- int (*rd)(struct lib_context *lc, struct event_rd *e_rd);
+ int (*rd) (struct lib_context * lc, struct event_rd * e_rd);
+};
+
+/*
+ * Hot-spare search types list: it can be searched locally/globally
+ */
+enum scope {
+ t_scope_local = 0x01,
+ t_scope_global = 0x02
+};
+
+/* Metadata Handler commands */
+enum handler_commands {
+ UPDATE_REBUILD_STATE,
+ GET_REBUILD_STATE,
+ GET_REBUILD_DRIVE,
+ GET_REBUILD_DRIVE_NO,
+ CHECK_HOT_SPARE,
+ /* ... */
+};
+
+/* Union to return metadata_handler information. */
+struct handler_info {
+ unsigned short size;
+
+ union {
+ char *str;
+ void *ptr;
+ int8_t i8;
+ int16_t i16;
+ int32_t i32;
+ int64_t i64;
+ uint8_t u8;
+ uint16_t u16;
+ uint32_t u32;
+ uint64_t u64;
+ } data;
};

/*
@@ -69,33 +108,54 @@
/*
* Read RAID metadata off a device and unify it.
*/
- struct raid_dev* (*read)(struct lib_context *lc, struct dev_info* di);
+ struct raid_dev *(*read) (struct lib_context * lc,
+ struct dev_info * di);

/*
* Write RAID metadata to a device deunifying it
* or erase ondisk metadata if erase != 0.
*/
- int (*write)(struct lib_context *lc, struct raid_dev* rd, int erase);
+ int (*write) (struct lib_context * lc, struct raid_dev * rd, int erase);
+
+ /*
+ * delete RAID metadata to devices.
+ */
+ int (*delete) (struct lib_context * lc, struct raid_set * rs);
+
+ /*
+ * create RAID metadata to devices.
+ */
+ int (*create) (struct lib_context * lc, struct raid_set * rs);

/*
* Group a RAID device into a set.
*/
- struct raid_set* (*group)(struct lib_context *lc, struct raid_dev *rd);
+ struct raid_set *(*group) (struct lib_context * lc,
+ struct raid_dev * rd);

/*
* Check consistency of the RAID set metadata.
*/
- int (*check)(struct lib_context *lc, struct raid_set *rs);
+ int (*check) (struct lib_context * lc, struct raid_set * rs);
+
+ /* Metadata handler. */
+ int (*metadata_handler) (struct lib_context * lc,
+ enum handler_commands command,
+ struct handler_info * info, void *ptr);

/*
* Event handlers (eg, I/O error).
*/
struct event_handlers *events;

+ /*
+ * Hot-spare disk search scope
+ */
+ enum scope scope;
/*
* Display RAID disk metadata native.
*/
- void (*log)(struct lib_context *lc, struct raid_dev *rd);
+ void (*log) (struct lib_context * lc, struct raid_dev * rd);
};

/* Chain of registered format handlers (needed for library context). */
@@ -113,14 +173,13 @@
*/
#define NO_CHECK_RD NULL
extern int check_raid_set(struct lib_context *lc, struct raid_set *rs,
- unsigned int (*f_devices)(struct raid_dev *rd,
- void *context),
+ unsigned int (*f_devices) (struct raid_dev * rd,
+ void *context),
void *f_devices_context,
- int (*f_check)(struct lib_context *lc,
- struct raid_set *rs,
- struct raid_dev *rd, void *context),
- void *f_check_context,
- const char *handler);
+ int (*f_check) (struct lib_context * lc,
+ struct raid_set * rs,
+ struct raid_dev * rd, void *context),
+ void *f_check_context, const char *handler);
extern int check_valid_format(struct lib_context *lc, char *fmt);
extern int init_raid_set(struct lib_context *lc, struct raid_set *rs,
struct raid_dev *rd, unsigned int stride,
@@ -135,22 +194,29 @@
uint64_t u64;
};

-struct raid_dev *read_raid_dev(
- struct lib_context *lc,
- struct dev_info *di,
- void* (*f_read_metadata)(struct lib_context *lc, struct dev_info *di,
- size_t *size, uint64_t *offset,
- union read_info *info),
- size_t size, uint64_t offset,
- void (*f_to_cpu)(void *meta),
- int (*f_is_meta)(struct lib_context *lc, struct dev_info *di,
- void *meta),
- void (*f_file_metadata)(struct lib_context *lc, struct dev_info *di,
- void *meta),
- int (*f_setup_rd)(struct lib_context *lc, struct raid_dev *rd,
- struct dev_info *di, void *meta,
- union read_info *info),
- const char *handler);
+struct raid_dev *read_raid_dev(struct lib_context *lc,
+ struct dev_info *di,
+ void *(*f_read_metadata) (struct lib_context *
+ lc,
+ struct dev_info * di,
+ size_t * size,
+ uint64_t * offset,
+ union read_info *
+ info), size_t size,
+ uint64_t offset, void (*f_to_cpu) (void *meta),
+ int (*f_is_meta) (struct lib_context * lc,
+ struct dev_info * di,
+ void *meta),
+ void (*f_file_metadata) (struct lib_context *
+ lc,
+ struct dev_info * di,
+ void *meta),
+ int (*f_setup_rd) (struct lib_context * lc,
+ struct raid_dev * rd,
+ struct dev_info * di,
+ void *meta,
+ union read_info * info),
+ const char *handler);

extern void *alloc_meta_areas(struct lib_context *lc, struct raid_dev *rd,
const char *who, unsigned int n);
@@ -158,14 +224,17 @@
size_t size);
extern void *alloc_private_and_read(struct lib_context *lc, const char *who,
size_t size, char *path, loff_t offset);
-extern struct raid_set *join_superset(
- struct lib_context *lc,
- char *(*f_name)(struct lib_context *lc, struct raid_dev *rd,
- unsigned int subset),
- void (*f_create)(struct raid_set *super, void *private),
- int (*f_set_sort)(struct list_head *pos, struct list_head *new),
- struct raid_set *rs, struct raid_dev *rd
-);
+extern struct raid_set *join_superset(struct lib_context *lc,
+ char *(*f_name) (struct lib_context * lc,
+ struct raid_dev * rd,
+ unsigned int subset),
+ void (*f_create) (struct raid_set *
+ super, void *private),
+ int (*f_set_sort) (struct list_head *
+ pos,
+ struct list_head *
+ new),
+ struct raid_set *rs, struct raid_dev *rd);
extern int register_format_handler(struct lib_context *lc,
struct dmraid_format *fmt);
extern int write_metadata(struct lib_context *lc, const char *handler,
@@ -175,7 +244,7 @@

#define to_disk to_cpu

-#define struct_offset(s, member) ((unsigned short) &((struct s *) 0)->member)
+#define struct_offset(s, member) ((size_t) &((struct s *) 0)->member)

/* Print macros used in log methods. */

--- dmraid/include/dmraid/lib_context.h 2008/04/02 13:35:31 1.2
+++ dmraid/include/dmraid/lib_context.h 2008/06/20 21:52:16 1.3
@@ -1,7 +1,10 @@
/*
- * Copyright (C) 2004,2005 Heinz Mauelshagen, Red Hat GmbH.
+ * Copyright (C) 2004-2008 Heinz Mauelshagen, Red Hat GmbH.
* All rights reserved.
*
+ * Copyright (C) 2007 Intel Corporation. All rights reserved.
+ * November, 2007 - additions for Create, Delete, Rebuild & Raid 10.
+ *
* See file LICENSE at the top of this source tree for license information.
*/

@@ -13,12 +16,12 @@
#include <dmraid/misc.h>

enum lc_lists {
- LC_FORMATS = 0, /* Metadata format handlers. */
- LC_DISK_INFOS, /* Disks discovered. */
- LC_RAID_DEVS, /* Raid devices discovered. */
- LC_RAID_SETS, /* Raid sets grouped. */
+ LC_FORMATS = 0, /* Metadata format handlers. */
+ LC_DISK_INFOS, /* Disks discovered. */
+ LC_RAID_DEVS, /* Raid devices discovered. */
+ LC_RAID_SETS, /* Raid sets grouped. */
/* Add new lists below here ! */
- LC_LISTS_SIZE, /* Must be the last enumerator. */
+ LC_LISTS_SIZE, /* Must be the last enumerator. */
};

/* List access macros. */
@@ -39,8 +42,12 @@
LC_IGNORELOCKING,
LC_SEPARATOR,
LC_DEVICES,
- LC_PARTCHAR, /* Add new options below this one ! */
- LC_OPTIONS_SIZE, /* Must be the last enumerator. */
+ LC_PARTCHAR,
+ LC_CREATE,
+ LC_REBUILD_SET,
+ LC_REBUILD_DISK,
+ LC_HOT_SPARE_SET, /* Add new options below this one ! */
+ LC_OPTIONS_SIZE, /* Must be the last enumerator. */
};

/* Options access macros. */
@@ -57,6 +64,9 @@
#define OPT_TEST(lc) (lc_opt(lc, LC_TEST))
#define OPT_VERBOSE(lc) (lc_opt(lc, LC_VERBOSE))
#define OPT_PARTCHAR(lc) (lc_opt(lc, LC_PARTCHAR))
+#define OPT_CREATE(lc) (lc_opt(lc, LC_CREATE))
+#define OPT_HOT_SPARE_SET(lc) (lc_opt(lc, LC_HOT_SPARE_SET))
+#define OPT_REBUILD_DISK(lc) (lc_opt(lc, LC_REBUILD_DISK))

/* Return option value. */
#define OPT_STR(lc, o) (lc->options[o].arg.str)
@@ -64,6 +74,8 @@
#define OPT_STR_FORMAT(lc) OPT_STR(lc, LC_FORMAT)
#define OPT_STR_SEPARATOR(lc) OPT_STR(lc, LC_SEPARATOR)
#define OPT_STR_PARTCHAR(lc) OPT_STR(lc, LC_PARTCHAR)
+#define OPT_STR_HOT_SPARE_SET(lc) OPT_STR(lc, LC_HOT_SPARE_SET)
+#define OPT_STR_REBUILD_DISK(lc) OPT_STR(lc, LC_REBUILD_DISK)

struct lib_version {
const char *text;
@@ -95,29 +107,116 @@
/*
* Lists for:
*
- * o metadata format handlers the library supports
- * o block devices discovered
- * o RAID devices discovered
- * o RAID sets grouped
+ * o metadata format handlers the library supports
+ * o block devices discovered
+ * o RAID devices discovered
+ * o RAID sets grouped
*/
struct list_head lists[LC_LISTS_SIZE];

- char *locking_name; /* Locking mechanism selector. */
- struct locking *lock; /* Resource locking. */
+ char *locking_name; /* Locking mechanism selector. */
+ struct locking *lock; /* Resource locking. */

- mode_t mode; /* File/directrory create modes. */
+ mode_t mode; /* File/directrory create modes. */

struct {
const char *error; /* For error mappings. */
} path;
};

+
+/* Options actions dmraid performs. */
+enum action {
+ UNDEF = 0x0,
+ ACTIVATE = 0x1,
+ DEACTIVATE = 0x2,
+ FORMAT = 0x4,
+#ifndef DMRAID_MINI
+ BLOCK_DEVICES = 0x8,
+ COLUMN = 0x10,
+ DBG = 0x20,
+ DUMP = 0x40,
+ DMERASE = 0x80,
+ GROUP = 0x100,
+#endif
+ HELP = 0x200,
+#ifndef DMRAID_MINI
+ LIST_FORMATS = 0x400,
+# ifdef DMRAID_NATIVE_LOG
+ NATIVE_LOG = 0x800,
+# endif
+#endif
+ NOPARTITIONS = 0x1000,
+#ifndef DMRAID_MINI
+ RAID_DEVICES = 0x2000,
+ RAID_SETS = 0x4000,
+ TEST = 0x8000,
+ VERBOSE = 0x10000,
+ ACTIVE = 0x20000,
+ INACTIVE = 0x40000,
+ SEPARATOR = 0x80000,
+#endif
+ VERSION = 0x100000,
+ IGNORELOCKING = 0x200000,
+#ifndef DMRAID_MINI
+ DEL_SETS = 0x400000,
+ CREATE = 0x800000,
+ REBUILD = 0x1000000,
+ SPARE = 0x2000000,
+ MEDIA = 0x4000000,
+ END_REBUILD = 0x8000000,
+ GET_MEMBERS = 0x10000000,
+ PARTCHAR = 0x20000000,
+
+#endif
+};
+
+/* Arguments allowed ? */
+enum args {
+ NO_ARGS,
+ ARGS,
+};
+
+/* Define which metadata is needed before we can call post functions. */
+enum metadata_need {
+ M_NONE = 0x00,
+ M_DEVICE = 0x01,
+ M_RAID = 0x02,
+ M_SET = 0x04,
+};
+
+enum id {
+ ROOT,
+ ANY_ID,
+};
+
+enum lock {
+ LOCK,
+ NO_LOCK,
+};
+
+/*
+ * Pre and Post functions to perform for an option.
+ */
+struct prepost {
+ enum action action;
+ enum metadata_need metadata;
+ enum id id;
+ enum lock lock;
+ int (*pre) (int arg);
+ int arg;
+ int (*post) (struct lib_context * lc, int arg);
+};
+
+
+
+
extern struct lib_context *alloc_lib_context(char **argv);
extern void free_lib_context(struct lib_context *lc);
extern int lc_opt(struct lib_context *lc, enum lc_options o);
const char *lc_opt_arg(struct lib_context *lc, enum lc_options o);
const char *lc_stralloc_opt(struct lib_context *lc, enum lc_options o,
- char *arg);
+ char *arg);
const char *lc_strcat_opt(struct lib_context *lc, enum lc_options o,
char *arg, const char delim);
extern int lc_inc_opt(struct lib_context *lc, int o);
--- dmraid/include/dmraid/list.h 2008/02/22 17:04:35 1.2
+++ dmraid/include/dmraid/list.h 2008/06/20 21:52:16 1.3
@@ -1,7 +1,10 @@
/*
- * Copyright (C) 2004,2005 Heinz Mauelshagen, Red Hat GmbH.
+ * Copyright (C) 2004-2008 Heinz Mauelshagen, Red Hat GmbH.
* All rights reserved.
*
+ * Copyright (C) 2007 Intel Corporation. All rights reserved.
+ * November, 2007 - additions for Create, Delete, Rebuild & Raid 10.
+ *
* See file LICENSE at the top of this source tree for license information.
*/

@@ -23,9 +26,9 @@

#define list_empty(pos) ((pos)->next == pos)

-static inline void __list_add(struct list_head *new,
- struct list_head *prev,
- struct list_head *next)
+static inline void
+__list_add(struct list_head *new,
+ struct list_head *prev, struct list_head *next)
{
next->prev = new;
new->next = next;
@@ -74,4 +77,10 @@
pos != (head);
pos = n, n = pos->next)

+#define list_for_each_entry_safe(pos, n, head, member)
+ for (pos = list_entry((head)->next, typeof(*pos), member),
+ n = list_entry(pos->member.next, typeof(*pos), member);
+ &pos->member != (head);
+pos = n, n = list_entry(pos->member.next, typeof(*pos), member))
+
#endif
--- dmraid/include/dmraid/locking.h 2008/02/22 16:57:35 1.1
+++ dmraid/include/dmraid/locking.h 2008/06/20 21:52:16 1.2
@@ -17,9 +17,9 @@
struct lib_context;
struct locking {
const char *name;
- int (*lock)(struct lib_context *lc, struct resource *res);
- void (*unlock)(struct lib_context *lc, struct resource *res);
- void *private; /* Private context. */
+ int (*lock) (struct lib_context * lc, struct resource * res);
+ void (*unlock) (struct lib_context * lc, struct resource * res);
+ void *private; /* Private context. */
};

extern int init_locking(struct lib_context *lc);
--- dmraid/include/dmraid/metadata.h 2008/02/22 17:04:35 1.2
+++ dmraid/include/dmraid/metadata.h 2008/06/20 21:52:16 1.3
@@ -1,7 +1,10 @@
/*
- * Copyright (C) 2004,2005 Heinz Mauelshagen, Red Hat GmbH.
+ * Copyright (C) 2004-2008 Heinz Mauelshagen, Red Hat GmbH.
* All rights reserved.
*
+ * Copyright (C) 2007 Intel Corporation. All rights reserved.
+ * November, 2007 - additions for Create, Delete, Rebuild & Raid 10.
+ *
* See file LICENSE at the top of this source tree for license information.
*/

@@ -15,23 +18,23 @@
* Unified RAID set types.
*/
enum type {
- t_undef = 0x01,
- t_group = 0x02, /* To group subsets (eg, Intel Software RAID). */
- t_partition = 0x04, /* FIXME: remove in favour of kpartx ? */
- t_spare = 0x08,
- t_linear = 0x10,
- t_raid0 = 0x20,
- t_raid1 = 0x40,
+ t_undef = 0x01,
+ t_group = 0x02, /* To group subsets (eg, Intel Software RAID). */
+ t_partition = 0x04, /* FIXME: remove in favour of kpartx ? */
+ t_spare = 0x08,
+ t_linear = 0x10,
+ t_raid0 = 0x20,
+ t_raid1 = 0x40,
/*
* Higher RAID types below not supported (yet)
* because of device-mapper constraints.
*/
- t_raid4 = 0x80,
- t_raid5_ls = 0x100,
- t_raid5_rs = 0x200,
- t_raid5_la = 0x400,
- t_raid5_ra = 0x800,
- t_raid6 = 0x1000,
+ t_raid4 = 0x80,
+ t_raid5_ls = 0x100,
+ t_raid5_rs = 0x200,
+ t_raid5_la = 0x400,
+ t_raid5_ra = 0x800,
+ t_raid6 = 0x1000,
};

/* Check macros for types. */
@@ -64,21 +67,23 @@
* from format specific types to the unified ones above.
*/
struct types {
- unsigned int type; /* Must be long enough for vendor definition. */
- enum type unified_type;
+ unsigned int type; /* Must be long enough for vendor definition. */
+ enum type unified_type;
};

/* RAID disk/set status. */
enum status {
- s_undef = 0x01,
- s_broken = 0x02, /* Completely broken (not accessible). */
- s_inconsistent = 0x04, /* RAID disk/set inconsistent (needs
+ s_undef = 0x01,
+ s_broken = 0x02, /* Completely broken (not accessible). */
+ s_inconsistent = 0x04, /* RAID disk/set inconsistent (needs
synchronization or reconfiguration). */
/* FIXME: is s_nosync sufficient or do I need s_upgrade (eg, NVidia) */
- s_nosync = 0x08, /* RAID disk/set *not* in sync
+ s_nosync = 0x08, /* RAID disk/set *not* in sync
(needs synchronization). */
- s_ok = 0x10, /* Fully operational. */
- s_setup = 0x20, /* Only during RAID setup transition. */
+ s_ok = 0x10, /* Fully operational. */
+ s_setup = 0x20, /* Only during RAID setup transition. */
+ s_init = 0x40, /* RAID set to be created */
+ s_config = 0x80, /* RAID set hasn't been configured */
};

/*
@@ -104,24 +109,24 @@

/* find_*() function enums */
enum find {
- FIND_TOP, /* Search top level RAID sets only. */
- FIND_ALL, /* Decend all RAID set trees. */
+ FIND_TOP, /* Search top level RAID sets only. */
+ FIND_ALL, /* Decend all RAID set trees. */
};

/* Device information. */
struct dev_info {
struct list_head list; /* Global chain of discovered devices. */

- char *path; /* Actual device node path. */
- char *serial; /* ATA/SCSI serial number. */
- uint64_t sectors; /* Device size. */
+ char *path; /* Actual device node path. */
+ char *serial; /* ATA/SCSI serial number. */
+ uint64_t sectors; /* Device size. */
};

/* Metadata areas and size stored on a RAID device. */
struct meta_areas {
- uint64_t offset; /* on disk metadata offset in sectors. */
- size_t size; /* on disk metadata size in bytes. */
- void *area; /* pointer to format specific metadata. */
+ uint64_t offset; /* on disk metadata offset in sectors. */
+ size_t size; /* on disk metadata size in bytes. */
+ void *area; /* pointer to format specific metadata. */
};

/*
@@ -131,29 +136,29 @@
* exist at the lowest level of a RAID set stack (eg, for RAID10).
*/
struct raid_dev {
- struct list_head list; /* Global chain of RAID devices. */
- struct list_head devs; /* Chain of devices belonging to set. */
+ struct list_head list; /* Global chain of RAID devices. */
+ struct list_head devs; /* Chain of devices belonging to set. */

- char *name; /* Metadata format handler generated
- name of set this device belongs to.*/
+ char *name; /* Metadata format handler generated
+ name of set this device belongs to. */

- struct dev_info *di; /* Pointer to dev_info. */
+ struct dev_info *di; /* Pointer to dev_info. */
struct dmraid_format *fmt; /* Format handler for this device. */

- enum status status; /* Status of device. */
- enum type type; /* Type of device. */
+ enum status status; /* Status of device. */
+ enum type type; /* Type of device. */

- uint64_t offset; /* Data offset on device. */
- uint64_t sectors; /* Length of the segment to map. */
+ uint64_t offset; /* Data offset on device. */
+ uint64_t sectors; /* Length of the segment to map. */

- unsigned int areas; /* # of metadata areas on the device. */
+ unsigned int areas; /* # of metadata areas on the device. */
struct meta_areas *meta_areas; /* Dynamic array of metadata areas. */

/*
* For format handler use (eg, to keep references between calls).
*
* WARNING: non pointer members need to get zeroed before exit,
- * because the metadata layer frees private->ptr on cleanup.
+ * because the metadata layer frees private->ptr on cleanup.
*/
union {
void *ptr;
@@ -169,16 +174,16 @@
* Defines RAID attributes for the set as a whole (eg: RAID0, Status).
*/
enum flags {
- f_maximize = 0x01, /* If set, maximize set capacity,
+ f_maximize = 0x01, /* If set, maximize set capacity,
if not set, limit to smallest device. */
- f_partitions = 0x02, /* Set has partitions. */
+ f_partitions = 0x02, /* Set has partitions. */
};

#define F_MAXIMIZE(rs) ((rs)->flags & f_maximize)
#define F_PARTITIONS(rs) ((rs)->flags & f_partitions)

struct raid_set {
- struct list_head list; /* Chain of independent sets. */
+ struct list_head list; /* Chain of independent sets. */

/*
* List of subsets (eg, RAID10) which make up RAID set stacks.
@@ -199,12 +204,13 @@
unsigned int total_devs; /* The number of devices expected */
unsigned int found_devs; /* The number of devices found */

- char *name; /* Name of the set. */
+ char *name; /* Name of the set. */

- unsigned int stride; /* Stride size. */
- enum type type; /* Unified raid type. */
- enum flags flags; /* Set flags. */
- enum status status; /* Status of set. */
+ uint64_t size; /* size of a raid set */
+ unsigned int stride; /* Stride size. */
+ enum type type; /* Unified raid type. */
+ enum flags flags; /* Set flags. */
+ enum status status; /* Status of set. */
};

extern struct raid_set *get_raid_set(struct lib_context *lc,
@@ -220,29 +226,31 @@
extern struct raid_dev *alloc_raid_dev(struct lib_context *lc, const char *who);
extern void free_raid_dev(struct lib_context *lc, struct raid_dev **rd);
extern void list_add_sorted(struct lib_context *lc,
- struct list_head *to, struct list_head *new,
- int (*sort)(struct list_head *pos,
- struct list_head *new));
+ struct list_head *to, struct list_head *new,
+ int (*sort) (struct list_head * pos,
+ struct list_head * new));
extern struct raid_set *alloc_raid_set(struct lib_context *lc, const char *who);
extern unsigned int count_sets(struct lib_context *lc, struct list_head *list);
extern unsigned int count_devs(struct lib_context *lc, struct raid_set *rs,
- enum count_type type);
+ enum count_type type);
extern void free_raid_set(struct lib_context *lc, struct raid_set *rs);
-extern struct raid_set *find_set(struct lib_context *lc, struct list_head *list,
- const char *name, enum find where);
+extern struct raid_set *find_set(struct lib_context *lc,
+ struct list_head *list, const char *name,
+ enum find where);
extern struct raid_set *find_or_alloc_raid_set(struct lib_context *lc,
- char *name, enum find where,
- struct raid_dev *rd,
- struct list_head *list,
- void (*create) (struct raid_set *super,
- void *private),
- void *private);
+ char *name, enum find where,
+ struct raid_dev *rd,
+ struct list_head *list,
+ void (*create) (struct raid_set
+ * super,
+ void *private),
+ void *private);
#define NO_RD NULL
#define NO_LIST NULL
#define NO_CREATE NULL
#define NO_CREATE_ARG NULL
extern const char *get_set_name(struct lib_context *lc, void *rs);
-extern int group_set(struct lib_context *lc, char *name);
+extern int group_set(struct lib_context *lc, char **name);

enum set_type {
SETS,
@@ -250,8 +258,8 @@
};

extern void process_sets(struct lib_context *lc,
- int (*func)(struct lib_context *lc, void *rs, int arg),
- int arg, enum set_type type);
+ int (*func) (struct lib_context * lc, void *rs,
+ int arg), int arg, enum set_type type);
extern int write_set(struct lib_context *lc, void *rs);
extern int partitioned_set(struct lib_context *lc, void *rs);
extern int base_partitioned_set(struct lib_context *lc, void *rs);
@@ -262,10 +270,12 @@
enum compare cmp);
extern enum type rd_type(struct types *types, unsigned int type);
extern void file_metadata(struct lib_context *lc, const char *handler,
- char *path, void *data, size_t size, uint64_t offset);
+ char *path, void *data, size_t size, uint64_t offset);
extern void file_dev_size(struct lib_context *lc, const char *handler,
- struct dev_info *di);
+ struct dev_info *di);
extern int write_dev(struct lib_context *lc, struct raid_dev *rd, int erase);
extern int erase_metadata(struct lib_context *lc);
-
+extern int delete_raidsets(struct lib_context *lc);
+extern int lib_perform(struct lib_context *lc, enum action action,
+ struct prepost *p, char **argv);
#endif
--- dmraid/include/dmraid/misc.h 2008/02/22 16:57:35 1.1
+++ dmraid/include/dmraid/misc.h 2008/06/20 21:52:16 1.2
@@ -1,13 +1,18 @@
/*
- * Copyright (C) 2004,2005 Heinz Mauelshagen, Red Hat GmbH.
+ * Copyright (C) 2004-2005 Heinz Mauelshagen, Red Hat GmbH.
* All rights reserved.
*
+ * Copyright (C) 2007 Intel Corporation. All rights reserved.
+ * November, 2007 - additions for Create, Delete, Rebuild & Raid 10.
+ *
* See file LICENSE at the top of this source tree for license information.
*/

#ifndef _MISC_H_
#define _MISC_H_

+#define DM_ASSERT(__cond) do { if (!(__cond)) { printf("ASSERT file:%s line:%d fuction:%s cond: %s
", __FILE__, __LINE__, __FUNCTION__, #__cond); } } while(0);
+
extern struct lib_context *libdmraid_init(int argc, char **argv);
extern void libdmraid_exit(struct lib_context *lc);

@@ -16,8 +21,10 @@
extern char *get_basename(struct lib_context *lc, char *str);
extern char *get_dirname(struct lib_context *lc, char *str);
extern char *remove_white_space(struct lib_context *lc, char *str, size_t len);
+extern void remove_tail_space(char *str);
extern char *remove_delimiter(char *ptr, char c);
extern void add_delimiter(char **ptr, char c);
+extern char *replace_delimiter(char *str, char delim, char c);

extern int mk_dir(struct lib_context *lc, const char *dir);

@@ -31,21 +38,33 @@
extern void free_string(struct lib_context *lc, char **string);
extern int p_fmt(struct lib_context *lc, char **string, const char *fmt, ...);

-static inline uint64_t round_down(uint64_t what, unsigned int by)
+static inline uint64_t
+round_down(uint64_t what, unsigned int by)
{
return what & ~((uint64_t) by - 1);
}

-static inline uint64_t round_up(uint64_t what, unsigned int by)
+static inline uint64_t
+round_up(uint64_t what, unsigned int by)
{
uint64_t t = round_down(what, by);

return t == what ? t : t + by;
}

-static inline uint64_t div_up(uint64_t what, unsigned int by)
+static inline uint64_t
+div_up(uint64_t what, unsigned int by)
{
return round_up(what, by) / by;
}

+
+#ifdef DMRAID_LED
+/* Definitions for LED support */
+#define LED_OFF 0
+#define LED_REBUILD 1
+
+int led(char *rd, int status);
+#endif
+
#endif
--- dmraid/include/dmraid/reconfig.h 2008/02/22 17:04:35 1.1
+++ dmraid/include/dmraid/reconfig.h 2008/06/20 21:52:16 1.2
@@ -2,8 +2,8 @@
* Copyright (C) 2006 Darrick Wong, IBM.
* All rights reserved.
*
- * Copyright (C) 2006 Heinz Mauelshagen Red Hat GmbH.
- * All rights reserved.
+ * Copyright (C) 2006-2008 Heinz Mauelshagen Red Hat GmbH.
+ * All rights reserved.
*
* See the file LICENSE at the top of this source tree for license information.
*/
@@ -50,5 +50,9 @@
struct raid_dev *rd);
extern void end_log(struct lib_context *lc, struct list_head *log);
extern int revert_log(struct lib_context *lc, struct list_head *log);
+extern int hot_spare_add(struct lib_context *lc, struct raid_set *rs);
+extern struct raid_set *find_group(struct lib_context *lc,
+ struct raid_set *sub_rs);
+extern int rebuild_raidset(struct lib_context *lc, char *set_name);

#endif
--- dmraid/lib/.export.sym 2008/02/22 16:57:35 1.1
+++ dmraid/lib/.export.sym 2008/06/20 21:52:16 1.2
@@ -1,51 +1,58 @@
-Base {
- global:
- add_delimiter;
- change_set;
- check_valid_format;
- collapse_delimiter;
- count_devices;
- count_devs;
- count_sets;
- _dbg_free;
- _dbg_malloc;
- _dbg_realloc;
- _dbg_strdup;
- discover_devices;
- discover_partitions;
- discover_raid_devices;
- display_devices;
- display_set;
- dm_version;
- erase_metadata;
- find_set;
- get_dm_type;
- get_set_type;
- get_set_name;
- get_status;
- get_type;
- group_set;
- init_locking;
- lc_inc_opt;
- lc_list;
- lc_opt;
- lc_stralloc_opt;
- lc_strcat_opt;
- libdmraid_exit;
- libdmraid_init;
- libdmraid_date;
- libdmraid_version;
- libdmraid_make_table;
- list_formats;
- lock_resource;
- log_alloc_err;
- plog;
- process_sets;
- remove_delimiter;
- remove_white_space;
- total_sectors;
- unlock_resource;
-
- local:
- *;
-};
+Base {
+ global:
+ add_delimiter;
+ change_set;
+ check_valid_format;
+ collapse_delimiter;
+ count_devices;
+ count_devs;
+ count_sets;
+ _dbg_free;
+ _dbg_malloc;
+ _dbg_realloc;
+ _dbg_strdup;
+ discover_devices;
+ discover_partitions;
+ discover_raid_devices;
+ display_devices;
+ display_set;
+ dm_version;
+ erase_metadata;
+ find_set;
+ get_dm_type;
+ get_set_type;
+ get_set_name;
+ get_status;
+ get_type;
+ group_set;
+ init_locking;
+ lc_inc_opt;
+ lc_list;
+ lc_opt;
+ lc_stralloc_opt;
+ lc_strcat_opt;
+ libdmraid_exit;
+ libdmraid_init;
+ libdmraid_date;
+ libdmraid_version;
+ libdmraid_make_table;
+ list_formats;
+ lock_resource;
+ log_alloc_err;
+ plog;
+ process_sets;
+ remove_delimiter;
+ remove_white_space;
+ total_sectors;
+ unlock_resource;
+ add_dev_to_array;
+ delete_raidsets;
+ lib_perform;
+ rebuild_raidset;
+ dso_end_rebuild;
+ hot_spare_add;
+ dso_get_members;
+ local:
+ *;
+};
+
--- dmraid/lib/version.h 2008/04/02 13:35:31 1.5
+++ dmraid/lib/version.h 2008/06/20 21:52:16 1.6
@@ -7,6 +7,6 @@
#define DMRAID_LIB_SUBMINOR_VERSION 0
#define DMRAID_LIB_VERSION_SUFFIX "rc15"

-#define DMRAID_LIB_DATE "(2008.04.02)"
+#define DMRAID_LIB_DATE "(2008.06.20)"

#endif
--- dmraid/lib/activate/activate.c 2008/04/02 13:35:31 1.3
+++ dmraid/lib/activate/activate.c 2008/06/20 21:52:16 1.4
@@ -1,7 +1,10 @@
/*
- * Copyright (C) 2004,2005 Heinz Mauelshagen, Red Hat GmbH.
+ * Copyright (C) 2004-2008 Heinz Mauelshagen, Red Hat GmbH.
* All rights reserved.
*
+ * Copyright (C) 2007 Intel Corporation. All rights reserved.
+ * November, 2007 - additions for Create, Delete, Rebuild & Raid 10.
+ *
* See file LICENSE at the top of this source tree for license information.
*/

@@ -12,26 +15,28 @@
#include "internal.h"
#include "devmapper.h"

-static int valid_rd(struct raid_dev *rd)
+static int
+valid_rd(struct raid_dev *rd)
{
return S_OK(rd->status) && !T_SPARE(rd);
}

-static int valid_rs(struct raid_set *rs)
+static int
+valid_rs(struct raid_set *rs)
{
return S_OK(rs->status) && !T_SPARE(rs);
}

/* Return rounded size in case of unbalanced mappings */
-static uint64_t maximize(struct raid_set *rs, uint64_t sectors,
- uint64_t last, uint64_t min)
+static uint64_t
+maximize(struct raid_set *rs, uint64_t sectors, uint64_t last, uint64_t min)
{
return sectors > min ? min(last, sectors) : last;
}

/* Find smallest set/disk larger than given minimum. */
-static uint64_t _smallest(struct lib_context *lc,
- struct raid_set *rs, uint64_t min)
+static uint64_t
+_smallest(struct lib_context *lc, struct raid_set *rs, uint64_t min)
{
uint64_t ret = ~0;
struct raid_set *r;
@@ -45,7 +50,7 @@
ret = maximize(rs, rd->sectors, ret, min);
}

- return ret == (uint64_t) ~0 ? 0 : ret;
+ return ret == (uint64_t) ~ 0 ? 0 : ret;
}

/*
@@ -53,33 +58,38 @@
*/

/* Undefined/-supported mapping. */
-static int _dm_un(struct lib_context *lc, char **table,
- struct raid_set *rs, const char *what)
+static int
+_dm_un(struct lib_context *lc, char **table,
+ struct raid_set *rs, const char *what)
{
LOG_ERR(lc, 0, "Un%sed RAID type %s[%u] on %s", what,
get_set_type(lc, rs), rs->type, rs->name);
}

-static int dm_undef(struct lib_context *lc, char **table, struct raid_set *rs)
+static int
+dm_undef(struct lib_context *lc, char **table, struct raid_set *rs)
{
return _dm_un(lc, table, rs, "defin");
}

-static int dm_unsup(struct lib_context *lc, char **table, struct raid_set *rs)
+static int
+dm_unsup(struct lib_context *lc, char **table, struct raid_set *rs)
{
return _dm_un(lc, table, rs, "support");
}


/* "Spare mapping". */
-static int dm_spare(struct lib_context *lc, char **table, struct raid_set *rs)
+static int
+dm_spare(struct lib_context *lc, char **table, struct raid_set *rs)
{
- LOG_ERR(lc, 0, "spare set");
+ LOG_ERR(lc, 0, "spare set "%s" cannot be activated", rs->name);
}

/* Push path and offset onto a table. */
-static int _dm_path_offset(struct lib_context *lc, char **table,
- int valid, const char *path, uint64_t offset)
+static int
+_dm_path_offset(struct lib_context *lc, char **table,
+ int valid, const char *path, uint64_t offset)
{
return p_fmt(lc, table, " %s %U",
valid ? path : lc->path.error, offset);
@@ -88,17 +98,17 @@
/*
* Create dm table for linear mapping.
*/
-static int _dm_linear(struct lib_context *lc, char **table, int valid,
- const char *path, uint64_t start, uint64_t sectors,
- uint64_t offset)
+static int
+_dm_linear(struct lib_context *lc, char **table, int valid,
+ const char *path, uint64_t start, uint64_t sectors, uint64_t offset)
{
return p_fmt(lc, table, "%U %U %s", start, sectors,
get_dm_type(lc, t_linear)) ?
- _dm_path_offset(lc, table, valid, path, offset) : 0;
+ _dm_path_offset(lc, table, valid, path, offset) : 0;
}

-static int dm_linear(struct lib_context *lc, char **table,
- struct raid_set *rs)
+static int
+dm_linear(struct lib_context *lc, char **table, struct raid_set *rs)
{
unsigned int segments = 0;
uint64_t start = 0, sectors = 0;
@@ -113,14 +123,14 @@

if (!(path = mkdm_path(lc, r->name)))
goto err;
-
+
sectors = total_sectors(lc, r);
ret = _dm_linear(lc, table, valid_rs(r), path,
start, sectors, 0);
dbg_free(path);
segments++;
start += sectors;
-
+
if (!ret ||
(r->sets.next != &rs->sets &&
!p_fmt(lc, table, "
")))
@@ -131,10 +141,11 @@
/* Devices of a linear set. */
list_for_each_entry(rd, &rs->devs, devs) {
if (!T_SPARE(rd)) {
- if (!_dm_linear(lc, table, valid_rd(rd), rd->di->path,
- start, rd->sectors, rd->offset))
+ if (!_dm_linear
+ (lc, table, valid_rd(rd), rd->di->path, start,
+ rd->sectors, rd->offset))
goto err;
-
+
segments++;
start += rd->sectors;

@@ -146,7 +157,7 @@

return segments ? 1 : 0;

- err:
+ err:
return log_alloc_err(lc, __func__);
}

@@ -156,8 +167,8 @@
* Partitioned RAID set with 1 RAID device
* defining a linear partition mapping.
*/
-static int dm_partition(struct lib_context *lc, char **table,
- struct raid_set *rs)
+static int
+dm_partition(struct lib_context *lc, char **table, struct raid_set *rs)
{
return dm_linear(lc, table, rs);
}
@@ -178,21 +189,22 @@
*
*/
/* Push begin of line onto a RAID0 table. */
-static int _dm_raid0_bol(struct lib_context *lc, char **table,
- uint64_t min, uint64_t last_min,
- unsigned int n, unsigned int stride)
+static int
+_dm_raid0_bol(struct lib_context *lc, char **table,
+ uint64_t min, uint64_t last_min,
+ unsigned int n, unsigned int stride)
{
return p_fmt(lc, table,
n > 1 ? "%U %U %s %u %u" : "%U %U %s",
last_min * n, (min - last_min) * n,
- get_dm_type(lc, n > 1 ? t_raid0 : t_linear),
- n, stride);
+ get_dm_type(lc, n > 1 ? t_raid0 : t_linear), n, stride);
}

/* Push end of line onto a RAID0 table. */
-static int _dm_raid0_eol(struct lib_context *lc,
- char **table, struct raid_set *rs,
- unsigned int *stripes, uint64_t last_min)
+static int
+_dm_raid0_eol(struct lib_context *lc,
+ char **table, struct raid_set *rs,
+ unsigned int *stripes, uint64_t last_min)
{
struct raid_set *r;
struct raid_dev *rd;
@@ -216,7 +228,7 @@
(*stripes)++;
}
}
-
+
list_for_each_entry(rd, &rs->devs, devs) {
if (!T_SPARE(rd) &&
rd->sectors > last_min &&
@@ -229,13 +241,13 @@

return 1;

- err:
+ err:
return 0;
}

/* Count RAID sets/devices larger than given minimum size. */
-static unsigned int _dm_raid_devs(struct lib_context *lc,
- struct raid_set *rs, uint64_t min)
+static unsigned int
+_dm_raid_devs(struct lib_context *lc, struct raid_set *rs, uint64_t min)
{
unsigned int ret = 0;
struct raid_set *r;
@@ -246,7 +258,7 @@
if (!T_SPARE(r) && total_sectors(lc, r) > min)
ret++;
}
-
+
list_for_each_entry(rd, &rs->devs, devs) {
if (!T_SPARE(rd) && rd->sectors > min)
ret++;
@@ -254,9 +266,9 @@

return ret;
}
-
-static int dm_raid0(struct lib_context *lc, char **table,
- struct raid_set *rs)
+
+static int
+dm_raid0(struct lib_context *lc, char **table, struct raid_set *rs)
{
unsigned int stripes = 0;
uint64_t min, last_min = 0;
@@ -266,9 +278,10 @@
goto err;

if (!_dm_raid0_bol(lc, table, round_down(min, rs->stride),
- last_min, _dm_raid_devs(lc, rs, last_min),
- rs->stride) ||
- !_dm_raid0_eol(lc, table, rs, &stripes, last_min))
+ last_min, _dm_raid_devs(lc, rs,
+ last_min),
+ rs->stride)
+ || !_dm_raid0_eol(lc, table, rs, &stripes, last_min))
goto err;

if (!F_MAXIMIZE(rs))
@@ -277,7 +290,7 @@

return stripes ? 1 : 0;

- err:
+ err:
return log_alloc_err(lc, __func__);
}

@@ -286,20 +299,21 @@
*/

/* Calculate dirty log region size. */
-static unsigned int calc_region_size(struct lib_context *lc, uint64_t sectors)
+static unsigned int
+calc_region_size(struct lib_context *lc, uint64_t sectors)
{
- const unsigned int mb_128 = 128*2*1024;
+ const unsigned int mb_128 = 128 * 2 * 1024;
unsigned int max, region_size;

if ((max = sectors / 1024) > mb_128)
max = mb_128;

for (region_size = 128; region_size < max; region_size <<= 1);
-
return region_size >> 1;
}

-static unsigned int get_rds(struct raid_set *rs, int valid)
+static unsigned int
+get_rds(struct raid_set *rs, int valid)
{
unsigned int ret = 0;
struct raid_dev *rd;
@@ -315,7 +329,8 @@
return ret;
}

-static unsigned int get_dm_devs(struct raid_set *rs, int valid)
+static unsigned int
+get_dm_devs(struct raid_set *rs, int valid)
{
unsigned int ret = 0;
struct raid_set *r;
@@ -329,30 +344,68 @@
ret++;
}

- ret+= get_rds(rs, valid);
+ return ret + get_rds(rs, valid);
+}

- return ret;
+/* Retrieve number of drive to rebuild from metadata format handler. */
+static int
+get_rebuild_drive(struct lib_context *lc, struct raid_set *rs,
+ struct handler_info *info)
+{
+ /* Initialize drive to rebuild invalid. */
+ info->data.i32 = -1;
+
+ if (lc->options[LC_REBUILD_SET].opt) {
+ struct raid_dev *rd;
+
+ if (list_empty(&rs->devs))
+ LOG_ERR(lc, 0, "RAID set has no devices!");
+
+ rd = list_entry(rs->devs.next, typeof(*rd), devs);
+ if (rd->fmt->metadata_handler) {
+ if (!rd->
+ fmt->metadata_handler(lc, GET_REBUILD_DRIVE_NO,
+ info, rs))
+ LOG_ERR(lc, 0, "Can't get rebuild drive #!");
+ } else
+ LOG_ERR(lc, 0,
+ "Can't rebuild w/o metadata_handler for %s",
+ rd->fmt->name);
+ }
+
+ return 1;
}

+/* Return true if RAID set needs rebuilding. */
+static inline int
+rs_need_sync(struct raid_set *rs)
+{
+ return S_INCONSISTENT(rs->status) || S_NOSYNC(rs->status);
+}
+
+
/* Push begin of line onto a RAID1 table. */
/* FIXME: persistent dirty log. */
-static int _dm_raid1_bol(struct lib_context *lc, char **table,
- struct raid_set *rs,
- uint64_t sectors, unsigned int mirrors)
+static int
+_dm_raid1_bol(struct lib_context *lc, char **table,
+ struct raid_set *rs,
+ uint64_t sectors, unsigned int mirrors, int need_sync)
{
return (p_fmt(lc, table, "0 %U %s core 2 %u %s %u",
sectors, get_dm_type(lc, t_raid1),
calc_region_size(lc, sectors),
- (S_INCONSISTENT(rs->status) || S_NOSYNC(rs->status)) ?
- "sync" : "nosync", mirrors));
+ (need_sync) ? "sync" : "nosync", mirrors));
}

-static int dm_raid1(struct lib_context *lc, char **table, struct raid_set *rs)
+static int
+dm_raid1(struct lib_context *lc, char **table, struct raid_set *rs)
{
+ int need_sync;
+ struct handler_info rebuild_drive;
uint64_t sectors = 0;
unsigned int mirrors = get_dm_devs(rs, 1);
- struct raid_set *r;
- struct raid_dev *rd;
+ struct raid_set *r, *swap_rs;
+ struct raid_dev *rd, *swap_rd;

switch (mirrors) {
case 0:
@@ -367,23 +420,36 @@
rs->name);
return dm_linear(lc, table, rs);
}
-
+
if (!(sectors = _smallest(lc, rs, 0)))
LOG_ERR(lc, 0, "can't find smallest mirror!");

- if (!_dm_raid1_bol(lc, table, rs, sectors, mirrors))
+ /*
+ * Get drive for reordering - copy is made from first
+ * drive (i.e. the master) to the other mirrors.
+ */
+ need_sync = rs_need_sync(rs);
+ if (need_sync && !get_rebuild_drive(lc, rs, &rebuild_drive))
+ return 0;
+
+ if (!_dm_raid1_bol(lc, table, rs, sectors, mirrors, need_sync))
goto err;

/* Stacked mirror sets. */
+ swap_rs = NULL;
list_for_each_entry(r, &rs->sets, list) {
if (valid_rs(r)) {
- int ret;
+ int ret = 1;
char *path;

if (!(path = mkdm_path(lc, r->name)))
goto err;

- ret = _dm_path_offset(lc, table, 1, path, 0);
+ if (!rebuild_drive.data.i32 && !swap_rs)
+ swap_rs = r;
+ else
+ ret = _dm_path_offset(lc, table, 1, path, 0);
+
dbg_free(path);

if (!ret)
@@ -391,20 +457,47 @@
}
}

- /* Lowest level mirror devices */
- list_for_each_entry(rd, &rs->devs, devs) {
- if (valid_rd(rd) &&
- !_dm_path_offset(lc, table, 1, rd->di->path, rd->offset))
+ /* Add rebuild target to the end of the list. */
+ if (swap_rs && valid_rs(swap_rs)) {
+ int ret = 1;
+ char *path;
+
+ if (!(path = mkdm_path(lc, swap_rs->name)))
goto err;
+
+ ret = _dm_path_offset(lc, table, 1, path, 0);
+ dbg_free(path);
+
+ if (!ret)
+ goto err;
+ }
+
+ /* Lowest level mirror devices. */
+ swap_rd = NULL;
+ list_for_each_entry(rd, &rs->devs, devs) {
+ if (valid_rd(rd)) {
+ if (!rebuild_drive.data.i32 && !swap_rd)
+ swap_rd = rd;
+ else if (!_dm_path_offset(lc, table, 1,
+ rd->di->path, rd->offset))
+ goto err;
+ }
}

- /* Append the flag/feature required for dmraid1
- * event handling in the kernel driver
+ /* Add rebuild target to the end of the list. */
+ if (swap_rd && valid_rd(swap_rd))
+ if (!_dm_path_offset(lc, table, valid_rd(swap_rd),
+ swap_rd->di->path, swap_rd->offset))
+ goto err;
+
+ /*
+ * Append the flag/feature required for dmraid1
+ * event handling in the kernel driver.
*/
- if(p_fmt(lc, table, " 1 handle_errors"))
+ if (p_fmt(lc, table, " 1 handle_errors"))
return 1;

- err:
+ err:
return log_alloc_err(lc, __func__);
}

@@ -414,19 +507,28 @@

/* Push begin of line onto a RAID5 table. */
/* FIXME: persistent dirty log. */
-static int _dm_raid45_bol(struct lib_context *lc, char **table,
- struct raid_set *rs,
- uint64_t sectors, unsigned int members)
+static int
+_dm_raid45_bol(struct lib_context *lc, char **table, struct raid_set *rs,
+ uint64_t sectors, unsigned int members)
{
- return p_fmt(lc, table, "0 %U %s core 2 %u %s %s 1 %u %u -1",
+ int need_sync = rs_need_sync(rs);
+ struct handler_info rebuild_drive;
+
+ /* Get drive as rebuild target. */
+ if (need_sync && !get_rebuild_drive(lc, rs, &rebuild_drive))
+ return 0;
+
+ return p_fmt(lc, table, "0 %U %s core 2 %u %s %s 1 %u %u %d",
sectors, get_dm_type(lc, rs->type),
- calc_region_size(lc, total_sectors(lc, rs) / _dm_raid_devs(lc, rs, 0)),
- (S_INCONSISTENT(rs->status) || S_NOSYNC(rs->status)) ?
- "sync" : "nosync",
- get_type(lc, rs->type), rs->stride, members);
+ calc_region_size(lc,
+ total_sectors(lc, rs) /
+ _dm_raid_devs(lc, rs, 0)),
+ (need_sync) ? "sync" : "nosync", get_type(lc, rs->type),
+ rs->stride, members, rebuild_drive.data.i32);
}

-static int dm_raid45(struct lib_context *lc, char **table, struct raid_set *rs)
+static int
+dm_raid45(struct lib_context *lc, char **table, struct raid_set *rs)
{
uint64_t sectors = 0;
unsigned int members = get_dm_devs(rs, 0);
@@ -465,14 +567,14 @@

/* Lowest level RAID devices */
list_for_each_entry(rd, &rs->devs, devs) {
- if (!_dm_path_offset(lc, table, valid_rd(rd), rd->di->path,
- rd->offset))
+ if (!_dm_path_offset(lc, table, valid_rd(rd), rd->di->path,
+ rd->offset))
goto err;
}

return 1;

- err:
+ err:
return log_alloc_err(lc, __func__);
}

@@ -485,25 +587,28 @@
*/
static struct type_handler {
const enum type type;
- int(*f)(struct lib_context *lc, char **table, struct raid_set *rs);
+ int (*f) (struct lib_context * lc, char **table, struct raid_set * rs);
} type_handler[] = {
- { t_undef, dm_undef }, /* Needs to stay here! */
- { t_partition, dm_partition },
- { t_spare, dm_spare },
- { t_linear, dm_linear },
- { t_raid0, dm_raid0 },
- { t_raid1, dm_raid1 },
- { t_raid4, dm_raid45 },
- { t_raid5_ls, dm_raid45 },
- { t_raid5_rs, dm_raid45 },
- { t_raid5_la, dm_raid45 },
- { t_raid5_ra, dm_raid45 },
- /* RAID types below not supported (yet) */
- { t_raid6, dm_unsup },
-};
+ {
+ t_undef, dm_undef}, /* Needs to stay here! */
+ {
+ t_partition, dm_partition}, {
+ t_spare, dm_spare}, {
+ t_linear, dm_linear}, {
+ t_raid0, dm_raid0}, {
+ t_raid1, dm_raid1}, {
+ t_raid4, dm_raid45}, {
+ t_raid5_ls, dm_raid45}, {
+ t_raid5_rs, dm_raid45}, {
+ t_raid5_la, dm_raid45}, {
+ t_raid5_ra, dm_raid45},
+ /* RAID types below not supported (yet) */
+ {
+t_raid6, dm_unsup},};

/* Retrieve type handler from array. */
-static struct type_handler *handler(struct raid_set *rs)
+static struct type_handler *
+handler(struct raid_set *rs)
{
struct type_handler *th = type_handler;

@@ -516,7 +621,8 @@
}

/* Return mapping table */
-char *libdmraid_make_table(struct lib_context *lc, struct raid_set *rs)
+char *
+libdmraid_make_table(struct lib_context *lc, struct raid_set *rs)
{
char *ret = NULL;

@@ -531,23 +637,25 @@
}


-enum dm_what { DM_ACTIVATE, DM_REGISTER};
+enum dm_what { DM_ACTIVATE, DM_REGISTER };

/* Register devices of the RAID set with the dmeventd. */
/* REMOVEME: dummy functions once linking to the real ones. */
#define ALL_EVENTS 0xffffffff
-static int dm_register_for_event(char *a, char *b, int c)
+static int
+dm_register_for_event(char *a, char *b, int c)
{
return 1;
}

-static int dm_unregister_for_event(char *a, char *b, int c)
+static int
+dm_unregister_for_event(char *a, char *b, int c)
{
return 1;
}

-static int do_device(struct lib_context *lc, struct raid_set *rs,
- int (*f)()) // char *, char *, enum event_type))
+static int
+do_device(struct lib_context *lc, struct raid_set *rs, int (*f) ())
{
int ret = 0;
struct raid_dev *rd;
@@ -555,7 +663,7 @@
if (OPT_TEST(lc))
return 1;

- return 1; /* REMOVEME: */
+ return 1; /* REMOVEME: */

list_for_each_entry(rd, &rs->devs, devs) {
if (!(ret = f("dmraid", rd->di->path, ALL_EVENTS)))
@@ -565,24 +673,27 @@
return ret ? 1 : 0;
}

-static int register_devices(struct lib_context *lc, struct raid_set *rs)
+static int
+register_devices(struct lib_context *lc, struct raid_set *rs)
{
return do_device(lc, rs, dm_register_for_event);
}

/* Unregister devices of the RAID set with the dmeventd. */
-static int unregister_devices(struct lib_context *lc, struct raid_set *rs)
+static int
+unregister_devices(struct lib_context *lc, struct raid_set *rs)
{
return do_device(lc, rs, dm_unregister_for_event);
}

/* Reload a single set. */
-static int reload_subset(struct lib_context *lc, struct raid_set *rs)
+static int
+reload_subset(struct lib_context *lc, struct raid_set *rs)
{
int ret = 0;
char *table = NULL;

- if (T_GROUP(rs))
+ if (T_GROUP(rs) || T_RAID0(rs))
return 1;

/* Suspend device */
@@ -603,23 +714,21 @@
/* Try to resume */
if (ret)
dm_resume(lc, rs);
- else
- if (!(ret = dm_resume(lc, rs)))
- LOG_ERR(lc, ret, "Device resume failed.");
+ else if (!(ret = dm_resume(lc, rs)))
+ LOG_ERR(lc, ret, "Device resume failed.");

return ret;
}

/* Reload a RAID set recursively (eg, RAID1 on top of RAID0). */
-static int reload_set(struct lib_context *lc, struct raid_set *rs)
+static int
+reload_set(struct lib_context *lc, struct raid_set *rs)
{
struct raid_set *r;

/* FIXME: Does it matter if the set is (in)active? */
#if 0
- if (!OPT_TEST(lc) &&
- what == DM_ACTIVATE &&
- dm_status(lc, rs)) {
+ if (!OPT_TEST(lc) && what == DM_ACTIVATE && dm_status(lc, rs)) {
log_print(lc, "RAID set "%s" already active", rs->name);
return 1;
}
@@ -629,15 +738,15 @@
list_for_each_entry(r, &rs->sets, list) {
/* Activate set below this one */
if (!reload_set(lc, r) && !T_GROUP(rs))
- return 0;
+ continue;
}

return reload_subset(lc, rs);
}

/* Activate a single set. */
-static int activate_subset(struct lib_context *lc, struct raid_set *rs,
- enum dm_what what)
+static int
+activate_subset(struct lib_context *lc, struct raid_set *rs, enum dm_what what)
{
int ret = 0;
char *table = NULL;
@@ -652,8 +761,12 @@
if ((ret = (handler(rs))->f(lc, &table, rs))) {
if (OPT_TEST(lc))
display_table(lc, rs->name, table);
+ else if ((ret = dm_create(lc, rs, table)))
+ log_print(lc, "RAID set "%s" was activated",
+ rs->name);
else
- ret = dm_create(lc, rs, table);
+ log_print(lc, "RAID set "%s" was not activated",
+ rs->name);
} else
log_err(lc, "no mapping possible for RAID set %s", rs->name);

@@ -663,14 +776,12 @@
}

/* Activate a RAID set recursively (eg, RAID1 on top of RAID0). */
-static int activate_set(struct lib_context *lc, struct raid_set *rs,
- enum dm_what what)
+static int
+activate_set(struct lib_context *lc, struct raid_set *rs, enum dm_what what)
{
struct raid_set *r;

- if (!OPT_TEST(lc) &&
- what == DM_ACTIVATE &&
- dm_status(lc, rs)) {
+ if (!OPT_TEST(lc) && what == DM_ACTIVATE && dm_status(lc, rs)) {
log_print(lc, "RAID set "%s" already active", rs->name);
return 1;
}
@@ -686,30 +797,29 @@
}

/* Deactivate a single set (one level of a device stack). */
-static int deactivate_superset(struct lib_context *lc, struct raid_set *rs,
- enum dm_what what)
+static int
+deactivate_superset(struct lib_context *lc, struct raid_set *rs,
+ enum dm_what what)
{
int ret = 1, status;

if (what == DM_REGISTER)
return unregister_devices(lc, rs);
-
+
status = dm_status(lc, rs);
if (OPT_TEST(lc))
log_print(lc, "%s [%sactive]", rs->name, status ? "" : "in");
else if (status)
ret = dm_remove(lc, rs);
- else {
+ else
log_print(lc, "RAID set "%s" is not active", rs->name);
- ret = 1;
- }

return ret;
}

/* Deactivate a RAID set. */
-static int deactivate_set(struct lib_context *lc, struct raid_set *rs,
- enum dm_what what)
+static int
+deactivate_set(struct lib_context *lc, struct raid_set *rs, enum dm_what what)
{
struct raid_set *r;

@@ -717,8 +827,7 @@
* Deactivate myself if not a group set,
* which gets never activated itself.
*/
- if (!T_GROUP(rs) &&
- !deactivate_superset(lc, rs, what))
+ if (!T_GROUP(rs) && !deactivate_superset(lc, rs, what))
return 0;

/* Deactivate any subsets recursively. */
@@ -732,25 +841,30 @@


/* External (de)activate interface. */
-int change_set(struct lib_context *lc, enum activate_type what, void *v)
+int
+change_set(struct lib_context *lc, enum activate_type what, void *v)
{
- int ret = 0;
+ int ret;
struct raid_set *rs = v;

switch (what) {
case A_ACTIVATE:
ret = activate_set(lc, rs, DM_ACTIVATE) &&
- activate_set(lc, rs, DM_REGISTER);
+ activate_set(lc, rs, DM_REGISTER);
break;

case A_DE
 

Thread Tools




All times are GMT. The time now is 11:57 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org