Skip to content

Commit

Permalink
MD: fix sleep in atomic
Browse files Browse the repository at this point in the history
bioset_free() will take a mutex, so can't get called with spinlock hold.

Fix: 5a85071(md: use a separate bio_set for synchronous IO.)
Cc: NeilBrown <[email protected]>
Signed-off-by: Shaohua Li <[email protected]>
  • Loading branch information
shligit committed Jul 3, 2017
1 parent 7f053a6 commit 7184ef8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,17 +475,17 @@ static void mddev_delayed_delete(struct work_struct *ws);

static void mddev_put(struct mddev *mddev)
{
struct bio_set *bs = NULL, *sync_bs = NULL;

if (!atomic_dec_and_lock(&mddev->active, &all_mddevs_lock))
return;
if (!mddev->raid_disks && list_empty(&mddev->disks) &&
mddev->ctime == 0 && !mddev->hold_active) {
/* Array is not configured at all, and not held active,
* so destroy it */
list_del_init(&mddev->all_mddevs);
if (mddev->bio_set)
bioset_free(mddev->bio_set);
if (mddev->sync_set)
bioset_free(mddev->sync_set);
bs = mddev->bio_set;
sync_bs = mddev->sync_set;
mddev->bio_set = NULL;
mddev->sync_set = NULL;
if (mddev->gendisk) {
Expand All @@ -500,6 +500,10 @@ static void mddev_put(struct mddev *mddev)
kfree(mddev);
}
spin_unlock(&all_mddevs_lock);
if (bs)
bioset_free(bs);
if (sync_bs)
bioset_free(sync_bs);
}

static void md_safemode_timeout(unsigned long data);
Expand Down

0 comments on commit 7184ef8

Please sign in to comment.