Grow: be careful of corrupt dev_roles list
PATCH 1/1 Grow: be careful of corrupt dev_roles list
I've seen a case where the dev_roles list of a linear array was corrupt. ->max_dev was > 128 and > raid_disks, and the extra slots were '0', not 0xFFFE or 0xFFFF.
This caused problems when a 128th device was added.
So:
1/ make Grow_Add_device more robust so that if numbers
look wrong, it fails-safe.
2/ make examine_super1() report details if the dev_roles
array is corrupt.
--- Grow.c | 15 ++++++++++++--- super1.c | 48 ++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 50 insertions(+), 13 deletions(-)
Grow.c +12 -3
@@ -197,7 +197,12 @@ int Grow_Add_device(char *devname, int fd, char *newdev) info.disk.minor =minor (rdev); info.disk.raid_disk = d; info.disk.state = (1 <<MD_DISK_SYNC ) | (1 <<MD_DISK_ACTIVE ); - st->ss->update_super (st, &info,"linear-grow-new" , newdev,0 ,0 ,NULL ); +if (st->ss->update_super (st, &info,"linear-grow-new" , newdev, +0 ,0 ,NULL ) !=0 ) { +pr_err ("Preparing new metadata failed on %s\n" , newdev); +close (nfd); +return 1 ; + }if (st->ss->store_super (st, nfd)) {pr_err ("Cannot store new superblock on %s\n" , newdev);
@@ -250,8 +255,12 @@ int Grow_Add_device(char *devname, int fd, char *newdev) info.array.active_disks = nd+1 ; info.array.working_disks = nd+1 ; - st->ss->update_super (st, &info,"linear-grow-update" , dv, -0 ,0 ,NULL ); +if (st->ss->update_super (st, &info,"linear-grow-update" , dv, +0 ,0 ,NULL ) !=0 ) { +pr_err ("Updating metadata failed on %s\n" , dv); +close (fd2); +return 1 ; + }if (st->ss->store_super (st, fd2)) {pr_err ("Cannot store new superblock on %s\n" , dv);
super1.c +38 -10
93 lines not on this page · raw message
Signature · 1 line
2.30.1
Jes Sorensen
AppliedQuoted 11 lines · NeilBrown
I've seen a case where the
dev_roleslist of a linear array was corrupt. ->max_dev was > 128 and >raid_disks, and the extra slots were '0', not0xFFFEor0xFFFF.This caused problems when a 128th device was added.
So:
1/ makeGrow_Add_devicemore robust so that if numbers
look wrong, it fails-safe.
Quoted 9 lines
2/ make
examine_super1()report details if thedev_roles
array is corrupt.Signed-off-by NeilBrown <[email protected]>--- Grow.c | 15 ++++++++++++--- super1.c | 48 ++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 50 insertions(+), 13 deletions(-)
Ohhh error handling!
Applied!
Thanks,
Jes