Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1098738rdg; Fri, 11 Aug 2023 09:37:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG5BSP2j9FpuJFxIetelPjAMliLB18IDFJDs7cAG9M6PgDOgGB9cDHvPUPJSlx6dSh9Td77 X-Received: by 2002:a05:6a20:2591:b0:132:f61e:7d41 with SMTP id k17-20020a056a20259100b00132f61e7d41mr3469847pzd.5.1691771829805; Fri, 11 Aug 2023 09:37:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691771829; cv=none; d=google.com; s=arc-20160816; b=VHeVPFPk0i1AYFu3FSQ5BvfFG+fDaFEY1eWvwNdWfuIYDKE8fC74a62s6zZkJmofwP iKZ857YTlkpaXM+I4nxSOa9OQe6zxWA511/PyaL1Tc7rUocxaiEt6NBfumHAvm8vOKZZ ckIQ+BMQkvwShXx1NIqrYO5qH9o3Omti5npcqwAxO32HlEyqIgqX449jf41tLh8g2a0y VNP05eOLpIVaWIIVzXvlla015vrWMcJ1alo/FhVkJqC3YP9Dkq5ZHF/w5qTyeMsRa/N5 7J1EbNGMfQXTaNn6WqORrZfDcJc38dqjhWBuMv0efc/Mu+NL+wTxWjda4mj6FNi1Aa/g yurg== 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=mGLxLmLqoMtqKqObPpHvI58V/LNR6g3q9ebkb1KeSj4=; fh=BvTsPvZmwNzIqPb2bL1VMvtoAQxT1jAJEBJAY1B8Ad0=; b=IaSCzD3W1aC6Or06Ha8SOQ6p59ArnSgjoXlBUaQ7klktyifNzmMSuFZW/bAORoK6S5 XZ3GvFJjMtPpsYvhKFrkcx3BEIDPAQQbLOPD8VcF0slS2Z2iHe7Y9YTM1gc93jfZBz76 EVITLBLAFbCPBfFC1eNcIvp9RkKLCVtVsVh3j0iIfThCHWOxA7d45OZjrvBcNg2A9Kqh 2rpUtFZK8N8jby8f+m5RZIIgBImKcTSbcFzTSzgYyuli0jZY7DHrrCp4a/LfC79mNYD+ JImyZGZP3SoH4nosTrb62aaNP5FuffvGNKoaYXBQlZkEHasFpEhEYrL84GGCvj+RC+jW AW+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=qovPmxo6; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a23-20020aa78657000000b0068741c5a152si3461361pfo.391.2023.08.11.09.36.50; Fri, 11 Aug 2023 09:37:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=qovPmxo6; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234661AbjHKQPq (ORCPT + 99 others); Fri, 11 Aug 2023 12:15:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234275AbjHKQPm (ORCPT ); Fri, 11 Aug 2023 12:15:42 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57D5C273E; Fri, 11 Aug 2023 09:15:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=mGLxLmLqoMtqKqObPpHvI58V/LNR6g3q9ebkb1KeSj4=; b=qovPmxo6vngNv6zu0MhFQMQVHu JY/vfqtADdsSKY48Foze9fiVOUY3EU3/VEqkPES+ALe5cZIxWHqsapi6R9IED0OuShRmmW4PkvOvp Kf9j7PWrHUhPDOVezbqHIXon6GD+UAvTOtuFgvJYqqm6j82cL+oz2fq3uk98sN8msmz1cEPUO0nBc zHl+CIGgWFQ3wfAIA1IGVYBGERRuhswJjYLxSpu5X8MnF/+wQBbrAKNCpJW/KYa3RTVNdUCPDreXm eXsPvj/6KL/F6q8Q0rrBFNWrCr8VxSY4taIg3tqe/hzCTW3OTtexFfCjslQP/k4qYAB8oSEwV+k4D P7Kr/r0w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qUUnT-0027kW-0A; Fri, 11 Aug 2023 16:15:31 +0000 From: "Matthew Wilcox (Oracle)" To: akpm@linux-foundation.org Cc: "Matthew Wilcox (Oracle)" , Hui Zhu , linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org Subject: [PATCH 1/3] buffer: Pass GFP flags to folio_alloc_buffers() Date: Fri, 11 Aug 2023 17:15:26 +0100 Message-Id: <20230811161528.506437-2-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230811161528.506437-1-willy@infradead.org> References: <20230811161528.506437-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Instead of creating entirely new flags, inherit them from grow_dev_page(). The other callers create the same flags that this function used to create. Signed-off-by: Matthew Wilcox (Oracle) --- fs/buffer.c | 17 +++++++++-------- include/linux/buffer_head.h | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index bd091329026c..7326acc29541 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -920,16 +920,12 @@ int remove_inode_buffers(struct inode *inode) * which may not fail from ordinary buffer allocations. */ struct buffer_head *folio_alloc_buffers(struct folio *folio, unsigned long size, - bool retry) + gfp_t gfp) { struct buffer_head *bh, *head; - gfp_t gfp = GFP_NOFS | __GFP_ACCOUNT; long offset; struct mem_cgroup *memcg, *old_memcg; - if (retry) - gfp |= __GFP_NOFAIL; - /* The folio lock pins the memcg */ memcg = folio_memcg(folio); old_memcg = set_active_memcg(memcg); @@ -972,7 +968,11 @@ EXPORT_SYMBOL_GPL(folio_alloc_buffers); struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size, bool retry) { - return folio_alloc_buffers(page_folio(page), size, retry); + gfp_t gfp = GFP_NOFS | __GFP_ACCOUNT; + if (retry) + gfp |= __GFP_NOFAIL; + + return folio_alloc_buffers(page_folio(page), size, gfp); } EXPORT_SYMBOL_GPL(alloc_page_buffers); @@ -1074,7 +1074,7 @@ grow_dev_page(struct block_device *bdev, sector_t block, goto failed; } - bh = folio_alloc_buffers(folio, size, true); + bh = folio_alloc_buffers(folio, size, gfp_mask); /* * Link the folio to the buffers and initialise them. Take the @@ -1665,8 +1665,9 @@ void folio_create_empty_buffers(struct folio *folio, unsigned long blocksize, unsigned long b_state) { struct buffer_head *bh, *head, *tail; + gfp_t gfp = GFP_NOFS | __GFP_ACCOUNT | __GFP_NOFAIL; - head = folio_alloc_buffers(folio, blocksize, true); + head = folio_alloc_buffers(folio, blocksize, gfp); bh = head; do { bh->b_state |= b_state; diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 6cb3e9af78c9..d17efb8b7976 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -200,7 +200,7 @@ void folio_set_bh(struct buffer_head *bh, struct folio *folio, unsigned long offset); bool try_to_free_buffers(struct folio *); struct buffer_head *folio_alloc_buffers(struct folio *folio, unsigned long size, - bool retry); + gfp_t gfp); struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size, bool retry); void create_empty_buffers(struct page *, unsigned long, -- 2.40.1