]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - mdadm.h
Allow a uuid of all f's to always match
[thirdparty/mdadm.git] / mdadm.h
diff --git a/mdadm.h b/mdadm.h
index 08b78689b1c410120e3bde3427f09b2669b20cd6..1eba5783231ee5530402848e8814ae15d39d3140 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -149,6 +149,7 @@ struct mdinfo {
        int                     reshape_active;
        unsigned long long      reshape_progress;
        unsigned long long      resync_start;
+       unsigned long           safe_mode_delay; /* ms delay to mark clean */
        int                     new_level, delta_disks, new_layout, new_chunk;
        int                     errors;
        int                     cache_size; /* size of raid456 stripe cache*/
@@ -171,6 +172,7 @@ struct mdinfo {
        #define DS_SPARE        8
        #define DS_BLOCKED      16
        #define DS_REMOVE       1024
+       #define DS_UNBLOCK      2048
        int prev_state, curr_state, next_state;
 
 };
@@ -222,6 +224,7 @@ enum special_options {
        AutoHomeHost,
        Symlinks,
        AutoDetect,
+       Waitclean,
 };
 
 /* structures read from config file */
@@ -256,6 +259,12 @@ typedef struct mddev_ident_s {
        char    *bitmap_file;
        int     bitmap_fd;
 
+       char    *container;     /* /dev/whatever name of container.  You
+                                * would expect this to be the 'devname'
+                                * of some other entry.
+                                */
+       char    *member;        /* subarray within a container */
+
        struct mddev_ident_s *next;
 } *mddev_ident_t;
 
@@ -324,6 +333,8 @@ extern void map_add(struct map_ent **melp,
 #define        GET_MISMATCH    32
 #define        GET_VERSION     64
 #define        GET_DISKS       128
+#define        GET_DEGRADED    256
+#define        GET_SAFEMODE    512
 
 #define        GET_DEVS        1024 /* gets role, major, minor */
 #define        GET_OFFSET      2048
@@ -335,20 +346,23 @@ extern void map_add(struct map_ent **melp,
  * else use devnum. >=0 -> major9. <0.....
  */
 extern int sysfs_open(int devnum, char *devname, char *attr);
+extern void sysfs_init(struct mdinfo *mdi, int fd, int devnum);
 extern void sysfs_free(struct mdinfo *sra);
 extern struct mdinfo *sysfs_read(int fd, int devnum, unsigned long options);
+extern int sysfs_attr_match(const char *attr, const char *str);
+extern int sysfs_match_word(const char *word, char **list);
 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_get_ll(struct mdinfo *sra, struct mdinfo *dev,
                        char *name, unsigned long long *val);
-extern int sysfs_set_array(struct mdinfo *sra,
-                          struct mdinfo *info);
+extern int sysfs_set_safemode(struct mdinfo *sra, unsigned long ms);
+extern int sysfs_set_array(struct mdinfo *info, int vers);
 extern int sysfs_add_disk(struct mdinfo *sra, struct mdinfo *sd);
-extern int sysfs_disk_to_sg(int fd);
 extern int sysfs_disk_to_scsi_id(int fd, __u32 *id);
 extern int sysfs_unique_holder(int devnum, long rdev);
+extern int load_sys(char *path, char *buf);
 
 
 extern int save_stripes(int *source, unsigned long long *offsets,
@@ -438,8 +452,7 @@ extern struct superswitch {
        void (*getinfo_super)(struct supertype *st, struct mdinfo *info);
 
        /* Check if the given metadata is flagged as belonging to "this"
-        * host.  For arrays that don't determine a minor-number, this
-        * can always be true (??)
+        * host.  0 for 'no', 1 for 'yes', -1 for "Don't record homehost"
         */
        int (*match_home)(struct supertype *st, char *homehost);
 
@@ -514,7 +527,8 @@ extern struct superswitch {
        int (*validate_geometry)(struct supertype *st, int level, int layout,
                                 int raiddisks,
                                 int chunk, unsigned long long size,
-                                char *subdev, unsigned long long *freesize);
+                                char *subdev, unsigned long long *freesize,
+                                int verbose);
 
        struct mdinfo *(*container_content)(struct supertype *st);
 
@@ -524,12 +538,16 @@ extern struct superswitch {
 
        /* Tell the metadata handler the current state of the array.
         * This covers whether it is known to be consistent (no pending writes)
-        * when how far along a resync is known to have progressed
+        * and how far along a resync is known to have progressed
         * (in a->resync_start).
         * resync status is really irrelevant if the array is not consistent,
         * but some metadata (DDF!) have a place to record the distinction.
+        * If 'consistent' is '2', then the array can mark it dirty if a 
+        * resync/recovery/whatever is required, or leave it clean if not.
+        * Return value is 0 dirty (not consistent) and 1 if clean.
+        * it is only really important if consistent is passed in as '2'.
         */
-       void (*set_array_state)(struct active_array *a, int consistent);
+       int (*set_array_state)(struct active_array *a, int consistent);
 
        /* When the state of a device might have changed, we call set_disk to
         * tell the metadata what the current state is.
@@ -542,6 +560,8 @@ extern struct superswitch {
        void (*sync_metadata)(struct supertype *st);
        void (*process_update)(struct supertype *st,
                               struct metadata_update *update);
+       void (*prepare_update)(struct supertype *st,
+                              struct metadata_update *update);
 
        /* activate_spare will check if the array is degraded and, if it
         * is, try to find some spare space in the container.
@@ -559,12 +579,25 @@ extern struct superswitch {
 
 extern struct superswitch super_imsm;
 
+struct metadata_update {
+       int     len;
+       char    *buf;
+       void    *space; /* allocated space that monitor will use */
+       struct metadata_update *next;
+};
+
 /* A supertype holds a particular collection of metadata.
  * It identifies the metadata type by the superswitch, and the particular
  * sub-version of that metadata type.
  * metadata read in or created is stored in 'sb' and 'info'.
  * There are also fields used by mdmon to track containers.
  *
+ * A supertype may refer to:
+ *   Just an array, possibly in a container
+ *   A container, not identifying any particular array
+ *   Info read from just one device, not yet fully describing the array/container.
+ *
+ *
  * A supertype is created by:
  *   super_by_fd
  *   guess_super
@@ -578,6 +611,11 @@ struct supertype {
        char subarray[32];      /* name of array inside container */
        void *sb;
        void *info;
+       int loaded_container;   /* Set if load_super found a container,
+                                * not just one device */
+
+       struct metadata_update *updates;
+       struct metadata_update **update_tail;
 
        /* extra stuff used by mdmon */
        struct active_array *arrays;
@@ -685,6 +723,7 @@ extern int Monitor(mddev_dev_t devlist,
 
 extern int Kill(char *dev, int force, int quiet, int noexcl);
 extern int Wait(char *dev);
+extern int WaitClean(char *dev);
 
 extern int Incremental(char *devname, int verbose, int runstop,
                       struct supertype *st, char *homehost, int autof);
@@ -728,8 +767,11 @@ extern char *conf_word(FILE *file, int allow_key);
 extern void free_line(char *line);
 extern int match_oneof(char *devices, char *devname);
 extern void uuid_from_super(int uuid[4], mdp_super_t *super);
+extern const int uuid_match_any[4];
 extern int same_uuid(int a[4], int b[4], int swapuuid);
 extern void copy_uuid(void *a, int b[4], int swapuuid);
+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);
@@ -738,7 +780,12 @@ extern unsigned long long get_component_size(int fd);
 extern void remove_partitions(int fd);
 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 add_disk(int mdfd, struct supertype *st,
+                   struct mdinfo *sra, struct mdinfo *info);
+extern int set_array_info(int mdfd, struct supertype *st, struct mdinfo *info);
 
 extern char *human_size(long long bytes);
 char *human_size_brief(long long bytes);
@@ -758,8 +805,12 @@ extern int open_container(int fd);
 
 extern int mdmon_running(int devnum);
 extern int signal_mdmon(int devnum);
+extern int env_no_mdmon(void);
+extern int start_mdmon(int devnum);
 
 extern char *devnum2devname(int num);
+extern int devname2devnum(char *name);
+extern int stat2devnum(struct stat *st);
 extern int fd2devnum(int fd);
 
 static inline int dev2major(int d)
@@ -777,6 +828,31 @@ 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;
+}
+
+static inline int is_subarray(char *vers)
+{
+       /* The version string for a 'subarray' (an array in a container)
+        * is 
+        *    /containername/componentname    for normal read-write arrays
+        *    -containername/componentname    for read-only arrays.
+        * containername is e.g. md0, md_d1
+        * componentname is dependant on the metadata. e.g. '1' 'S1' ...
+        */
+       return (*vers == '/' || *vers == '-');
+}
+
+#ifdef DEBUG
+#define dprintf(fmt, arg...) \
+       fprintf(stderr, fmt, ##arg)
+#else
+#define dprintf(fmt, arg...) \
+        ({ if (0) fprintf(stderr, fmt, ##arg); 0; })
+#endif
+
 #define        LEVEL_MULTIPATH         (-4)
 #define        LEVEL_LINEAR            (-1)
 #define        LEVEL_FAULTY            (-5)