[xenial:linux-azure,05/15] dm mpath: fix missing call of path selector type->end_io
diff mbox series

Message ID 20191127201820.32174-6-marcelo.cerri@canonical.com
State New
Headers show
  • Bug #1848739 - [linux-azure] Patch to prevent possible data corruption
Related show

Commit Message

Marcelo Henrique Cerri Nov. 27, 2019, 8:18 p.m. UTC
From: Yufen Yu <yuyufen@huawei.com>

BugLink: https://bugs.launchpad.net/bugs/1848739

After commit 396eaf21ee17 ("blk-mq: improve DM's blk-mq IO merging via
blk_insert_cloned_request feedback"), map_request() will requeue the tio
when issued clone request return BLK_STS_RESOURCE or BLK_STS_DEV_RESOURCE.

Thus, if device driver status is error, a tio may be requeued multiple
times until the return value is not DM_MAPIO_REQUEUE.  That means
type->start_io may be called multiple times, while type->end_io is only
called when IO complete.

In fact, even without commit 396eaf21ee17, setup_clone() failure can
also cause tio requeue and associated missed call to type->end_io.

The service-time path selector selects path based on in_flight_size,
which is increased by st_start_io() and decreased by st_end_io().
Missed calls to st_end_io() can lead to in_flight_size count error and
will cause the selector to make the wrong choice.  In addition,
queue-length path selector will also be affected.

To fix the problem, call type->end_io in ->release_clone_rq before tio
requeue.  map_info is passed to ->release_clone_rq() for map_request()
error path that result in requeue.

Fixes: 396eaf21ee17 ("blk-mq: improve DM's blk-mq IO merging via blk_insert_cloned_request feedback")
Cc: stable@vger.kernl.org
Signed-off-by: Yufen Yu <yuyufen@huawei.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
(cherry picked from commit 5de719e3d01b4abe0de0d7b857148a880ff2a90b)
[marcelo.cerri@canonical.com: This patch was already partially applied
 before via upstream stable updates. This patch adds the remaining
 changes after the inclusion of 396eaf21ee17 ("blk-mq: improve DM's
 blk-mq IO merging via blk_insert_cloned_request feedback").]
Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
 drivers/md/dm-rq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff mbox series

diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
index ecbf1f422f94..134cd855ba35 100644
--- a/drivers/md/dm-rq.c
+++ b/drivers/md/dm-rq.c
@@ -498,7 +498,7 @@  static int map_request(struct dm_rq_target_io *tio)
 		ret = dm_dispatch_clone_request(clone, rq);
 		if (ret == BLK_STS_RESOURCE) {
-			tio->ti->type->release_clone_rq(clone);
+			tio->ti->type->release_clone_rq(clone, &tio->info);
 			tio->clone = NULL;
 			if (!rq->q->mq_ops)