From patchwork Fri Feb 18 19:57:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12751884 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 571E2C433EF for ; Fri, 18 Feb 2022 19:58:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239087AbiBRT7K (ORCPT ); Fri, 18 Feb 2022 14:59:10 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238946AbiBRT66 (ORCPT ); Fri, 18 Feb 2022 14:58:58 -0500 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B46182A278 for ; Fri, 18 Feb 2022 11:58:18 -0800 (PST) Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.16.1.2/8.16.1.2) with ESMTP id 21IHUiSR014229 for ; Fri, 18 Feb 2022 11:58:18 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=ds6aA0r8D5r2Fq6gKB5PCnyOU1VkJi+nNKZbhqDyrxA=; b=hNNIwQB8nqPM9vIuH9rKO13Bf8txFeYzGlg4Z6qpjl6rl4W0QnbGG1orYTnDtGpNtUo+ M/GDknoxNHaWUb3DBUHe6p5m1iR70VKVZm3uzWEWUGAoi0dEt84Yi/HdIaKpa+nP7Xzl JUDox+8V9NfwlalGW8cw9QwiUgHEfu2mhJw= Received: from mail.thefacebook.com ([163.114.132.120]) by m0001303.ppops.net (PPS) with ESMTPS id 3eafwrh1bq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 18 Feb 2022 11:58:17 -0800 Received: from twshared27297.14.frc2.facebook.com (2620:10d:c085:208::f) by mail.thefacebook.com (2620:10d:c085:11d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Fri, 18 Feb 2022 11:58:16 -0800 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id A97B7AEB6609; Fri, 18 Feb 2022 11:57:50 -0800 (PST) From: Stefan Roesch To: , , , CC: Subject: [PATCH v2 06/13] fs: Add gfp_t parameter to create_page_buffers() Date: Fri, 18 Feb 2022 11:57:32 -0800 Message-ID: <20220218195739.585044-7-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220218195739.585044-1-shr@fb.com> References: <20220218195739.585044-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: FHHJSl-cD2VldnLDkzWGggMlZjtvh-_I X-Proofpoint-GUID: FHHJSl-cD2VldnLDkzWGggMlZjtvh-_I X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-18_09,2022-02-18_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=fb_outbound_notspam policy=fb_outbound score=0 phishscore=0 adultscore=0 lowpriorityscore=0 malwarescore=0 spamscore=0 impostorscore=0 clxscore=1015 suspectscore=0 priorityscore=1501 mlxscore=0 mlxlogscore=950 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202180122 X-FB-Internal: deliver Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org This adds the gfp_t parameter to the create_page_buffers function. This allows the caller to specify the required parameters. Signed-off-by: Stefan Roesch Reported-by: kernel test robot --- fs/buffer.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 648e1cba6da3..ae588ae4b1c1 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1682,13 +1682,20 @@ static inline int block_size_bits(unsigned int blocksize) return ilog2(blocksize); } -static struct buffer_head *create_page_buffers(struct page *page, struct inode *inode, unsigned int b_state) +static struct buffer_head *create_page_buffers(struct page *page, + struct inode *inode, + unsigned int b_state, + gfp_t flags) { BUG_ON(!PageLocked(page)); - if (!page_has_buffers(page)) - create_empty_buffers(page, 1 << READ_ONCE(inode->i_blkbits), - b_state); + if (!page_has_buffers(page)) { + gfp_t gfp = GFP_NOFS | __GFP_ACCOUNT | flags; + + __create_empty_buffers(page, 1 << READ_ONCE(inode->i_blkbits), + b_state, gfp); + } + return page_buffers(page); } @@ -1734,7 +1741,7 @@ int __block_write_full_page(struct inode *inode, struct page *page, int write_flags = wbc_to_write_flags(wbc); head = create_page_buffers(page, inode, - (1 << BH_Dirty)|(1 << BH_Uptodate)); + (1 << BH_Dirty)|(1 << BH_Uptodate), __GFP_NOFAIL); /* * Be very careful. We have no exclusion from __set_page_dirty_buffers @@ -2000,7 +2007,7 @@ int __block_write_begin_int(struct folio *folio, loff_t pos, unsigned len, BUG_ON(to > PAGE_SIZE); BUG_ON(from > to); - head = create_page_buffers(&folio->page, inode, 0); + head = create_page_buffers(&folio->page, inode, 0, flags); blocksize = head->b_size; bbits = block_size_bits(blocksize); @@ -2127,12 +2134,17 @@ int block_write_begin(struct address_space *mapping, loff_t pos, unsigned len, pgoff_t index = pos >> PAGE_SHIFT; struct page *page; int status; + gfp_t gfp = 0; + bool no_wait = (flags & AOP_FLAG_NOWAIT); + + if (no_wait) + gfp = GFP_ATOMIC | __GFP_NOWARN; page = grab_cache_page_write_begin(mapping, index, flags); if (!page) return -ENOMEM; - status = __block_write_begin_int(page_folio(page), pos, len, get_block, NULL, flags); + status = __block_write_begin_int(page_folio(page), pos, len, get_block, NULL, gfp); if (unlikely(status)) { unlock_page(page); put_page(page); @@ -2280,7 +2292,7 @@ int block_read_full_page(struct page *page, get_block_t *get_block) int nr, i; int fully_mapped = 1; - head = create_page_buffers(page, inode, 0); + head = create_page_buffers(page, inode, 0, __GFP_NOFAIL); blocksize = head->b_size; bbits = block_size_bits(blocksize);