Commit 4f2e639a authored by NeilBrown's avatar NeilBrown Committed by Linus Torvalds

[PATCH] md: endian annotations for the bitmap superblock

And a couple of bug fixes found by sparse.
Signed-off-by: default avatarNeil Brown <neilb@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 1c05b4bc
...@@ -536,7 +536,7 @@ static int bitmap_read_sb(struct bitmap *bitmap) ...@@ -536,7 +536,7 @@ static int bitmap_read_sb(struct bitmap *bitmap)
printk(KERN_INFO "%s: bitmap file is out of date (%llu < %llu) " printk(KERN_INFO "%s: bitmap file is out of date (%llu < %llu) "
"-- forcing full recovery\n", bmname(bitmap), events, "-- forcing full recovery\n", bmname(bitmap), events,
(unsigned long long) bitmap->mddev->events); (unsigned long long) bitmap->mddev->events);
sb->state |= BITMAP_STALE; sb->state |= cpu_to_le32(BITMAP_STALE);
} }
success: success:
/* assign fields using values from superblock */ /* assign fields using values from superblock */
...@@ -544,11 +544,11 @@ static int bitmap_read_sb(struct bitmap *bitmap) ...@@ -544,11 +544,11 @@ static int bitmap_read_sb(struct bitmap *bitmap)
bitmap->daemon_sleep = daemon_sleep; bitmap->daemon_sleep = daemon_sleep;
bitmap->daemon_lastrun = jiffies; bitmap->daemon_lastrun = jiffies;
bitmap->max_write_behind = write_behind; bitmap->max_write_behind = write_behind;
bitmap->flags |= sb->state; bitmap->flags |= le32_to_cpu(sb->state);
if (le32_to_cpu(sb->version) == BITMAP_MAJOR_HOSTENDIAN) if (le32_to_cpu(sb->version) == BITMAP_MAJOR_HOSTENDIAN)
bitmap->flags |= BITMAP_HOSTENDIAN; bitmap->flags |= BITMAP_HOSTENDIAN;
bitmap->events_cleared = le64_to_cpu(sb->events_cleared); bitmap->events_cleared = le64_to_cpu(sb->events_cleared);
if (sb->state & BITMAP_STALE) if (sb->state & cpu_to_le32(BITMAP_STALE))
bitmap->events_cleared = bitmap->mddev->events; bitmap->events_cleared = bitmap->mddev->events;
err = 0; err = 0;
out: out:
...@@ -578,9 +578,9 @@ static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits, ...@@ -578,9 +578,9 @@ static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits,
spin_unlock_irqrestore(&bitmap->lock, flags); spin_unlock_irqrestore(&bitmap->lock, flags);
sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0); sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0);
switch (op) { switch (op) {
case MASK_SET: sb->state |= bits; case MASK_SET: sb->state |= cpu_to_le32(bits);
break; break;
case MASK_UNSET: sb->state &= ~bits; case MASK_UNSET: sb->state &= cpu_to_le32(~bits);
break; break;
default: BUG(); default: BUG();
} }
......
...@@ -146,16 +146,16 @@ enum bitmap_state { ...@@ -146,16 +146,16 @@ enum bitmap_state {
/* the superblock at the front of the bitmap file -- little endian */ /* the superblock at the front of the bitmap file -- little endian */
typedef struct bitmap_super_s { typedef struct bitmap_super_s {
__u32 magic; /* 0 BITMAP_MAGIC */ __le32 magic; /* 0 BITMAP_MAGIC */
__u32 version; /* 4 the bitmap major for now, could change... */ __le32 version; /* 4 the bitmap major for now, could change... */
__u8 uuid[16]; /* 8 128 bit uuid - must match md device uuid */ __u8 uuid[16]; /* 8 128 bit uuid - must match md device uuid */
__u64 events; /* 24 event counter for the bitmap (1)*/ __le64 events; /* 24 event counter for the bitmap (1)*/
__u64 events_cleared;/*32 event counter when last bit cleared (2) */ __le64 events_cleared;/*32 event counter when last bit cleared (2) */
__u64 sync_size; /* 40 the size of the md device's sync range(3) */ __le64 sync_size; /* 40 the size of the md device's sync range(3) */
__u32 state; /* 48 bitmap state information */ __le32 state; /* 48 bitmap state information */
__u32 chunksize; /* 52 the bitmap chunk size in bytes */ __le32 chunksize; /* 52 the bitmap chunk size in bytes */
__u32 daemon_sleep; /* 56 seconds between disk flushes */ __le32 daemon_sleep; /* 56 seconds between disk flushes */
__u32 write_behind; /* 60 number of outstanding write-behind writes */ __le32 write_behind; /* 60 number of outstanding write-behind writes */
__u8 pad[256 - 64]; /* set to zero */ __u8 pad[256 - 64]; /* set to zero */
} bitmap_super_t; } bitmap_super_t;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment