Re: 2.6.19-rc6-mm2

From: Neil Brown
Date: Thu Dec 07 2006 - 20:31:58 EST


On Tuesday December 5, jikos@xxxxxxxx wrote:
> On Tue, 5 Dec 2006, Jiri Kosina wrote:
>
> > It seemed to be 100% reproducible - happened on every boot of FC6
> > system, so it was probably triggered by some raid/lvm command executed
> > from init scripts after boot, but I didn't examine it further. As soon
> > as I get to the machine where this happens, I will try to narrow it down
> > to the exact userspace command that triggers it and will let you know
> > (probably this evening).
>
> OK, so more details follow (I am not sure how valuable they are, though).

They do help a bit..

I've found a possible race that could possibly be related to this
BUG. Can you try this patch and see if it helps?

Note: this isn't the final form I would use to fix the race, but if it
makes a difference, then it tells me I am on the right track.

Thanks,
NeilBrown


Signed-off-by: Neil Brown <neilb@xxxxxxx>

### Diffstat output
./drivers/md/md.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff .prev/drivers/md/md.c ./drivers/md/md.c
--- .prev/drivers/md/md.c 2006-12-06 14:49:20.000000000 +1100
+++ ./drivers/md/md.c 2006-12-07 10:29:40.000000000 +1100
@@ -222,10 +222,14 @@ static inline mddev_t *mddev_get(mddev_t
return mddev;
}

+static DEFINE_MUTEX(disks_mutex);
static void mddev_put(mddev_t *mddev)
{
- if (!atomic_dec_and_lock(&mddev->active, &all_mddevs_lock))
+ mutex_lock(&disks_mutex);
+ if (!atomic_dec_and_lock(&mddev->active, &all_mddevs_lock)) {
+ mutex_unlock(&disks_mutex);
return;
+ }
list_del(&mddev->all_mddevs);
spin_unlock(&all_mddevs_lock);

@@ -234,6 +238,7 @@ static void mddev_put(mddev_t *mddev)
blk_cleanup_queue(mddev->queue);
mddev->queue = NULL;
kobject_unregister(&mddev->kobj);
+ mutex_unlock(&disks_mutex);
}

static mddev_t * mddev_find(dev_t unit)
@@ -2948,7 +2953,6 @@ int mdp_major = 0;

static struct kobject *md_probe(dev_t dev, int *part, void *data)
{
- static DEFINE_MUTEX(disks_mutex);
mddev_t *mddev = mddev_find(dev);
struct gendisk *disk;
int partitioned = (MAJOR(dev) != MD_MAJOR);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/