From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E64AAC433EF for ; Thu, 16 Jun 2022 21:58:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7A9D86B0071; Thu, 16 Jun 2022 17:58:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 733516B0072; Thu, 16 Jun 2022 17:58:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5AB8D6B0073; Thu, 16 Jun 2022 17:58:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 475896B0071 for ; Thu, 16 Jun 2022 17:58:19 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 16D0F6EE for ; Thu, 16 Jun 2022 21:58:19 +0000 (UTC) X-FDA: 79585463118.27.0873108 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf09.hostedemail.com (Postfix) with ESMTP id 9808C140015 for ; Thu, 16 Jun 2022 21:58:18 +0000 (UTC) Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.17.1.5/8.17.1.5) with ESMTP id 25GKPSJN002330 for ; Thu, 16 Jun 2022 14:58:17 -0700 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=gfRc1/nPFIvCPltEInFLBIIZpX8aj3lmAi2CboYoUQA=; b=mJJzHxJWruRY+XzkOXFjGrWhslWDW/S18UQlMYNqQdAFfL7zFIten8OmSXvReEAvgWHu Dalv8ndxlBSHfe3yG84FobcTvX+xCer9H1V3jBPPnwb3+YGUk72UV1MfKngSgi99Lx4h A7fGj1Q0KPxTd5dPGZXVapRkNORSO68dxg0= Received: from maileast.thefacebook.com ([163.114.130.16]) by m0001303.ppops.net (PPS) with ESMTPS id 3gpw7rnspx-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 16 Jun 2022 14:58:17 -0700 Received: from twshared14818.18.frc3.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::c) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 16 Jun 2022 14:58:15 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id A3BE7108B709D; Thu, 16 Jun 2022 14:22:23 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , , , , , Christoph Hellwig , "Darrick J . Wong" Subject: [PATCH v9 04/14] iomap: Add flags parameter to iomap_page_create() Date: Thu, 16 Jun 2022 14:22:11 -0700 Message-ID: <20220616212221.2024518-5-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220616212221.2024518-1-shr@fb.com> References: <20220616212221.2024518-1-shr@fb.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-GUID: z7IPytL2nmsaRdc9r63CTeP2vf7bdsKW X-Proofpoint-ORIG-GUID: z7IPytL2nmsaRdc9r63CTeP2vf7bdsKW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-16_18,2022-06-16_01,2022-02-23_01 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655416698; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gfRc1/nPFIvCPltEInFLBIIZpX8aj3lmAi2CboYoUQA=; b=ST7iqIIm8ruGLVAhXm9WEyS4F0KXnSxHehzlkJeStnpCrNEZz/1Vht54i6UE3ZHaTWyoy5 ysV4aq0QnFfdzxtrT0DMeu598QbcJSXIBl3oX1AnH4BjbOLZ7si8NtnQHYF4NY6FeuxPdH W37LyUht6QkV1+jmUsuLYixql+djt0c= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655416698; a=rsa-sha256; cv=none; b=dXzynz7l6XEIVbSFhxuf/ryGZg+jdOi4dHtRbKQg+3mnFTCcgvXWO8AHs3biVF0f6+xDwC KlYRiJqFt6nK75OfygmiEjJKZNUPofhmxtFl5g4ncHUdCZNe15MEPJYAGkM28ip+rbSyKP u2YkKHPY9yWGfve0At61CFIzvciXjYM= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=mJJzHxJW; dmarc=pass (policy=reject) header.from=fb.com; spf=none (imf09.hostedemail.com: domain of "prvs=7166657324=shr@fb.com" has no SPF policy when checking 67.231.153.30) smtp.mailfrom="prvs=7166657324=shr@fb.com" Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=mJJzHxJW; dmarc=pass (policy=reject) header.from=fb.com; spf=none (imf09.hostedemail.com: domain of "prvs=7166657324=shr@fb.com" has no SPF policy when checking 67.231.153.30) smtp.mailfrom="prvs=7166657324=shr@fb.com" X-Rspamd-Server: rspam12 X-Rspam-User: X-Stat-Signature: mfeim4p4kxtnixkdgffo8dk17xf5aqpf X-Rspamd-Queue-Id: 9808C140015 X-HE-Tag: 1655416698-14411 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Add the kiocb flags parameter to the function iomap_page_create(). Depending on the value of the flags parameter it enables different gfp flags. No intended functional changes in this patch. Signed-off-by: Stefan Roesch Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/iomap/buffered-io.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index d2a9f699e17e..3c97b713f831 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -44,20 +44,28 @@ static inline struct iomap_page *to_iomap_page(struct= folio *folio) static struct bio_set iomap_ioend_bioset; =20 static struct iomap_page * -iomap_page_create(struct inode *inode, struct folio *folio) +iomap_page_create(struct inode *inode, struct folio *folio, unsigned int= flags) { struct iomap_page *iop =3D to_iomap_page(folio); unsigned int nr_blocks =3D i_blocks_per_folio(inode, folio); + gfp_t gfp; =20 if (iop || nr_blocks <=3D 1) return iop; =20 + if (flags & IOMAP_NOWAIT) + gfp =3D GFP_NOWAIT; + else + gfp =3D GFP_NOFS | __GFP_NOFAIL; + iop =3D kzalloc(struct_size(iop, uptodate, BITS_TO_LONGS(nr_blocks)), - GFP_NOFS | __GFP_NOFAIL); - spin_lock_init(&iop->uptodate_lock); - if (folio_test_uptodate(folio)) - bitmap_fill(iop->uptodate, nr_blocks); - folio_attach_private(folio, iop); + gfp); + if (iop) { + spin_lock_init(&iop->uptodate_lock); + if (folio_test_uptodate(folio)) + bitmap_fill(iop->uptodate, nr_blocks); + folio_attach_private(folio, iop); + } return iop; } =20 @@ -226,7 +234,7 @@ static int iomap_read_inline_data(const struct iomap_= iter *iter, if (WARN_ON_ONCE(size > iomap->length)) return -EIO; if (offset > 0) - iop =3D iomap_page_create(iter->inode, folio); + iop =3D iomap_page_create(iter->inode, folio, iter->flags); else iop =3D to_iomap_page(folio); =20 @@ -264,7 +272,7 @@ static loff_t iomap_readpage_iter(const struct iomap_= iter *iter, return iomap_read_inline_data(iter, folio); =20 /* zero post-eof blocks as the page may be mapped */ - iop =3D iomap_page_create(iter->inode, folio); + iop =3D iomap_page_create(iter->inode, folio, iter->flags); iomap_adjust_read_range(iter->inode, folio, &pos, length, &poff, &plen)= ; if (plen =3D=3D 0) goto done; @@ -547,7 +555,7 @@ static int __iomap_write_begin(const struct iomap_ite= r *iter, loff_t pos, size_t len, struct folio *folio) { const struct iomap *srcmap =3D iomap_iter_srcmap(iter); - struct iomap_page *iop =3D iomap_page_create(iter->inode, folio); + struct iomap_page *iop; loff_t block_size =3D i_blocksize(iter->inode); loff_t block_start =3D round_down(pos, block_size); loff_t block_end =3D round_up(pos + len, block_size); @@ -558,6 +566,8 @@ static int __iomap_write_begin(const struct iomap_ite= r *iter, loff_t pos, return 0; folio_clear_error(folio); =20 + iop =3D iomap_page_create(iter->inode, folio, iter->flags); + do { iomap_adjust_read_range(iter->inode, folio, &block_start, block_end - block_start, &poff, &plen); @@ -1329,7 +1339,7 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc= , struct writeback_control *wbc, struct inode *inode, struct folio *folio, u64 end_pos) { - struct iomap_page *iop =3D iomap_page_create(inode, folio); + struct iomap_page *iop =3D iomap_page_create(inode, folio, 0); struct iomap_ioend *ioend, *next; unsigned len =3D i_blocksize(inode); unsigned nblocks =3D i_blocks_per_folio(inode, folio); --=20 2.30.2