aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/md.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2006-10-21 13:24:08 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-21 16:35:05 -0400
commit1c05b4bc22cd640d3a534bd2851a8413d5df3709 (patch)
treedceceabea9bdb92213e2a2d318cdd1b152832cbd /drivers/md/md.c
parentda3ed32fe568148ede256975d40825ffcdac767b (diff)
[PATCH] md: endian annotation for v1 superblock access
Includes a couple of bugfixes found by sparse. Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r--drivers/md/md.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index f7f19088f3be..7daa7b1e145f 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -974,12 +974,13 @@ static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev)
974 * version 1 superblock 974 * version 1 superblock
975 */ 975 */
976 976
977static unsigned int calc_sb_1_csum(struct mdp_superblock_1 * sb) 977static __le32 calc_sb_1_csum(struct mdp_superblock_1 * sb)
978{ 978{
979 unsigned int disk_csum, csum; 979 __le32 disk_csum;
980 u32 csum;
980 unsigned long long newcsum; 981 unsigned long long newcsum;
981 int size = 256 + le32_to_cpu(sb->max_dev)*2; 982 int size = 256 + le32_to_cpu(sb->max_dev)*2;
982 unsigned int *isuper = (unsigned int*)sb; 983 __le32 *isuper = (__le32*)sb;
983 int i; 984 int i;
984 985
985 disk_csum = sb->sb_csum; 986 disk_csum = sb->sb_csum;
@@ -989,7 +990,7 @@ static unsigned int calc_sb_1_csum(struct mdp_superblock_1 * sb)
989 newcsum += le32_to_cpu(*isuper++); 990 newcsum += le32_to_cpu(*isuper++);
990 991
991 if (size == 2) 992 if (size == 2)
992 newcsum += le16_to_cpu(*(unsigned short*) isuper); 993 newcsum += le16_to_cpu(*(__le16*) isuper);
993 994
994 csum = (newcsum & 0xffffffff) + (newcsum >> 32); 995 csum = (newcsum & 0xffffffff) + (newcsum >> 32);
995 sb->sb_csum = disk_csum; 996 sb->sb_csum = disk_csum;
@@ -1106,7 +1107,7 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version)
1106 if (le32_to_cpu(sb->chunksize)) 1107 if (le32_to_cpu(sb->chunksize))
1107 rdev->size &= ~((sector_t)le32_to_cpu(sb->chunksize)/2 - 1); 1108 rdev->size &= ~((sector_t)le32_to_cpu(sb->chunksize)/2 - 1);
1108 1109
1109 if (le32_to_cpu(sb->size) > rdev->size*2) 1110 if (le64_to_cpu(sb->size) > rdev->size*2)
1110 return -EINVAL; 1111 return -EINVAL;
1111 return ret; 1112 return ret;
1112} 1113}
@@ -1228,7 +1229,7 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1228 else 1229 else
1229 sb->resync_offset = cpu_to_le64(0); 1230 sb->resync_offset = cpu_to_le64(0);
1230 1231
1231 sb->cnt_corrected_read = atomic_read(&rdev->corrected_errors); 1232 sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
1232 1233
1233 sb->raid_disks = cpu_to_le32(mddev->raid_disks); 1234 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
1234 sb->size = cpu_to_le64(mddev->size<<1); 1235 sb->size = cpu_to_le64(mddev->size<<1);