Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3503492pxb; Mon, 24 Jan 2022 10:56:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJxZEEYStEgUtHKyK376JPjC5gEAbB6AE2z5rZFneSQ7Kz3OhbgYxyNgj1RsQX+vKzYZXN77 X-Received: by 2002:a17:90b:2251:: with SMTP id hk17mr3223475pjb.200.1643050563790; Mon, 24 Jan 2022 10:56:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643050563; cv=none; d=google.com; s=arc-20160816; b=pASninLrxp8Btl0+Cw/Ib43LAPs5pNKvkQXnmBdVNVwHgez7UrHNUkILlcKG+Ypgku nw5I+WT+rXN9i6VUmyFao/0vU566JIAhrYaRJZ6rSrNdh+acdTs34aB2DcW6hkeLWV4/ 2bUkUFtHuvxXINK//TnMWusUT0SRMfVzg5Kk4iRd3p4AitU//s5qRK3kswVwCW7PmZnD 8zBXNmmb9IQw+fryqFtE+ZCxYA+ajaNNOV8TPyush7OSiWJWhYSAXGg61wQMtcOgVzI/ Sd+TW4Jd1bsLJjqzFoqDn53BtPWL6JBHvO8BcA6upqctLaKX75x7NsJU8yEs8LonzDFD vnSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=k9xFroBmk3qsQBF01SQtJtA/UuQWo3OoxDB4XEu/hlU=; b=abxFVoIk2+nrja3qbyr1e1vmhJ4Zd7P+jt9oMKINz0zyfFPJjggCMnXDy8W2NJbYyU mdg9oBGIGn9bFWNRs2Wv6djkQn7Y7hkomBzCRXw+taFvImzl3vq8U52thrzdNR/2culi 8IwTTri9x19xCbiVvOEsrnWQxBxy3/GULdqQWGX2fsMuC5LR1EKdsy+kasuAIcHsmXiy WyRfYlwjghPcx8WWfgMFYvfMTMPtytP3xuXUzRQ0VUSDMZTqmBkvlEEH7Je7e7ALlvLw pEnbqVf4aWrYX1HW3C0JDpE9KdtSgLZ2yZihJf9EFgW4okiN9hCPc4e8NXFwpyOc3fxL Lazg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=eOrLkdjf; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t35si15447824pfg.95.2022.01.24.10.55.50; Mon, 24 Jan 2022 10:56:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=eOrLkdjf; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242609AbiAXJLY (ORCPT + 99 others); Mon, 24 Jan 2022 04:11:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242495AbiAXJLW (ORCPT ); Mon, 24 Jan 2022 04:11:22 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39BE5C06173B; Mon, 24 Jan 2022 01:11:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=k9xFroBmk3qsQBF01SQtJtA/UuQWo3OoxDB4XEu/hlU=; b=eOrLkdjf0mmS8f/CtvAZiPo6uX G/VVNiKCFucEha0OyK/bZHsYEWLQ8xt7Bm9GixZ3tXgynPAQ2lxe/OElmzLeezeL0/RwDpkgmYeKY sz0jxyE8u/ZmbzvVPqeFTOOgFV5BttmczKSHZSHX083YPyiVCbcYIJUXbwklJ27Jxtkj9NACszfwn KyrdR4b8FWyP3Y2PI8CYfXr543bSterKv2k1N8EN6qQbnNeTnXRNQZ1IY/xSrJDRAih0f3uqmi1Wh Xl0xPQ3rDdce0WxMXn872laxukK7ywf9uRa3awgU+FjYW4wAryVnmN6XEnrDqL3ko+YEed4hUg3uX 3w4WP7yw==; Received: from [2001:4bb8:184:72a4:a337:a75f:a24e:7e39] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nBvNY-002jyp-2k; Mon, 24 Jan 2022 09:11:12 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Pavel Begunkov , Mike Snitzer , Ryusuke Konishi , Konstantin Komarov , Andrew Morton , "Md . Haris Iqbal " , Jack Wang , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Philipp Reisner , Lars Ellenberg , linux-block@vger.kernel.org, dm-devel@redhat.com, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-nilfs@vger.kernel.org, ntfs3@lists.linux.dev, xen-devel@lists.xenproject.org, drbd-dev@lists.linbit.com Subject: [PATCH 01/19] fs: remove mpage_alloc Date: Mon, 24 Jan 2022 10:10:49 +0100 Message-Id: <20220124091107.642561-2-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220124091107.642561-1-hch@lst.de> References: <20220124091107.642561-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org open code mpage_alloc in it's two callers and simplify the results because of the context: - __mpage_writepage always passes GFP_NOFS and can thus always sleep and will never get a NULL return from bio_alloc at all. - do_mpage_readpage can only get a non-sleeping context for readahead which never sets PF_MEMALLOC and thus doesn't need the retry loop either. Both cases will never have __GFP_HIGH set. Signed-off-by: Christoph Hellwig --- fs/mpage.c | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/fs/mpage.c b/fs/mpage.c index 87f5cfef6caa7..06e95d777e940 100644 --- a/fs/mpage.c +++ b/fs/mpage.c @@ -66,29 +66,6 @@ static struct bio *mpage_bio_submit(int op, int op_flags, struct bio *bio) return NULL; } -static struct bio * -mpage_alloc(struct block_device *bdev, - sector_t first_sector, int nr_vecs, - gfp_t gfp_flags) -{ - struct bio *bio; - - /* Restrict the given (page cache) mask for slab allocations */ - gfp_flags &= GFP_KERNEL; - bio = bio_alloc(gfp_flags, nr_vecs); - - if (bio == NULL && (current->flags & PF_MEMALLOC)) { - while (!bio && (nr_vecs /= 2)) - bio = bio_alloc(gfp_flags, nr_vecs); - } - - if (bio) { - bio_set_dev(bio, bdev); - bio->bi_iter.bi_sector = first_sector; - } - return bio; -} - /* * support function for mpage_readahead. The fs supplied get_block might * return an up to date buffer. This is used to map that buffer into @@ -296,10 +273,11 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args) page)) goto out; } - args->bio = mpage_alloc(bdev, blocks[0] << (blkbits - 9), - bio_max_segs(args->nr_pages), gfp); + args->bio = bio_alloc(gfp, bio_max_segs(args->nr_pages)); if (args->bio == NULL) goto confused; + bio_set_dev(args->bio, bdev); + args->bio->bi_iter.bi_sector = blocks[0] << (blkbits - 9); } length = first_hole << blkbits; @@ -608,10 +586,9 @@ static int __mpage_writepage(struct page *page, struct writeback_control *wbc, page, wbc)) goto out; } - bio = mpage_alloc(bdev, blocks[0] << (blkbits - 9), - BIO_MAX_VECS, GFP_NOFS|__GFP_HIGH); - if (bio == NULL) - goto confused; + bio = bio_alloc(GFP_NOFS, BIO_MAX_VECS); + bio_set_dev(bio, bdev); + bio->bi_iter.bi_sector = blocks[0] << (blkbits - 9); wbc_init_bio(wbc, bio); bio->bi_write_hint = inode->i_write_hint; -- 2.30.2