aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2006-10-21 13:24:09 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-21 16:35:05 -0400
commit4f2e639af4bd5e152fc79256e333643d3dd6c10f (patch)
tree1adf32d929c552d7e4b24475baa45c6108436f79
parent1c05b4bc22cd640d3a534bd2851a8413d5df3709 (diff)
[PATCH] md: endian annotations for the bitmap superblock
And a couple of bug fixes 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>
-rw-r--r--drivers/md/bitmap.c10
-rw-r--r--include/linux/raid/bitmap.h20
2 files changed, 15 insertions, 15 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index d47d38ac71b1..d6f614738bbd 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -536,7 +536,7 @@ static int bitmap_read_sb(struct bitmap *bitmap)
536 printk(KERN_INFO "%s: bitmap file is out of date (%llu < %llu) " 536 printk(KERN_INFO "%s: bitmap file is out of date (%llu < %llu) "
537 "-- forcing full recovery\n", bmname(bitmap), events, 537 "-- forcing full recovery\n", bmname(bitmap), events,
538 (unsigned long long) bitmap->mddev->events); 538 (unsigned long long) bitmap->mddev->events);
539 sb->state |= BITMAP_STALE; 539 sb->state |= cpu_to_le32(BITMAP_STALE);
540 } 540 }
541success: 541success:
542 /* assign fields using values from superblock */ 542 /* assign fields using values from superblock */
@@ -544,11 +544,11 @@ success:
544 bitmap->daemon_sleep = daemon_sleep; 544 bitmap->daemon_sleep = daemon_sleep;
545 bitmap->daemon_lastrun = jiffies; 545 bitmap->daemon_lastrun = jiffies;
546 bitmap->max_write_behind = write_behind; 546 bitmap->max_write_behind = write_behind;
547 bitmap->flags |= sb->state; 547 bitmap->flags |= le32_to_cpu(sb->state);
548 if (le32_to_cpu(sb->version) == BITMAP_MAJOR_HOSTENDIAN) 548 if (le32_to_cpu(sb->version) == BITMAP_MAJOR_HOSTENDIAN)
549 bitmap->flags |= BITMAP_HOSTENDIAN; 549 bitmap->flags |= BITMAP_HOSTENDIAN;
550 bitmap->events_cleared = le64_to_cpu(sb->events_cleared); 550 bitmap->events_cleared = le64_to_cpu(sb->events_cleared);
551 if (sb->state & BITMAP_STALE) 551 if (sb->state & cpu_to_le32(BITMAP_STALE))
552 bitmap->events_cleared = bitmap->mddev->events; 552 bitmap->events_cleared = bitmap->mddev->events;
553 err = 0; 553 err = 0;
554out: 554out:
@@ -578,9 +578,9 @@ static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits,
578 spin_unlock_irqrestore(&bitmap->lock, flags); 578 spin_unlock_irqrestore(&bitmap->lock, flags);
579 sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0); 579 sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0);
580 switch (op) { 580 switch (op) {
581 case MASK_SET: sb->state |= bits; 581 case MASK_SET: sb->state |= cpu_to_le32(bits);
582 break; 582 break;
583 case MASK_UNSET: sb->state &= ~bits; 583 case MASK_UNSET: sb->state &= cpu_to_le32(~bits);
584 break; 584 break;
585 default: BUG(); 585 default: BUG();
586 } 586 }
diff --git a/include/linux/raid/bitmap.h b/include/linux/raid/bitmap.h
index 84d887751855..ebd42a3710b4 100644
--- a/include/linux/raid/bitmap.h
+++ b/include/linux/raid/bitmap.h
@@ -146,16 +146,16 @@ enum bitmap_state {
146 146
147/* the superblock at the front of the bitmap file -- little endian */ 147/* the superblock at the front of the bitmap file -- little endian */
148typedef struct bitmap_super_s { 148typedef struct bitmap_super_s {
149 __u32 magic; /* 0 BITMAP_MAGIC */ 149 __le32 magic; /* 0 BITMAP_MAGIC */
150 __u32 version; /* 4 the bitmap major for now, could change... */ 150 __le32 version; /* 4 the bitmap major for now, could change... */
151 __u8 uuid[16]; /* 8 128 bit uuid - must match md device uuid */ 151 __u8 uuid[16]; /* 8 128 bit uuid - must match md device uuid */
152 __u64 events; /* 24 event counter for the bitmap (1)*/ 152 __le64 events; /* 24 event counter for the bitmap (1)*/
153 __u64 events_cleared;/*32 event counter when last bit cleared (2) */ 153 __le64 events_cleared;/*32 event counter when last bit cleared (2) */
154 __u64 sync_size; /* 40 the size of the md device's sync range(3) */ 154 __le64 sync_size; /* 40 the size of the md device's sync range(3) */
155 __u32 state; /* 48 bitmap state information */ 155 __le32 state; /* 48 bitmap state information */
156 __u32 chunksize; /* 52 the bitmap chunk size in bytes */ 156 __le32 chunksize; /* 52 the bitmap chunk size in bytes */
157 __u32 daemon_sleep; /* 56 seconds between disk flushes */ 157 __le32 daemon_sleep; /* 56 seconds between disk flushes */
158 __u32 write_behind; /* 60 number of outstanding write-behind writes */ 158 __le32 write_behind; /* 60 number of outstanding write-behind writes */
159 159
160 __u8 pad[256 - 64]; /* set to zero */ 160 __u8 pad[256 - 64]; /* set to zero */
161} bitmap_super_t; 161} bitmap_super_t;