mdadm support for Partial Parity Log
v3 cover mdadm support for Partial Parity Log
This is the mdadm part of the PPL functionality. It adds a new parameter to mdadm to allow selecting the consistency policy for an array and implements PPL as one of the policies.
All of this is currently targeted and tested with imsm and super1 metadata arrays. The kernel patches are available on Shaohua's md tree on the for-next branch.
v3:
- Rebased to latest mdadm code.
- Replaced --rwh-policy with --consistency-policy.
- Adjusted to the kernel interface changes.
- Write the initial ppl header in mdadm when creating an array.
- Validate ppl when starting an imsm array.
- Support for --update.
- Support also 1.0 metadata.
- Use Grow mode for enabing or disabling ppl for an active array.
v2:
- Rebased to latest mdadm code.
- Fixed runtime policy switching.
- Recognize IMSM PPL journal drive correctly.
- Removed bitfields from imsm_dev.
- Made dirty/consistent checks in imsm_set_array_state() more readable.
- Added comment about calculating sb_start.
Artur Paszkiewicz (6):
Generic support for --consistency-policy and PPL
Detail: show consistency policy
imsm: PPL support
super1: PPL support
Add 'ppl' and 'no-ppl' options for --update=
Grow: support consistency policy change
Assemble.c | 58 ++++++++++ Create.c | 20 +++- Detail.c | 90 +++++++++------ Grow.c | 187 ++++++++++++++++++++++++++++++- Incremental.c | 3 + Kill.c | 2 +- Makefile | 5 +- ReadMe.c | 7 +- maps.c | 10 ++ md_p.h | 25 +++++ mdadm.8.in | 85 ++++++++++++-- mdadm.c | 64 ++++++++++- mdadm.h | 30 ++++- super-ddf.c | 12 +- super-gpt.c | 2 +- super-intel.c | 347 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ super-mbr.c | 2 +- super0.c | 12 +- super1.c | 214 +++++++++++++++++++++++++++++++----- sysfs.c | 25 +++++ 20 files changed, 1069 insertions(+), 131 deletions(-)
Signature · 1 line
2.11.0
PATCH v3 1/6 Generic support for --consistency-policy and PPL
Add a new parameter to mdadm: --consistency-policy=. It determines how the array maintains consistency in case of unexpected shutdown. This maps to the md sysfs attribute 'consistency_policy'. It can be used to create a raid5 array using PPL. Add the necessary plumbing to pass this option to metadata handlers. The write journal and bitmap functionalities are treated as different policies, which are implicitly selected when using --write-journal or --bitmap options.
--- Create.c | 18 ++++++++++++++---- Kill.c | 2 +- ReadMe.c | 7 ++++--- maps.c | 10 ++++++++++ mdadm.8.in | 40 +++++++++++++++++++++++++++++++++++++--- mdadm.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- mdadm.h | 21 ++++++++++++++++++--- super-ddf.c | 6 +++--- super-gpt.c | 2 +- super-intel.c | 16 ++++++++-------- super-mbr.c | 2 +- super0.c | 8 ++++---- super1.c | 6 +++--- sysfs.c | 11 +++++++++++ 14 files changed, 167 insertions(+), 37 deletions(-)
Create.c +14 -4
@@ -259,7 +259,8 @@ int Create(struct supertype *st, char *mddev,if (st && ! st->ss->validate_geometry (st, s->level, s->layout, s->raiddisks, &s->chunk, s->size*2 , data_offset,NULL , - &newsize, c->verbose>=0 )) + &newsize, s->consistency_policy, + c->verbose>=0 ))return 1 ;if (s->chunk && s->chunk != UnSet) {
@@ -358,7 +359,8 @@ int Create(struct supertype *st, char *mddev, st, s->level, s->layout, s->raiddisks, &s->chunk, s->size*2, dv->data_offset, dname, - &freesize, c->verbose > 0)) { + &freesize, s->consistency_policy, + c->verbose > 0)) {case -1 :/* Not valid, message printed, and not * worth checking any further */ exit (2 );
@@ -395,6 +397,7 @@ int Create(struct supertype *st, char *mddev, &s->chunk, s->size*2, dv->data_offset, dname, &freesize, + s->consistency_policy, c->verbose >= 0)) { pr_err("%s is not suitable for this array.\n",
@@ -501,7 +504,8 @@ int Create(struct supertype *st, char *mddev, s->raiddisks, &s->chunk, minsize*2, data_offset, - NULL, NULL, 0)) { + NULL, NULL, + s->consistency_policy, 0)) {pr_err ("devices too large for RAID level %d\n" , s->level);return 1 ; }
@@ -528,6 +532,12 @@ int Create(struct supertype *st, char *mddev,if (s->bitmap_file &&strcmp (s->bitmap_file,"none" ) ==0 ) s->bitmap_file =NULL ; +if (s->consistency_policy ==CONSISTENCY_POLICY_PPL && + !st->ss->write_init_ppl) { +pr_err ("%s metadata does not support PPL\n" , st->ss->name); +return 1 ; + } +if (!have_container && s->level >0 && ((maxsize-s->size)*100 > maxsize)) {if (c->runstop !=1 || c->verbose >=0 ) pr_err("largest drive (%s) exceeds size (%lluK) by more than 1%%\n",
@@ -720,7 +730,7 @@ int Create(struct supertype *st, char *mddev, name +=2 ; } } -if (!st->ss->init_super (st, &info.array, s->size, name, c->homehost, uuid, +if (!st->ss->init_super (st, &info.array, s, name, c->homehost, uuid, data_offset)) goto abort_locked;
Kill.c +1 -1
@@ -63,7 +63,7 @@ int Kill(char *dev, struct supertype *st, int force, int verbose, int noexcl) rv = st->ss->load_super (st, fd, dev);if (rv ==0 || (force && rv >=2 )) { st->ss->free_super (st); - st->ss->init_super (st,NULL ,0 ,"" ,NULL ,NULL , + st->ss->init_super (st,NULL ,NULL ,"" ,NULL ,NULL ,INVALID_SECTORS );if (st->ss->store_super (st, fd)) {if (verbose >=0 )
ReadMe.c +4 -3
@@ -78,11 +78,11 @@ char Version[] = "mdadm - v" VERSION " - " VERS_DATE "\n";* found, it is started. */ -char short_options[]="-ABCDEFGIQhVXYWZ:vqbc:i:l:p:m:n:x:u:c:d:z:U:N:sarfRSow1tye:" ; +char short_options[]="-ABCDEFGIQhVXYWZ:vqbc:i:l:p:m:n:x:u:c:d:z:U:N:sarfRSow1tye:k:" ;char short_bitmap_options[]= -"-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:n:x:u:c:d:z:U:N:sarfRSow1tye:" ; +"-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:n:x:u:c:d:z:U:N:sarfRSow1tye:k:" ;char short_bitmap_auto_options[]= -"-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:n:x:u:c:d:z:U:N:sa:rfRSow1tye:" ; +"-ABCDEFGIQhVXYWZ:vqb:c:i:l:p:m:n:x:u:c:d:z:U:N:sa:rfRSow1tye:k:" ;struct option long_options[] = { {"manage" ,0 ,0 , ManageOpt},
@@ -148,6 +148,7 @@ struct option long_options[] = { {"nodes",1, 0, Nodes}, /* also for --assemble */ {"home-cluster",1, 0, ClusterName}, {"write-journal",1, 0, WriteJournal}, + {"consistency-policy",1, 0, 'k'},/* For assemble */ {"uuid", 1, 0, 'u'},
maps.c +10 -0
@@ -129,6 +129,16 @@ mapping_t faultylayout[] = { { NULL, 0} }; +mapping_t consistency_policies[] = { + {"unknown" ,CONSISTENCY_POLICY_UNKNOWN }, + {"none" ,CONSISTENCY_POLICY_NONE }, + {"resync" ,CONSISTENCY_POLICY_RESYNC }, + {"bitmap" ,CONSISTENCY_POLICY_BITMAP }, + {"journal" ,CONSISTENCY_POLICY_JOURNAL }, + {"ppl" ,CONSISTENCY_POLICY_PPL }, + {NULL ,0 } +}; +char *map_num (mapping_t *map,int num) {while (map->name) {
mdadm.8.in +37 -3
@@ -724,7 +724,9 @@ When creating an array on devices which are 100G or larger, .I mdadm automatically adds an internal bitmap as it will usually be beneficial. This can be suppressed with -.B "\-\-bitmap=none". +.B "\-\-bitmap=none" +or by selecting a different consistency policy with +.BR \-\-consistency\-policy . .TP .BR \-\-bitmap\-chunk=
@@ -1020,6 +1022,36 @@ should be a SSD with reasonable lifetime. Auto creation of symlinks in /dev to /dev/md, option --symlinks must be 'no' or 'yes' and work with --create and --build. +.TP +.BR \-k ", " \-\-consistency\-policy= +Specify how the array maintains consistency in case of unexpected shutdown. +Only relevant for RAID levels with redundancy. +Currently supported options are: +.RS + +.TP +.B resync +Full resync is performed and all redundancy is regenerated when the array is +started after unclean shutdown. + +.TP +.B bitmap +Resync assisted by a write-intent bitmap. Implicitly selected when using +.BR \-\-bitmap . + +.TP +.B journal +For RAID levels 4/5/6, journal device is used to log transactions and replay +after unclean shutdown. Implicitly selected when using +.BR \-\-write\-journal . + +.TP +.B ppl +For RAID5 only, Partial Parity Log is used to close the write hole and +eliminate resync. PPL is stored in the metadata region of RAID member drives, +no additional journal drive is needed. +.RE + .SH For assemble:
@@ -2153,8 +2185,10 @@ in the array exceed 100G is size, an internal write-intent bitmap will automatically be added unless some other option is explicitly requested with the .B \-\-bitmap -option. In any case space for a bitmap will be reserved so that one -can be added layer with +option or a different consistency policy is selected with the +.B \-\-consistency\-policy +option. In any case space for a bitmap will be reserved so that one +can be added later with .BR "\-\-grow \-\-bitmap=internal" . If the metadata type supports it (currently only 1.x metadata), space
mdadm.c +52 -3
73 lines not on this page · raw message
mdadm.h +18 -3
@@ -279,6 +279,15 @@ struct mdinfo {int journal_device_required;int journal_clean; +enum { +CONSISTENCY_POLICY_UNKNOWN , +CONSISTENCY_POLICY_NONE , +CONSISTENCY_POLICY_RESYNC , +CONSISTENCY_POLICY_BITMAP , +CONSISTENCY_POLICY_JOURNAL , +CONSISTENCY_POLICY_PPL , + } consistency_policy; +/* 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.
@@ -426,6 +435,7 @@ enum special_options { ClusterName, ClusterConfirm, WriteJournal, + ConsistencyPolicy, }; enum prefix_standard {
@@ -527,6 +537,7 @@ struct shape {int assume_clean;int write_behind;unsigned long long size; +int consistency_policy; };/* List of device names - wildcards expanded */
@@ -618,6 +629,7 @@ enum sysfs_read_flags {GET_STATE = (1 <<23 ),GET_ERROR = (1 <<24 ),GET_ARRAY_STATE = (1 <<25 ), + GET_CONSISTENCY_POLICY = (1 << 26), };/* If fd >= 0, get the array it is open on,
@@ -701,7 +713,7 @@ extern int restore_stripes(int *dest, unsigned long long *offsets,extern char *map_num (mapping_t *map,int num);extern int map_name (mapping_t *map,char *name); -extern mapping_t r5layout[], r6layout[], pers[], modes[], faultylayout[]; +extern mapping_t r5layout[], r6layout[], pers[], modes[], faultylayout[], consistency_policies[];extern char *map_dev_preferred (int major,int minor,int create,char *prefer);
@@ -863,7 +875,7 @@ extern struct superswitch {* metadata. */ int (*init_super)(struct supertype *st,mdu_array_info_t *info, -unsigned long long size,char *name, +struct shape *s,char *name,char *homehost,int *uuid,unsigned long long data_offset);
@@ -961,7 +973,7 @@ extern struct superswitch { int *chunk, unsigned long long size, unsigned long long data_offset, char *subdev, unsigned long long *freesize, - int verbose); + int consistency_policy, int verbose);/* Return a linked list of 'mdinfo' structures for all arrays * in the container. For non-containers, it is like
@@ -1059,6 +1071,9 @@ extern struct superswitch {/* validate container after assemble */ int (*validate_container)(struct mdinfo *info); +/* write initial empty PPL on device */ +int (*write_init_ppl)(struct supertype *st,struct mdinfo *info,int fd); +/* records new bad block in metadata */ int (*record_bad_block)(struct active_array *a,int n,unsigned long long sector,int length);
super-ddf.c +3 -3
@@ -2290,7 +2290,7 @@ static unsigned int find_vde_by_guid(const struct ddf_super *ddf,static int init_super_ddf (struct supertype *st,mdu_array_info_t *info, -unsigned long long size,char *name,char *homehost, +struct shape *s,char *name,char *homehost,int *uuid,unsigned long long data_offset) {/* This is primarily called by Create when creating a new array.
@@ -2328,7 +2328,7 @@ static int init_super_ddf(struct supertype *st,struct virtual_disk *vd;if (st->sb) -return init_super_ddf_bvd (st, info, size, name, homehost, uuid, +return init_super_ddf_bvd (st, info, s->size, name, homehost, uuid, data_offset);if (posix_memalign ((void **)&ddf,512 ,sizeof (*ddf)) !=0 ) {
@@ -3347,7 +3347,7 @@ static int validate_geometry_ddf(struct supertype *st, int *chunk, unsigned long long size, unsigned long long data_offset, char *dev, unsigned long long *freesize, - int verbose) + int consistency_policy, int verbose) { int fd;struct mdinfo *sra;
super-gpt.c +1 -1
@@ -205,7 +205,7 @@ static int validate_geometry(struct supertype *st, int level, int *chunk, unsigned long long size, unsigned long long data_offset, char *subdev, unsigned long long *freesize, - int verbose) + int consistency_policy, int verbose) { pr_err("gpt metadata cannot be used this way\n");return 0 ;
super-intel.c +8 -8
@@ -5154,7 +5154,7 @@ static int check_name(struct intel_super *super, char *name, int quiet) }static int init_super_imsm_volume (struct supertype *st,mdu_array_info_t *info, -unsigned long long size,char *name, +struct shape *s,char *name,char *homehost,int *uuid,long long data_offset) {
@@ -5249,7 +5249,7 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info,strncpy ((char *) dev->volume, name,MAX_RAID_SERIAL_LEN ); array_blocks =calc_array_size (info->level, info->raid_disks, info->layout, info->chunk_size, - size *2 ); + s->size *2 );/* round array size down to closest MB */ array_blocks = (array_blocks >>SECT_PER_MB_SHIFT ) <<SECT_PER_MB_SHIFT ;
@@ -5263,7 +5263,7 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info, vol->curr_migr_unit =0 ; map =get_imsm_map (dev,MAP_0 );set_pba_of_lba0 (map, super->create_offset); -set_blocks_per_member (map,info_to_blocks_per_member (info, size)); +set_blocks_per_member (map,info_to_blocks_per_member (info, s->size)); map->blocks_per_strip =__cpu_to_le16 (info_to_blocks_per_strip (info)); map->failed_disk_num = ~0 ;if (info->level >0 )
@@ -5291,7 +5291,7 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info, map->num_domains =1 ;/* info->size is only int so use the 'size' parameter instead */ - num_data_stripes = (size *2 ) /info_to_blocks_per_strip (info); + num_data_stripes = (s->size *2 ) /info_to_blocks_per_strip (info); num_data_stripes /= map->num_domains;set_num_data_stripes (map, num_data_stripes);
@@ -5313,7 +5313,7 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info, }static int init_super_imsm (struct supertype *st,mdu_array_info_t *info, -unsigned long long size,char *name, +struct shape *s,char *name,char *homehost,int *uuid,unsigned long long data_offset) {
@@ -5336,7 +5336,7 @@ static int init_super_imsm(struct supertype *st, mdu_array_info_t *info, }if (st->sb) -return init_super_imsm_volume (st, info, size, name, homehost, uuid, +return init_super_imsm_volume (st, info, s, name, homehost, uuid, data_offset);if (info)
@@ -6913,7 +6913,7 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout, int raiddisks, int *chunk, unsigned long long size, unsigned long long data_offset, char *dev, unsigned long long *freesize, - int verbose) + int consistency_policy, int verbose) { int fd, cfd;struct mdinfo *sra;
@@ -10950,7 +10950,7 @@ enum imsm_reshape_type imsm_analyze_change(struct supertype *st, geo->raid_disks + devNumChange, &chunk, geo->size, INVALID_SECTORS, - 0, 0, 1)) + 0, 0, info.consistency_policy, 1)) change =-1 ;if (check_devs) {
super-mbr.c +1 -1
@@ -193,7 +193,7 @@ static int validate_geometry(struct supertype *st, int level, int *chunk, unsigned long long size, unsigned long long data_offset, char *subdev, unsigned long long *freesize, - int verbose) + int consistency_policy, int verbose) { pr_err("mbr metadata cannot be used this way\n");return 0 ;
super0.c +4 -4
@@ -725,7 +725,7 @@ static int update_super0(struct supertype *st, struct mdinfo *info,* We use the first 8 bytes (64bits) of the sha1 of the host name */ static int init_super0 (struct supertype *st,mdu_array_info_t *info, -unsigned long long size,char *ignored_name, +struct shape *s,char *ignored_name,char *homehost,int *uuid,unsigned long long data_offset) {
@@ -764,8 +764,8 @@ static int init_super0(struct supertype *st, mdu_array_info_t *info, sb->gvalid_words =0 ;/* ignored */ sb->ctime =time (0 ); sb->level = info->level; - sb->size = size; -if (size != (unsigned long long )sb->size) + sb->size = s->size; +if (s->size != (unsigned long long )sb->size)return 0 ; sb->nr_disks = info->nr_disks; sb->raid_disks = info->raid_disks;
@@ -1267,7 +1267,7 @@ static int validate_geometry0(struct supertype *st, int level, int *chunk, unsigned long long size, unsigned long long data_offset, char *subdev, unsigned long long *freesize, - int verbose) + int consistency_policy, int verbose) { unsigned long long ldsize;int fd;
super1.c +3 -3
@@ -1397,7 +1397,7 @@ static int update_super1(struct supertype *st, struct mdinfo *info, }static int init_super1 (struct supertype *st,mdu_array_info_t *info, -unsigned long long size,char *name,char *homehost, +struct shape *s,char *name,char *homehost,int *uuid,unsigned long long data_offset) {struct mdp_superblock_1 *sb;
@@ -1450,7 +1450,7 @@ static int init_super1(struct supertype *st, mdu_array_info_t *info, sb->ctime =__cpu_to_le64 ((unsigned long long )time (0 )); sb->level =__cpu_to_le32 (info->level); sb->layout =__cpu_to_le32 (info->layout); - sb->size =__cpu_to_le64 (size*2ULL ); + sb->size =__cpu_to_le64 (s->size*2ULL ); sb->chunksize =__cpu_to_le32 (info->chunk_size>>9 ); sb->raid_disks =__cpu_to_le32 (info->raid_disks);
@@ -2485,7 +2485,7 @@ static int validate_geometry1(struct supertype *st, int level, int *chunk, unsigned long long size, unsigned long long data_offset, char *subdev, unsigned long long *freesize, - int verbose) + int consistency_policy, int verbose) { unsigned long long ldsize, devsize;int bmspace;
sysfs.c +11 -0
@@ -242,6 +242,17 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options) }else sra->sysfs_array_state[0 ] =0 ; +if (options &GET_CONSISTENCY_POLICY ) { +strcpy (base,"consistency_policy" ); +if (load_sys (fname, buf,sizeof (buf))) { + sra->consistency_policy =CONSISTENCY_POLICY_UNKNOWN ; + }else { + sra->consistency_policy =map_name (consistency_policies, buf); +if (sra->consistency_policy == UnSet) + sra->consistency_policy =CONSISTENCY_POLICY_UNKNOWN ; + } + } +if (! (options &GET_DEVS ))return sra;
Signature · 1 line
2.11.0
PATCH v3 2/6 Detail: show consistency policy
In reply to Artur PaszkiewiczShow the currently enabled consistency policy in the output from --detail. Add 3 spaces to all existing items in Detail output to align with "Consistency Policy : ".
--- Detail.c | 90 +++++++++++++++++++++++++++++++++++------------------------ super-ddf.c | 6 ++-- super-intel.c | 2 +- super0.c | 4 +-- super1.c | 9 +++--- 5 files changed, 65 insertions(+), 46 deletions(-)
Detail.c +54 -36
@@ -394,24 +394,25 @@ int Detail(char *dev, struct context *c)printf ("%s:\n" , dev);if (container) -printf (" Container : %s, member %s\n" , container, member); +printf (" Container : %s, member %s\n" , container, + member);else {if (sra && sra->array.major_version <0 ) -printf (" Version : %s\n" , sra->text_version); +printf (" Version : %s\n" , sra->text_version);else -printf (" Version : %d.%d\n" , +printf (" Version : %d.%d\n" , array.major_version, array.minor_version); } atime = array.ctime;if (atime) -printf (" Creation Time : %.24s\n" ,ctime (&atime)); +printf (" Creation Time : %.24s\n" ,ctime (&atime));if (array.raid_disks ==0 && external) str ="container" ;if (str) -printf (" Raid Level : %s\n" , str); +printf (" Raid Level : %s\n" , str);if (larray_size) -printf (" Array Size : %llu%s\n" , (larray_size>>10 ), +printf (" Array Size : %llu%s\n" , (larray_size>>10 ),human_size (larray_size));if (array.level >=1 ) {if (sra)
@@ -420,38 +421,38 @@ int Detail(char *dev, struct context *c) (larray_size >= 0xFFFFFFFFULL|| array.size == 0)) {unsigned long long dsize =get_component_size (fd);if (dsize >0 ) -printf (" Used Dev Size : %llu%s\n" , +printf (" Used Dev Size : %llu%s\n" , dsize/2 ,human_size ((long long )dsize<<9 ));else -printf (" Used Dev Size : unknown\n" ); +printf (" Used Dev Size : unknown\n" ); } else - printf(" Used Dev Size : %lu%s\n", + printf(" Used Dev Size : %lu%s\n", (unsigned long )array.size, human_size((unsigned long long)array.size<<10)); }if (array.raid_disks) -printf (" Raid Devices : %d\n" , array.raid_disks); -printf (" Total Devices : %d\n" , array.nr_disks); +printf (" Raid Devices : %d\n" , array.raid_disks); +printf (" Total Devices : %d\n" , array.nr_disks);if (!container && ((sra ==NULL && array.major_version ==0 ) || (sra && sra->array.major_version ==0 ))) -printf ("Preferred Minor : %d\n" , array.md_minor); +printf (" Preferred Minor : %d\n" , array.md_minor);if (sra ==NULL || sra->array.major_version >=0 ) -printf (" Persistence : Superblock is %spersistent\n" , +printf (" Persistence : Superblock is %spersistent\n" , array.not_persistent?"not " :"" );printf ("\n" );/* Only try GET_BITMAP_FILE for 0.90.01 and later */ if (vers >=9001 &&ioctl (fd,GET_BITMAP_FILE , &bmf) ==0 && bmf.pathname[0 ]) { -printf (" Intent Bitmap : %s\n" , bmf.pathname); +printf (" Intent Bitmap : %s\n" , bmf.pathname);printf ("\n" ); }else if (array.state & (1 <<MD_SB_BITMAP_PRESENT )) -printf (" Intent Bitmap : Internal\n\n" ); +printf (" Intent Bitmap : Internal\n\n" ); atime = array.utime;if (atime) -printf (" Update Time : %.24s\n" ,ctime (&atime)); +printf (" Update Time : %.24s\n" ,ctime (&atime));if (array.raid_disks) {static char *sync_action[] = {", recovering" ,", resyncing" ,
@@ -465,7 +466,7 @@ int Detail(char *dev, struct context *c)else st =", degraded" ; - printf(" State : %s%s%s%s%s%s \n", + printf(" State : %s%s%s%s%s%s \n", (array.state&(1<<MD_SB_CLEAN))?"clean":"active", st, (!e || (e->percent < 0 && e->percent != RESYNC_PENDING && e->percent != RESYNC_DELAYED)) ? "" : sync_action[e->resync],
@@ -473,27 +474,27 @@ int Detail(char *dev, struct context *c) (e && e->percent ==RESYNC_DELAYED ) ?" (DELAYED)" :"" , (e && e->percent == RESYNC_PENDING) ? " (PENDING)": ""); }else if (inactive) { -printf (" State : inactive\n" ); +printf (" State : inactive\n" ); }if (array.raid_disks) -printf (" Active Devices : %d\n" , array.active_disks); +printf (" Active Devices : %d\n" , array.active_disks);if (array.working_disks >0 ) -printf ("Working Devices : %d\n" , array.working_disks); +printf (" Working Devices : %d\n" , array.working_disks);if (array.raid_disks) { -printf (" Failed Devices : %d\n" , array.failed_disks); -printf (" Spare Devices : %d\n" , array.spare_disks); +printf (" Failed Devices : %d\n" , array.failed_disks); +printf (" Spare Devices : %d\n" , array.spare_disks); }printf ("\n" );if (array.level ==5 ) { str =map_num (r5layout, array.layout); -printf (" Layout : %s\n" , str?str:"-unknown-" ); +printf (" Layout : %s\n" , str?str:"-unknown-" ); }if (array.level ==6 ) { str =map_num (r6layout, array.layout); -printf (" Layout : %s\n" , str?str:"-unknown-" ); +printf (" Layout : %s\n" , str?str:"-unknown-" ); }if (array.level ==10 ) { -printf (" Layout :" ); +printf (" Layout :" );print_r10_layout (array.layout);printf ("\n" ); }
@@ -504,20 +505,35 @@ int Detail(char *dev, struct context *c)case 10 :case 6 :if (array.chunk_size) -printf (" Chunk Size : %dK\n\n" , +printf (" Chunk Size : %dK\n\n" , array.chunk_size/1024 );break ;case -1 : -printf (" Rounding : %dK\n\n" , array.chunk_size/1024 ); +printf (" Rounding : %dK\n\n" , + array.chunk_size/1024 );break ;default :break ; } +if (array.raid_disks) { +struct mdinfo *mdi =sysfs_read (fd,NULL , +GET_CONSISTENCY_POLICY ); +if (mdi) { +char *policy =map_num (consistency_policies, + mdi->consistency_policy); +sysfs_free (mdi); +if (policy) +printf ("Consistency Policy : %s\n\n" , + policy); + } + } +if (e && e->percent >=0 ) {static char *sync_action[] = {"Rebuild" ,"Resync" ,"Reshape" ,"Check" }; -printf (" %7s Status : %d%% complete\n" , sync_action[e->resync], e->percent); +printf (" %7s Status : %d%% complete\n" , + sync_action[e->resync], e->percent); is_rebuilding =1 ; }free_mdstat (ms);
@@ -525,39 +541,41 @@ int Detail(char *dev, struct context *c)if ((st && st->sb) && (info && info->reshape_active)) {#if 0 This is pretty boring -printf (" Reshape pos'n : %llu%s\n" , (unsigned long long ) info->reshape_progress<<9 , +printf (" Reshape pos'n : %llu%s\n" , + (unsigned long long ) info->reshape_progress<<9 ,human_size ((unsigned long long )info->reshape_progress<<9 ));#endif if (info->delta_disks !=0 ) -printf (" Delta Devices : %d, (%d->%d)\n" , +printf (" Delta Devices : %d, (%d->%d)\n" , info->delta_disks, array.raid_disks - info->delta_disks, array.raid_disks);if (info->new_level != array.level) { str =map_num (pers, info->new_level); -printf (" New Level : %s\n" , str?str:"-unknown-" ); +printf (" New Level : %s\n" , str?str:"-unknown-" ); }if (info->new_level != array.level || info->new_layout != array.layout) {if (info->new_level ==5 ) { str =map_num (r5layout, info->new_layout); -printf (" New Layout : %s\n" , +printf (" New Layout : %s\n" , str?str:"-unknown-" ); }if (info->new_level ==6 ) { str =map_num (r6layout, info->new_layout); -printf (" New Layout : %s\n" , +printf (" New Layout : %s\n" , str?str:"-unknown-" ); }if (info->new_level ==10 ) { -printf (" New Layout : near=%d, %s=%d\n" , +printf (" New Layout : near=%d, %s=%d\n" , info->new_layout&255 , (info->new_layout&0x10000 )?"offset" :"far" , (info->new_layout>>8 )&255 ); } }if (info->new_chunk != array.chunk_size) -printf (" New Chunksize : %dK\n" , info->new_chunk/1024 ); +printf (" New Chunksize : %dK\n" , + info->new_chunk/1024 );printf ("\n" ); }else if (e && e->percent >=0 )printf ("\n" );
@@ -572,7 +590,7 @@ This is pretty boringDIR *dir =opendir ("/sys/block" );struct dirent *de; -printf (" Member Arrays :" ); +printf (" Member Arrays :" );while (dir && (de =readdir (dir)) !=NULL ) {char path[200 ];
super-ddf.c +3 -3
@@ -1742,10 +1742,10 @@ static void detail_super_ddf(struct supertype *st, char *homehost)struct ddf_super *sb = st->sb;int cnt =be16_to_cpu (sb->virt->populated_vdes); -printf (" Container GUID : " );print_guid (sb->anchor.guid,1 ); +printf (" Container GUID : " );print_guid (sb->anchor.guid,1 );printf ("\n" ); -printf (" Seq : %08x\n" ,be32_to_cpu (sb->active->seq)); -printf (" Virtual Disks : %d\n" , cnt); +printf (" Seq : %08x\n" ,be32_to_cpu (sb->active->seq)); +printf (" Virtual Disks : %d\n" , cnt); printf("\n"); }#endif
super-intel.c +1 -1
@@ -1986,7 +1986,7 @@ static void detail_super_imsm(struct supertype *st, char *homehost)getinfo_super_imsm (st, &info,NULL );fname_from_uuid (st, &info, nbuf,':' ); -printf ("\n UUID : %s\n" , nbuf +5 ); +printf ("\n UUID : %s\n" , nbuf +5 ); }static void brief_detail_super_imsm (struct supertype *st)
super0.c +2 -2
@@ -353,7 +353,7 @@ err:static void detail_super0 (struct supertype *st,char *homehost) {mdp_super_t *sb = st->sb; -printf (" UUID : " ); +printf (" UUID : " );if (sb->minor_version >=90 )printf ("%08x:%08x:%08x:%08x" , sb->set_uuid0, sb->set_uuid1, sb->set_uuid2, sb->set_uuid3);
@@ -367,7 +367,7 @@ static void detail_super0(struct supertype *st, char *homehost)if (memcmp (&sb->set_uuid2, hash,8 )==0 )printf (" (local to host %s)" , homehost); } -printf ("\n Events : %d.%d\n\n" , sb->events_hi, sb->events_lo); +printf ("\n Events : %d.%d\n\n" , sb->events_hi, sb->events_lo); }static void brief_detail_super0 (struct supertype *st)
super1.c +5 -4
@@ -780,19 +780,20 @@ static void detail_super1(struct supertype *st, char *homehost)int i;int l = homehost ?strlen (homehost) :0 ; -printf (" Name : %.32s" , sb->set_name); +printf (" Name : %.32s" , sb->set_name);if (l >0 && l <32 && sb->set_name[l] ==':' &&strncmp (sb->set_name, homehost, l) ==0 )printf (" (local to host %s)" , homehost);if (bms->nodes >0 && (__le32_to_cpu (sb->feature_map) &MD_FEATURE_BITMAP_OFFSET )) -printf ("\n Cluster Name : %-64s" , bms->cluster_name); -printf ("\n UUID : " ); +printf ("\n Cluster Name : %-64s" , bms->cluster_name); +printf ("\n UUID : " );for (i=0 ; i<16 ; i++) {if ((i&3 )==0 && i !=0 )printf (":" );printf ("%02x" , sb->set_uuid[i]); } -printf ("\n Events : %llu\n\n" , (unsigned long long )__le64_to_cpu (sb->events)); +printf ("\n Events : %llu\n\n" , + (unsigned long long )__le64_to_cpu (sb->events)); }static void brief_detail_super1 (struct supertype *st)
Signature · 1 line
2.11.0
PATCH v3 3/6 imsm: PPL support
In reply to Artur PaszkiewiczEnable creating and assembling IMSM raid5 arrays with PPL. Update the IMSM metadata format to include new fields used for PPL.
Add structures for PPL metadata. They are used also by super1 and shared with the kernel, so put them in md_p.h.
Write the initial empty PPL header when creating an array. When assembling an array with PPL, validate the PPL header and in case it is not correct allow to overwrite it if --force was provided.
Write the PPL location and size for a device to the new rdev sysfs attributes 'ppl_sector' and 'ppl_size'. Enable PPL in the kernel by writing to 'consistency_policy' before the array is activated.
--- Assemble.c | 49 +++++++++++ Makefile | 5 +- md_p.h | 25 ++++++ mdadm.h | 6 ++ super-intel.c | 274 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- sysfs.c | 14 +++ 6 files changed, 349 insertions(+), 24 deletions(-)
Assemble.c +49 -0
@@ -1942,6 +1942,55 @@ int assemble_container_content(struct supertype *st, int mdfd,map_update (NULL ,fd2devnm (mdfd), content->text_version, content->uuid, chosen_name); +if (content->consistency_policy ==CONSISTENCY_POLICY_PPL && + st->ss->validate_ppl) { + content->array.state |=1 ; + err =0 ; + +for (dev = content->devs; dev; dev = dev->next) { +int dfd; +char *devpath; +int ret; + + ret = st->ss->validate_ppl (st, content, dev); +if (ret ==0 ) +continue ; + +if (ret <0 ) { + err =1 ; +break ; + } + +if (!c->force) { +pr_err ("%s contains invalid PPL - consider --force or --update-subarray with --update=no-ppl\n" , + chosen_name); + content->array.state &= ~1 ; + avail[dev->disk.raid_disk] =0 ; +break ; + } + +/* have --force - overwrite the invalid ppl */ + devpath =map_dev (dev->disk.major, dev->disk.minor,0 ); + dfd =dev_open (devpath,O_RDWR ); +if (dfd <0 ) { +pr_err ("Failed to open %s\n" , devpath); + err =1 ; +break ; + } + + err = st->ss->write_init_ppl (st, content, dfd); +close (dfd); + +if (err) +break ; + } + +if (err) { +free (avail); +return err; + } + } +if (enough (content->array.level, content->array.raid_disks, content->array.layout, content->array.state &1 , avail) ==0 ) {if (c->export && result)
Makefile +3 -2
@@ -146,7 +146,7 @@ MON_OBJS = mdmon.o monitor.o managemon.o util.o maps.o mdstat.o sysfs.o \ Kill.o sg_io.o dlink.o ReadMe.o super-intel.o \ super-mbr.o super-gpt.o \ super-ddf.o sha1.o crc32.o msg.o bitmap.o xmalloc.o \ - platform-intel.o probe_roms.o + platform-intel.o probe_roms.o crc32c.o MON_SRCS = $(patsubst %.o,%.c,$(MON_OBJS))
@@ -156,7 +156,8 @@ STATICOBJS = pwgr.o ASSEMBLE_SRCS := mdassemble.c Assemble.c Manage.c config.c policy.c dlink.c util.c \ maps.c lib.c xmalloc.c \ super0.c super1.c super-ddf.c super-intel.c sha1.c crc32.c sg_io.c mdstat.c \ - platform-intel.c probe_roms.c sysfs.c super-mbr.c super-gpt.c mapfile.c + platform-intel.c probe_roms.c sysfs.c super-mbr.c super-gpt.c mapfile.c \ + crc32c.o ASSEMBLE_AUTO_SRCS := mdopen.c ASSEMBLE_FLAGS:= $(CFLAGS) -DMDASSEMBLE ifdef MDASSEMBLE_AUTO
md_p.h +25 -0
@@ -267,4 +267,29 @@ struct r5l_meta_block {#define R5LOG_VERSION 0x1#define R5LOG_MAGIC 0x6433c509 +struct ppl_header_entry { +__u64 data_sector;/* raid sector of the new data */ +__u32 pp_size;/* length of partial parity */ +__u32 data_size;/* length of data */ +__u32 parity_disk;/* member disk containing parity */ +__u32 checksum;/* checksum of this entry's partial parity */ +} __attribute__ ((__packed__ )); + +#define PPL_HEADER_SIZE 4096 +#define PPL_HDR_RESERVED 512 +#define PPL_HDR_ENTRY_SPACE \ + (PPL_HEADER_SIZE - PPL_HDR_RESERVED - 4 * sizeof(__u32) - sizeof(__u64)) +#define PPL_HDR_MAX_ENTRIES \ + (PPL_HDR_ENTRY_SPACE / sizeof(struct ppl_header_entry)) + +struct ppl_header { +__u8 reserved[PPL_HDR_RESERVED ];/* reserved space, fill with 0xff */ +__u32 signature;/* signature (family number of volume) */ +__u32 padding;/* zero pad */ +__u64 generation;/* generation number of the header */ +__u32 entries_count;/* number of entries in entry array */ +__u32 checksum;/* checksum of the header */ +struct ppl_header_entry entries[PPL_HDR_MAX_ENTRIES ]; +} __attribute__ ((__packed__ )); +#endif
mdadm.h +6 -0
@@ -300,6 +300,8 @@ struct mdinfo {#define MaxSector (~0ULL)/* resync/recovery complete position */ };long bitmap_offset;/* 0 == none, 1 == a file */ +unsigned int ppl_size; +unsigned long long ppl_sector;unsigned long safe_mode_delay;/* ms delay to mark clean */ int new_level, delta_disks, new_layout, new_chunk;int errors;
@@ -1074,6 +1076,10 @@ extern struct superswitch {/* write initial empty PPL on device */ int (*write_init_ppl)(struct supertype *st,struct mdinfo *info,int fd); +/* validate ppl before assemble */ +int (*validate_ppl)(struct supertype *st,struct mdinfo *info, +struct mdinfo *disk); +/* records new bad block in metadata */ int (*record_bad_block)(struct active_array *a,int n,unsigned long long sector,int length);
super-intel.c +252 -22
417 lines not on this page · raw message
sysfs.c +14 -0
@@ -689,6 +689,16 @@ int sysfs_set_array(struct mdinfo *info, int vers)* once the reshape completes. */ } + +if (info->consistency_policy ==CONSISTENCY_POLICY_PPL ) { +if (sysfs_set_str (info,NULL ,"consistency_policy" , +map_num (consistency_policies, + info->consistency_policy))) { +pr_err ("This kernel does not support PPL\n" ); +return 1 ; + } + } +return rv; }
@@ -720,6 +730,10 @@ int sysfs_add_disk(struct mdinfo *sra, struct mdinfo *sd, int resume) rv =sysfs_set_num (sra, sd,"offset" , sd->data_offset); rv |=sysfs_set_num (sra, sd,"size" , (sd->component_size+1 ) /2 );if (sra->array.level !=LEVEL_CONTAINER ) { +if (sd->consistency_policy ==CONSISTENCY_POLICY_PPL ) { + rv |=sysfs_set_num (sra, sd,"ppl_sector" , sd->ppl_sector); + rv |=sysfs_set_num (sra, sd,"ppl_size" , sd->ppl_size); + }if (sd->recovery_start == MaxSector)/* This can correctly fail if array isn't started, * yet, so just ignore status for now.
Signature · 1 line
2.11.0
Re: [PATCH v3 3/6] imsm: PPL support
Quoted 98 lines · Artur Paszkiewicz
Enable creating and assembling IMSM raid5 arrays with PPL. Update the IMSM metadata format to include new fields used for PPL.
Add structures for PPL metadata. They are used also by super1 and shared with the kernel, so put them in
md_p.h.Write the initial empty PPL header when creating an array. When assembling an array with PPL, validate the PPL header and in case it is not correct allow to overwrite it if --force was provided.
Write the PPL location and size for a device to the new rdev sysfs attributes '
ppl_sector' and 'ppl_size'. Enable PPL in the kernel by writing to 'consistency_policy' before the array is activated.Signed-off-by Artur Paszkiewicz <[email protected]>--- Assemble.c | 49 +++++++++++ Makefile | 5 +- md_p.h | 25 ++++++ mdadm.h | 6 ++ super-intel.c | 274 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- sysfs.c | 14 +++ 6 files changed, 349 insertions(+), 24 deletions(-)Assemble.c +49
-0@@ -1942,6 +1942,55 @@ int assemble_container_content(struct supertype *st, int mdfd,map_update (NULL ,fd2devnm (mdfd), content->text_version, content->uuid, chosen_name); +if (content->consistency_policy ==CONSISTENCY_POLICY_PPL && + st->ss->validate_ppl) { + content->array.state |=1 ; + err =0 ; + +for (dev = content->devs; dev; dev = dev->next) { +int dfd; +char *devpath; +int ret; + + ret = st->ss->validate_ppl (st, content, dev); +if (ret ==0 ) +continue ; + +if (ret <0 ) { + err =1 ; +break ; + } + +if (!c->force) { +pr_err ("%s contains invalid PPL - consider --force or --update-subarray with --update=no-ppl\n" , + chosen_name); + content->array.state &= ~1 ; + avail[dev->disk.raid_disk] =0 ; +break ; + } + +/* have --force - overwrite the invalid ppl */ + devpath =map_dev (dev->disk.major, dev->disk.minor,0 ); + dfd =dev_open (devpath,O_RDWR ); +if (dfd <0 ) { +pr_err ("Failed to open %s\n" , devpath); + err =1 ; +break ; + } + + err = st->ss->write_init_ppl (st, content, dfd); +close (dfd); + +if (err) +break ; + } + +if (err) { +free (avail); +return err; + } + } +if (enough (content->array.level, content->array.raid_disks, content->array.layout, content->array.state &1 , avail) ==0 ) {if (c->export && result)Makefile +1
-1@@ -146,7 +146,7 @@ MON_OBJS = mdmon.o monitor.o managemon.o util.o maps.o mdstat.o sysfs.o \ Kill.o sg_io.o dlink.o ReadMe.o super-intel.o \ super-mbr.o super-gpt.o \ super-ddf.o sha1.o crc32.o msg.o bitmap.o xmalloc.o \ - platform-intel.o probe_roms.o + platform-intel.o probe_roms.o crc32c.o MON_SRCS = $(patsubst %.o,%.c,$(MON_OBJS))
Makefile STATICOBJS = pwgr.o · line 160
Quoted 6 lines
Makefile +2
-1@@ -156,7 +156,8 @@ STATICOBJS = pwgr.o ASSEMBLE_SRCS := mdassemble.c Assemble.c Manage.c config.c policy.c dlink.c util.c \ maps.c lib.c xmalloc.c \ super0.c super1.c super-ddf.c super-intel.c sha1.c crc32.c sg_io.c mdstat.c \ - platform-intel.c probe_roms.c sysfs.c super-mbr.c super-gpt.c mapfile.c + platform-intel.c probe_roms.c sysfs.c super-mbr.c super-gpt.c mapfile.c \ + crc32c.o
Hi Artur,
This looks odd - sure you don't mean crc32c.c ?
Thanks,
Jes
Re: [PATCH v3 3/6] imsm: PPL support
Quoted 108 lines · On 03/17/2017 09:11 PM, [email protected] wrote:
Quoted 98 lines · Artur Paszkiewicz
Enable creating and assembling IMSM raid5 arrays with PPL. Update the IMSM metadata format to include new fields used for PPL.
Add structures for PPL metadata. They are used also by super1 and shared with the kernel, so put them in
md_p.h.Write the initial empty PPL header when creating an array. When assembling an array with PPL, validate the PPL header and in case it is not correct allow to overwrite it if --force was provided.
Write the PPL location and size for a device to the new rdev sysfs attributes '
ppl_sector' and 'ppl_size'. Enable PPL in the kernel by writing to 'consistency_policy' before the array is activated.Signed-off-by Artur Paszkiewicz <[email protected]>--- Assemble.c | 49 +++++++++++ Makefile | 5 +- md_p.h | 25 ++++++ mdadm.h | 6 ++ super-intel.c | 274 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- sysfs.c | 14 +++ 6 files changed, 349 insertions(+), 24 deletions(-)Assemble.c +49
-0@@ -1942,6 +1942,55 @@ int assemble_container_content(struct supertype *st, int mdfd,map_update (NULL ,fd2devnm (mdfd), content->text_version, content->uuid, chosen_name); +if (content->consistency_policy ==CONSISTENCY_POLICY_PPL && + st->ss->validate_ppl) { + content->array.state |=1 ; + err =0 ; + +for (dev = content->devs; dev; dev = dev->next) { +int dfd; +char *devpath; +int ret; + + ret = st->ss->validate_ppl (st, content, dev); +if (ret ==0 ) +continue ; + +if (ret <0 ) { + err =1 ; +break ; + } + +if (!c->force) { +pr_err ("%s contains invalid PPL - consider --force or --update-subarray with --update=no-ppl\n" , + chosen_name); + content->array.state &= ~1 ; + avail[dev->disk.raid_disk] =0 ; +break ; + } + +/* have --force - overwrite the invalid ppl */ + devpath =map_dev (dev->disk.major, dev->disk.minor,0 ); + dfd =dev_open (devpath,O_RDWR ); +if (dfd <0 ) { +pr_err ("Failed to open %s\n" , devpath); + err =1 ; +break ; + } + + err = st->ss->write_init_ppl (st, content, dfd); +close (dfd); + +if (err) +break ; + } + +if (err) { +free (avail); +return err; + } + } +if (enough (content->array.level, content->array.raid_disks, content->array.layout, content->array.state &1 , avail) ==0 ) {if (c->export && result)Makefile +1
-1@@ -146,7 +146,7 @@ MON_OBJS = mdmon.o monitor.o managemon.o util.o maps.o mdstat.o sysfs.o \ Kill.o sg_io.o dlink.o ReadMe.o super-intel.o \ super-mbr.o super-gpt.o \ super-ddf.o sha1.o crc32.o msg.o bitmap.o xmalloc.o \ - platform-intel.o probe_roms.o + platform-intel.o probe_roms.o crc32c.o MON_SRCS = $(patsubst %.o,%.c,$(MON_OBJS))Makefile STATICOBJS = pwgr.o · line 160
Quoted 6 lines
Makefile +2
-1@@ -156,7 +156,8 @@ STATICOBJS = pwgr.o ASSEMBLE_SRCS := mdassemble.c Assemble.c Manage.c config.c policy.c dlink.c util.c \ maps.c lib.c xmalloc.c \ super0.c super1.c super-ddf.c super-intel.c sha1.c crc32.c sg_io.c mdstat.c \ - platform-intel.c probe_roms.c sysfs.c super-mbr.c super-gpt.c mapfile.c + platform-intel.c probe_roms.c sysfs.c super-mbr.c super-gpt.c mapfile.c \ + crc32c.oHi Artur,
Quoted 1 line
This looks odd - sure you don't mean
crc32c.c?
Of course this is a mistake, it should be crc32c.c. Sorry for that. But surprisingly it builds correctly.
Thanks,
Artur
Re: [PATCH v3 3/6] imsm: PPL support
Quoted 10 lines · Artur Paszkiewicz
Quoted 3 lines · On 03/17/2017 09:11 PM, [email protected] wrote:
Hi Artur,
This looks odd - sure you don't mean
crc32c.c?Of course this is a mistake, it should be
crc32c.c. Sorry for that. But surprisingly it builds correctly.Thanks,
Artur
Hi Artur,
I can no longer apply this set. Would you mind sending me a fresh update so I don't end up botching it?
Thanks,
Jes
PATCH v3 4/6 super1: PPL support
In reply to Artur PaszkiewiczEnable creating and assembling raid5 arrays with PPL for 1.x metadata.
When creating, reserve enough space for PPL and store its size and location in the superblock and set MD_FEATURE_PPL bit. Write an initial empty header in the PPL area on each device. PPL is stored in the metadata region reserved for internal write-intent bitmap, so don't allow using bitmap and PPL together.
While at it, fix two endianness issues in write_empty_r5l_meta_block() and write_init_super1().
--- Assemble.c | 3 ++ Create.c | 2 + Grow.c | 15 +++++- Incremental.c | 3 ++ mdadm.h | 1 + super1.c | 150 +++++++++++++++++++++++++++++++++++++++++++++++++++------- 6 files changed, 155 insertions(+), 19 deletions(-)
Assemble.c +3 -0
@@ -962,6 +962,9 @@ static int start_array(int mdfd, c->readonly =1 ; } +if (content->consistency_policy ==CONSISTENCY_POLICY_PPL ) + clean =1 ; + rv =set_array_info (mdfd, st, content);if (rv && !err_ok) { pr_err("failed to set array info for %s: %s\n",
Create.c +2 -0
@@ -524,6 +524,8 @@ int Create(struct supertype *st, char *mddev,if (!s->bitmap_file && s->level >=1 && st->ss->add_internal_bitmap && + (s->consistency_policy !=CONSISTENCY_POLICY_RESYNC && + s->consistency_policy !=CONSISTENCY_POLICY_PPL ) && (s->write_behind || s->size >100 *1024 *1024ULL )) {if (c->verbose >0 )pr_err ("automatically enabling write-intent bitmap on large array\n" );
Grow.c +14 -1
@@ -290,6 +290,7 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)int major =BITMAP_MAJOR_HI ;int vers =md_get_version (fd);unsigned long long bitmapsize, array_size; +struct mdinfo *mdi;if (vers <9003 ) { major =BITMAP_MAJOR_HOSTENDIAN ;
@@ -389,12 +390,23 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)free (st);return 1 ; } + + mdi =sysfs_read (fd,NULL ,GET_CONSISTENCY_POLICY ); +if (mdi) { +if (mdi->consistency_policy ==CONSISTENCY_POLICY_PPL ) { +pr_err ("Cannot add bitmap to array with PPL\n" ); +free (mdi); +free (st); +return 1 ; + } +free (mdi); + } +if (strcmp (s->bitmap_file,"internal" ) ==0 ||strcmp (s->bitmap_file,"clustered" ) ==0 ) {int rv;int d;int offset_setable =0 ; -struct mdinfo *mdi;if (st->ss->add_internal_bitmap ==NULL ) {pr_err ("Internal bitmaps not supported with %s metadata\n" , st->ss->name);return 1 ;
@@ -446,6 +458,7 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)sysfs_init (mdi, fd,NULL ); rv =sysfs_set_num_signed (mdi,NULL ,"bitmap/location" , mdi->bitmap_offset); +free (mdi); }else {if (strcmp (s->bitmap_file,"clustered" ) ==0 ) array.state |= (1 <<MD_SB_CLUSTERED );
Incremental.c +3 -0
@@ -528,6 +528,9 @@ int Incremental(struct mddev_dev *devlist, struct context *c, journal_device_missing = (info.journal_device_required) && (info.journal_clean ==0 ); +if (info.consistency_policy ==CONSISTENCY_POLICY_PPL ) + info.array.state |=1 ; +if (enough (info.array.level, info.array.raid_disks, info.array.layout, info.array.state &1 , avail) ==0 ) {
mdadm.h +1 -0
@@ -302,6 +302,7 @@ struct mdinfo {long bitmap_offset;/* 0 == none, 1 == a file */ unsigned int ppl_size;unsigned long long ppl_sector; +int ppl_offset;unsigned long safe_mode_delay;/* ms delay to mark clean */ int new_level, delta_disks, new_layout, new_chunk;int errors;
super1.c +132 -18
287 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v3 5/6 Add 'ppl' and 'no-ppl' options for --update=
In reply to Artur PaszkiewiczThis can be used with --assemble for super1 and with --update-subarray for imsm to enable or disable PPL in the metadata.
--- Assemble.c | 6 ++++++ mdadm.8.in | 27 ++++++++++++++++++++++++--- mdadm.c | 6 +++++- super-intel.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ super1.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 139 insertions(+), 4 deletions(-)
Assemble.c +6 -0
@@ -602,6 +602,12 @@ static int load_devices(struct devs *devices, char *devmap,if (strcmp (c->update,"uuid" ) ==0 && !ident->uuid_set)random_uuid ((__u8 *)ident->uuid); +if (strcmp (c->update,"ppl" ) ==0 && + ident->bitmap_fd >=0 ) { +pr_err ("PPL is not compatible with bitmap\n" ); +return -1 ; + } + dfd =dev_open (devname, tmpdev->disposition =='I' ?O_RDWR : (O_RDWR |O_EXCL ));
mdadm.8.in +24 -3
@@ -1176,6 +1176,8 @@ argument given to this flag can be one of .BR no\-bitmap , .BR bbl , .BR no\-bbl , +.BR ppl , +.BR no\-ppl , .BR metadata , or .BR super\-minor .
@@ -1316,6 +1318,16 @@ option will cause any reservation of space for a bad block list to be removed. If the bad block list contains entries, this will fail, as removing the list could cause data corruption. +The +.B ppl +option will enable PPL for a RAID5 array and reserve space for PPL on each +device. There must be enough free space between the data and superblock and a +write-intent bitmap or journal must not be used. + +The +.B no\-ppl +option will disable PPL in the superblock. + .TP .BR \-\-freeze\-reshape Option is intended to be used in start-up scripts during initrd boot phase.
@@ -2327,9 +2339,11 @@ superblock field in the subarray. Similar to updating an array in .B \-U or .B \-\-update= -option. Currently only -.B name -is supported. +option. The supported options are +.BR name , +.B ppl +and +.BR no\-ppl . The .B name
@@ -2340,6 +2354,13 @@ re\-assembled. If updating would change the UUID of an active subarray this operation is blocked, and the command will end in an error. +The +.B ppl +and +.B no\-ppl +options enable and disable PPL in the metadata. Currently supported only for +IMSM subarrays. + .TP .B \-\-examine The device should be a component of an md array.
mdadm.c +5 -1
@@ -769,6 +769,10 @@ int main(int argc, char *argv[])continue ;if (strcmp (c.update,"force-no-bbl" ) ==0 )continue ; +if (strcmp (c.update,"ppl" ) ==0 ) +continue ; +if (strcmp (c.update,"no-ppl" ) ==0 ) +continue ;if (strcmp (c.update,"metadata" ) ==0 )continue ;if (strcmp (c.update,"revert-reshape" ) ==0 )
@@ -802,7 +806,7 @@ int main(int argc, char *argv[])" 'sparc2.2', 'super-minor', 'uuid', 'name', 'nodes', 'resync',\n" " 'summaries', 'homehost', 'home-cluster', 'byteorder', 'devicesize',\n" " 'no-bitmap', 'metadata', 'revert-reshape'\n" -" 'bbl', 'no-bbl', 'force-no-bbl'\n" +" 'bbl', 'no-bbl', 'force-no-bbl', 'ppl', 'no-ppl'\n" );exit (outf == stdout ?0 :2 );
super-intel.c +55 -0
85 lines not on this page · raw message
super1.c +49 -0
55 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v3 6/6 Grow: support consistency policy change
In reply to Artur PaszkiewiczExtend the --consistency-policy parameter to work also in Grow mode. Using it changes the currently active consistency policy in the kernel driver and updates the metadata to make this change permanent. Currently this supports only changing between "ppl" and "resync" policies, that is enabling or disabling PPL at runtime.
--- Grow.c | 172 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mdadm.8.in | 18 ++++++- mdadm.c | 3 ++ mdadm.h | 2 + 4 files changed, 194 insertions(+), 1 deletion(-)
Grow.c +172 -0
@@ -528,6 +528,178 @@ int Grow_addbitmap(char *devname, int fd, struct context *c, struct shape *s)return 0 ; } +int Grow_consistency_policy (char *devname,int fd,struct context *c,struct shape *s) +{ +struct supertype *st; +struct mdinfo *sra; +struct mdinfo *sd; +char *subarray =NULL ; +int ret =0 ; +char container_dev[PATH_MAX ]; + +if (s->consistency_policy !=CONSISTENCY_POLICY_RESYNC && + s->consistency_policy !=CONSISTENCY_POLICY_PPL ) { +pr_err ("Operation not supported for consistency policy %s\n" , +map_num (consistency_policies, s->consistency_policy)); +return 1 ; + } + + st =super_by_fd (fd, &subarray); +if (!st) +return 1 ; + + sra =sysfs_read (fd,NULL ,GET_CONSISTENCY_POLICY |GET_LEVEL | +GET_DEVS |GET_STATE ); +if (!sra) { + ret =1 ; + goto free_st; + } + +if (s->consistency_policy ==CONSISTENCY_POLICY_PPL && + !st->ss->write_init_ppl) { +pr_err ("%s metadata does not support PPL\n" , st->ss->name); + ret =1 ; + goto free_info; + } + +if (sra->array.level !=5 ) { +pr_err ("Operation not supported for array level %d\n" , + sra->array.level); + ret =1 ; + goto free_info; + } + +if (sra->consistency_policy == (unsigned )s->consistency_policy) { +pr_err ("Consistency policy is already %s\n" , +map_num (consistency_policies, s->consistency_policy)); + ret =1 ; + goto free_info; + }else if (sra->consistency_policy !=CONSISTENCY_POLICY_RESYNC && + sra->consistency_policy !=CONSISTENCY_POLICY_PPL ) { +pr_err ("Current consistency policy is %s, cannot change to %s\n" , +map_num (consistency_policies, sra->consistency_policy), +map_num (consistency_policies, s->consistency_policy)); + ret =1 ; + goto free_info; + } + +if (subarray) { +char *update; + +if (s->consistency_policy ==CONSISTENCY_POLICY_PPL ) + update ="ppl" ; +else + update ="no-ppl" ; + +sprintf (container_dev,"/dev/%s" , st->container_devnm); + + ret =Update_subarray (container_dev, subarray, update,NULL , + c->verbose); +if (ret) + goto free_info; + } + +if (s->consistency_policy ==CONSISTENCY_POLICY_PPL ) { +struct mdinfo info; + +if (subarray) { +struct mdinfo *mdi; +int cfd; + + cfd =open (container_dev,O_RDWR |O_EXCL ); +if (cfd <0 ) { +pr_err ("Failed to open %s\n" , container_dev); + ret =1 ; + goto free_info; + } + + ret = st->ss->load_container (st, cfd, st->container_devnm); +close (cfd); + +if (ret) { +pr_err ("Cannot read superblock for %s\n" , + container_dev); + goto free_info; + } + + mdi = st->ss->container_content (st, subarray); + info = *mdi; +free (mdi); + } + +for (sd = sra->devs; sd; sd = sd->next) { +int dfd; +char *devpath; + +if ((sd->disk.state & (1 <<MD_DISK_SYNC )) ==0 ) +continue ; + + devpath =map_dev (sd->disk.major, sd->disk.minor,0 ); + dfd =dev_open (devpath,O_RDWR ); +if (dfd <0 ) { +pr_err ("Failed to open %s\n" , devpath); + ret =1 ; + goto free_info; + } + +if (!subarray) { + ret = st->ss->load_super (st, dfd,NULL ); +if (ret) { +pr_err ("Failed to load super-block.\n" ); +close (dfd); + goto free_info; + } + + ret = st->ss->update_super (st, sra,"ppl" , devname, + c->verbose,0 ,NULL ); +if (ret) { +close (dfd); + st->ss->free_super (st); + goto free_info; + } + st->ss->getinfo_super (st, &info,NULL ); + } + + ret |=sysfs_set_num (sra, sd,"ppl_sector" , info.ppl_sector); + ret |=sysfs_set_num (sra, sd,"ppl_size" , info.ppl_size); + +if (ret) { +pr_err ("Failed to set PPL attributes for %s\n" , + sd->sys_name); +close (dfd); + st->ss->free_super (st); + goto free_info; + } + + ret = st->ss->write_init_ppl (st, &info, dfd); +if (ret) +pr_err ("Failed to write PPL\n" ); + +close (dfd); + +if (!subarray) + st->ss->free_super (st); + +if (ret) + goto free_info; + } + } + + ret =sysfs_set_str (sra,NULL ,"consistency_policy" , +map_num (consistency_policies, + s->consistency_policy)); +if (ret) +pr_err ("Failed to change array consistency policy\n" ); + +free_info: +sysfs_free (sra); +free_st: +free (st); +free (subarray); + +return ret; +} +/* * When reshaping an array we might need to backup some data. * This is written to all spares with a 'super_block' describing it.
mdadm.8.in +17 -1
@@ -126,7 +126,7 @@ of component devices and changing the number of active devices in Linear and RAID levels 0/1/4/5/6, changing the RAID level between 0, 1, 5, and 6, and between 0 and 10, changing the chunk size and layout for RAID 0,4,5,6,10 as well as adding or -removing a write-intent bitmap. +removing a write-intent bitmap and changing the array's consistency policy. .TP .B "Incremental Assembly"
@@ -1050,6 +1050,10 @@ after unclean shutdown. Implicitly selected when using For RAID5 only, Partial Parity Log is used to close the write hole and eliminate resync. PPL is stored in the metadata region of RAID member drives, no additional journal drive is needed. + +.PP +Can be used with \-\-grow to change the consistency policy of an active array +in some cases. See CONSISTENCY POLICY CHANGES below. .RE
@@ -2694,6 +2698,8 @@ RAID0, RAID4, and RAID5, and between RAID0 and RAID10 (in the near-2 mode). .IP \(bu 4 add a write-intent bitmap to any array which supports these bitmaps, or remove a write-intent bitmap from such an array. +.IP \(bu 4 +change the array's consistency policy. .PP Using GROW on containers is currently supported only for Intel's IMSM
@@ -2850,6 +2856,16 @@ can be added. Note that if you add a bitmap stored in a file which is in a filesystem that is on the RAID array being affected, the system will deadlock. The bitmap must be on a separate filesystem. +.SS CONSISTENCY POLICY CHANGES + +The consistency policy of an active array can be changed by using the +.B \-\-consistency\-policy +option in Grow mode. Currently this works only for the +.B ppl +and +.B resync +policies and allows to enable or disable the RAID5 Partial Parity Log (PPL). + .SH INCREMENTAL MODE .HP 12
mdadm.c +3 -0
@@ -1217,6 +1217,7 @@ int main(int argc, char *argv[]) s.journaldisks =1 ;continue ;case O (CREATE ,'k' ): +case O (GROW ,'k' ): s.consistency_policy =map_name (consistency_policies, optarg); if (s.consistency_policy == UnSet ||
@@ -1675,6 +1676,8 @@ int main(int argc, char *argv[]) rv =Grow_reshape (devlist->devname, mdfd, devlist->next, data_offset, &c, &s); + }else if (s.consistency_policy != UnSet) { + rv =Grow_consistency_policy (devlist->devname, mdfd, &c, &s); }else if (array_size ==0 )pr_err ("no changes to --grow\n" );break ;
mdadm.h +2 -0
@@ -1331,6 +1331,8 @@ extern int Grow_restart(struct supertype *st, struct mdinfo *info,extern int Grow_continue (int mdfd,struct supertype *st,struct mdinfo *info,char *backup_file,int forked,int freeze_reshape); +extern int Grow_consistency_policy (char *devname,int fd, +struct context *c,struct shape *s); extern int restore_backup(struct supertype *st, struct mdinfo *content,
Signature · 1 line
2.11.0