/* MAP_DIR should be somewhere that persists across the pivotroot
* from early boot to late boot.
- * Currently /dev seems to be the only option on most distros.
+ * /run seems to have emerged as the best standard.
*/
#ifndef MAP_DIR
-#define MAP_DIR "/dev/.mdadm"
+#define MAP_DIR "/run/mdadm"
#endif /* MAP_DIR */
/* MAP_FILE is what we name the map file we put in MAP_DIR, in case you
* want something other than the default of "map"
#define MAP_FILE "map"
#endif /* MAP_FILE */
/* MDMON_DIR is where pid and socket files used for communicating
- * with mdmon normally live. It *should* be /var/run, but when
+ * with mdmon normally live. Best is /var/run/mdadm as
* mdmon is needed at early boot then it needs to write there prior
* to /var/run being mounted read/write, and it also then needs to
* persist beyond when /var/run is mounter read-only. So, to be
* boot process and stays up as long as possible during shutdown.
*/
#ifndef MDMON_DIR
-#define MDMON_DIR "/dev/.mdadm/"
+#define MDMON_DIR "/run/mdadm"
#endif /* MDMON_DIR */
/* FAILED_SLOTS is where to save files storing recent removal of array
* slot for array recovery
*/
#ifndef FAILED_SLOTS_DIR
-#define FAILED_SLOTS_DIR "/dev/.mdadm/failed-slots"
+#define FAILED_SLOTS_DIR "/run/mdadm/failed-slots"
#endif /* FAILED_SLOTS */
#include "md_u.h"
unsigned long long recovery_start; /* per-device rebuild position */
#define MaxSector (~0ULL) /* resync/recovery complete position */
};
+ long bitmap_offset; /* 0 == none, 1 == a file */
unsigned long safe_mode_delay; /* ms delay to mark clean */
int new_level, delta_disks, new_layout, new_chunk;
int errors;
GROW,
INCREMENTAL,
AUTODETECT,
+ mode_count
};
extern char short_options[];
extern char short_bitmap_auto_options[];
extern struct option long_options[];
extern char Version[], Usage[], Help[], OptionHelp[],
+ *mode_help[],
Help_create[], Help_build[], Help_assemble[], Help_grow[],
Help_incr[],
Help_manage[], Help_misc[], Help_monitor[], Help_config[];
UdevRules,
FreezeReshape,
Continue,
+ OffRootOpt,
+ Prefer,
+ KillOpt,
};
/* structures read from config file */
/* List of device names - wildcards expanded */
struct mddev_dev {
char *devname;
- int disposition; /* 'a' for add, 'r' for remove, 'f' for fail.
+ int disposition; /* 'a' for add, 'r' for remove, 'f' for fail,
+ * 'A' for re_add.
* Not set for names read from .config
*/
char writemostly; /* 1 for 'set writemostly', 2 for 'clear writemostly' */
- char re_add;
char used; /* set when used */
struct mddev_dev *next;
};
GET_DISKS = (1 << 7),
GET_DEGRADED = (1 << 8),
GET_SAFEMODE = (1 << 9),
- GET_DEVS = (1 << 10), /* gets role, major, minor */
- GET_OFFSET = (1 << 11),
- GET_SIZE = (1 << 12),
- GET_STATE = (1 << 13),
- GET_ERROR = (1 << 14),
+ GET_BITMAP_LOCATION = (1 << 10),
+
+ GET_DEVS = (1 << 20), /* gets role, major, minor */
+ GET_OFFSET = (1 << 21),
+ GET_SIZE = (1 << 22),
+ GET_STATE = (1 << 23),
+ GET_ERROR = (1 << 24),
};
/* If fd >= 0, get the array it is open on,
char *name, char *val);
extern int sysfs_set_num(struct mdinfo *sra, struct mdinfo *dev,
char *name, unsigned long long val);
+extern int sysfs_set_num_signed(struct mdinfo *sra, struct mdinfo *dev,
+ char *name, long long val);
extern int sysfs_uevent(struct mdinfo *sra, char *event);
extern int sysfs_get_fd(struct mdinfo *sra, struct mdinfo *dev,
char *name);
extern int map_name(mapping_t *map, char *name);
extern mapping_t r5layout[], r6layout[], pers[], modes[], faultylayout[];
-extern char *map_dev(int major, int minor, int create);
+extern char *map_dev_preferred(int major, int minor, int create,
+ char *prefer);
+static inline char *map_dev(int major, int minor, int create)
+{
+ return map_dev_preferred(major, minor, create, NULL);
+}
struct active_array;
struct metadata_update;
* initialized to indicate if reshape is being performed at the
* container or subarray level
*/
+#define APPLY_METADATA_CHANGES 1
+#define ROLLBACK_METADATA_CHANGES 0
+
int (*reshape_super)(struct supertype *st, long long size, int level,
int layout, int chunksize, int raid_disks,
int delta_disks, char *backup, char *dev,
+ int direction,
int verbose); /* optional */
int (*manage_reshape)( /* optional */
int afd, struct mdinfo *sra, struct reshape *reshape,
* external:/md0/12
*/
int devcnt;
+ int retry_soon;
struct mdinfo *devs;
extern int Create(struct supertype *st, char *mddev,
- int chunk, int level, int layout, unsigned long long size, int raiddisks, int sparedisks,
+ int chunk, int level, int layout, unsigned long long size,
+ int raiddisks, int sparedisks,
char *name, char *homehost, int *uuid,
int subdevs, struct mddev_dev *devlist,
- int runstop, int verbose, int force, int assume_clean,
+ int runstop, int readonly, int verbose,
+ int force, int assume_clean,
char *bitmap_file, int bitmap_chunk, int write_behind, int delay, int autof);
-extern int Detail(char *dev, int brief, int export, int test, char *homehost);
+extern int Detail(char *dev, int brief, int export, int test, char *homehost, char *prefer);
extern int Detail_Platform(struct superswitch *ss, int scan, int verbose);
extern int Query(char *dev);
extern int Examine(struct mddev_dev *devlist, int brief, int export, int scan,
char *mailaddr, char *alert_cmd,
int period, int daemonise, int scan, int oneshot,
int dosyslog, int test, char *pidfile, int increments,
- int share);
+ int share, char *prefer);
extern int Kill(char *dev, struct supertype *st, int force, int quiet, int noexcl);
extern int Kill_subarray(char *dev, char *subarray, int quiet);
struct mdinfo *info, char *buf, char sep);
extern unsigned long calc_csum(void *super, int bytes);
extern int enough(int level, int raid_disks, int layout, int clean,
- char *avail, int avail_disks);
+ char *avail);
extern int enough_fd(int fd);
extern int ask(char *mesg);
extern unsigned long long get_component_size(int fd);
extern void append_metadata_update(struct supertype *st, void *buf, int len);
extern int assemble_container_content(struct supertype *st, int mdfd,
struct mdinfo *content, int runstop,
+ int readonly,
char *chosen_name, int verbose,
char *backup_file, int freeze_reshape);
extern struct mdinfo *container_choose_spares(struct supertype *st,
return (-1-d) << MdpMinorShift;
}
-static inline int ROUND_UP(int a, int base)
-{
- return ((a+base-1)/base)*base;
-}
+#define _ROUND_UP(val, base) (((val) + (base) - 1) & ~(base - 1))
+#define ROUND_UP(val, base) _ROUND_UP(val, (typeof(val))(base))
+#define ROUND_UP_PTR(ptr, base) ((typeof(ptr)) \
+ (ROUND_UP((unsigned long)(ptr), base)))
static inline int is_subarray(char *vers)
{
return ret;
}
+#define pr_err(fmt ...) fprintf(stderr, Name ": " fmt)
+#define cont_err(fmt ...) fprintf(stderr, " " fmt)
+
+void *xmalloc(size_t len);
+void *xrealloc(void *ptr, size_t len);
+void *xcalloc(size_t num, size_t size);
+char *xstrdup(const char *str);
+
#define LEVEL_MULTIPATH (-4)
#define LEVEL_LINEAR (-1)
#define LEVEL_FAULTY (-5)
#define PATH_MAX 4096
#endif
-#define PROCESS_DELAYED -2
-#define PROCESS_PENDING -3
+#define RESYNC_NONE -1
+#define RESYNC_DELAYED -2
+#define RESYNC_PENDING -3
+#define RESYNC_UNKNOWN -4
+
+/* When using "GET_DISK_INFO" it isn't certain how high
+ * we need to check. So we impose an absolute limit of
+ * MAX_DISKS. This needs to be much more than the largest
+ * number of devices any metadata can support. Currently
+ * v1.x can support 1920
+ */
+#define MAX_DISKS 4096
+
+extern int __offroot;