]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - mdadm.h
fix mdmon takeover
[thirdparty/mdadm.git] / mdadm.h
diff --git a/mdadm.h b/mdadm.h
index 2bfe840f59c0b50a9d1deed50724188b2b2da013..df3a056a5613d63981c48818b8c7446277b0c44e 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -68,6 +68,15 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
 #define DEFAULT_BITMAP_DELAY 5
 #define DEFAULT_MAX_WRITE_BEHIND 256
 
+#define VAR_RUN "/var/run/mdadm"
+/* ALT_RUN should be somewhere that persists across the pivotroot
+ * from early boot to late boot.
+ * If you don't have /lib/init/rw you might want to use /dev/.something
+ */
+#ifndef ALT_RUN
+#define ALT_RUN "/lib/init/rw/mdadm"
+#endif /* ALT_RUN */
+
 #include       "md_u.h"
 #include       "md_p.h"
 #include       "bitmap.h"
@@ -129,6 +138,22 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
 #endif /* __KLIBC__ */
 
 
+/*
+ * min()/max()/clamp() macros that also do
+ * strict type-checking.. See the
+ * "unnecessary" pointer comparison.
+ */
+#define min(x, y) ({                            \
+       typeof(x) _min1 = (x);                  \
+       typeof(y) _min2 = (y);                  \
+       (void) (&_min1 == &_min2);              \
+       _min1 < _min2 ? _min1 : _min2; })
+
+#define max(x, y) ({                            \
+       typeof(x) _max1 = (x);                  \
+       typeof(y) _max2 = (y);                  \
+       (void) (&_max1 == &_max2);              \
+       _max1 > _max2 ? _max1 : _max2; })
 
 /* general information that might be extracted from a superblock */
 struct mdinfo {
@@ -146,7 +171,11 @@ struct mdinfo {
                                                    */
        int                     reshape_active;
        unsigned long long      reshape_progress;
-       unsigned long long      resync_start;
+       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 */
+       };
        unsigned long           safe_mode_delay; /* ms delay to mark clean */
        int                     new_level, delta_disks, new_layout, new_chunk;
        int                     errors;
@@ -168,6 +197,7 @@ struct mdinfo {
        struct mdinfo *next;
 
        /* Device info for mdmon: */
+       int recovery_fd;
        int state_fd;
        #define DS_FAULTY       1
        #define DS_INSYNC       2
@@ -271,6 +301,10 @@ typedef struct mddev_ident_s {
        char    *member;        /* subarray within a container */
 
        struct mddev_ident_s *next;
+       union {
+               /* fields needed by different users of this structure */
+               int assembled;  /* set when assembly succeeds */
+       };
 } *mddev_ident_t;
 
 /* List of device names - wildcards expanded */
@@ -380,8 +414,7 @@ extern int sysfs_get_str(struct mdinfo *sra, struct mdinfo *dev,
                         char *name, char *val, int size);
 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,
-                         int in_sync);
+extern int sysfs_add_disk(struct mdinfo *sra, struct mdinfo *sd, int resume);
 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);
@@ -839,6 +872,7 @@ extern int assemble_container_content(struct supertype *st, int mdfd,
 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);
+unsigned long long min_recovery_start(struct mdinfo *array);
 
 extern char *human_size(long long bytes);
 extern char *human_size_brief(long long bytes);
@@ -861,8 +895,9 @@ extern int create_mddev(char *dev, char *name, int autof, int trustworthy,
 extern int open_mddev(char *dev, int report_errors);
 extern int open_container(int fd);
 
+extern char *pid_dir;
 extern int mdmon_running(int devnum);
-extern int signal_mdmon(int devnum);
+extern int mdmon_pid(int devnum);
 extern int check_env(char *name);
 extern __u32 random32(void);
 extern int start_mdmon(int devnum);
@@ -1002,3 +1037,10 @@ static inline int xasprintf(char **strp, const char *fmt, ...) {
 #define ALGORITHM_PARITY_0_6           20
 #define ALGORITHM_PARITY_N_6           ALGORITHM_PARITY_N
 
+/* Define PATH_MAX in case we don't use glibc or standard library does
+ * not have PATH_MAX defined. Assume max path length is 4K characters.
+ */
+#ifndef PATH_MAX
+#define PATH_MAX       4096
+#endif
+