From: Tejun Heo <tj@kernel.org>
To: axboe@kernel.dk, linux-kernel@vger.kernel.org, bzolnier@gmail.com
Cc: Tejun Heo <tj@kernel.org>
Subject: [PATCH 09/17] block: reorder request completion functions
Date: Mon, 16 Mar 2009 11:28:52 +0900 [thread overview]
Message-ID: <1237170540-19130-10-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1237170540-19130-1-git-send-email-tj@kernel.org>
Impact: cleanup, code reorganization
Reorder request completion functions such that
* All request completion functions are located together.
* Functions which are used by only one caller is put right above the
caller.
* end_request() is put after other completion functions but before
blk_update_request().
This change is for completion function cleanup which will follow.
Signed-off-by: Tejun Heo <tj@kernel.org>
---
block/blk-core.c | 144 ++++++++++++++++++++++++------------------------
include/linux/blkdev.h | 16 +++---
2 files changed, 80 insertions(+), 80 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index 9e5f154..fd9dec3 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1674,6 +1674,35 @@ static void blk_account_io_done(struct request *req)
}
/**
+ * blk_rq_bytes - Returns bytes left to complete in the entire request
+ * @rq: the request being processed
+ **/
+unsigned int blk_rq_bytes(struct request *rq)
+{
+ if (blk_fs_request(rq))
+ return rq->hard_nr_sectors << 9;
+
+ return rq->data_len;
+}
+EXPORT_SYMBOL_GPL(blk_rq_bytes);
+
+/**
+ * blk_rq_cur_bytes - Returns bytes left to complete in the current segment
+ * @rq: the request being processed
+ **/
+unsigned int blk_rq_cur_bytes(struct request *rq)
+{
+ if (blk_fs_request(rq))
+ return rq->current_nr_sectors << 9;
+
+ if (rq->bio)
+ return rq->bio->bi_size;
+
+ return rq->data_len;
+}
+EXPORT_SYMBOL_GPL(blk_rq_cur_bytes);
+
+/**
* __end_that_request_first - end I/O on a request
* @req: the request being processed
* @error: %0 for success, < %0 for error
@@ -1783,6 +1812,22 @@ static int __end_that_request_first(struct request *req, int error,
return 1;
}
+static int end_that_request_data(struct request *rq, int error,
+ unsigned int nr_bytes, unsigned int bidi_bytes)
+{
+ if (rq->bio) {
+ if (__end_that_request_first(rq, error, nr_bytes))
+ return 1;
+
+ /* Bidi request must be completed as a whole */
+ if (blk_bidi_rq(rq) &&
+ __end_that_request_first(rq->next_rq, error, bidi_bytes))
+ return 1;
+ }
+
+ return 0;
+}
+
/*
* queue lock must be held
*/
@@ -1812,78 +1857,6 @@ static void end_that_request_last(struct request *req, int error)
}
/**
- * blk_rq_bytes - Returns bytes left to complete in the entire request
- * @rq: the request being processed
- **/
-unsigned int blk_rq_bytes(struct request *rq)
-{
- if (blk_fs_request(rq))
- return rq->hard_nr_sectors << 9;
-
- return rq->data_len;
-}
-EXPORT_SYMBOL_GPL(blk_rq_bytes);
-
-/**
- * blk_rq_cur_bytes - Returns bytes left to complete in the current segment
- * @rq: the request being processed
- **/
-unsigned int blk_rq_cur_bytes(struct request *rq)
-{
- if (blk_fs_request(rq))
- return rq->current_nr_sectors << 9;
-
- if (rq->bio)
- return rq->bio->bi_size;
-
- return rq->data_len;
-}
-EXPORT_SYMBOL_GPL(blk_rq_cur_bytes);
-
-/**
- * end_request - end I/O on the current segment of the request
- * @req: the request being processed
- * @uptodate: error value or %0/%1 uptodate flag
- *
- * Description:
- * Ends I/O on the current segment of a request. If that is the only
- * remaining segment, the request is also completed and freed.
- *
- * This is a remnant of how older block drivers handled I/O completions.
- * Modern drivers typically end I/O on the full request in one go, unless
- * they have a residual value to account for. For that case this function
- * isn't really useful, unless the residual just happens to be the
- * full current segment. In other words, don't use this function in new
- * code. Use blk_end_request() or __blk_end_request() to end a request.
- **/
-void end_request(struct request *req, int uptodate)
-{
- int error = 0;
-
- if (uptodate <= 0)
- error = uptodate ? uptodate : -EIO;
-
- __blk_end_request(req, error, req->hard_cur_sectors << 9);
-}
-EXPORT_SYMBOL(end_request);
-
-static int end_that_request_data(struct request *rq, int error,
- unsigned int nr_bytes, unsigned int bidi_bytes)
-{
- if (rq->bio) {
- if (__end_that_request_first(rq, error, nr_bytes))
- return 1;
-
- /* Bidi request must be completed as a whole */
- if (blk_bidi_rq(rq) &&
- __end_that_request_first(rq->next_rq, error, bidi_bytes))
- return 1;
- }
-
- return 0;
-}
-
-/**
* blk_end_io - Generic end_io function to complete a request.
* @rq: the request being processed
* @error: %0 for success, < %0 for error
@@ -1993,6 +1966,33 @@ int blk_end_bidi_request(struct request *rq, int error, unsigned int nr_bytes,
EXPORT_SYMBOL_GPL(blk_end_bidi_request);
/**
+ * end_request - end I/O on the current segment of the request
+ * @req: the request being processed
+ * @uptodate: error value or %0/%1 uptodate flag
+ *
+ * Description:
+ * Ends I/O on the current segment of a request. If that is the only
+ * remaining segment, the request is also completed and freed.
+ *
+ * This is a remnant of how older block drivers handled I/O completions.
+ * Modern drivers typically end I/O on the full request in one go, unless
+ * they have a residual value to account for. For that case this function
+ * isn't really useful, unless the residual just happens to be the
+ * full current segment. In other words, don't use this function in new
+ * code. Use blk_end_request() or __blk_end_request() to end a request.
+ **/
+void end_request(struct request *req, int uptodate)
+{
+ int error = 0;
+
+ if (uptodate <= 0)
+ error = uptodate ? uptodate : -EIO;
+
+ __blk_end_request(req, error, req->hard_cur_sectors << 9);
+}
+EXPORT_SYMBOL(end_request);
+
+/**
* blk_update_request - Special helper function for request stacking drivers
* @rq: the request being processed
* @error: %0 for success, < %0 for error
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 4c05bb9..cdfac4f 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -810,6 +810,14 @@ static inline void blk_run_address_space(struct address_space *mapping)
extern void blkdev_dequeue_request(struct request *req);
/*
+ * blk_end_request() takes bytes instead of sectors as a complete size.
+ * blk_rq_bytes() returns bytes left to complete in the entire request.
+ * blk_rq_cur_bytes() returns bytes left to complete in the current segment.
+ */
+extern unsigned int blk_rq_bytes(struct request *rq);
+extern unsigned int blk_rq_cur_bytes(struct request *rq);
+
+/*
* blk_end_request() and friends.
* __blk_end_request() and end_request() must be called with
* the request queue spinlock acquired.
@@ -836,14 +844,6 @@ extern void blk_update_request(struct request *rq, int error,
unsigned int nr_bytes);
/*
- * blk_end_request() takes bytes instead of sectors as a complete size.
- * blk_rq_bytes() returns bytes left to complete in the entire request.
- * blk_rq_cur_bytes() returns bytes left to complete in the current segment.
- */
-extern unsigned int blk_rq_bytes(struct request *rq);
-extern unsigned int blk_rq_cur_bytes(struct request *rq);
-
-/*
* Access functions for manipulating queue properties
*/
extern struct request_queue *blk_init_queue_node(request_fn_proc *rfn,
--
1.6.0.2
next prev parent reply other threads:[~2009-03-16 2:32 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-16 2:28 [GIT PATCH] block: cleanup patches, take#2 Tejun Heo
2009-03-16 2:28 ` [PATCH 01/17] ide: use blk_run_queue() instead of blk_start_queueing() Tejun Heo
2009-03-16 2:28 ` [PATCH 02/17] ide: don't set REQ_SOFTBARRIER Tejun Heo
2009-03-16 2:28 ` [PATCH 03/17] ide: use blk_update_request() instead of blk_end_request_callback() Tejun Heo
2009-03-16 2:28 ` [PATCH 04/17] block: merge blk_invoke_request_fn() into __blk_run_queue() Tejun Heo
2009-03-16 2:28 ` [PATCH 05/17] block: kill blk_start_queueing() Tejun Heo
2009-03-16 2:28 ` [PATCH 06/17] block: don't set REQ_NOMERGE unnecessarily Tejun Heo
2009-03-16 2:28 ` [PATCH 07/17] block: cleanup REQ_SOFTBARRIER usages Tejun Heo
2009-03-16 2:28 ` [PATCH 08/17] block: clean up misc stuff after block layer timeout conversion Tejun Heo
2009-03-16 2:28 ` Tejun Heo [this message]
2009-03-16 2:28 ` [PATCH 10/17] block: reorganize request fetching functions Tejun Heo
2009-03-16 2:28 ` [PATCH 11/17] block: kill blk_end_request_callback() Tejun Heo
2009-03-16 2:28 ` [PATCH 12/17] block: clean up request completion API Tejun Heo
2009-03-16 2:28 ` [PATCH 13/17] block: move rq->start_time initialization to blk_rq_init() Tejun Heo
2009-03-16 2:28 ` [PATCH 14/17] block: implement and use [__]blk_end_request_all() Tejun Heo
2009-03-16 2:28 ` [PATCH 15/17] block: kill end_request() Tejun Heo
2009-03-16 3:23 ` Grant Likely
2009-03-16 3:27 ` Grant Likely
2009-03-21 2:58 ` Tejun Heo
2009-03-24 11:37 ` Jens Axboe
2009-03-24 13:07 ` Tejun Heo
2009-03-16 2:28 ` [PATCH 16/17] ubd: simplify block request completion Tejun Heo
2009-03-16 2:29 ` [PATCH 17/17] block: clean up unnecessary stuff from block drivers Tejun Heo
2009-03-16 17:53 ` [GIT PATCH] block: cleanup patches, take#2 Bartlomiej Zolnierkiewicz
2009-03-17 0:10 ` Tejun Heo
2009-03-18 17:17 ` Bartlomiej Zolnierkiewicz
2009-03-19 0:19 ` Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1237170540-19130-10-git-send-email-tj@kernel.org \
--to=tj@kernel.org \
--cc=axboe@kernel.dk \
--cc=bzolnier@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox