]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - mdadm.h
Honor safemode_delay at Create() and Incremental() time
[thirdparty/mdadm.git] / mdadm.h
diff --git a/mdadm.h b/mdadm.h
index c728badcdcc1f4dca8ef60dac411617d75434db0..3eee61a5adad7de5fc7e32d313c0421a5d911a78 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;
 
 };
@@ -324,6 +326,7 @@ 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_DEVS        1024 /* gets role, major, minor */
 #define        GET_OFFSET      2048
@@ -343,11 +346,12 @@ 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_safemode(struct mdinfo *sra, unsigned long ms);
 extern int sysfs_set_array(struct mdinfo *sra,
                           struct mdinfo *info);
 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 save_stripes(int *source, unsigned long long *offsets,
@@ -429,10 +433,12 @@ extern struct superswitch {
         * The determination is made either by:
         *   load_super being given a 'component' string.
         *   validate_geometry determining what to create.
-        * getinfo_super_n really needs to be removed..
+        * The info includes both array information and device information.
+        * The particular device should be:
+        *   The last device added by add_to_super
+        *   The device the metadata was loaded from by load_super
         */
        void (*getinfo_super)(struct supertype *st, struct mdinfo *info);
-       void (*getinfo_super_n)(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
@@ -499,10 +505,20 @@ extern struct superswitch {
        void (*locate_bitmap)(struct supertype *st, int fd);
        int (*write_bitmap)(struct supertype *st, int fd);
        void (*free_super)(struct supertype *st);
+
+       /* validate_geometry is called with an st returned by
+        * match_metadata_desc.
+        * It should check that the geometry described in compatible with
+        * the metadata type.  It will be called repeatedly as devices
+        * added to validate changing size and new devices.  If there are
+        * inter-device dependencies, it should record sufficient details
+        * so these can be validated.
+        */
        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);
 
@@ -512,12 +528,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.
@@ -530,6 +550,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.
@@ -547,6 +569,13 @@ 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.
@@ -567,11 +596,12 @@ struct supertype {
        void *sb;
        void *info;
 
+       struct metadata_update *updates;
+       struct metadata_update **update_tail;
+
        /* extra stuff used by mdmon */
        struct active_array *arrays;
        int sock; /* listen to external programs */
-       int mgr_pipe[2]; /* communicate between threads */
-       int mon_pipe[2]; /* communicate between threads */
        int devnum;
        char *devname; /* e.g. md0.  This appears in metadata_verison:
                        *  external:/md0/12
@@ -728,6 +758,8 @@ 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 char *human_size(long long bytes);
@@ -748,8 +780,11 @@ 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 fd2devnum(int fd);
 
 static inline int dev2major(int d)
@@ -767,6 +802,23 @@ 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 == '-');
+}
+
 #define        LEVEL_MULTIPATH         (-4)
 #define        LEVEL_LINEAR            (-1)
 #define        LEVEL_FAULTY            (-5)