Skip to contentSkip to conversation

erofs: get rid of raw bi_end_io() usage

PATCH Superseded Gao Xiang 4 participants 7 messages Nov 27, 2025 – Nov 28, 2025 EROFS file system

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 erofs: get rid of raw bi_end_io() usage

These BIOs are actually harmless in practice, as they are all pseudo BIOs and do not use advanced features like chaining. Using the BIO interface is a more friendly and unified approach for both bdev and and file-backed I/Os.

Let's use bio_endio() instead.

---
 fs/erofs/fileio.c  | 2 +-
 fs/erofs/fscache.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
fs/erofs/fileio.c +1 -1
index b7b3432a9882..a65f86dc79b6 100644
@@ -34,7 +34,7 @@ static void erofs_fileio_ki_complete(struct kiocb *iocb, long ret)
 	if (rq->bio.bi_end_io) {
 		if (ret < 0 && !rq->bio.bi_status)
 			rq->bio.bi_status = errno_to_blk_status(ret);
-		rq->bio.bi_end_io(&rq->bio);
+		bio_endio(&rq->bio);
 	} else {
 		bio_for_each_folio_all(fi, &rq->bio) {
 			DBG_BUGON(folio_test_uptodate(fi.folio));
fs/erofs/fscache.c +2 -2
index 362acf828279..7a346e20f7b7 100644
@@ -185,7 +185,7 @@ static void erofs_fscache_bio_endio(void *priv, ssize_t transferred_or_error)
 
 	if (IS_ERR_VALUE(transferred_or_error))
 		io->bio.bi_status = errno_to_blk_status(transferred_or_error);
-	io->bio.bi_end_io(&io->bio);
+	bio_endio(&io->bio);
 	BUILD_BUG_ON(offsetof(struct erofs_fscache_bio, io) != 0);
 	erofs_fscache_io_put(&io->io);
 }
@@ -216,7 +216,7 @@ void erofs_fscache_submit_bio(struct bio *bio)
 	if (!ret)
 		return;
 	bio->bi_status = errno_to_blk_status(ret);
-	bio->bi_end_io(bio);
+	bio_endio(bio);
 }
 
 static int erofs_fscache_meta_read_folio(struct file *data, struct folio *folio)
Signature · 1 line
2.43.5
author
#1 lore raw

PATCH v2 1/1 erofs: get rid of raw bi_end_io() usage

These BIOs are actually harmless in practice, as they are all pseudo BIOs and do not use advanced features like chaining. Using the BIO interface is a more friendly and unified approach for both bdev and and file-backed I/Os.

Let's use bio_endio() instead.

---
v2:
- call bio_endio() unconditionally in erofs_fileio_ki_complete().

 fs/erofs/fileio.c  | 2 +-
 fs/erofs/fscache.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
fs/erofs/fileio.c +1 -1
index b7b3432a9882..301647b84ca9 100644
@@ -34,13 +34,13 @@ static void erofs_fileio_ki_complete(struct kiocb *iocb, long ret)
 	if (rq->bio.bi_end_io) {
 		if (ret < 0 && !rq->bio.bi_status)
 			rq->bio.bi_status = errno_to_blk_status(ret);
-		rq->bio.bi_end_io(&rq->bio);
 	} else {
 		bio_for_each_folio_all(fi, &rq->bio) {
 			DBG_BUGON(folio_test_uptodate(fi.folio));
 			erofs_onlinefolio_end(fi.folio, ret, false);
 		}
 	}
+	bio_endio(&rq->bio);
 	bio_uninit(&rq->bio);
 	kfree(rq);
 }
fs/erofs/fscache.c +2 -2
index 362acf828279..7a346e20f7b7 100644
@@ -185,7 +185,7 @@ static void erofs_fscache_bio_endio(void *priv, ssize_t transferred_or_error)
 
 	if (IS_ERR_VALUE(transferred_or_error))
 		io->bio.bi_status = errno_to_blk_status(transferred_or_error);
-	io->bio.bi_end_io(&io->bio);
+	bio_endio(&io->bio);
 	BUILD_BUG_ON(offsetof(struct erofs_fscache_bio, io) != 0);
 	erofs_fscache_io_put(&io->io);
 }
@@ -216,7 +216,7 @@ void erofs_fscache_submit_bio(struct bio *bio)
 	if (!ret)
 		return;
 	bio->bi_status = errno_to_blk_status(ret);
-	bio->bi_end_io(bio);
+	bio_endio(bio);
 }
 
 static int erofs_fscache_meta_read_folio(struct file *data, struct folio *folio)
Signature · 1 line
2.43.5
Reviewed-by on v2 1/1
#2 lore raw
Quoted 6 lines · Gao Xiang

These BIOs are actually harmless in practice, as they are all pseudo BIOs and do not use advanced features like chaining. Using the BIO interface is a more friendly and unified approach for both bdev and and file-backed I/Os.

Let's use bio_endio() instead.

Looks good:

Reviewed-by on v2 1/1
#3 lore raw
In reply to Gao Xiang
Quoted 11 lines · Gao Xiang

These BIOs are actually harmless in practice, as they are all pseudo BIOs and do not use advanced features like chaining. Using the BIO interface is a more friendly and unified approach for both bdev and and file-backed I/Os.

Let's use bio_endio() instead.

---
v2:
- call bio_endio() unconditionally in erofs_fileio_ki_complete().

bio_endio() can cover bio not submitted yet, so:

Thanks,
Ming

author
#4 lore raw
Quoted 8 lines · Ming Lei
Quoted 7 lines · Gao Xiang

These BIOs are actually harmless in practice, as they are all pseudo BIOs and do not use advanced features like chaining. Using the BIO interface is a more friendly and unified approach for both bdev and and file-backed I/Os.

Let's use bio_endio() instead.

Quoted 8 lines
Quoted 4 lines

---
v2:
- call bio_endio() unconditionally in erofs_fileio_ki_complete().

bio_endio() can cover bio not submitted yet, so:

Thank you and Christoph for review!

Thanks,
Gao Xiang

author
#5 lore raw
Quoted 9 lines · Gao Xiang
Quoted 6 lines · Ming Lei
Quoted 5 lines · Gao Xiang

These BIOs are actually harmless in practice, as they are all pseudo BIOs and do not use advanced features like chaining.  Using the BIO interface is a more friendly and unified approach for both bdev and and file-backed I/Os.

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

Let's use bio_endio() instead.

---
v2:
  - call bio_endio() unconditionally in erofs_fileio_ki_complete().

bio_endio() can cover bio not submitted yet, so:

( btw, nevertheless, it's not submitted, just with or without
a given bio callback. )

I believe that is ok anyway.

Quoted 7 lines
Quoted 2 lines

Thank you and Christoph for review!

Thanks,
Gao Xiang