On Fri, 29 Aug 2014 04:42:26 +0000 Andy Smith <andy@xxxxxxxxxxxxxx> wrote: > Hi Neil, > > On Fri, Aug 29, 2014 at 02:35:28PM +1000, NeilBrown wrote: > > On Fri, 29 Aug 2014 04:26:18 +0000 Andy Smith <andy@xxxxxxxxxxxxxx> wrote: > > > Sorry, still no joy: > > > > > > # echo 309363696 > /sys/block/md2/md/dev-sda3/size > > > # cat /sys/block/md2/md/dev-sda3/size > > > 309363264 > > > > Try use "/bin/echo" so you get an error message. > > Also try smaller numbers. Can you write anything larger than what is already > > there? Increasing by 64 (match the 128 sectors that mdadm wants for > > new_offset) should be enough. > > I can't even increase it by 64 from what it is now: > > # /bin/echo 309363328 > /sys/block/md2/md/dev-sda3/size > # cat /sys/block/md2/md/dev-sda3/size > 309363264 > > In fact I can't increase it by 1, and /bin/echo doesn't say why. > Hmm.... I've obviously been assuming something that was wrong. So I did some experiments myself.... If you apply the following patch to mdadm, stop the array, and then assemble with --update=devicesize, you should then be able to reshape the array to fewer devices. This isn't a final solution, I need to think about the whole thing more carefully. But it will work for you. Thanks for your patience. NeilBrown diff --git a/super1.c b/super1.c index 727a08a110e0..efa1042ab47a 100644 --- a/super1.c +++ b/super1.c @@ -1251,6 +1251,17 @@ static int update_super1(struct supertype *st, struct mdinfo *info, misc->device_size - __le64_to_cpu(sb->data_offset)); printf("Size is %llu\n", (unsigned long long) __le64_to_cpu(sb->data_size)); + } else if (strcmp(update, "devicesize") == 0 && + !(__le32_to_cpu(sb->feature_map)&MD_FEATURE_BITMAP_OFFSET) && + __le64_to_cpu(sb->super_offset) > + __le64_to_cpu(sb->data_offset)) { + /* set data_size to device size less data_offset */ + printf("Size was %llu\n", (unsigned long long) + __le64_to_cpu(sb->data_size)); + sb->data_size = __cpu_to_le64( + __le64_to_cpu(sb->super_offset) - __le64_to_cpu(sb->data_offset)); + printf("Size is %llu\n", (unsigned long long) + __le64_to_cpu(sb->data_size)); } else if (strcmp(update, "revert-reshape") == 0) { rv = -2; if (!(sb->feature_map & __cpu_to_le32(MD_FEATURE_RESHAPE_ACTIVE)))
Attachment:
signature.asc
Description: PGP signature