mdadm support for Partial Parity Log
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 RWH policy for an array. Other changes include displaying the RWH policy in the output from --detail and --examine.
As with the kernel patches sent earlier, all of this is currently targeted and tested with IMSM and native MD v1.1 and v1.2 metadata arrays.
Artur Paszkiewicz (6):
imsm: metadata changes for PPL
Generic support for --rwh-policy and PPL
imsm: PPL support
super1: PPL support
Allow changing the RWH policy for a running array Man page changes for --rwh-policy
Pawel Baldysiak (1):
imsm: allow to assemble with PPL even if dirty degraded
Assemble.c | 4 +- Create.c | 26 ++++++++-- Detail.c | 18 ++++++- Grow.c | 15 +++++- Kill.c | 2 +- Manage.c | 79 ++++++++++++++++++++++++++++ ReadMe.c | 1 + maps.c | 7 +++ mdadm.8.in | 28 ++++++++++ mdadm.c | 44 ++++++++++++++-- mdadm.h | 21 ++++++-- super-ddf.c | 6 +-- super-gpt.c | 2 +- super-intel.c | 161 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ super-mbr.c | 2 +- super0.c | 8 +-- super1.c | 92 +++++++++++++++++++++++++++------ sysfs.c | 15 ++++++ 18 files changed, 475 insertions(+), 56 deletions(-)
Signature · 1 line
2.10.1
PATCH 1/7 imsm: metadata changes for PPL
Updates for the IMSM metadata format, including PPL header structures.
Extend imsm_vol dirty field adding a third value, which is required to enable PPL recovery in Windows and UEFI drivers.
--- super-intel.c | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-)
super-intel.c +40 -8
@@ -104,8 +104,11 @@ struct imsm_disk {__u32 status;/* 0xF0 - 0xF3 */ __u32 owner_cfg_num;/* which config 0,1,2... owns this disk */ __u32 total_blocks_hi;/* 0xF4 - 0xF5 total blocks hi */ -#define IMSM_DISK_FILLERS 3 -__u32 filler[IMSM_DISK_FILLERS ];/* 0xF5 - 0x107 MPB_DISK_FILLERS for future expansion */ +__u8 is_journal_disk; +__u8 filler1;/* MPB_DISK_FILLERS - reserved for future expansion */ +__u16 filler2; +#define IMSM_DISK_FILLERS 2 +__u32 filler[IMSM_DISK_FILLERS ]; };/* map selector for map managment
@@ -154,6 +157,9 @@ struct imsm_vol {#define MIGR_STATE_CHANGE 4#define MIGR_REPAIR 5__u8 migr_type;/* Initializing, Rebuilding, ... */ +#define RAIDVOL_CLEAN 0 +#define RAIDVOL_DIRTY 1 +#define RAIDVOL_DSRECORD_VALID 2__u8 dirty;__u8 fs_state;/* fast-sync state for CnG (0xff == disabled) */ __u16 verify_errors;/* number of mismatches */
@@ -189,7 +195,30 @@ struct imsm_dev {__u16 cache_policy;__u8 cng_state;__u8 cng_sub_state; -#define IMSM_DEV_FILLERS 10 +__u16 my_vol_raid_dev_num;/* Used in Unique volume Id for this RaidDev */ + +/* NVM_EN */ +__u8 nv_cache_mode; +union { +__u8 nv_cache_flags; +struct { +__u8 dirty:1 ;/* 1 - cache is dirty, 0 - clean */ +__u8 nvc_health:2 ; +__u8 expansion_bytes:5 ; + } nvCache; + }; + +/* Unique Volume Id of the NvCache Volume associated with this volume */ +__u32 nvc_vol_orig_family_num; +__u16 nvc_vol_raid_dev_num; + +#define RWH_OFF 0 +#define RWH_DISTRIBUTED 1 +#define RWH_JOURNALING_DRIVE 2 +__u8 rwh_policy;/* Raid Write Hole Policy */ +__u8 filler1; + +#define IMSM_DEV_FILLERS 7__u32 filler[IMSM_DEV_FILLERS ];struct imsm_vol vol; } __attribute__ ((packed));
@@ -7565,12 +7594,15 @@ mark_checkpoint: skip_mark_checkpoint:/* mark dirty / clean */ -if (dev->vol.dirty != !consistent) { +if ((dev->vol.dirty &RAIDVOL_DIRTY ) != !consistent) {dprintf ("imsm: mark '%s'\n" , consistent ?"clean" :"dirty" ); -if (consistent) - dev->vol.dirty =0 ; -else - dev->vol.dirty =1 ; +if (consistent) { + dev->vol.dirty =RAIDVOL_CLEAN ; + }else { + dev->vol.dirty =RAIDVOL_DIRTY ; +if (dev->rwh_policy) + dev->vol.dirty |=RAIDVOL_DSRECORD_VALID ; + } super->updates_pending++; }
Signature · 1 line
2.10.1
PATCH 2/7 Generic support for --rwh-policy and PPL
In reply to Artur PaszkiewiczAdd a new parameter to mdadm: --rwh-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 functionality is treated as a different RWH policy, which is implicitly selected when using --write-journal.
Show the currently enabled RWH policy type in the output from mdadm --detail. The value is retrieved from the array's sysfs attribute 'rwh_policy'.
--- Create.c | 7 ++++++- Detail.c | 18 ++++++++++++++++-- Kill.c | 2 +- ReadMe.c | 1 + maps.c | 7 +++++++ mdadm.c | 35 ++++++++++++++++++++++++++++++++--- mdadm.h | 15 +++++++++++++-- super-ddf.c | 4 ++-- super-intel.c | 12 ++++++------ super0.c | 6 +++--- super1.c | 4 ++-- sysfs.c | 11 +++++++++++ 12 files changed, 100 insertions(+), 22 deletions(-)
Create.c +6 -1
@@ -594,6 +594,11 @@ int Create(struct supertype *st, char *mddev,return 1 ; } +if (s->rwh_policy ==RWH_POLICY_PPL && !st->ss->supports_ppl) { +pr_err ("%s metadata does not support PPL\n" , st->ss->name); +return 1 ; + } +/* We need to create the device */ map_lock (&map); mdfd =create_mddev (mddev, name, c->autof,LOCAL , chosen_name);
@@ -720,7 +725,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;
Detail.c +16 -2
@@ -504,15 +504,29 @@ 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" , array.chunk_size/1024 );break ;case -1 : -printf (" Rounding : %dK\n\n" , array.chunk_size/1024 ); +printf (" Rounding : %dK\n" , array.chunk_size/1024 );break ;default :break ; } +if (array.level ==4 || array.level ==5 || array.level ==6 ) { +struct mdinfo *mdi =sysfs_read (fd,NULL , +GET_RWH_POLICY ); +if (mdi) { +char *rwh_policy =map_num (rwh_policies, + mdi->rwh_policy); +sysfs_free (mdi); +if (rwh_policy) +printf (" RWH Policy : %s\n" , + rwh_policy); + } + } +printf ("\n" ); +if (e && e->percent >=0 ) {static char *sync_action[] = {"Rebuild" ,"Resync" ,
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 +1 -0
@@ -143,6 +143,7 @@ struct option long_options[] = { {"nodes",1, 0, Nodes}, /* also for --assemble */ {"home-cluster",1, 0, ClusterName}, {"write-journal",1, 0, WriteJournal}, + {"rwh-policy",1, 0, RwhPolicy},/* For assemble */ {"uuid", 1, 0, 'u'},
maps.c +7 -0
@@ -129,6 +129,13 @@ mapping_t faultylayout[] = { { NULL, 0} }; +mapping_t rwh_policies[] = { + {"off" ,RWH_POLICY_OFF }, + {"journal" ,RWH_POLICY_JOURNAL }, + {"ppl" ,RWH_POLICY_PPL }, + {NULL ,0 } +}; +char *map_num (mapping_t *map,int num) {while (map->name) {
mdadm.c +32 -3
@@ -78,6 +78,7 @@ int main(int argc, char *argv[]) .level = UnSet, .layout = UnSet, .bitmap_chunk = UnSet, + .rwh_policy = UnSet, };char sys_hostname[256 ];
@@ -1198,6 +1199,13 @@ int main(int argc, char *argv[]) s.journaldisks =1 ;continue ; +case O (CREATE , RwhPolicy): + s.rwh_policy =map_name (rwh_policies, optarg); +if (s.rwh_policy == UnSet) { +pr_err ("Invalid RWH policy: %s\n" , optarg); +exit (2 ); + } +continue ; }/* We have now processed all the valid options. Anything else is * an error
@@ -1225,9 +1233,30 @@ int main(int argc, char *argv[])exit (0 ); } -if (s.journaldisks && (s.level <4 || s.level >6 )) { -pr_err ("--write-journal is only supported for RAID level 4/5/6.\n" ); -exit (2 ); +if (s.journaldisks) { +if (s.level <4 || s.level >6 ) { +pr_err ("--write-journal is only supported for RAID level 4/5/6.\n" ); +exit (2 ); + } +if (s.rwh_policy == UnSet) { + s.rwh_policy =RWH_POLICY_JOURNAL ; + }else if (s.rwh_policy !=RWH_POLICY_JOURNAL ) { +pr_err ("--write-journal is not supported with RWH policy: %s\n" , +map_num (rwh_policies, s.rwh_policy)); +exit (2 ); + } + } + +if (s.rwh_policy != UnSet) { +if (s.level <4 || s.level >6 ) { +pr_err ("--rwh-policy is only supported for RAID level 4/5/6.\n" ); +exit (2 ); + } +if (s.rwh_policy ==RWH_POLICY_JOURNAL && !s.journaldisks) { +pr_err ("--write-journal is required for RWH policy: %s\n" , +map_num (rwh_policies, s.rwh_policy)); +exit (2 ); + } }if (!mode && devs_found) {
mdadm.h +13 -2
@@ -268,6 +268,13 @@ struct mdinfo {int journal_device_required;int journal_clean; +enum { +RWH_POLICY_UNKNOWN , +RWH_POLICY_OFF , +RWH_POLICY_JOURNAL , +RWH_POLICY_PPL , + } rwh_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.
@@ -409,6 +416,7 @@ enum special_options { ClusterName, ClusterConfirm, WriteJournal, + RwhPolicy, }; enum prefix_standard {
@@ -506,6 +514,7 @@ struct shape {int assume_clean;int write_behind;unsigned long long size; +int rwh_policy; };/* List of device names - wildcards expanded */
@@ -596,6 +605,7 @@ enum sysfs_read_flags {GET_STATE = (1 <<23 ),GET_ERROR = (1 <<24 ),GET_ARRAY_STATE = (1 <<25 ), + GET_RWH_POLICY = (1 << 26), };/* If fd >= 0, get the array it is open on,
@@ -679,7 +689,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[], rwh_policies[];extern char *map_dev_preferred (int major,int minor,int create,char *prefer);
@@ -839,7 +849,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);
@@ -1035,6 +1045,7 @@ extern struct superswitch {/* validate container after assemble */ int (*validate_container)(struct mdinfo *info); +int supports_ppl;int swapuuid;/* true if uuid is bigending rather than hostendian */ int external;const char *name;/* canonical metadata name */
super-ddf.c +2 -2
@@ -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 ) {
super-intel.c +6 -6
@@ -4887,7 +4887,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) {
@@ -4981,7 +4981,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 ;
@@ -4995,7 +4995,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 )
@@ -5023,7 +5023,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);
@@ -5045,7 +5045,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) {
@@ -5068,7 +5068,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)
super0.c +3 -3
@@ -721,7 +721,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) {
@@ -760,8 +760,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;
super1.c +2 -2
@@ -1388,7 +1388,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;
@@ -1441,7 +1441,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);
sysfs.c +11 -0
@@ -240,6 +240,17 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options) }else sra->sysfs_array_state[0 ] =0 ; +if (options &GET_RWH_POLICY ) { +strcpy (base,"rwh_policy" ); +if (load_sys (fname, buf,sizeof (buf))) { + sra->rwh_policy =RWH_POLICY_UNKNOWN ; + }else { + sra->rwh_policy =map_name (rwh_policies, buf); +if (sra->rwh_policy == UnSet) + sra->rwh_policy =RWH_POLICY_UNKNOWN ; + } + } +if (! (options &GET_DEVS ))return sra;
Signature · 1 line
2.10.1
PATCH 3/7 imsm: PPL support
In reply to Artur PaszkiewiczEnable creating and assembling IMSM raid5 arrays with PPL.
Write the IMSM MPB location for a device to the newly added rdev sb_start sysfs attribute and 'journal_ppl' to 'state' attribute for every active member.
--- mdadm.h | 1 + super-intel.c | 33 +++++++++++++++++++++++++++++++++ sysfs.c | 4 ++++ 3 files changed, 38 insertions(+)
mdadm.h +1 -0
@@ -252,6 +252,7 @@ struct mdinfo {unsigned long long custom_array_size;/* size for non-default sized * arrays (in sectors) */ +unsigned long long sb_start;#define NO_RESHAPE 0#define VOLUME_RESHAPE 1#define CONTAINER_RESHAPE 2
super-intel.c +33 -0
@@ -1261,6 +1261,15 @@ static void print_imsm_dev(struct intel_super *super, }printf ("\n" );printf (" Dirty State : %s\n" , dev->vol.dirty ?"dirty" :"clean" ); +printf (" RWH Policy : " ); +if (dev->rwh_policy ==RWH_OFF ) +printf ("off\n" ); +else if (dev->rwh_policy ==RWH_DISTRIBUTED ) +printf ("PPL distributed\n" ); +else if (dev->rwh_policy ==RWH_JOURNALING_DRIVE ) +printf ("PPL journaling drive\n" ); +else +printf ("<unknown:%d>\n" , dev->rwh_policy); }static void print_imsm_disk (struct imsm_disk *disk,int index,__u32 reserved)
@@ -3043,6 +3052,15 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info, } } } + +if (info->array.level ==5 ) { +if (dev->rwh_policy ==RWH_OFF ) + info->rwh_policy =RWH_POLICY_OFF ; +else if (dev->rwh_policy ==RWH_DISTRIBUTED ) + info->rwh_policy =RWH_POLICY_PPL ; +else + info->rwh_policy =RWH_POLICY_UNKNOWN ; + } } static __u8 imsm_check_degraded(struct intel_super *super, struct imsm_dev *dev,
@@ -3177,6 +3195,9 @@ static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info, char * disk = &super->disks->disk; info->data_offset =total_blocks (&super->disks->disk) - reserved; +/* mpb anchor sector - see store_imsm_mpb() */ + info->sb_start =total_blocks (&super->disks->disk) - + ((2 * super->sector_size) >>9 ); info->component_size = reserved; info->disk.state =is_configured (disk) ? (1 <<MD_DISK_ACTIVE ) :0 ;/* we don't change info->disk.raid_disk here because
@@ -5034,6 +5055,17 @@ static int init_super_imsm_volume(struct supertype *st, mdu_array_info_t *info, } mpb->num_raid_devs++; +if (s->rwh_policy == UnSet || s->rwh_policy ==RWH_POLICY_OFF ) { + dev->rwh_policy =RWH_OFF ; + }else if (s->rwh_policy ==RWH_POLICY_PPL ) { + dev->rwh_policy =RWH_DISTRIBUTED ; + }else { +free (dev); +free (dv); +pr_err ("imsm supports only PPL RWH Policy\n" ); +return 0 ; + } + dv->dev = dev; dv->index = super->current_vol; dv->next = super->devlist;
@@ -11061,6 +11093,7 @@ struct superswitch super_imsm = { .container_content = container_content_imsm, .validate_container = validate_container_imsm, + .supports_ppl = 1, .external = 1, .name = "imsm",
sysfs.c +4 -0
@@ -732,7 +732,11 @@ int sysfs_add_disk(struct mdinfo *sra, struct mdinfo *sd, int resume) rv |=sysfs_set_num (sra, sd,"slot" , sd->disk.raid_disk);if (resume)sysfs_set_num (sra, sd,"recovery_start" , sd->recovery_start); +if (sra->rwh_policy ==RWH_POLICY_PPL && + (sd->recovery_start == MaxSector || !resume)) +sysfs_set_str (sra, sd,"state" ,"journal_ppl" ); } +sysfs_set_num (sra, sd,"sb_start" , sd->sb_start);return rv; }
Signature · 1 line
2.10.1
PATCH 4/7 super1: PPL support
In reply to Artur PaszkiewiczEnable creating and assembling raid5 arrays with PPL for 1.1 and 1.2 metadata.
When creating, reserve enough space for PPL and store its size and location in the superblock and set MD_FEATURE_PPL bit. PPL is stored in the metadata region reserved for internal write-intent bitmap, so don't allow using bitmap and PPL together.
--- Create.c | 19 +++++++++++-- Grow.c | 15 +++++++++- mdadm.h | 4 ++- super-ddf.c | 2 +- super-gpt.c | 2 +- super-intel.c | 4 +-- super-mbr.c | 2 +- super0.c | 2 +- super1.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++---------- 9 files changed, 113 insertions(+), 25 deletions(-)
Create.c +16 -3
@@ -201,6 +201,15 @@ int Create(struct supertype *st, char *mddev,return 1 ; } +if (s->rwh_policy ==RWH_POLICY_PPL ) { +if (s->bitmap_file) { +pr_err ("PPL is not compatible with bitmap\n" ); +return 1 ; + }else { + s->bitmap_file ="none" ; + } + } +/* now set some defaults */ if (s->layout == UnSet) {
@@ -259,7 +268,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->rwh_policy, + c->verbose>=0 ))return 1 ;if (s->chunk && s->chunk != UnSet) {
@@ -358,7 +368,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->rwh_policy, + c->verbose > 0)) {case -1 :/* Not valid, message printed, and not * worth checking any further */ exit (2 );
@@ -395,6 +406,7 @@ int Create(struct supertype *st, char *mddev, &s->chunk, s->size*2, dv->data_offset, dname, &freesize, + s->rwh_policy, c->verbose >= 0)) { pr_err("%s is not suitable for this array.\n",
@@ -501,7 +513,8 @@ int Create(struct supertype *st, char *mddev, s->raiddisks, &s->chunk, minsize*2, data_offset, - NULL, NULL, 0)) { + NULL, NULL, + s->rwh_policy, 0)) {pr_err ("devices too large for RAID level %d\n" , s->level);return 1 ; }
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_RWH_POLICY ); +if (mdi) { +if (mdi->rwh_policy ==RWH_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 );
mdadm.h +3 -1
@@ -288,6 +288,8 @@ struct mdinfo {#define MaxSector (~0ULL)/* resync/recovery complete position */ };long bitmap_offset;/* 0 == none, 1 == a file */ +unsigned int ppl_offset; +unsigned int ppl_sectors;unsigned long safe_mode_delay;/* ms delay to mark clean */ int new_level, delta_disks, new_layout, new_chunk;int errors;
@@ -948,7 +950,7 @@ extern struct superswitch { int *chunk, unsigned long long size, unsigned long long data_offset, char *subdev, unsigned long long *freesize, - int verbose); + int rwh_policy, int verbose);/* Return a linked list of 'mdinfo' structures for all arrays * in the container. For non-containers, it is like
super-ddf.c +1 -1
@@ -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 rwh_policy, int verbose) { int fd;struct mdinfo *sra;
super-gpt.c +1 -1
@@ -195,7 +195,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 rwh_policy, int verbose) { pr_err("gpt metadata cannot be used this way\n");return 0 ;
super-intel.c +2 -2
@@ -6631,7 +6631,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 rwh_policy, int verbose) { int fd, cfd;struct mdinfo *sra;
@@ -10447,7 +10447,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.rwh_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 rwh_policy, int verbose) { pr_err("mbr metadata cannot be used this way\n");return 0 ;
super0.c +1 -1
@@ -1263,7 +1263,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 rwh_policy, int verbose) { unsigned long long ldsize;int fd;
super1.c +74 -14
208 lines not on this page · raw message
Signature · 1 line
2.10.1
PATCH 5/7 imsm: allow to assemble with PPL even if dirty degraded
In reply to Artur PaszkiewiczFrom: Pawel Baldysiak <[email protected]>
This is necessary to allow PPL recovery in the kernel driver. If the recovery succeeds, the array is no longer in dirty state and can be started normally as degraded.
--- Assemble.c | 4 +++- super-intel.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-)
Assemble.c +3 -1
@@ -1943,7 +1943,9 @@ int assemble_container_content(struct supertype *st, int mdfd, content->uuid, chosen_name);if (enough (content->array.level, content->array.raid_disks, - content->array.layout, content->array.state &1 , avail) ==0 ) { + content->array.layout, + (content->array.state &1 ) || content->journal_clean, + avail) ==0 ) {if (c->export && result) *result |=INCR_NO ;else if (c->verbose >=0 ) {
super-intel.c +1 -0
@@ -2896,6 +2896,7 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info, info->custom_array_size <<=32 ; info->custom_array_size |=__le32_to_cpu (dev->size_low); info->recovery_blocked =imsm_reshape_blocks_arrays_changes (st->sb); + info->journal_clean = dev->rwh_policy;if (is_gen_migration (dev)) { info->reshape_active =1 ;
Signature · 1 line
2.10.1
PATCH 6/7 Allow changing the RWH policy for a running array
In reply to Artur PaszkiewiczThis extends the --rwh-policy parameter to work also in Misc mode. Using it changes the currently active RWH policy in the kernel driver and updates the metadata to make this change permanent. Updating metadata is not yet implemented for super1, so this is limited to IMSM for now.
--- Manage.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mdadm.c | 9 +++++++ mdadm.h | 1 + super-intel.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 153 insertions(+), 1 deletion(-)
Manage.c +79 -0
@@ -1805,4 +1805,83 @@ int move_spare(char *from_devname, char *to_devname, dev_t devid)close (fd2);return 0 ; } + +int ChangeRwhPolicy (char *dev,char *update,int verbose) +{ +struct supertype *st; +struct mdinfo *info; +char *subarray =NULL ; +int ret =0 ; +int fd; +int new_policy =map_name (rwh_policies, update); + +if (new_policy == UnSet) +return 1 ; + + fd =open (dev,O_RDONLY ); +if (fd <0 ) +return 1 ; + + st =super_by_fd (fd, &subarray); +if (!st) { +close (fd); +return 1 ; + } + + info =sysfs_read (fd,NULL ,GET_RWH_POLICY |GET_LEVEL ); +close (fd); +if (!info) { + ret =1 ; + goto free_st; + } + +if (new_policy ==RWH_POLICY_PPL && !st->ss->supports_ppl) { +pr_err ("%s metadata does not support PPL\n" , st->ss->name); + ret =1 ; + goto free_info; + } + +if (info->array.level <4 || info->array.level >6 ) { +pr_err ("Operation not supported for array level %d\n" , + info->array.level); + ret =1 ; + goto free_info; + } + +if (info->rwh_policy != (unsigned )new_policy) { +if (!st->ss->external && new_policy ==RWH_POLICY_PPL ) { +pr_err ("Operation supported for external metadata only.\n" ); + ret =1 ; + goto free_info; + } + +if (sysfs_set_str (info,NULL ,"rwh_policy" , update)) { +pr_err ("Failed to change array RWH Policy\n" ); + ret =1 ; + goto free_info; + } + info->rwh_policy = new_policy; + } + +if (subarray) { +char container_dev[PATH_MAX ]; +struct mddev_ident ident; + +sprintf (container_dev,"/dev/%s" , st->container_devnm); + + st->info = info; + ident.st = st; + + ret =Update_subarray (container_dev, subarray,"rwh-policy" , + &ident, verbose); + } + +free_info: +sysfs_free (info); +free_st: +free (st); +free (subarray); + +return ret; +}#endif
mdadm.c +9 -0
@@ -251,6 +251,7 @@ int main(int argc, char *argv[])case UpdateSubarray:case UdevRules:case KillOpt: +case RwhPolicy:if (!mode) newmode =MISC ;break ;
@@ -1200,11 +1201,16 @@ int main(int argc, char *argv[]) s.journaldisks =1 ;continue ;case O (CREATE , RwhPolicy): +case O (MISC , RwhPolicy): s.rwh_policy =map_name (rwh_policies, optarg);if (s.rwh_policy == UnSet) {pr_err ("Invalid RWH policy: %s\n" , optarg);exit (2 ); } +if (mode ==MISC ) { + devmode = opt; + c.update = optarg; + }continue ; }/* We have now processed all the valid options. Anything else is
@@ -1916,6 +1922,9 @@ static int misc_list(struct mddev_dev *devlist,case Action: rv |=SetAction (dv->devname, c->action);continue ; +case RwhPolicy: + rv |=ChangeRwhPolicy (dv->devname, c->update, c->verbose); +continue ; }if (dv->devname[0 ] =='/' ) mdfd =open_mddev (dv->devname,1 );
mdadm.h +1 -0
@@ -1332,6 +1332,7 @@ extern int Update_subarray(char *dev, char *subarray, char *update, struct mddevextern int Wait (char *dev);extern int WaitClean (char *dev,int sock,int verbose);extern int SetAction (char *dev,char *action); +extern int ChangeRwhPolicy (char *dev,char *update,int verbose);extern int Incremental (struct mddev_dev *devlist,struct context *c,struct supertype *st);
super-intel.c +64 -1
107 lines not on this page · raw message
Signature · 1 line
2.10.1
PATCH 7/7 Man page changes for --rwh-policy
In reply to Artur PaszkiewiczDescribe the usage of the --rwh-policy parameter in Create and Misc modes.
--- mdadm.8.in | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
mdadm.8.in +28 -0
@@ -996,6 +996,26 @@ simultaneously. If not specified, this defaults to 4. Specify journal device for the RAID-4/5/6 array. The journal device should be a SSD with reasonable lifetime. +.TP +.BR \-\-rwh-policy= +Specify the RAID Write Hole policy for a RAID-4/5/6 array. Currently supported +options are +.BR off , +.B journal +and +.BR ppl . + +The +.B journal +policy is implicitly selected when using +.BR \-\-write-journal . + +The +.B ppl +policy (Partial Parity Log) is a mechanism that can be used with RAID5 arrays. +This feature prevents data loss by keeping parity consistent with data even in +case of drive failure during dirty shutdown. PPL is stored in the metadata +region of RAID member drives, no additional journal drive is needed. .SH For assemble:
@@ -1675,6 +1695,14 @@ can be found it under .BR "SCRUBBING AND MISMATCHES" . +.TP +.BR \-\-rwh-policy= +Change the RAID Write Hole policy for a RAID-4/5/6 array at runtime. For +details about the RWH policies, see the description for the same parameter +under +.B Create mode +options. + .SH For Incremental Assembly mode: .TP .BR \-\-rebuild\-map ", " \-r
Signature · 1 line
2.10.1
Re: [PATCH 1/7] imsm: metadata changes for PPL
In reply to Artur PaszkiewiczQuoted 9 lines · Artur Paszkiewicz
Updates for the IMSM metadata format, including PPL header structures.
Extend
imsm_voldirty field adding a third value, which is required to enable PPL recovery in Windows and UEFI drivers.Signed-off-by Artur Paszkiewicz <[email protected]>--- super-intel.c | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-)
A couple of comments on this change:
Quoted 21 lines
super-intel.c +5
-1@@ -154,6 +157,9 @@ struct imsm_vol {#define MIGR_STATE_CHANGE 4#define MIGR_REPAIR 5__u8 migr_type;/* Initializing, Rebuilding, ... */ +#define RAIDVOL_CLEAN 0 +#define RAIDVOL_DIRTY 1 +#define RAIDVOL_DSRECORD_VALID 2__u8 dirty;__u8 fs_state;/* fast-sync state for CnG (0xff == disabled) */ __u16 verify_errors;/* number of mismatches */ @@ -189,7 +195,30 @@ struct imsm_dev {__u16 cache_policy;__u8 cng_state;__u8 cng_sub_state; -#define IMSM_DEV_FILLERS 10 +__u16 my_vol_raid_dev_num;/* Used in Unique volume Id for this RaidDev */ +
super-intel.c struct imsm_dev { · line 209
Quoted 10 lines
super-intel.c +10
-0+/* NVM_EN */ +__u8 nv_cache_mode; +union { +__u8 nv_cache_flags; +struct { +__u8 dirty:1 ;/* 1 - cache is dirty, 0 - clean */ +__u8 nvc_health:2 ; +__u8 expansion_bytes:5 ; + } nvCache; + };
This sets off alarm bells here - you declare a union of a u8 and a matching bitfield, but do not handle bit endian bitfields. If someone tried to use this on a big endian system this could get messy.
super-intel.c mark_checkpoint: · line 7597
Quoted 6 lines
super-intel.c +1
-1@@ -7565,12 +7594,15 @@ mark_checkpoint: skip_mark_checkpoint:/* mark dirty / clean */ -if (dev->vol.dirty != !consistent) { +if ((dev->vol.dirty &RAIDVOL_DIRTY ) != !consistent) {
This part makes my head spin (to be honest, the original code did too). I had to go write a small snipped of C to figure out what the compiler does with !x given x > 0, since consistent can be 0, 1, and 2 here.
Basically for RAIDVOL_CLEAN and consistent = 0, and RAIDVOL_DIRTY and consistent = 1 and 2, this statement triggers. Maybe I am just terrible dense when it comes to reading obfuscated C, but could we change this round to a construct that is a little easier to read?
Cheers,
Jes
Re: [PATCH 3/7] imsm: PPL support
In reply to Artur PaszkiewiczQuoted 62 lines · Artur Paszkiewicz
Enable creating and assembling IMSM raid5 arrays with PPL.
Write the IMSM MPB location for a device to the newly added rdev
sb_startsysfs attribute and 'journal_ppl' to 'state' attribute for every active member.Signed-off-by Artur Paszkiewicz <[email protected]>--- mdadm.h | 1 + super-intel.c | 33 +++++++++++++++++++++++++++++++++ sysfs.c | 4 ++++ 3 files changed, 38 insertions(+)mdadm.h +1
-0@@ -252,6 +252,7 @@ struct mdinfo {unsigned long long custom_array_size;/* size for non-default sized * arrays (in sectors) */ +unsigned long long sb_start;#define NO_RESHAPE 0#define VOLUME_RESHAPE 1#define CONTAINER_RESHAPE 2super-intel.c +18
-0@@ -1261,6 +1261,15 @@ static void print_imsm_dev(struct intel_super *super, }printf ("\n" );printf (" Dirty State : %s\n" , dev->vol.dirty ?"dirty" :"clean" ); +printf (" RWH Policy : " ); +if (dev->rwh_policy ==RWH_OFF ) +printf ("off\n" ); +else if (dev->rwh_policy ==RWH_DISTRIBUTED ) +printf ("PPL distributed\n" ); +else if (dev->rwh_policy ==RWH_JOURNALING_DRIVE ) +printf ("PPL journaling drive\n" ); +else +printf ("<unknown:%d>\n" , dev->rwh_policy); }static void print_imsm_disk (struct imsm_disk *disk,int index,__u32 reserved)@@ -3043,6 +3052,15 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info, } } } + +if (info->array.level ==5 ) { +if (dev->rwh_policy ==RWH_OFF ) + info->rwh_policy =RWH_POLICY_OFF ; +else if (dev->rwh_policy ==RWH_DISTRIBUTED ) + info->rwh_policy =RWH_POLICY_PPL ; +else + info->rwh_policy =RWH_POLICY_UNKNOWN ; + } } static __u8 imsm_check_degraded(struct intel_super *super, struct imsm_dev *dev,
super-intel.c static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info, char * · line 3203
Quoted 9 lines
super-intel.c +3
-0@@ -3177,6 +3195,9 @@ static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info, char * disk = &super->disks->disk; info->data_offset =total_blocks (&super->disks->disk) - reserved; +/* mpb anchor sector - see store_imsm_mpb() */ + info->sb_start =total_blocks (&super->disks->disk) - + ((2 * super->sector_size) >>9 ); info->component_size = reserved; info->disk.state =is_configured (disk) ? (1 <<MD_DISK_ACTIVE ) :0 ;/* we don't change info->disk.raid_disk here because
Hi Artur,
I have been sitting staring at the above for a while, and looking at store_imsm_mpb() it is not clear to me what is meant to happen here.
For 4k sector drives, aren't you pushing back sb_start way further than you are for 512 byte sector drives? Ie. you are subtracting 16 sectors for the 4k drive but only two sectors for the 512 byte sector drive?
Maybe it's because it's Monday or I lost the last of my marbles, but could you possibly enlighten me here please?
Thanks,
Jes
Re: [PATCH 1/7] imsm: metadata changes for PPL
In reply to Jes SorensenQuoted 40 lines · Jes Sorensen
Quoted 9 lines · Artur Paszkiewicz
Updates for the IMSM metadata format, including PPL header structures.
Extend
imsm_voldirty field adding a third value, which is required to enable PPL recovery in Windows and UEFI drivers.Signed-off-by Artur Paszkiewicz <[email protected]>--- super-intel.c | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-)A couple of comments on this change:
Quoted 27 lines
super-intel.c +11
-1@@ -154,6 +157,9 @@ struct imsm_vol {#define MIGR_STATE_CHANGE 4#define MIGR_REPAIR 5__u8 migr_type;/* Initializing, Rebuilding, ... */ +#define RAIDVOL_CLEAN 0 +#define RAIDVOL_DIRTY 1 +#define RAIDVOL_DSRECORD_VALID 2__u8 dirty;__u8 fs_state;/* fast-sync state for CnG (0xff == disabled) */ __u16 verify_errors;/* number of mismatches */ @@ -189,7 +195,30 @@ struct imsm_dev {__u16 cache_policy;__u8 cng_state;__u8 cng_sub_state; -#define IMSM_DEV_FILLERS 10 +__u16 my_vol_raid_dev_num;/* Used in Unique volume Id for this RaidDev */ + +/* NVM_EN */ +__u8 nv_cache_mode; +union { +__u8 nv_cache_flags; +struct { +__u8 dirty:1 ;/* 1 - cache is dirty, 0 - clean */
Quoted 8 lines
super-intel.c struct imsm_dev { · line 209
Quoted 4 lines
super-intel.c +4
-0+ __u8 nvc_health:2; + __u8 expansion_bytes:5; + } nvCache; + };This sets off alarm bells here - you declare a union of a u8 and a matching bitfield, but do not handle bit endian bitfields. If someone tried to use this on a big endian system this could get messy.
Those fields are not used in the code at all, the only thing added to this structure that is used is 'rwh_policy'. The rest is to fill the gaps between IMSM format in UEFI/Windows.
Quoted 13 lines
super-intel.c mark_checkpoint: · line 7597
Quoted 7 lines
super-intel.c +1
-1@@ -7565,12 +7594,15 @@ mark_checkpoint: skip_mark_checkpoint:/* mark dirty / clean */ -if (dev->vol.dirty != !consistent) { +if ((dev->vol.dirty &RAIDVOL_DIRTY ) != !consistent) {This part makes my head spin (to be honest, the original code did too). I had to go write a small snipped of C to figure out what the compiler does with !x given x > 0, since consistent can be 0, 1, and 2 here.
Quoted 4 lines
Basically for
RAIDVOL_CLEANand consistent = 0, andRAIDVOL_DIRTYand consistent = 1 and 2, this statement triggers. Maybe I am just terrible dense when it comes to reading obfuscated C, but could we change this round to a construct that is a little easier to read?
Yes, I admit it is confusing. Does this look better?
- if (dev->vol.dirty != !consistent) {
+ if (((dev->vol.dirty & RAIDVOL_DIRTY) && consistent) ||
+ (!(dev->vol.dirty & RAIDVOL_DIRTY) && !consistent)) {
Thanks,
Artur
Re: [PATCH 3/7] imsm: PPL support
In reply to Jes SorensenQuoted 78 lines · Jes Sorensen
Quoted 62 lines · Artur Paszkiewicz
Enable creating and assembling IMSM raid5 arrays with PPL.
Write the IMSM MPB location for a device to the newly added rdev
sb_startsysfs attribute and 'journal_ppl' to 'state' attribute for every active member.Signed-off-by Artur Paszkiewicz <[email protected]>--- mdadm.h | 1 + super-intel.c | 33 +++++++++++++++++++++++++++++++++ sysfs.c | 4 ++++ 3 files changed, 38 insertions(+)mdadm.h +1
-0@@ -252,6 +252,7 @@ struct mdinfo {unsigned long long custom_array_size;/* size for non-default sized * arrays (in sectors) */ +unsigned long long sb_start;#define NO_RESHAPE 0#define VOLUME_RESHAPE 1#define CONTAINER_RESHAPE 2super-intel.c +18
-0@@ -1261,6 +1261,15 @@ static void print_imsm_dev(struct intel_super *super, }printf ("\n" );printf (" Dirty State : %s\n" , dev->vol.dirty ?"dirty" :"clean" ); +printf (" RWH Policy : " ); +if (dev->rwh_policy ==RWH_OFF ) +printf ("off\n" ); +else if (dev->rwh_policy ==RWH_DISTRIBUTED ) +printf ("PPL distributed\n" ); +else if (dev->rwh_policy ==RWH_JOURNALING_DRIVE ) +printf ("PPL journaling drive\n" ); +else +printf ("<unknown:%d>\n" , dev->rwh_policy); }static void print_imsm_disk (struct imsm_disk *disk,int index,__u32 reserved)@@ -3043,6 +3052,15 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info, } } } + +if (info->array.level ==5 ) { +if (dev->rwh_policy ==RWH_OFF ) + info->rwh_policy =RWH_POLICY_OFF ; +else if (dev->rwh_policy ==RWH_DISTRIBUTED ) + info->rwh_policy =RWH_POLICY_PPL ; +else + info->rwh_policy =RWH_POLICY_UNKNOWN ; + } } static __u8 imsm_check_degraded(struct intel_super *super, struct imsm_dev *dev,super-intel.c static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info, char * · line 3203
Quoted 9 lines
super-intel.c +3
-0@@ -3177,6 +3195,9 @@ static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info, char * disk = &super->disks->disk; info->data_offset =total_blocks (&super->disks->disk) - reserved; +/* mpb anchor sector - see store_imsm_mpb() */ + info->sb_start =total_blocks (&super->disks->disk) - + ((2 * super->sector_size) >>9 ); info->component_size = reserved; info->disk.state =is_configured (disk) ? (1 <<MD_DISK_ACTIVE ) :0 ;/* we don't change info->disk.raid_disk here because Hi Artur,
I have been sitting staring at the above for a while, and looking at
store_imsm_mpb()it is not clear to me what is meant to happen here.
Quoted 6 lines
For 4k sector drives, aren't you pushing back
sb_startway further than you are for 512 byte sector drives? Ie. you are subtracting 16 sectors for the 4k drive but only two sectors for the 512 byte sector drive?Maybe it's because it's Monday or I lost the last of my marbles, but could you possibly enlighten me here please?
Jes,
You read it correctly. The reason for this is that the IMSM anchor is located in the second _logical_ sector from the end of the drive. So for 4k drives this will be 16 512-byte sectors from the end.
Thanks,
Artur
Re: [PATCH 1/7] imsm: metadata changes for PPL
In reply to Artur PaszkiewiczQuoted 24 lines · Artur Paszkiewicz
Quoted 14 lines · Jes Sorensen
Quoted 13 lines · Artur Paszkiewicz
super-intel.c +8
-1@@ -189,7 +195,30 @@ struct imsm_dev {__u16 cache_policy;__u8 cng_state;__u8 cng_sub_state; -#define IMSM_DEV_FILLERS 10 +__u16 my_vol_raid_dev_num;/* Used in Unique volume Id for this RaidDev */ + +/* NVM_EN */ +__u8 nv_cache_mode; +union { +__u8 nv_cache_flags; +struct { +__u8 dirty:1 ;/* 1 - cache is dirty, 0 - clean */ Quoted 8 lines
super-intel.c struct imsm_dev { · line 209
Quoted 4 lines
super-intel.c +4
-0+ __u8 nvc_health:2; + __u8 expansion_bytes:5; + } nvCache; + };This sets off alarm bells here - you declare a union of a u8 and a matching bitfield, but do not handle bit endian bitfields. If someone tried to use this on a big endian system this could get messy.
Quoted 3 lines
Those fields are not used in the code at all, the only thing added to this structure that is used is '
rwh_policy'. The rest is to fill the gaps between IMSM format in UEFI/Windows.
Hi Artur,
I did notice the code wasn't actually used, sorry I didn't mention that. However I would still prefer to see at least a comment in the code indicating that this would fail on BE systems.
Quoted 19 lines
Quoted 12 lines
super-intel.c mark_checkpoint: · line 7597
Quoted 6 lines
super-intel.c +1
-1@@ -7565,12 +7594,15 @@ mark_checkpoint: skip_mark_checkpoint:/* mark dirty / clean */ -if (dev->vol.dirty != !consistent) { +if ((dev->vol.dirty &RAIDVOL_DIRTY ) != !consistent) {This part makes my head spin (to be honest, the original code did too). I had to go write a small snipped of C to figure out what the compiler does with !x given x > 0, since consistent can be 0, 1, and 2 here.
Quoted 4 lines
Basically for
RAIDVOL_CLEANand consistent = 0, andRAIDVOL_DIRTYand consistent = 1 and 2, this statement triggers. Maybe I am just terrible dense when it comes to reading obfuscated C, but could we change this round to a construct that is a little easier to read?Yes, I admit it is confusing. Does this look better?
Review
Quoted 3 lines
(quoted diff) +2
-1- if (dev->vol.dirty != !consistent) { + if (((dev->vol.dirty & RAIDVOL_DIRTY) && consistent) || + (!(dev->vol.dirty & RAIDVOL_DIRTY) && !consistent)) {
This I can read without getting headache, so yes :)
Cheers,
Jes
Re: [PATCH 3/7] imsm: PPL support
In reply to Artur PaszkiewiczQuoted 21 lines · Artur Paszkiewicz
Quoted 20 lines · Jes Sorensen
super-intel.c static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info, char * · line 3203
Quoted 10 lines
super-intel.c +3
-0@@ -3177,6 +3195,9 @@ static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info, char * disk = &super->disks->disk; info->data_offset =total_blocks (&super->disks->disk) - reserved; +/* mpb anchor sector - see store_imsm_mpb() */ + info->sb_start =total_blocks (&super->disks->disk) - + ((2 * super->sector_size) >>9 ); info->component_size = reserved; info->disk.state =is_configured (disk) ? (1 <<MD_DISK_ACTIVE ) :0 ;/* we don't change info->disk.raid_disk here because Hi Artur,
I have been sitting staring at the above for a while, and looking at
store_imsm_mpb()it is not clear to me what is meant to happen here.For 4k sector drives, aren't you pushing back
sb_startway further than you are for 512 byte sector drives? Ie. you are subtracting 16 sectors for the 4k drive but only two sectors for the 512 byte sector drive?
Quoted 8 lines
Quoted 2 lines
Maybe it's because it's Monday or I lost the last of my marbles, but could you possibly enlighten me here please?
Jes,
You read it correctly. The reason for this is that the IMSM anchor is located in the second _logical_ sector from the end of the drive. So for 4k drives this will be 16 512-byte sectors from the end.
I see, so the IMSM implementation uses 512 byte logical sectors on top of 4k drives? Could I ask you to add a note explaining this in the code?
Thanks,
Jes
Re: [PATCH 1/7] imsm: metadata changes for PPL
In reply to Jes SorensenQuoted 29 lines · Jes Sorensen
Quoted 24 lines · Artur Paszkiewicz
Quoted 14 lines · Jes Sorensen
Quoted 13 lines · Artur Paszkiewicz
super-intel.c +8
-1@@ -189,7 +195,30 @@ struct imsm_dev {__u16 cache_policy;__u8 cng_state;__u8 cng_sub_state; -#define IMSM_DEV_FILLERS 10 +__u16 my_vol_raid_dev_num;/* Used in Unique volume Id for this RaidDev */ + +/* NVM_EN */ +__u8 nv_cache_mode; +union { +__u8 nv_cache_flags; +struct { +__u8 dirty:1 ;/* 1 - cache is dirty, 0 - clean */ Quoted 8 lines
super-intel.c struct imsm_dev { · line 209
Quoted 4 lines
super-intel.c +4
-0+ __u8 nvc_health:2; + __u8 expansion_bytes:5; + } nvCache; + };This sets off alarm bells here - you declare a union of a u8 and a matching bitfield, but do not handle bit endian bitfields. If someone tried to use this on a big endian system this could get messy.
Quoted 3 lines
Those fields are not used in the code at all, the only thing added to this structure that is used is '
rwh_policy'. The rest is to fill the gaps between IMSM format in UEFI/Windows.
Quoted 5 lines
Hi Artur,
I did notice the code wasn't actually used, sorry I didn't mention that. However I would still prefer to see at least a comment in the code indicating that this would fail on BE systems.
Since I wasn't going to use those fields I had not given this much thought, but you are right - this is definitely not portable. I think I'll remove those bitfields in the next version.
Thanks,
Artur
Re: [PATCH 3/7] imsm: PPL support
In reply to Jes SorensenQuoted 25 lines · Jes Sorensen
Quoted 24 lines · Artur Paszkiewicz
Quoted 22 lines · Jes Sorensen
super-intel.c static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info, char * · line 3203
Quoted 10 lines
super-intel.c +3
-0@@ -3177,6 +3195,9 @@ static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info, char * disk = &super->disks->disk; info->data_offset =total_blocks (&super->disks->disk) - reserved; +/* mpb anchor sector - see store_imsm_mpb() */ + info->sb_start =total_blocks (&super->disks->disk) - + ((2 * super->sector_size) >>9 ); info->component_size = reserved; info->disk.state =is_configured (disk) ? (1 <<MD_DISK_ACTIVE ) :0 ;/* we don't change info->disk.raid_disk here because Hi Artur,
I have been sitting staring at the above for a while, and looking at
store_imsm_mpb()it is not clear to me what is meant to happen here.For 4k sector drives, aren't you pushing back
sb_startway further than you are for 512 byte sector drives? Ie. you are subtracting 16 sectors for the 4k drive but only two sectors for the 512 byte sector drive?Maybe it's because it's Monday or I lost the last of my marbles, but could you possibly enlighten me here please?
Quoted 8 lines
Quoted 5 lines
Jes,
You read it correctly. The reason for this is that the IMSM anchor is located in the second _logical_ sector from the end of the drive. So for 4k drives this will be 16 512-byte sectors from the end.
I see, so the IMSM implementation uses 512 byte logical sectors on top of 4k drives? Could I ask you to add a note explaining this in the code?
IMSM uses logical (4k or 512b) sector sizes in the metadata, but mdadm implementation uses just 512 byte sectors. This is how it works since Pawel's 4k support patches - it converts 4k metadata internally to 512b sector values. Plus here the sb_start value is passed to the kernel, so it must be in 512 byte sectors. Sure, I can add a comment about this.
Thanks,
Artur
Re: [PATCH 3/7] imsm: PPL support
Quoted 35 lines · Artur Paszkiewicz
Quoted 34 lines · Jes Sorensen
Quoted 32 lines · Artur Paszkiewicz
Quoted 19 lines · Jes Sorensen
Quoted 11 lines
(quoted diff) +0
-0@@ -3177,6 +3195,9 @@ static void getinfo_super_imsm(structsupertype *st, struct mdinfo *info, char *
super-intel.c +3
-1disk = &super->disks->disk; info->data_offset =total_blocks (&super->disks->disk) - reserved; +/* mpb anchor sector - see store_imsm_mpb() */ + info->sb_start = total_blocks(&super->disks->disk) - + ((2 * super->sector_size) >>9 ); info->component_size = reserved; info->disk.state = is_configured(disk) ? (1 <<Quoted 2 lines
MD_DISK_ACTIVE) : 0;
/* we don't changeinfo->disk.raid_diskhere becauseHi Artur,
I have been sitting staring at the above for a while, and looking at
store_imsm_mpb()it is not clear to me what is meant to happen here.Quoted 6 lines
For 4k sector drives, aren't you pushing back
sb_startway further than you are for 512 byte sector drives? Ie. you are subtracting 16 sectors for the 4k drive but only two sectors for the 512 byte sector drive?Maybe it's because it's Monday or I lost the last of my marbles, but could you possibly enlighten me here please?
Jes,
You read it correctly. The reason for this is that the IMSM anchor is located in the second _logical_ sector from the end of the drive. So for 4k drives this will be 16 512-byte sectors from the end.
Quoted 8 lines
Quoted 2 lines
I see, so the IMSM implementation uses 512 byte logical sectors on top of 4k drives? Could I ask you to add a note explaining this in the code?
IMSM uses logical (4k or 512b) sector sizes in the metadata, but mdadm implementation uses just 512 byte sectors. This is how it works since Pawel's 4k support patches - it converts 4k metadata internally to 512b sector values. Plus here the
sb_startvalue is passed to the kernel, so it must be in 512 byte sectors. Sure, I can add a comment about this.
Great, I prefer to have it documented so nobody else tries to pull all their hairs out trying to understand it :)
Thanks,
Jes