Consider user space generated checksum
PATCH 1/1 Consider user space generated checksum
On alpha systems, the kernel computed checksum, csum_partial(), and user space computed checksum are different. As a consequence, the kernel MD driver aborts detection of MD superblock. This means running mdadm --assemble -f or -U summaries will not always work.
I have been wondering... Should MD driver use csum_partial() at all?
The attached patch includes the checksum function found in mdadm code. If the architecture dependent checksum validation fails, at least try the common function (only for 0.90 superblock format).
Regards,
Mike T.
drivers/md/md.c +21 -0
@@ -439,6 +439,22 @@return csum; } +static unsigned int calc_sb_csum_common (mdp_super_t *super) +{ +unsigned int disk_csum = super->sb_csum; +unsigned long long newcsum =0 ; +unsigned int csum; +int i; +unsigned int *superc = (int *) super; + super->sb_csum =0 ; + +for (i=0 ; i<MD_SB_BYTES /4 ; i++) + newcsum+= superc[i]; + csum = (newcsum&0xffffffff ) + (newcsum>>32 ); + super->sb_csum = disk_csum; +return csum; +} +/* * Handle superblock details. * We want to be able to handle multiple superblock formats
@@ -522,10 +538,15 @@ goto abort;if (calc_sb_csum (sb) != sb->sb_csum) { +printk (KERN_WARNING "md: First attemp to validate checksum on %s failed." +" Trying the common method...\n" , + b); +if (calc_sb_csum_common (sb) != sb->sb_csum) {printk (KERN_WARNING "md: invalid superblock checksum on %s\n" , b); goto abort; } + } rdev->preferred_minor = sb->md_minor; rdev->data_offset =0 ;
Quoted 4 lines · On July 13, [email protected] wrote:
On alpha systems, the kernel computed checksum,
csum_partial(), and user space computed checksum are different. As a consequence, the kernel MD driver aborts detection of MD superblock. This means running mdadm --assemble -f or -U summaries will not always work.
Weird... arch/alpha/checksum.c seem to do a 16 bit checksum rather than the 32bit csum that i386 does. It's mostly used for network code and IP uses 16bit csum, but it is odd that it claims to return a 32 bit number, but really it will always be 16bit...
Quoted 2 lines
I have been wondering... Should MD driver use
csum_partial()at all?
Well, as we seem to want a 32bit checksum, I guess we cannot. But for historical reasons, we probably have to.
I guess a patch much like yours is needed. I'll add something to make sure version-1 superblock are a bit more predictable.
NeilBrown