Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp405126ybx; Tue, 29 Oct 2019 21:24:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqxaSoyaLoil6htRgIu15SFTJu9XicHTT4f+AEYn2JBIAAlf8/8QXbNR9ACBc1FxwT1T+tl6 X-Received: by 2002:a17:906:7202:: with SMTP id m2mr6812899ejk.138.1572409457370; Tue, 29 Oct 2019 21:24:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572409457; cv=none; d=google.com; s=arc-20160816; b=qTgiHuGuzqLJWGhCEt4QfLmmJUt3NZ6OThjPHook+Zf1OzrFZ/RSJbmwPybvJce7gn Bi+egAjq/rQRcKVnNQ+dIaTO5WnCZ/TqdcnDL1abNkYukP2PZTnt97rZPLkSaWRPegi0 bM/CDIhhHQpgs7kPOiiix1ZCkSSMjSvcK9YeCtcvkEv32eEx+SwY0ebsoZoj4IDuz6tB 4398LldZLZk21V757+XIjgpNR6+hBfp5l9EBacJY8K6mckyklMflBjZiWCu/MwLLj281 Tb6tdBqezfyAEPNWjfXnF4tbQyhUxLEWZtSE12ZkzlEYr6fAlckE41zSjKoy2EQKXW+C dXFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=1bukSxnogaLGjD3MkfaKn9fI+XPZfbYXxg0r9IZ/FsU=; b=FvmTUrmgz3C9p3V13J0J/0IC5EwvNjKVbKGaqfPGNreGSgnnT1ouUrzVGmyBalwKup 3qqS/Y++jKYUCk4b7/InhTunQgLcJ5dpVJ+RU01NmOOQvUG2ARKUTKoW8f/sft7ej3id QpRpTap2MFYB2lc2RrpfpXWVAdTlmLKK1XnpzrUCDVK0ShFIfmyrjHN8yMFWeYOiI9sf Q9hOwpaCqoS0C32y1O7QUTi9wnfXD8HrRT6BUcGGvBZ6y1zvhJrMvtpw3j2VpARlDz/q YjWAuOX/I+FMAkqIWAgj8COUOHcuSTgvm58YJfIXPxDAqmejPjb+Zx7ZtH0QzRa4IdSc o3Yg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c2si582381eda.322.2019.10.29.21.23.42; Tue, 29 Oct 2019 21:24:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725855AbfJ3EXm (ORCPT + 99 others); Wed, 30 Oct 2019 00:23:42 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:54614 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725308AbfJ3EXl (ORCPT ); Wed, 30 Oct 2019 00:23:41 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 92F56914FB7379F9428A; Wed, 30 Oct 2019 12:23:39 +0800 (CST) Received: from architecture4.huawei.com (10.140.130.215) by smtp.huawei.com (10.3.19.206) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 30 Oct 2019 12:23:32 +0800 From: Gao Xiang To: Theodore Ts'o , Andreas Dilger CC: , , Gao Xiang Subject: [PATCH] ext4: bio_alloc never fails Date: Wed, 30 Oct 2019 12:26:18 +0800 Message-ID: <20191030042618.124220-1-gaoxiang25@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.140.130.215] X-CFilter-Loop: Reflected Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 --- 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