]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - mdadm.h
recreate journal in mdadm
[thirdparty/mdadm.git] / mdadm.h
diff --git a/mdadm.h b/mdadm.h
old mode 100644 (file)
new mode 100755 (executable)
index 5633663..477ef18
--- a/mdadm.h
+++ b/mdadm.h
@@ -35,6 +35,7 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
 
 #include       <sys/types.h>
 #include       <sys/stat.h>
+#include       <stdint.h>
 #include       <stdlib.h>
 #include       <time.h>
 #include       <sys/time.h>
@@ -51,6 +52,32 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
 #define srandom srand
 #endif
 
+#ifdef NO_COROSYNC
+#define CS_OK 1
+typedef uint64_t cmap_handle_t;
+#else
+#include       <corosync/cmap.h>
+#endif
+
+#ifndef NO_DLM
+#include       <libdlm.h>
+#include       <errno.h>
+#else
+#define LKF_NOQUEUE    0x00000001
+#define LKF_CONVERT    0x00000004
+#define LKM_PWMODE     4
+#define EUNLOCK                0x10002
+
+typedef void *dlm_lshandle_t;
+
+struct dlm_lksb {
+       int sb_status;
+       uint32_t sb_lkid;
+       char sb_flags;
+       char *sb_lvbptr;
+};
+#endif
+
 #include       <linux/kdev_t.h>
 /*#include     <linux/fs.h> */
 #include       <sys/mount.h>
@@ -161,6 +188,31 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
 #endif
 #endif /* __KLIBC__ */
 
+/*
+  * Check at compile time that something is of a particular type.
+  * Always evaluates to 1 so you may use it easily in comparisons.
+*/
+
+#define typecheck(type,x) \
+({        type __dummy; \
+          typeof(x) __dummy2; \
+          (void)(&__dummy == &__dummy2); \
+          1; \
+})
+
+/*
+ *  These inlines deal with timer wrapping correctly.
+ *
+ * time_after(a,b) returns true if the time a is after time b.
+*/
+
+#define time_after(a,b)        \
+        (typecheck(unsigned int, a) && \
+         typecheck(unsigned int, b) && \
+         ((int)((b) - (a)) < 0))
+
+#define time_before(a,b)        time_after(b,a)
+
 /*
  * min()/max()/clamp() macros that also do
  * strict type-checking.. See the
@@ -210,6 +262,9 @@ struct mdinfo {
                                                   * for native metadata it is
                                                   * reshape_active field mirror
                                                   */
+       int journal_device_required;
+       int journal_clean;
+
        /* During reshape we can sometimes change the data_offset to avoid
         * over-writing still-valid data.  We need to know if there is space.
         * So getinfo_super will fill in space_before and space_after in sectors.
@@ -251,6 +306,8 @@ struct mdinfo {
        #define DS_UNBLOCK      2048
        int prev_state, curr_state, next_state;
 
+       /* info read from sysfs */
+       char            sysfs_array_state[20];
 };
 
 struct createinfo {
@@ -313,6 +370,7 @@ enum special_options {
        ManageOpt,
        Add,
        AddSpare,
+       AddJournal,
        Remove,
        Fail,
        Replace,
@@ -347,6 +405,7 @@ enum special_options {
        Nodes,
        ClusterName,
        ClusterConfirm,
+       WriteJournal,
 };
 
 enum prefix_standard {
@@ -434,6 +493,7 @@ struct context {
 struct shape {
        int     raiddisks;
        int     sparedisks;
+       int     journaldisks;
        int     level;
        int     layout;
        char    *layout_str;
@@ -532,6 +592,7 @@ enum sysfs_read_flags {
        GET_SIZE        = (1 << 22),
        GET_STATE       = (1 << 23),
        GET_ERROR       = (1 << 24),
+       GET_ARRAY_STATE = (1 << 25),
 };
 
 /* If fd >= 0, get the array it is open on,
@@ -1418,7 +1479,45 @@ extern char *stat2devnm(struct stat *st);
 extern char *fd2devnm(int fd);
 
 extern int in_initrd(void);
+
+struct cmap_hooks {
+       void *cmap_handle;      /* corosync lib related */
+
+       int (*initialize)(cmap_handle_t *handle);
+       int (*get_string)(cmap_handle_t handle,
+                         const char *string,
+                         char **name);
+       int (*finalize)(cmap_handle_t handle);
+};
+
+extern void set_cmap_hooks(void);
+extern void set_hooks(void);
+
+struct dlm_hooks {
+       void *dlm_handle;       /* dlm lib related */
+
+       dlm_lshandle_t (*create_lockspace)(const char *name,
+                                          unsigned int mode);
+       int (*release_lockspace)(const char *name, dlm_lshandle_t ls,
+                                int force);
+       int (*ls_lock)(dlm_lshandle_t lockspace, uint32_t mode,
+                      struct dlm_lksb *lksb, uint32_t flags,
+                      const void *name, unsigned int namelen,
+                      uint32_t parent, void (*astaddr) (void *astarg),
+                      void *astarg, void (*bastaddr) (void *astarg),
+                      void *range);
+       int (*ls_unlock)(dlm_lshandle_t lockspace, uint32_t lkid,
+                        uint32_t flags, struct dlm_lksb *lksb,
+                        void *astarg);
+       int (*ls_get_fd)(dlm_lshandle_t ls);
+       int (*dispatch)(int fd);
+};
+
 extern int get_cluster_name(char **name);
+extern int is_clustered(struct supertype *st);
+extern int cluster_get_dlmlock(struct supertype *st, int *lockid);
+extern int cluster_release_dlmlock(struct supertype *st, int lockid);
+extern void set_dlm_hooks(void);
 
 #define _ROUND_UP(val, base)   (((val) + (base) - 1) & ~(base - 1))
 #define ROUND_UP(val, base)    _ROUND_UP(val, (typeof(val))(base))