]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - mdadm.h
Create: support --readonly flag.
[thirdparty/mdadm.git] / mdadm.h
diff --git a/mdadm.h b/mdadm.h
index 4687a21040ee536ad0e0170dfcd1b0371bceb488..564b5105c186da5dde80bde0169bf0dc4256b8d0 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -71,10 +71,10 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
 
 /* 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"
@@ -83,7 +83,7 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
 #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
@@ -91,7 +91,7 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
  * 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
@@ -99,7 +99,7 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
  * 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"
@@ -194,24 +194,30 @@ struct mdinfo {
        unsigned long long      custom_array_size; /* size for non-default sized
                                                    * arrays (in sectors)
                                                    */
+#define NO_RESHAPE             0
+#define VOLUME_RESHAPE         1
+#define CONTAINER_RESHAPE      2
        int                     reshape_active;
        unsigned long long      reshape_progress;
+       int                     recovery_blocked; /* for external metadata it
+                                                  * indicates that there is
+                                                  * reshape in progress in
+                                                  * container,
+                                                  * for native metadata it is
+                                                  * reshape_active field mirror
+                                                  */
        union {
                unsigned long long resync_start; /* per-array resync position */
                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;
        unsigned long           cache_size; /* size of raid456 stripe cache*/
        int                     mismatch_cnt;
        char                    text_version[50];
-       void                    *update_private; /* for passing metadata-format
-                                                 * specific update data
-                                                 * between successive calls to
-                                                 * update_super()
-                                                 */
 
        int container_member; /* for assembling external-metatdata arrays
                               * This is to be used internally by metadata
@@ -258,6 +264,7 @@ enum mode {
        GROW,
        INCREMENTAL,
        AUTODETECT,
+       mode_count
 };
 
 extern char short_options[];
@@ -265,6 +272,7 @@ extern char short_bitmap_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[];
@@ -314,6 +322,10 @@ enum special_options {
        InvalidBackup,
        UdevRules,
        FreezeReshape,
+       Continue,
+       OffRootOpt,
+       Prefer,
+       KillOpt,
 };
 
 /* structures read from config file */
@@ -365,11 +377,11 @@ struct mddev_ident {
 /* 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;
 };
@@ -442,11 +454,13 @@ enum sysfs_read_flags {
        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,
@@ -462,6 +476,8 @@ extern int sysfs_set_str(struct mdinfo *sra, struct mdinfo *dev,
                         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);
@@ -522,7 +538,12 @@ extern char *map_num(mapping_t *map, int num);
 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;
@@ -730,9 +751,13 @@ extern struct superswitch {
         * 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,
@@ -858,6 +883,7 @@ struct supertype {
                        *  external:/md0/12
                        */
        int devcnt;
+       int retry_soon;
 
        struct mdinfo *devs;
 
@@ -1041,6 +1067,8 @@ extern int restore_backup(struct supertype *st,
                          int spares,
                          char *backup_file,
                          int verbose);
+extern int Grow_continue_command(char *devname, int fd,
+                                char *backup_file, int verbose);
 
 extern int Assemble(struct supertype *st, char *mddev,
                    struct mddev_ident *ident,
@@ -1057,13 +1085,15 @@ extern int Build(char *mddev, int chunk, int level, int layout,
 
 
 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,
@@ -1072,7 +1102,7 @@ extern int Monitor(struct mddev_dev *devlist,
                   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);
@@ -1132,8 +1162,12 @@ extern char *conf_get_homehost(int *require_homehostp);
 extern char *conf_line(FILE *file);
 extern char *conf_word(FILE *file, int allow_key);
 extern int conf_name_is_free(char *name);
+extern int conf_verify_devnames(struct mddev_ident *array_list);
 extern int devname_matches(char *name, char *match);
-extern struct mddev_ident *conf_match(struct mdinfo *info, struct supertype *st);
+extern struct mddev_ident *conf_match(struct supertype *st,
+                                     struct mdinfo *info,
+                                     char *devname,
+                                     int verbose, int *rvp);
 extern int experimental(void);
 
 extern void free_line(char *line);
@@ -1147,19 +1181,21 @@ extern char *fname_from_uuid(struct supertype *st,
                             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 remove_partitions(int fd);
 extern int test_partition(int fd);
 extern int test_partition_from_id(dev_t id);
+extern int get_data_disks(int level, int layout, int raid_disks);
 extern unsigned long long calc_array_size(int level, int raid_disks, int layout,
                                   int chunksize, unsigned long long devsize);
 extern int flush_metadata_updates(struct supertype *st);
 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,
@@ -1234,10 +1270,10 @@ static inline int dev2minor(int d)
        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)
 {
@@ -1277,6 +1313,14 @@ static inline int xasprintf(char **strp, const char *fmt, ...) {
        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)
@@ -1363,5 +1407,17 @@ static inline int xasprintf(char **strp, const char *fmt, ...) {
 #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;