linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 000 of 4] md: Introduction - bugfix patches for md.
@ 2006-10-20  3:25 NeilBrown
  2006-10-20  3:25 ` [PATCH 001 of 4] md: Fix calculation of ->degraded for multipath and raid10 NeilBrown
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: NeilBrown @ 2006-10-20  3:25 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-raid, linux-kernel, stable

Following are 4 bugfix patches for md.
The first is suitable for 2.6.18.2.  All are suitable for 2.6.19.

Thanks,
NeilBrown


 [PATCH 001 of 4] md: Fix calculation of ->degraded for multipath and raid10
 [PATCH 002 of 4] md: Add another COMPAT_IOCTL for md.
 [PATCH 003 of 4] md: Endian annotation for v1 superblock access.
 [PATCH 004 of 4] md: Endian annotations for the bitmap superblock

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 001 of 4] md: Fix calculation of ->degraded for multipath and raid10
  2006-10-20  3:25 [PATCH 000 of 4] md: Introduction - bugfix patches for md NeilBrown
@ 2006-10-20  3:25 ` NeilBrown
  2006-10-20  3:25 ` [PATCH 002 of 4] md: Add another COMPAT_IOCTL for md NeilBrown
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: NeilBrown @ 2006-10-20  3:25 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-raid, linux-kernel, stable


Two less-used md personalities have bugs in the calculation of 
 ->degraded (the extent to which the array is degraded).

Signed-off-by: Neil Brown <neilb@suse.de>

### Diffstat output
 ./drivers/md/multipath.c |    2 +-
 ./drivers/md/raid10.c    |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff .prev/drivers/md/multipath.c ./drivers/md/multipath.c
--- .prev/drivers/md/multipath.c	2006-10-20 11:41:02.000000000 +1000
+++ ./drivers/md/multipath.c	2006-10-20 12:00:56.000000000 +1000
@@ -501,7 +501,7 @@ static int multipath_run (mddev_t *mddev
 			mdname(mddev));
 		goto out_free_conf;
 	}
-	mddev->degraded = conf->raid_disks = conf->working_disks;
+	mddev->degraded = conf->raid_disks - conf->working_disks;
 
 	conf->pool = mempool_create_kzalloc_pool(NR_RESERVED_BUFS,
 						 sizeof(struct multipath_bh));

diff .prev/drivers/md/raid10.c ./drivers/md/raid10.c
--- .prev/drivers/md/raid10.c	2006-10-20 11:41:02.000000000 +1000
+++ ./drivers/md/raid10.c	2006-10-20 12:00:56.000000000 +1000
@@ -2079,7 +2079,7 @@ static int run(mddev_t *mddev)
 		disk = conf->mirrors + i;
 
 		if (!disk->rdev ||
-		    !test_bit(In_sync, &rdev->flags)) {
+		    !test_bit(In_sync, &disk->rdev->flags)) {
 			disk->head_position = 0;
 			mddev->degraded++;
 		}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 002 of 4] md: Add another COMPAT_IOCTL for md.
  2006-10-20  3:25 [PATCH 000 of 4] md: Introduction - bugfix patches for md NeilBrown
  2006-10-20  3:25 ` [PATCH 001 of 4] md: Fix calculation of ->degraded for multipath and raid10 NeilBrown
@ 2006-10-20  3:25 ` NeilBrown
  2006-10-20  3:25 ` [PATCH 003 of 4] md: Endian annotation for v1 superblock access NeilBrown
  2006-10-20  3:25 ` [PATCH 004 of 4] md: Endian annotations for the bitmap superblock NeilBrown
  3 siblings, 0 replies; 5+ messages in thread
From: NeilBrown @ 2006-10-20  3:25 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-raid, linux-kernel


.. so that you can use bitmaps with 32bit userspace on a 
64 bit kernel.

Signed-off-by: Neil Brown <neilb@suse.de>

### Diffstat output
 ./include/linux/compat_ioctl.h |    1 +
 1 file changed, 1 insertion(+)

diff .prev/include/linux/compat_ioctl.h ./include/linux/compat_ioctl.h
--- .prev/include/linux/compat_ioctl.h	2006-10-20 11:49:14.000000000 +1000
+++ ./include/linux/compat_ioctl.h	2006-10-20 12:00:56.000000000 +1000
@@ -131,6 +131,7 @@ COMPATIBLE_IOCTL(RUN_ARRAY)
 COMPATIBLE_IOCTL(STOP_ARRAY)
 COMPATIBLE_IOCTL(STOP_ARRAY_RO)
 COMPATIBLE_IOCTL(RESTART_ARRAY_RW)
+COMPATIBLE_IOCTL(GET_BITMAP_FILE)
 ULONG_IOCTL(SET_BITMAP_FILE)
 /* DM */
 COMPATIBLE_IOCTL(DM_VERSION_32)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 003 of 4] md: Endian annotation for v1 superblock access.
  2006-10-20  3:25 [PATCH 000 of 4] md: Introduction - bugfix patches for md NeilBrown
  2006-10-20  3:25 ` [PATCH 001 of 4] md: Fix calculation of ->degraded for multipath and raid10 NeilBrown
  2006-10-20  3:25 ` [PATCH 002 of 4] md: Add another COMPAT_IOCTL for md NeilBrown
@ 2006-10-20  3:25 ` NeilBrown
  2006-10-20  3:25 ` [PATCH 004 of 4] md: Endian annotations for the bitmap superblock NeilBrown
  3 siblings, 0 replies; 5+ messages in thread
From: NeilBrown @ 2006-10-20  3:25 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-raid, linux-kernel


Includes a couple of bugfixed found by sparse.

Signed-off-by: Neil Brown <neilb@suse.de>

### Diffstat output
 ./drivers/md/md.c           |   13 +++++----
 ./include/linux/raid/md_p.h |   58 ++++++++++++++++++++++----------------------
 2 files changed, 36 insertions(+), 35 deletions(-)

diff .prev/drivers/md/md.c ./drivers/md/md.c
--- .prev/drivers/md/md.c	2006-10-20 11:49:17.000000000 +1000
+++ ./drivers/md/md.c	2006-10-20 12:00:57.000000000 +1000
@@ -974,12 +974,13 @@ static void super_90_sync(mddev_t *mddev
  * version 1 superblock
  */
 
-static unsigned int calc_sb_1_csum(struct mdp_superblock_1 * sb)
+static __le32 calc_sb_1_csum(struct mdp_superblock_1 * sb)
 {
-	unsigned int disk_csum, csum;
+	__le32 disk_csum;
+	u32 csum;
 	unsigned long long newcsum;
 	int size = 256 + le32_to_cpu(sb->max_dev)*2;
-	unsigned int *isuper = (unsigned int*)sb;
+	__le32 *isuper = (__le32*)sb;
 	int i;
 
 	disk_csum = sb->sb_csum;
@@ -989,7 +990,7 @@ static unsigned int calc_sb_1_csum(struc
 		newcsum += le32_to_cpu(*isuper++);
 
 	if (size == 2)
-		newcsum += le16_to_cpu(*(unsigned short*) isuper);
+		newcsum += le16_to_cpu(*(__le16*) isuper);
 
 	csum = (newcsum & 0xffffffff) + (newcsum >> 32);
 	sb->sb_csum = disk_csum;
@@ -1106,7 +1107,7 @@ static int super_1_load(mdk_rdev_t *rdev
 	if (le32_to_cpu(sb->chunksize))
 		rdev->size &= ~((sector_t)le32_to_cpu(sb->chunksize)/2 - 1);
 
-	if (le32_to_cpu(sb->size) > rdev->size*2)
+	if (le64_to_cpu(sb->size) > rdev->size*2)
 		return -EINVAL;
 	return ret;
 }
@@ -1228,7 +1229,7 @@ static void super_1_sync(mddev_t *mddev,
 	else
 		sb->resync_offset = cpu_to_le64(0);
 
-	sb->cnt_corrected_read = atomic_read(&rdev->corrected_errors);
+	sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
 
 	sb->raid_disks = cpu_to_le32(mddev->raid_disks);
 	sb->size = cpu_to_le64(mddev->size<<1);

diff .prev/include/linux/raid/md_p.h ./include/linux/raid/md_p.h
--- .prev/include/linux/raid/md_p.h	2006-10-20 11:41:01.000000000 +1000
+++ ./include/linux/raid/md_p.h	2006-10-20 12:00:57.000000000 +1000
@@ -206,52 +206,52 @@ static inline __u64 md_event(mdp_super_t
  */
 struct mdp_superblock_1 {
 	/* constant array information - 128 bytes */
-	__u32	magic;		/* MD_SB_MAGIC: 0xa92b4efc - little endian */
-	__u32	major_version;	/* 1 */
-	__u32	feature_map;	/* bit 0 set if 'bitmap_offset' is meaningful */
-	__u32	pad0;		/* always set to 0 when writing */
+	__le32	magic;		/* MD_SB_MAGIC: 0xa92b4efc - little endian */
+	__le32	major_version;	/* 1 */
+	__le32	feature_map;	/* bit 0 set if 'bitmap_offset' is meaningful */
+	__le32	pad0;		/* always set to 0 when writing */
 
 	__u8	set_uuid[16];	/* user-space generated. */
 	char	set_name[32];	/* set and interpreted by user-space */
 
-	__u64	ctime;		/* lo 40 bits are seconds, top 24 are microseconds or 0*/
-	__u32	level;		/* -4 (multipath), -1 (linear), 0,1,4,5 */
-	__u32	layout;		/* only for raid5 and raid10 currently */
-	__u64	size;		/* used size of component devices, in 512byte sectors */
-
-	__u32	chunksize;	/* in 512byte sectors */
-	__u32	raid_disks;
-	__u32	bitmap_offset;	/* sectors after start of superblock that bitmap starts
+	__le64	ctime;		/* lo 40 bits are seconds, top 24 are microseconds or 0*/
+	__le32	level;		/* -4 (multipath), -1 (linear), 0,1,4,5 */
+	__le32	layout;		/* only for raid5 and raid10 currently */
+	__le64	size;		/* used size of component devices, in 512byte sectors */
+
+	__le32	chunksize;	/* in 512byte sectors */
+	__le32	raid_disks;
+	__le32	bitmap_offset;	/* sectors after start of superblock that bitmap starts
 				 * NOTE: signed, so bitmap can be before superblock
 				 * only meaningful of feature_map[0] is set.
 				 */
 
 	/* These are only valid with feature bit '4' */
-	__u32	new_level;	/* new level we are reshaping to		*/
-	__u64	reshape_position;	/* next address in array-space for reshape */
-	__u32	delta_disks;	/* change in number of raid_disks		*/
-	__u32	new_layout;	/* new layout					*/
-	__u32	new_chunk;	/* new chunk size (bytes)			*/
+	__le32	new_level;	/* new level we are reshaping to		*/
+	__le64	reshape_position;	/* next address in array-space for reshape */
+	__le32	delta_disks;	/* change in number of raid_disks		*/
+	__le32	new_layout;	/* new layout					*/
+	__le32	new_chunk;	/* new chunk size (bytes)			*/
 	__u8	pad1[128-124];	/* set to 0 when written */
 
 	/* constant this-device information - 64 bytes */
-	__u64	data_offset;	/* sector start of data, often 0 */
-	__u64	data_size;	/* sectors in this device that can be used for data */
-	__u64	super_offset;	/* sector start of this superblock */
-	__u64	recovery_offset;/* sectors before this offset (from data_offset) have been recovered */
-	__u32	dev_number;	/* permanent identifier of this  device - not role in raid */
-	__u32	cnt_corrected_read; /* number of read errors that were corrected by re-writing */
+	__le64	data_offset;	/* sector start of data, often 0 */
+	__le64	data_size;	/* sectors in this device that can be used for data */
+	__le64	super_offset;	/* sector start of this superblock */
+	__le64	recovery_offset;/* sectors before this offset (from data_offset) have been recovered */
+	__le32	dev_number;	/* permanent identifier of this  device - not role in raid */
+	__le32	cnt_corrected_read; /* number of read errors that were corrected by re-writing */
 	__u8	device_uuid[16]; /* user-space setable, ignored by kernel */
 	__u8	devflags;	/* per-device flags.  Only one defined...*/
 #define	WriteMostly1	1	/* mask for writemostly flag in above */
 	__u8	pad2[64-57];	/* set to 0 when writing */
 
 	/* array state information - 64 bytes */
-	__u64	utime;		/* 40 bits second, 24 btes microseconds */
-	__u64	events;		/* incremented when superblock updated */
-	__u64	resync_offset;	/* data before this offset (from data_offset) known to be in sync */
-	__u32	sb_csum;	/* checksum upto devs[max_dev] */
-	__u32	max_dev;	/* size of devs[] array to consider */
+	__le64	utime;		/* 40 bits second, 24 btes microseconds */
+	__le64	events;		/* incremented when superblock updated */
+	__le64	resync_offset;	/* data before this offset (from data_offset) known to be in sync */
+	__le32	sb_csum;	/* checksum upto devs[max_dev] */
+	__le32	max_dev;	/* size of devs[] array to consider */
 	__u8	pad3[64-32];	/* set to 0 when writing */
 
 	/* device state information. Indexed by dev_number.
@@ -260,7 +260,7 @@ struct mdp_superblock_1 {
 	 * into the 'roles' value.  If a device is spare or faulty, then it doesn't
 	 * have a meaningful role.
 	 */
-	__u16	dev_roles[0];	/* role in array, or 0xffff for a spare, or 0xfffe for faulty */
+	__le16	dev_roles[0];	/* role in array, or 0xffff for a spare, or 0xfffe for faulty */
 };
 
 /* feature_map bits */

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 004 of 4] md: Endian annotations for the bitmap superblock
  2006-10-20  3:25 [PATCH 000 of 4] md: Introduction - bugfix patches for md NeilBrown
                   ` (2 preceding siblings ...)
  2006-10-20  3:25 ` [PATCH 003 of 4] md: Endian annotation for v1 superblock access NeilBrown
@ 2006-10-20  3:25 ` NeilBrown
  3 siblings, 0 replies; 5+ messages in thread
From: NeilBrown @ 2006-10-20  3:25 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-raid, linux-kernel


And a couple of bug fixes found by sparse.

Signed-off-by: Neil Brown <neilb@suse.de>

### Diffstat output
 ./drivers/md/bitmap.c         |   10 +++++-----
 ./include/linux/raid/bitmap.h |   20 ++++++++++----------
 2 files changed, 15 insertions(+), 15 deletions(-)

diff .prev/drivers/md/bitmap.c ./drivers/md/bitmap.c
--- .prev/drivers/md/bitmap.c	2006-10-20 11:49:19.000000000 +1000
+++ ./drivers/md/bitmap.c	2006-10-20 12:00:58.000000000 +1000
@@ -536,7 +536,7 @@ static int bitmap_read_sb(struct bitmap 
 		printk(KERN_INFO "%s: bitmap file is out of date (%llu < %llu) "
 			"-- forcing full recovery\n", bmname(bitmap), events,
 			(unsigned long long) bitmap->mddev->events);
-		sb->state |= BITMAP_STALE;
+		sb->state |= cpu_to_le32(BITMAP_STALE);
 	}
 success:
 	/* assign fields using values from superblock */
@@ -544,11 +544,11 @@ success:
 	bitmap->daemon_sleep = daemon_sleep;
 	bitmap->daemon_lastrun = jiffies;
 	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)
 		bitmap->flags |= BITMAP_HOSTENDIAN;
 	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;
 	err = 0;
 out:
@@ -578,9 +578,9 @@ static void bitmap_mask_state(struct bit
 	spin_unlock_irqrestore(&bitmap->lock, flags);
 	sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0);
 	switch (op) {
-		case MASK_SET: sb->state |= bits;
+		case MASK_SET: sb->state |= cpu_to_le32(bits);
 				break;
-		case MASK_UNSET: sb->state &= ~bits;
+		case MASK_UNSET: sb->state &= cpu_to_le32(~bits);
 				break;
 		default: BUG();
 	}

diff .prev/include/linux/raid/bitmap.h ./include/linux/raid/bitmap.h
--- .prev/include/linux/raid/bitmap.h	2006-10-20 11:41:01.000000000 +1000
+++ ./include/linux/raid/bitmap.h	2006-10-20 12:00:58.000000000 +1000
@@ -146,16 +146,16 @@ enum bitmap_state {
 
 /* the superblock at the front of the bitmap file -- little endian */
 typedef struct bitmap_super_s {
-	__u32 magic;        /*  0  BITMAP_MAGIC */
-	__u32 version;      /*  4  the bitmap major for now, could change... */
-	__u8  uuid[16];     /*  8  128 bit uuid - must match md device uuid */
-	__u64 events;       /* 24  event counter for the bitmap (1)*/
-	__u64 events_cleared;/*32  event counter when last bit cleared (2) */
-	__u64 sync_size;    /* 40  the size of the md device's sync range(3) */
-	__u32 state;        /* 48  bitmap state information */
-	__u32 chunksize;    /* 52  the bitmap chunk size in bytes */
-	__u32 daemon_sleep; /* 56  seconds between disk flushes */
-	__u32 write_behind; /* 60  number of outstanding write-behind writes */
+	__le32 magic;        /*  0  BITMAP_MAGIC */
+	__le32 version;      /*  4  the bitmap major for now, could change... */
+	__u8  uuid[16];      /*  8  128 bit uuid - must match md device uuid */
+	__le64 events;       /* 24  event counter for the bitmap (1)*/
+	__le64 events_cleared;/*32  event counter when last bit cleared (2) */
+	__le64 sync_size;    /* 40  the size of the md device's sync range(3) */
+	__le32 state;        /* 48  bitmap state information */
+	__le32 chunksize;    /* 52  the bitmap chunk size in bytes */
+	__le32 daemon_sleep; /* 56  seconds between disk flushes */
+	__le32 write_behind; /* 60  number of outstanding write-behind writes */
 
 	__u8  pad[256 - 64]; /* set to zero */
 } bitmap_super_t;

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-10-20  3:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-20  3:25 [PATCH 000 of 4] md: Introduction - bugfix patches for md NeilBrown
2006-10-20  3:25 ` [PATCH 001 of 4] md: Fix calculation of ->degraded for multipath and raid10 NeilBrown
2006-10-20  3:25 ` [PATCH 002 of 4] md: Add another COMPAT_IOCTL for md NeilBrown
2006-10-20  3:25 ` [PATCH 003 of 4] md: Endian annotation for v1 superblock access NeilBrown
2006-10-20  3:25 ` [PATCH 004 of 4] md: Endian annotations for the bitmap superblock NeilBrown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).