On Wed, Mar 06, 2013 at 04:56:40PM +0100, David Sterba wrote: > The superblock checksum is not verified upon mount. <awkward silence>
Hah! > /* > + * Return 0 if the superblock checksum type matches the checksum value of > that > + * alghorithm. Pass the raw disk superblock data. > + */ > +static int btrfs_check_super_csum(char *raw_disk_sb) I'd have it return 0 or -errno and print warnings with additional info so that each caller doesn't have to. > +{ > + struct btrfs_super_block *disk_sb = > + (struct btrfs_super_block *)raw_disk_sb; > + u16 csum_type = btrfs_super_csum_type(disk_sb); > + if (csum_type >= ARRAY_SIZE(btrfs_csum_sizes)) { > + printk(KERN_ERR "btrfs: unsupported checksum algorithm %u\n", > + csum_type); > + return 1; > + } Does this mean we can get rid of that BUG_ON in btrfs_super_csum_size()? And you can move this check down in an else after the CRC32 test to get rid of the extra exit path. Have each case ret = , the end of the function returns ret. > + if (csum_type == BTRFS_CSUM_TYPE_CRC32) { > [...] > + } > + > + return 1; int ret = 0 if (csum_type == BTRFS_CSUM_TYPE_CRC32) { [..] if (memcmp()) ret = -EIO; /* or whatever */ } else if (type > array_size() { printk("I'm sad."); ret = -EBOOHOO; } return ret; - z -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html