]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - mdadm.h
mdadm: Move pr_vrb define to mdadm.h
[thirdparty/mdadm.git] / mdadm.h
diff --git a/mdadm.h b/mdadm.h
index 39b86bd08029979ab5ae15e79dcee5afc8487ac0..fbb161ba4dc2bfa5ced6326ccc7b125655f3ed5a 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -433,6 +433,7 @@ struct spare_criteria {
        bool criteria_set;
        unsigned long long min_size;
        unsigned int sector_size;
+       struct dev_policy *pols;
 };
 
 typedef enum mdadm_status {
@@ -810,7 +811,7 @@ extern int sysfs_attribute_available(struct mdinfo *sra, struct mdinfo *dev,
 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_set_array(struct mdinfo *info);
 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(char *devnm, long rdev);
@@ -940,6 +941,23 @@ struct reshape {
        unsigned long long new_size; /* New size of array in sectors */
 };
 
+/**
+ * struct dev_policy - Data structure for policy management.
+ * @next: pointer to next dev_policy.
+ * @name: policy name, category.
+ * @metadata: the metadata type it affects.
+ * @value: value of the policy.
+ *
+ * The functions to manipulate dev_policy lists do not free elements, so they must be statically
+ * allocated. @name and @metadata can be compared by address.
+ */
+typedef struct dev_policy {
+       struct dev_policy *next;
+       char *name;
+       const char *metadata;
+       const char *value;
+} dev_policy_t;
+
 /* A superswitch provides entry point to a metadata handler.
  *
  * The superswitch primarily operates on some "metadata" that
@@ -1168,6 +1186,25 @@ extern struct superswitch {
                                 char *subdev, unsigned long long *freesize,
                                 int consistency_policy, int verbose);
 
+       /**
+        * test_and_add_drive_policies() - test new and add custom policies from metadata handler.
+        * @pols: list of currently recorded policies.
+        * @disk_fd: file descriptor of the device to check.
+        * @verbose: verbose flag.
+        *
+        * Used by IMSM to verify all drives in container/array, against requirements not recored
+        * in superblock, like controller type for IMSM. It should check all drives even if
+        * they are not actually used, because mdmon or kernel are free to use any drive assigned to
+        * container automatically.
+        *
+        * Generating and comparison methods belong to metadata handler. It is not mandatory to be
+        * implemented.
+        *
+        * Return: MDADM_STATUS_SUCCESS is expected on success.
+        */
+       mdadm_status_t (*test_and_add_drive_policies)(dev_policy_t **pols, int disk_fd,
+                                                     const int verbose);
+
        /* Return a linked list of 'mdinfo' structures for all arrays
         * in the container.  For non-containers, it is like
         * getinfo_super with an allocated mdinfo.*/
@@ -1249,21 +1286,6 @@ extern struct superswitch {
         */
        struct mdinfo *(*activate_spare)(struct active_array *a,
                                         struct metadata_update **updates);
-       /*
-        * Return statically allocated string that represents metadata specific
-        * controller domain of the disk. The domain is used in disk domain
-        * matching functions. Disks belong to the same domain if the they have
-        * the same domain from mdadm.conf and belong the same metadata domain.
-        * Returning NULL or not providing this handler means that metadata
-        * does not distinguish the differences between disks that belong to
-        * different controllers. They are in the domain specified by
-        * configuration file (mdadm.conf).
-        * In case when the metadata has the notion of domains based on disk
-        * it shall return NULL for disks that do not belong to the controller
-        * the supported domains. Such disks will form another domain and won't
-        * be mixed with supported ones.
-        */
-       const char *(*get_disk_controller_domain)(const char *path);
 
        /* for external backup area */
        int (*recover_backup)(struct supertype *st, struct mdinfo *info);
@@ -1372,23 +1394,6 @@ extern int get_dev_sector_size(int fd, char *dname, unsigned int *sectsizep);
 extern int must_be_container(int fd);
 void wait_for(char *dev, int fd);
 
-/*
- * Data structures for policy management.
- * Each device can have a policy structure that lists
- * various name/value pairs each possibly with a metadata associated.
- * The policy list is sorted by name/value/metadata
- */
-struct dev_policy {
-       struct dev_policy *next;
-       char *name;     /* None of these strings are allocated.  They are
-                        * all just references to strings which are known
-                        * to exist elsewhere.
-                        * name and metadata can be compared by address equality.
-                        */
-       const char *metadata;
-       const char *value;
-};
-
 extern char pol_act[], pol_domain[], pol_metadata[], pol_auto[];
 
 /* iterate over the sublist starting at list, having the same
@@ -1430,10 +1435,16 @@ extern struct dev_policy *disk_policy(struct mdinfo *disk);
 extern struct dev_policy *devid_policy(int devid);
 extern void dev_policy_free(struct dev_policy *p);
 
-//extern void pol_new(struct dev_policy **pol, char *name, char *val, char *metadata);
 extern void pol_add(struct dev_policy **pol, char *name, char *val, char *metadata);
 extern struct dev_policy *pol_find(struct dev_policy *pol, char *name);
 
+extern mdadm_status_t drive_test_and_add_policies(struct supertype *st, dev_policy_t **pols,
+                                                 int fd, const int verbose);
+extern mdadm_status_t sysfs_test_and_add_drive_policies(struct supertype *st, dev_policy_t **pols,
+                                                       struct mdinfo *mdi, const int verbose);
+extern mdadm_status_t mddev_test_and_add_drive_policies(struct supertype *st, dev_policy_t **pols,
+                                                       int array_fd, const int verbose);
+
 enum policy_action {
        act_default,
        act_include,
@@ -1685,8 +1696,7 @@ extern const int uuid_zero[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(int id[4], int swap, char *buf, char sep);
-extern char *fname_from_uuid(struct supertype *st,
-                            struct mdinfo *info, char *buf, char sep);
+extern char *fname_from_uuid(struct mdinfo *info, char *buf);
 extern unsigned long calc_csum(void *super, int bytes);
 extern int enough(int level, int raid_disks, int layout, int clean,
                   char *avail);
@@ -1709,8 +1719,8 @@ extern int assemble_container_content(struct supertype *st, int mdfd,
 #define        INCR_ALREADY    4
 #define        INCR_YES        8
 
-extern bool devid_matches_criteria(dev_t devid, struct spare_criteria *sc);
-extern bool disk_fd_matches_criteria(int disk_fd, struct spare_criteria *sc);
+extern bool devid_matches_criteria(struct supertype *st, dev_t devid, struct spare_criteria *sc);
+extern bool disk_fd_matches_criteria(struct supertype *st, int disk_fd, struct spare_criteria *sc);
 extern struct mdinfo *container_choose_spares(struct supertype *st,
                                              struct spare_criteria *criteria,
                                              struct domainlist *domlist,
@@ -1901,6 +1911,8 @@ static inline int xasprintf(char **strp, const char *fmt, ...) {
 
 #define pr_info(fmt, args...) printf("%s: "fmt, Name, ##args)
 
+#define pr_vrb(fmt, arg...) ((void)(verbose && pr_err(fmt, ##arg)))
+
 void *xmalloc(size_t len);
 void *xrealloc(void *ptr, size_t len);
 void *xcalloc(size_t num, size_t size);