Skip to content

Commit

Permalink
[PATCH] md: locking fix
Browse files Browse the repository at this point in the history
- fix mddev_lock() usage bugs in md_attr_show() and md_attr_store().
  [they did not anticipate the possibility of getting a signal]

- remove mddev_lock_uninterruptible() [unused]

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Acked-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Ingo Molnar authored and Linus Torvalds committed Apr 20, 2006
1 parent 72b38d4 commit 5dc5cf7
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,6 @@ static inline int mddev_lock(mddev_t * mddev)
return mutex_lock_interruptible(&mddev->reconfig_mutex);
}

static inline void mddev_lock_uninterruptible(mddev_t * mddev)
{
mutex_lock(&mddev->reconfig_mutex);
}

static inline int mddev_trylock(mddev_t * mddev)
{
return mutex_trylock(&mddev->reconfig_mutex);
Expand Down Expand Up @@ -2458,9 +2453,11 @@ md_attr_show(struct kobject *kobj, struct attribute *attr, char *page)

if (!entry->show)
return -EIO;
mddev_lock(mddev);
rv = entry->show(mddev, page);
mddev_unlock(mddev);
rv = mddev_lock(mddev);
if (!rv) {
rv = entry->show(mddev, page);
mddev_unlock(mddev);
}
return rv;
}

Expand All @@ -2474,9 +2471,11 @@ md_attr_store(struct kobject *kobj, struct attribute *attr,

if (!entry->store)
return -EIO;
mddev_lock(mddev);
rv = entry->store(mddev, page, length);
mddev_unlock(mddev);
rv = mddev_lock(mddev);
if (!rv) {
rv = entry->store(mddev, page, length);
mddev_unlock(mddev);
}
return rv;
}

Expand Down Expand Up @@ -4341,8 +4340,9 @@ static int md_seq_show(struct seq_file *seq, void *v)
return 0;
}

if (mddev_lock(mddev)!=0)
if (mddev_lock(mddev) < 0)
return -EINTR;

if (mddev->pers || mddev->raid_disks || !list_empty(&mddev->disks)) {
seq_printf(seq, "%s : %sactive", mdname(mddev),
mddev->pers ? "" : "in");
Expand Down

0 comments on commit 5dc5cf7

Please sign in to comment.