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 8F5F2C43334 for ; Thu, 23 Jun 2022 18:24:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 26CD68E017F; Thu, 23 Jun 2022 14:24:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 21D068E0144; Thu, 23 Jun 2022 14:24:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E5568E017F; Thu, 23 Jun 2022 14:24:49 -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 F3C2D8E0144 for ; Thu, 23 Jun 2022 14:24:48 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id CC48D2C823 for ; Thu, 23 Jun 2022 18:24:43 +0000 (UTC) X-FDA: 79610326446.17.C60026C Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by imf18.hostedemail.com (Postfix) with ESMTP id E69D31C009E for ; Thu, 23 Jun 2022 18:24:42 +0000 (UTC) Received: from pps.filterd (m0148461.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25NHunFc016009 for ; Thu, 23 Jun 2022 11:24:16 -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=kjAHNst19W6eiv1QGvc1zvRmfMOwLybaOSp/UmzV/QOJbRJOLgPWvVi3Go32Zd/oJZUY kV5HUIUOvNRmrLhTtp7A/7pg7FX+XAU4wlcsKFMQ5e1Ln+WR0OduNozEiDAcXuOmTh1j bXHUSFreQRDCyGAVdQWAAfFCZkbzRQ1cZ+Q= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3gv51n94fq-9 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 23 Jun 2022 11:24:16 -0700 Received: from twshared22934.08.ash9.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 23 Jun 2022 11:24:11 -0700 Received: by devvm225.atn0.facebook.com (Postfix, from userid 425415) id 6E12610C5DC52; Thu, 23 Jun 2022 10:52:00 -0700 (PDT) From: Stefan Roesch To: , , , , CC: , , , , , , Christoph Hellwig , "Darrick J . Wong" Subject: [RESEND PATCH v9 04/14] iomap: Add flags parameter to iomap_page_create() Date: Thu, 23 Jun 2022 10:51:47 -0700 Message-ID: <20220623175157.1715274-5-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220623175157.1715274-1-shr@fb.com> References: <20220623175157.1715274-1-shr@fb.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-GUID: R1VXN7EMtaEGP01V5QelG0YC21XhcWMt X-Proofpoint-ORIG-GUID: R1VXN7EMtaEGP01V5QelG0YC21XhcWMt X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-06-23_07,2022-06-23_01,2022-06-22_01 ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=kjAHNst1; spf=none (imf18.hostedemail.com: domain of "prvs=71737354e2=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=71737354e2=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656008683; 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=tuScfOde+/6F2myke7drmG0AvnD0uqFIGApHt8ot4i6aL86f4yEykb9orMcLC8WNb62QbF p4qysaMVjkKRT3c+tEmJIYw2zk9EQwu7t3aCWwUakxXPA8g9Veb+pd/vrUxJkGptOCeebn Gx0Kbv1zfxArbpjK/JG9J0zCBt/+eYw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656008683; a=rsa-sha256; cv=none; b=afQ8GdZFyYHQdDsKGNffat/ihNRPLNNBr7DhpYhfgZG0GPmpHpBfTna2os3b7N9cN+57VV HTrSGJzb8fQ5nCR1Vz9xI6VgSaYtDaqDQ5v5mVlI130f+5W3HYLdBTBAyTwDaYFUW9N4fn DKUsHFx58XYpvFdjMgvXDiQ7CKonApA= X-Stat-Signature: swpeb4nw9km4b7tioj6rmargemei1jb4 X-Rspamd-Queue-Id: E69D31C009E X-Rspam-User: Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=kjAHNst1; spf=none (imf18.hostedemail.com: domain of "prvs=71737354e2=shr@fb.com" has no SPF policy when checking 67.231.145.42) smtp.mailfrom="prvs=71737354e2=shr@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-Rspamd-Server: rspam02 X-HE-Tag: 1656008682-555208 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