aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-04-26 03:40:37 -0400
committerMike Snitzer <snitzer@redhat.com>2017-05-01 18:19:03 -0400
commit7ed8578a96ad98231d8bf6388f776e034673e18a (patch)
tree91d1d822e1e9c1e04343486df3860b93b9c57836
parentb79f10eefd4bc450a595b93c75e3a9d159ac3885 (diff)
dm rq: change ->rq_end_io calling conventions
Instead of returning either a DM_ENDIO_* constant or an error code, add a new DM_ENDIO_DONE value that means keep errno as is. This allows us to easily keep the existing error code in case where we can't push back, and it also preparares for the new block level status codes with strict type checking. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
-rw-r--r--drivers/md/dm-mpath.c13
-rw-r--r--drivers/md/dm-rq.c17
-rw-r--r--include/linux/device-mapper.h1
3 files changed, 20 insertions, 11 deletions
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index 8b394a08d427..926a6bcb32c8 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -1469,6 +1469,7 @@ static int multipath_end_io(struct dm_target *ti, struct request *clone,
1469{ 1469{
1470 struct dm_mpath_io *mpio = get_mpio(map_context); 1470 struct dm_mpath_io *mpio = get_mpio(map_context);
1471 struct pgpath *pgpath = mpio->pgpath; 1471 struct pgpath *pgpath = mpio->pgpath;
1472 int r = DM_ENDIO_DONE;
1472 1473
1473 /* 1474 /*
1474 * We don't queue any clone request inside the multipath target 1475 * We don't queue any clone request inside the multipath target
@@ -1484,14 +1485,18 @@ static int multipath_end_io(struct dm_target *ti, struct request *clone,
1484 if (error && !noretry_error(error)) { 1485 if (error && !noretry_error(error)) {
1485 struct multipath *m = ti->private; 1486 struct multipath *m = ti->private;
1486 1487
1487 error = DM_ENDIO_REQUEUE; 1488 r = DM_ENDIO_REQUEUE;
1488 1489
1489 if (pgpath) 1490 if (pgpath)
1490 fail_path(pgpath); 1491 fail_path(pgpath);
1491 1492
1492 if (atomic_read(&m->nr_valid_paths) == 0 && 1493 if (atomic_read(&m->nr_valid_paths) == 0 &&
1493 !test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags)) 1494 !test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags)) {
1494 error = dm_report_EIO(m); 1495 if (error == -EIO)
1496 error = dm_report_EIO(m);
1497 /* complete with the original error */
1498 r = DM_ENDIO_DONE;
1499 }
1495 } 1500 }
1496 1501
1497 if (pgpath) { 1502 if (pgpath) {
@@ -1501,7 +1506,7 @@ static int multipath_end_io(struct dm_target *ti, struct request *clone,
1501 ps->type->end_io(ps, &pgpath->path, mpio->nr_bytes); 1506 ps->type->end_io(ps, &pgpath->path, mpio->nr_bytes);
1502 } 1507 }
1503 1508
1504 return error; 1509 return r;
1505} 1510}
1506 1511
1507static int do_end_io_bio(struct multipath *m, struct bio *clone, 1512static int do_end_io_bio(struct multipath *m, struct bio *clone,
diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
index d445b712970b..920e854caba9 100644
--- a/drivers/md/dm-rq.c
+++ b/drivers/md/dm-rq.c
@@ -287,7 +287,7 @@ static void dm_requeue_original_request(struct dm_rq_target_io *tio, bool delay_
287 287
288static void dm_done(struct request *clone, int error, bool mapped) 288static void dm_done(struct request *clone, int error, bool mapped)
289{ 289{
290 int r = error; 290 int r = DM_ENDIO_DONE;
291 struct dm_rq_target_io *tio = clone->end_io_data; 291 struct dm_rq_target_io *tio = clone->end_io_data;
292 dm_request_endio_fn rq_end_io = NULL; 292 dm_request_endio_fn rq_end_io = NULL;
293 293
@@ -298,7 +298,7 @@ static void dm_done(struct request *clone, int error, bool mapped)
298 r = rq_end_io(tio->ti, clone, error, &tio->info); 298 r = rq_end_io(tio->ti, clone, error, &tio->info);
299 } 299 }
300 300
301 if (unlikely(r == -EREMOTEIO)) { 301 if (unlikely(error == -EREMOTEIO)) {
302 if (req_op(clone) == REQ_OP_WRITE_SAME && 302 if (req_op(clone) == REQ_OP_WRITE_SAME &&
303 !clone->q->limits.max_write_same_sectors) 303 !clone->q->limits.max_write_same_sectors)
304 disable_write_same(tio->md); 304 disable_write_same(tio->md);
@@ -307,16 +307,19 @@ static void dm_done(struct request *clone, int error, bool mapped)
307 disable_write_zeroes(tio->md); 307 disable_write_zeroes(tio->md);
308 } 308 }
309 309
310 if (r <= 0) 310 switch (r) {
311 case DM_ENDIO_DONE:
311 /* The target wants to complete the I/O */ 312 /* The target wants to complete the I/O */
312 dm_end_request(clone, r); 313 dm_end_request(clone, error);
313 else if (r == DM_ENDIO_INCOMPLETE) 314 break;
315 case DM_ENDIO_INCOMPLETE:
314 /* The target will handle the I/O */ 316 /* The target will handle the I/O */
315 return; 317 return;
316 else if (r == DM_ENDIO_REQUEUE) 318 case DM_ENDIO_REQUEUE:
317 /* The target wants to requeue the I/O */ 319 /* The target wants to requeue the I/O */
318 dm_requeue_original_request(tio, false); 320 dm_requeue_original_request(tio, false);
319 else { 321 break;
322 default:
320 DMWARN("unimplemented target endio return value: %d", r); 323 DMWARN("unimplemented target endio return value: %d", r);
321 BUG(); 324 BUG();
322 } 325 }
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index 925b63cdef52..5a02fc0ff311 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -593,6 +593,7 @@ extern struct ratelimit_state dm_ratelimit_state;
593/* 593/*
594 * Definitions of return values from target end_io function. 594 * Definitions of return values from target end_io function.
595 */ 595 */
596#define DM_ENDIO_DONE 0
596#define DM_ENDIO_INCOMPLETE 1 597#define DM_ENDIO_INCOMPLETE 1
597#define DM_ENDIO_REQUEUE 2 598#define DM_ENDIO_REQUEUE 2
598 599