Skip to content

Commit

Permalink
dm raid: avoid mddev->suspended access
Browse files Browse the repository at this point in the history
Use runtime flag to ensure that an mddev gets suspended/resumed just once.

Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
  • Loading branch information
Heinz Mauelshagen authored and Mike Snitzer committed Jul 25, 2017
1 parent f4af3f8 commit 0cf352e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions drivers/md/dm-raid.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ struct raid_dev {
#define RT_FLAG_RS_BITMAP_LOADED 2
#define RT_FLAG_UPDATE_SBS 3
#define RT_FLAG_RESHAPE_RS 4
#define RT_FLAG_RS_SUSPENDED 5

/* Array elements of 64 bit needed for rebuild/failed disk bits */
#define DISKS_ARRAY_ELEMS ((MAX_RAID_DEVICES + (sizeof(uint64_t) * 8 - 1)) / sizeof(uint64_t) / 8)
Expand Down Expand Up @@ -3169,6 +3170,7 @@ static int raid_ctr(struct dm_target *ti, unsigned int argc, char **argv)
}

mddev_suspend(&rs->md);
set_bit(RT_FLAG_RS_SUSPENDED, &rs->runtime_flags);

/* Try to adjust the raid4/5/6 stripe cache size to the stripe size */
if (rs_is_raid456(rs)) {
Expand Down Expand Up @@ -3626,7 +3628,7 @@ static void raid_postsuspend(struct dm_target *ti)
{
struct raid_set *rs = ti->private;

if (!rs->md.suspended)
if (!test_and_set_bit(RT_FLAG_RS_SUSPENDED, &rs->runtime_flags))
mddev_suspend(&rs->md);

rs->md.ro = 1;
Expand Down Expand Up @@ -3760,7 +3762,7 @@ static int rs_start_reshape(struct raid_set *rs)
return r;

/* Need to be resumed to be able to start reshape, recovery is frozen until raid_resume() though */
if (mddev->suspended)
if (test_and_clear_bit(RT_FLAG_RS_SUSPENDED, &rs->runtime_flags))
mddev_resume(mddev);

/*
Expand All @@ -3787,8 +3789,8 @@ static int rs_start_reshape(struct raid_set *rs)
}

/* Suspend because a resume will happen in raid_resume() */
if (!mddev->suspended)
mddev_suspend(mddev);
set_bit(RT_FLAG_RS_SUSPENDED, &rs->runtime_flags);
mddev_suspend(mddev);

/*
* Now reshape got set up, update superblocks to
Expand Down Expand Up @@ -3884,7 +3886,7 @@ static void raid_resume(struct dm_target *ti)
if (!(rs->ctr_flags & RESUME_STAY_FROZEN_FLAGS))
clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery);

if (mddev->suspended)
if (test_and_clear_bit(RT_FLAG_RS_SUSPENDED, &rs->runtime_flags))
mddev_resume(mddev);
}

Expand Down

0 comments on commit 0cf352e

Please sign in to comment.