dect
/
linux-2.6
Archived
13
0
Fork 0

dm: refactor request based completion functions

This patch factors out the clone completion code, dm_done(),
from dm_softirq_done() in preparation for a subsequent patch.
No functional change.

dm_done() will be used in barrier completion, which can't use and
doesn't need softirq.  The softirq_done callback needs to get a clone
from an original request but it can't in the case of barrier, where
an original request is shared by multiple clones.  On the other hand,
the completion of barrier clones doesn't involve re-submitting requests,
which was the primary reason of the need for softirq.

Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
This commit is contained in:
Kiyoshi Ueda 2009-12-10 23:52:17 +00:00 committed by Alasdair G Kergon
parent b4324feeae
commit 11a68244e1
1 changed files with 28 additions and 17 deletions

View File

@ -846,32 +846,43 @@ static void dm_end_request(struct request *clone, int error)
rq_completed(md, rw, 1);
}
static void dm_done(struct request *clone, int error, bool mapped)
{
int r = error;
struct dm_rq_target_io *tio = clone->end_io_data;
dm_request_endio_fn rq_end_io = tio->ti->type->rq_end_io;
if (mapped && rq_end_io)
r = rq_end_io(tio->ti, clone, error, &tio->info);
if (r <= 0)
/* The target wants to complete the I/O */
dm_end_request(clone, r);
else if (r == DM_ENDIO_INCOMPLETE)
/* The target will handle the I/O */
return;
else if (r == DM_ENDIO_REQUEUE)
/* The target wants to requeue the I/O */
dm_requeue_unmapped_request(clone);
else {
DMWARN("unimplemented target endio return value: %d", r);
BUG();
}
}
/*
* Request completion handler for request-based dm
*/
static void dm_softirq_done(struct request *rq)
{
bool mapped = true;
struct request *clone = rq->completion_data;
struct dm_rq_target_io *tio = clone->end_io_data;
dm_request_endio_fn rq_end_io = tio->ti->type->rq_end_io;
int error = tio->error;
if (!(rq->cmd_flags & REQ_FAILED) && rq_end_io)
error = rq_end_io(tio->ti, clone, error, &tio->info);
if (rq->cmd_flags & REQ_FAILED)
mapped = false;
if (error <= 0)
/* The target wants to complete the I/O */
dm_end_request(clone, error);
else if (error == DM_ENDIO_INCOMPLETE)
/* The target will handle the I/O */
return;
else if (error == DM_ENDIO_REQUEUE)
/* The target wants to requeue the I/O */
dm_requeue_unmapped_request(clone);
else {
DMWARN("unimplemented target endio return value: %d", error);
BUG();
}
dm_done(clone, tio->error, mapped);
}
/*