diff mbox

[26/27] kernel/power/swap.c: use bio_get_base_vec()

Message ID 1459858062-21075-12-git-send-email-tom.leiming@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ming Lei April 5, 2016, 12:07 p.m. UTC
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
 kernel/power/swap.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Christoph Hellwig April 5, 2016, 12:56 p.m. UTC | #1
I really don't like all these bio_get_base_vec uses.  The end_io
handlers generall want to iterate over all pages in the bio, with
a special case where all of them is the fixed number one.

So What I think we'll need is a bio_for_each_page, and if there is
any good justification for it as special version of the single
page case.
--
To unsubscribe from this list: send the line "unsubscribe linux-block" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ming Lei April 5, 2016, 1:19 p.m. UTC | #2
On Tue, Apr 5, 2016 at 8:56 PM, Christoph Hellwig <hch@infradead.org> wrote:
> I really don't like all these bio_get_base_vec uses.  The end_io
> handlers generall want to iterate over all pages in the bio, with
> a special case where all of them is the fixed number one.
>
> So What I think we'll need is a bio_for_each_page, and if there is
> any good justification for it as special version of the single
> page case.

I thought about that too, and bio_get_base_vec() can be thought as
the special version too, IMO.  Actually it is just about the name of
the helper, do you have a better name or other idea for such issue?

There are about ten such usages, as found in this patchset.


Thanks,
Ming Lei
--
To unsubscribe from this list: send the line "unsubscribe linux-block" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index 12cd989..cedf752 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -230,7 +230,15 @@  static void hib_init_batch(struct hib_bio_batch *hb)
 static void hib_end_io(struct bio *bio)
 {
 	struct hib_bio_batch *hb = bio->bi_private;
-	struct page *page = bio->bi_io_vec[0].bv_page;
+
+	/*
+	 * Single bvec bio.
+	 *
+	 * For accessing page pointed to by the 1st bvec, it
+	 * works too after multipage bvecs.
+	 */
+	struct bio_vec *bvec = bio_get_base_vec(bio);
+	struct page *page = bvec->bv_page;
 
 	if (bio->bi_error) {
 		printk(KERN_ALERT "Read-error on swap-device (%u:%u:%Lu)\n",