diff mbox series

[v2,3/5] mpage: split bi_end_io callback for reads and writes

Message ID 20230403132221.94921-4-p.raghav@samsung.com (mailing list archive)
State Mainlined, archived
Headers show
Series remove page_endio() | expand

Commit Message

Pankaj Raghav April 3, 2023, 1:22 p.m. UTC
Split the bi_end_io handler for reads and writes similar to other aops.
This is a prep patch before we convert end_io handlers to use folios.

Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
---
 fs/mpage.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

Comments

Christoph Hellwig April 4, 2023, 3:09 p.m. UTC | #1
>  		struct page *page = bv->bv_page;
> -		page_endio(page, bio_op(bio),
> +		page_endio(page, REQ_OP_READ,
> +			   blk_status_to_errno(bio->bi_status));

Nit: I think we can do without the page local variable here.

> +	bio_for_each_segment_all(bv, bio, iter_all) {
> +		struct page *page = bv->bv_page;
> +		page_endio(page, REQ_OP_WRITE,
>  			   blk_status_to_errno(bio->bi_status));

Same here.

>  	}
>  
> @@ -59,7 +73,11 @@ static void mpage_end_io(struct bio *bio)
>  
>  static struct bio *mpage_bio_submit(struct bio *bio)
>  {
> -	bio->bi_end_io = mpage_end_io;
> +	if (op_is_write(bio_op(bio)))
> +		bio->bi_end_io = mpage_write_end_io;
> +	else
> +		bio->bi_end_io = mpage_read_end_io;
> +

I'd also split mpage_bio_submit as all allers are clearly either
for reads or writes.
diff mbox series

Patch

diff --git a/fs/mpage.c b/fs/mpage.c
index 22b9de5ddd68..3a545bf0f184 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -43,14 +43,28 @@ 
  * status of that page is hard.  See end_buffer_async_read() for the details.
  * There is no point in duplicating all that complexity.
  */
-static void mpage_end_io(struct bio *bio)
+static void mpage_read_end_io(struct bio *bio)
 {
 	struct bio_vec *bv;
 	struct bvec_iter_all iter_all;
 
 	bio_for_each_segment_all(bv, bio, iter_all) {
 		struct page *page = bv->bv_page;
-		page_endio(page, bio_op(bio),
+		page_endio(page, REQ_OP_READ,
+			   blk_status_to_errno(bio->bi_status));
+	}
+
+	bio_put(bio);
+}
+
+static void mpage_write_end_io(struct bio *bio)
+{
+	struct bio_vec *bv;
+	struct bvec_iter_all iter_all;
+
+	bio_for_each_segment_all(bv, bio, iter_all) {
+		struct page *page = bv->bv_page;
+		page_endio(page, REQ_OP_WRITE,
 			   blk_status_to_errno(bio->bi_status));
 	}
 
@@ -59,7 +73,11 @@  static void mpage_end_io(struct bio *bio)
 
 static struct bio *mpage_bio_submit(struct bio *bio)
 {
-	bio->bi_end_io = mpage_end_io;
+	if (op_is_write(bio_op(bio)))
+		bio->bi_end_io = mpage_write_end_io;
+	else
+		bio->bi_end_io = mpage_read_end_io;
+
 	guard_bio_eod(bio);
 	submit_bio(bio);
 	return NULL;