linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: bio_alloc never fails
@ 2019-10-30  4:26 Gao Xiang
  2019-10-30 10:13 ` Ritesh Harjani
  2019-10-31  2:01 ` [PATCH] ext4: bio_alloc " Chao Yu
  0 siblings, 2 replies; 11+ messages in thread
From: Gao Xiang @ 2019-10-30  4:26 UTC (permalink / raw)
  To: Theodore Ts'o, Andreas Dilger; +Cc: linux-ext4, linux-kernel, Gao Xiang

Similar to [1] [2], it seems a trivial cleanup since
bio_alloc can handle memory allocation as mentioned in
fs/direct-io.c (also see fs/block_dev.c, fs/buffer.c, ..)

[1] https://lore.kernel.org/r/20191030035518.65477-1-gaoxiang25@huawei.com
[2] https://lore.kernel.org/r/20190830162812.GA10694@infradead.org
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
 fs/ext4/page-io.c  | 11 +++--------
 fs/ext4/readpage.c |  2 --
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index 12ceadef32c5..f1f7b6601780 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -358,14 +358,12 @@ void ext4_io_submit_init(struct ext4_io_submit *io,
 	io->io_end = NULL;
 }
 
-static int io_submit_init_bio(struct ext4_io_submit *io,
-			      struct buffer_head *bh)
+static void io_submit_init_bio(struct ext4_io_submit *io,
+			       struct buffer_head *bh)
 {
 	struct bio *bio;
 
 	bio = bio_alloc(GFP_NOIO, BIO_MAX_PAGES);
-	if (!bio)
-		return -ENOMEM;
 	bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9);
 	bio_set_dev(bio, bh->b_bdev);
 	bio->bi_end_io = ext4_end_bio;
@@ -373,7 +371,6 @@ static int io_submit_init_bio(struct ext4_io_submit *io,
 	io->io_bio = bio;
 	io->io_next_block = bh->b_blocknr;
 	wbc_init_bio(io->io_wbc, bio);
-	return 0;
 }
 
 static int io_submit_add_bh(struct ext4_io_submit *io,
@@ -388,9 +385,7 @@ static int io_submit_add_bh(struct ext4_io_submit *io,
 		ext4_io_submit(io);
 	}
 	if (io->io_bio == NULL) {
-		ret = io_submit_init_bio(io, bh);
-		if (ret)
-			return ret;
+		io_submit_init_bio(io, bh);
 		io->io_bio->bi_write_hint = inode->i_write_hint;
 	}
 	ret = bio_add_page(io->io_bio, page, bh->b_size, bh_offset(bh));
diff --git a/fs/ext4/readpage.c b/fs/ext4/readpage.c
index a30b203fa461..bfeb77b93f48 100644
--- a/fs/ext4/readpage.c
+++ b/fs/ext4/readpage.c
@@ -362,8 +362,6 @@ int ext4_mpage_readpages(struct address_space *mapping,
 
 			bio = bio_alloc(GFP_KERNEL,
 				min_t(int, nr_pages, BIO_MAX_PAGES));
-			if (!bio)
-				goto set_error_page;
 			ctx = get_bio_post_read_ctx(inode, bio, page->index);
 			if (IS_ERR(ctx)) {
 				bio_put(bio);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-11-15  3:21 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-30  4:26 [PATCH] ext4: bio_alloc never fails Gao Xiang
2019-10-30 10:13 ` Ritesh Harjani
2019-10-30 10:40   ` Gao Xiang
2019-10-30 15:04   ` Theodore Y. Ts'o
2019-10-30 16:12     ` Gao Xiang
2019-10-31  9:23       ` [PATCH v2] ext4: bio_alloc with __GFP_DIRECT_RECLAIM " Gao Xiang
2019-10-31  9:29         ` Chao Yu
2019-11-15  3:19           ` Theodore Y. Ts'o
2019-11-15  3:24             ` Gao Xiang
2019-10-31  2:01 ` [PATCH] ext4: bio_alloc " Chao Yu
2019-10-31  9:10   ` Gao Xiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).