#include <errno.h>
#include <string.h>
#include <syslog.h>
+#ifdef __GLIBC__
+/* Newer glibc requires sys/sysmacros.h directly for makedev() */
+#include <sys/sysmacros.h>
+#endif
#ifdef __dietlibc__
#include <strings.h>
/* dietlibc has deprecated random and srandom!! */
extern const char Name[];
+struct md_bb_entry {
+ unsigned long long sector;
+ int length;
+};
+
+struct md_bb {
+ int supported;
+ int count;
+ struct md_bb_entry *entries;
+};
+
/* general information that might be extracted from a superblock */
struct mdinfo {
mdu_array_info_t array;
int container_enough; /* flag external handlers can set to
* indicate that subarrays have not enough (-1),
* enough to start (0), or all expected disks (1) */
- char sys_name[20];
+ char sys_name[32];
struct mdinfo *devs;
struct mdinfo *next;
/* Device info for mdmon: */
int recovery_fd;
int state_fd;
+ int bb_fd;
+ int ubb_fd;
#define DS_FAULTY 1
#define DS_INSYNC 2
#define DS_WRITE_MOSTLY 4
/* info read from sysfs */
char sysfs_array_state[20];
+
+ struct md_bb bb;
};
struct createinfo {
ConfigFile,
ChunkSize,
WriteMostly,
+ FailFast,
+ NoFailFast,
Layout,
Auto,
Force,
NodeNumUpdate,
};
+enum flag_mode {
+ FlagDefault, FlagSet, FlagClear,
+};
+
/* structures read from config file */
/* List of mddevice names and identifiers
* Identifiers can be:
* 'A' for re_add.
* Not set for names read from .config
*/
- char writemostly; /* 1 for 'set writemostly', 2 for 'clear writemostly' */
+ enum flag_mode writemostly;
+ enum flag_mode failfast;
int used; /* set when used */
long long data_offset;
struct mddev_dev *next;
* linear-grow-update - now change the size of the array.
* writemostly - set the WriteMostly1 bit in the superblock devflags
* readwrite - clear the WriteMostly1 bit in the superblock devflags
+ * failfast - set the FailFast1 bit in the superblock
+ * nofailfast - clear the FailFast1 bit
* no-bitmap - clear any record that a bitmap is present.
* bbl - add a bad-block-log if possible
* no-bbl - remove any bad-block-log is it is empty.
* created, in which case data_size may be updated, or it might
* already exist. Metadata handler can know if init_super
* has been called, but not write_init_super.
+ * 0: Success
+ * -Exxxx: On error
*/
int (*add_internal_bitmap)(struct supertype *st, int *chunkp,
int delay, int write_behind,
/* validate container after assemble */
int (*validate_container)(struct mdinfo *info);
+ /* records new bad block in metadata */
+ int (*record_bad_block)(struct active_array *a, int n,
+ unsigned long long sector, int length);
+
+ /* clears bad block from metadata */
+ int (*clear_bad_block)(struct active_array *a, int n,
+ unsigned long long sector, int length);
+
+ /* get list of bad blocks from metadata */
+ struct md_bb *(*get_bad_blocks)(struct active_array *a, int n);
+
int swapuuid; /* true if uuid is bigending rather than hostendian */
int external;
const char *name; /* canonical metadata name */
}
extern struct supertype *dup_super(struct supertype *st);
extern int get_dev_size(int fd, char *dname, unsigned long long *sizep);
+extern int get_dev_sector_size(int fd, char *dname, unsigned int *sectsizep);
extern int must_be_container(int fd);
extern int dev_size_from_id(dev_t id, unsigned long long *size);
void wait_for(char *dev, int fd);
extern int ExamineBitmap(char *filename, int brief, struct supertype *st);
extern int Write_rules(char *rule_name);
extern int bitmap_update_uuid(int fd, int *uuid, int swap);
-extern unsigned long bitmap_sectors(struct bitmap_super_s *bsb);
+
+/* calculate the size of the bitmap given the array size and bitmap chunksize */
+static inline unsigned long long
+bitmap_bits(unsigned long long array_size, unsigned long chunksize)
+{
+ return (array_size * 512 + chunksize - 1) / chunksize;
+}
+
extern int Dump_metadata(char *dev, char *dir, struct context *c,
struct supertype *st);
extern int Restore_metadata(char *dev, char *dir, struct context *c,
extern void put_md_name(char *name);
extern char *devid2kname(int devid);
-extern char *devid2devnm(int devid);
-extern int devnm2devid(char *devnm);
+extern char *devid2devnm(dev_t devid);
+extern dev_t devnm2devid(char *devnm);
extern char *get_md_name(char *devnm);
extern char DefaultConfFile[];
extern int mdmon_pid(char *devnm);
extern int check_env(char *name);
extern __u32 random32(void);
+extern void random_uuid(__u8 *buf);
extern int start_mdmon(char *devnm);
extern int child_monitor(int afd, struct mdinfo *sra, struct reshape *reshape,