linux/drivers/md
Darrick J. Wong ac81b2ee45 [PATCH] make dm-mirror not issue invalid resync requests
I've been attempting to set up a (Host)RAID mirror with dm_mirror on
2.6.14.3, and I've been having a strange little problem.  The configuration
in question is a set of 9GB SCSI disks that have 17942584 sectors.  I set
up the dm_mirror table as such:

0 17942528 mirror core 2 2048 nosync 2 8:48 0 8:64 0

If I'm not mistaken, this sets up a 9GB RAID1 mriror with 1MB stripes
across both SCSI disks.  The sector count of the dm device is less than the
size of the disks, so we shouldn't fall off the end.  However, I always get
the messages like this in dmesg when I set up the dm table:

attempt to access beyond end of device
sdd: rw=0, want=17958656, limit=17942584

Clearly, something is trying to read sectors past the end of the drive.  I
traced it down to the __rh_recovery_prepare function in dm-raid1.c, which
gets called when we're putting the mirror set together.  This function
calls the dirty region log's get_resync_work function to see if there's any
resync that needs to be done, and queues up any areas that are out of sync.
 The log's get_resync_work function is actually a pointer to the
core_get_resync_work function in dm-log.c.

The core_get_resync_work function queries a bitset lc->sync_bits to find
out if there are any regions that are out of date (i.e.  the bit is 0),
which is where the problem occurs.  If every bit in lc->sync_bits is 1
(which is the case when we've just configured a new RAID1 with the nosync
option), the find_next_zero_bit does NOT return the size parameter
(lc->region_count in this case), it returns the size parameter rounded up
to the nearest multiple of 32!  I don't know if this is intentional, but
i386 and x86_64 both exhibit this behavior.

In any case, the statement "if (*region == lc->region_count)" looks like
it's supposed to catch the case where are no regions to resync and
return 0.  Since find_next_zero_bit apparently has a habit of returning
a value that's larger than lc->region_count, the enclosed patch changes
the equality test to a greater-than test so that we don't try to resync
areas outside of the RAID1 region.  Seeing as the HostRAID metadata
lives just past the end of the RAID1 data, mucking around in that area
is not a good idea.

I suppose another way to fix this would be to amend find_next_zero_bit so
that it doesn't return values larger than "size", but I don't know if
there's a reason for the current behavior.

Signed-Off-By: Darrick J. Wong <djwong@us.ibm.com>
Acked-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-06 08:34:01 -08:00
..
raid6test [PATCH] RAID6 Altivec fix 2005-09-17 11:49:58 -07:00
.gitignore gitignore: misc files 2006-01-01 22:21:50 +01:00
Kconfig Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
Makefile [PATCH] md: optimised resync using Bitmap based intent logging 2005-06-21 19:07:43 -07:00
bitmap.c [PATCH] md: don't pass a NULL file* into ->prepare_write() 2005-11-18 07:49:46 -08:00
dm-bio-list.h [PATCH] device-mapper snapshot: bio_list fix 2005-11-22 09:14:31 -08:00
dm-bio-record.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
dm-crypt.c [PATCH] dm-crypt: zero key before freeing it 2006-01-06 08:34:01 -08:00
dm-emc.c [PATCH] device-mapper dm-emc: Fix a memset 2005-05-05 16:36:46 -07:00
dm-exception-store.c [PATCH] vfree and kfree cleanup in drivers/ 2005-09-10 10:06:30 -07:00
dm-hw-handler.c [PATCH] device-mapper: Some missing statics 2005-05-05 16:36:46 -07:00
dm-hw-handler.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
dm-io.c [PATCH] gfp flags annotations - part 1 2005-10-08 15:00:57 -07:00
dm-io.h [PATCH] device-mapper: remove unused definition 2006-01-06 08:34:00 -08:00
dm-ioctl.c [PATCH] device-mapper ioctl: add skip lock_fs flag 2006-01-06 08:34:01 -08:00
dm-linear.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
dm-log.c [PATCH] make dm-mirror not issue invalid resync requests 2006-01-06 08:34:01 -08:00
dm-log.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
dm-mpath.c [PATCH] device-mapper dm-mpath: endio spinlock fix 2005-11-22 09:14:31 -08:00
dm-mpath.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
dm-path-selector.c [PATCH] device-mapper: Some missing statics 2005-05-05 16:36:46 -07:00
dm-path-selector.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
dm-raid1.c [PATCH] device-mapper raid1: add default mirror 2006-01-06 08:34:00 -08:00
dm-round-robin.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
dm-snap.c [PATCH] device-mapper snapshot: metadata reading separation 2006-01-06 08:34:00 -08:00
dm-snap.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
dm-stripe.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
dm-table.c [SCSI] seperate max_sectors from max_hw_sectors 2005-12-15 15:11:40 -08:00
dm-target.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
dm-zero.c [PATCH] device-mapper: Some missing statics 2005-05-05 16:36:46 -07:00
dm.c [PATCH] device-mapper: make lock_fs optional 2006-01-06 08:34:01 -08:00
dm.h [PATCH] device-mapper: make lock_fs optional 2006-01-06 08:34:01 -08:00
faulty.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
kcopyd.c [PATCH] drivers/md/kcopyd.c: #if 0 kcopyd_cancel() 2006-01-06 08:34:01 -08:00
kcopyd.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
linear.c [BLOCK] Unify the seperate read/write io stat fields into arrays 2005-11-01 09:26:16 +01:00
md.c [PATCH] md: Change case of raid level reported in sys/mdX/md/level 2005-12-19 16:47:50 -08:00
mktables.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
multipath.c [PATCH] md: convert 'faulty' and 'in_sync' fields to bits in 'flags' field 2005-11-09 07:56:38 -08:00
raid0.c [BLOCK] Unify the seperate read/write io stat fields into arrays 2005-11-01 09:26:16 +01:00
raid1.c [PATCH] md: fix a use-after-free bug in raid1 2005-12-12 09:06:04 -08:00
raid5.c [PATCH] md: use correct size of raid5 stripe cache when measuring how full it is 2005-12-12 09:06:04 -08:00
raid6.h [PATCH] RAID6 Altivec fix 2005-09-17 11:49:58 -07:00
raid6algos.c [PATCH] RAID6 Altivec fix 2005-09-17 11:49:58 -07:00
raid6altivec.uc [PATCH] RAID6 Altivec fix 2005-09-17 11:49:58 -07:00
raid6int.uc Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
raid6main.c [PATCH] md: fix --re-add for raid1 and raid6 2005-11-28 14:42:26 -08:00
raid6mmx.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
raid6recov.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
raid6sse1.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
raid6sse2.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
raid6x86.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
raid10.c [PATCH] md: improve read speed to raid10 arrays using 'far copies' 2005-11-28 14:42:25 -08:00
unroll.pl Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
xor.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00