Skip to content

Commit

Permalink
Merge tag 'dm-4.8-fixes' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/device-mapper/linux-dm

Pull device mapper fixes from Mike Snitzer:

 - a stable dm-flakey fix to error read IO during the 'down_interval'

 - a DM core suspend fix to establish the SUSPENDED flag before dropping
   the SUSPENDING flag

 - a blk-mq request-based DM (dm-mq) dm_stop_queue() fix to properly
   stop the blk-mq hw_queues (and cancel pending requeue work); also
   set/clear QUEUE_FLAG_STOPPED when stopping/starting the dm-mq
   request_queue.

 - a DM multipath fix to harden locking of in-core state flags in the
   face of concurrent access while handling path failures under heavy
   IO.

 - a few small DM raid fixes to edge cases caught with further testing.

* tag 'dm-4.8-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
  dm raid: fix use of wrong status char during resynchronization
  dm raid: constructor fails on non-zero incompat_features
  dm raid: fix processing of max_recovery_rate constructor flag
  dm: set DMF_SUSPENDED* _before_ clearing DMF_NOFLUSH_SUSPENDING
  dm rq: fix the starting and stopping of blk-mq queues
  dm mpath: add locking to multipath_resume and must_push_back
  dm flakey: error READ bios during the down_interval
  • Loading branch information
torvalds committed Aug 6, 2016
2 parents fff648d + 2a034ec commit d268675
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 22 deletions.
23 changes: 15 additions & 8 deletions drivers/md/dm-flakey.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,16 @@ static int flakey_map(struct dm_target *ti, struct bio *bio)
pb->bio_submitted = true;

/*
* Map reads as normal.
* Map reads as normal only if corrupt_bio_byte set.
*/
if (bio_data_dir(bio) == READ)
goto map_bio;
if (bio_data_dir(bio) == READ) {
/* If flags were specified, only corrupt those that match. */
if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) &&
all_corrupt_bio_flags_match(bio, fc))
goto map_bio;
else
return -EIO;
}

/*
* Drop writes?
Expand Down Expand Up @@ -330,12 +336,13 @@ static int flakey_end_io(struct dm_target *ti, struct bio *bio, int error)

/*
* Corrupt successful READs while in down state.
* If flags were specified, only corrupt those that match.
*/
if (fc->corrupt_bio_byte && !error && pb->bio_submitted &&
(bio_data_dir(bio) == READ) && (fc->corrupt_bio_rw == READ) &&
all_corrupt_bio_flags_match(bio, fc))
corrupt_bio_data(bio, fc);
if (!error && pb->bio_submitted && (bio_data_dir(bio) == READ)) {
if (fc->corrupt_bio_byte)
corrupt_bio_data(bio, fc);
else
return -EIO;
}

return error;
}
Expand Down
24 changes: 20 additions & 4 deletions drivers/md/dm-mpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,13 +507,27 @@ static bool __must_push_back(struct multipath *m)

static bool must_push_back_rq(struct multipath *m)
{
return (test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags) ||
__must_push_back(m));
bool r;
unsigned long flags;

spin_lock_irqsave(&m->lock, flags);
r = (test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags) ||
__must_push_back(m));
spin_unlock_irqrestore(&m->lock, flags);

return r;
}

static bool must_push_back_bio(struct multipath *m)
{
return __must_push_back(m);
bool r;
unsigned long flags;

spin_lock_irqsave(&m->lock, flags);
r = __must_push_back(m);
spin_unlock_irqrestore(&m->lock, flags);

return r;
}

/*
Expand Down Expand Up @@ -1680,12 +1694,14 @@ static void multipath_postsuspend(struct dm_target *ti)
static void multipath_resume(struct dm_target *ti)
{
struct multipath *m = ti->private;
unsigned long flags;

spin_lock_irqsave(&m->lock, flags);
if (test_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags))
set_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags);
else
clear_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags);
smp_mb__after_atomic();
spin_unlock_irqrestore(&m->lock, flags);
}

/*
Expand Down
4 changes: 2 additions & 2 deletions drivers/md/dm-raid.c
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@ static int parse_raid_params(struct raid_set *rs, struct dm_arg_set *as,
}
rs->md.sync_speed_min = (int)value;
} else if (!strcasecmp(key, dm_raid_arg_name_by_flag(CTR_FLAG_MAX_RECOVERY_RATE))) {
if (test_and_set_bit(__CTR_FLAG_MIN_RECOVERY_RATE, &rs->ctr_flags)) {
if (test_and_set_bit(__CTR_FLAG_MAX_RECOVERY_RATE, &rs->ctr_flags)) {
rs->ti->error = "Only one max_recovery_rate argument pair allowed";
return -EINVAL;
}
Expand Down Expand Up @@ -1960,6 +1960,7 @@ static void super_sync(struct mddev *mddev, struct md_rdev *rdev)
sb->data_offset = cpu_to_le64(rdev->data_offset);
sb->new_data_offset = cpu_to_le64(rdev->new_data_offset);
sb->sectors = cpu_to_le64(rdev->sectors);
sb->incompat_features = cpu_to_le32(0);

/* Zero out the rest of the payload after the size of the superblock */
memset(sb + 1, 0, rdev->sb_size - sizeof(*sb));
Expand Down Expand Up @@ -3577,7 +3578,6 @@ static int raid_preresume(struct dm_target *ti)
/* Be prepared for mddev_resume() in raid_resume() */
set_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
if (mddev->recovery_cp && mddev->recovery_cp < MaxSector) {
set_bit(MD_RECOVERY_REQUESTED, &mddev->recovery);
set_bit(MD_RECOVERY_SYNC, &mddev->recovery);
mddev->resync_min = mddev->recovery_cp;
}
Expand Down
20 changes: 19 additions & 1 deletion drivers/md/dm-rq.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ void dm_start_queue(struct request_queue *q)
if (!q->mq_ops)
dm_old_start_queue(q);
else {
queue_flag_clear_unlocked(QUEUE_FLAG_STOPPED, q);
blk_mq_start_stopped_hw_queues(q, true);
blk_mq_kick_requeue_list(q);
}
Expand All @@ -101,8 +102,14 @@ void dm_stop_queue(struct request_queue *q)
{
if (!q->mq_ops)
dm_old_stop_queue(q);
else
else {
spin_lock_irq(q->queue_lock);
queue_flag_set(QUEUE_FLAG_STOPPED, q);
spin_unlock_irq(q->queue_lock);

blk_mq_cancel_requeue_work(q);
blk_mq_stop_hw_queues(q);
}
}

static struct dm_rq_target_io *alloc_old_rq_tio(struct mapped_device *md,
Expand Down Expand Up @@ -864,6 +871,17 @@ static int dm_mq_queue_rq(struct blk_mq_hw_ctx *hctx,
dm_put_live_table(md, srcu_idx);
}

/*
* On suspend dm_stop_queue() handles stopping the blk-mq
* request_queue BUT: even though the hw_queues are marked
* BLK_MQ_S_STOPPED at that point there is still a race that
* is allowing block/blk-mq.c to call ->queue_rq against a
* hctx that it really shouldn't. The following check guards
* against this rarity (albeit _not_ race-free).
*/
if (unlikely(test_bit(BLK_MQ_S_STOPPED, &hctx->state)))
return BLK_MQ_RQ_QUEUE_BUSY;

if (ti->type->busy && ti->type->busy(ti))
return BLK_MQ_RQ_QUEUE_BUSY;

Expand Down
14 changes: 7 additions & 7 deletions drivers/md/dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2082,7 +2082,8 @@ static void unlock_fs(struct mapped_device *md)
* Caller must hold md->suspend_lock
*/
static int __dm_suspend(struct mapped_device *md, struct dm_table *map,
unsigned suspend_flags, int interruptible)
unsigned suspend_flags, int interruptible,
int dmf_suspended_flag)
{
bool do_lockfs = suspend_flags & DM_SUSPEND_LOCKFS_FLAG;
bool noflush = suspend_flags & DM_SUSPEND_NOFLUSH_FLAG;
Expand Down Expand Up @@ -2149,6 +2150,8 @@ static int __dm_suspend(struct mapped_device *md, struct dm_table *map,
* to finish.
*/
r = dm_wait_for_completion(md, interruptible);
if (!r)
set_bit(dmf_suspended_flag, &md->flags);

if (noflush)
clear_bit(DMF_NOFLUSH_SUSPENDING, &md->flags);
Expand Down Expand Up @@ -2210,12 +2213,10 @@ int dm_suspend(struct mapped_device *md, unsigned suspend_flags)

map = rcu_dereference_protected(md->map, lockdep_is_held(&md->suspend_lock));

r = __dm_suspend(md, map, suspend_flags, TASK_INTERRUPTIBLE);
r = __dm_suspend(md, map, suspend_flags, TASK_INTERRUPTIBLE, DMF_SUSPENDED);
if (r)
goto out_unlock;

set_bit(DMF_SUSPENDED, &md->flags);

dm_table_postsuspend_targets(map);

out_unlock:
Expand Down Expand Up @@ -2309,9 +2310,8 @@ static void __dm_internal_suspend(struct mapped_device *md, unsigned suspend_fla
* would require changing .presuspend to return an error -- avoid this
* until there is a need for more elaborate variants of internal suspend.
*/
(void) __dm_suspend(md, map, suspend_flags, TASK_UNINTERRUPTIBLE);

set_bit(DMF_SUSPENDED_INTERNALLY, &md->flags);
(void) __dm_suspend(md, map, suspend_flags, TASK_UNINTERRUPTIBLE,
DMF_SUSPENDED_INTERNALLY);

dm_table_postsuspend_targets(map);
}
Expand Down

0 comments on commit d268675

Please sign in to comment.