From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EF90C1B08C for ; Thu, 15 Jul 2021 05:21:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1C8D961360 for ; Thu, 15 Jul 2021 05:21:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1C8D961360 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 725B48D0087; Thu, 15 Jul 2021 01:21:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E1D08D0065; Thu, 15 Jul 2021 01:21:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 54FF18D0087; Thu, 15 Jul 2021 01:21:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0208.hostedemail.com [216.40.44.208]) by kanga.kvack.org (Postfix) with ESMTP id 26FBC8D0065 for ; Thu, 15 Jul 2021 01:21:26 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 05FEF183594E1 for ; Thu, 15 Jul 2021 05:21:24 +0000 (UTC) X-FDA: 78363674130.02.01E62E7 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf27.hostedemail.com (Postfix) with ESMTP id B100A700009D for ; Thu, 15 Jul 2021 05:21:24 +0000 (UTC) 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=7mM+4r3MgelJWIdGY296pIhhgFaWpEQSXi+vxd43vYc=; b=o+I6Q5JO0e9YRe5ZHrqSyKTMBT LWnzgyk1ChESJw43DpEOSq6Qr/aXeUU431Z13DS9M2LskBBAIhItt4n1Rf+GygcU9JErB21wBJYAu pFW1jNIE1ZwPaQ976e2Y4RUQQ6hQoV7A7mZQw/RFPlrPMYYXIuL0u0OHpyiOawxGvfYrw8mdBFig3 mZUI0k7MG/Z80sOec24gMya7ov1d4tV9ISwFWkTtVOMUZ+x75tTJfFLhwipIQe+tb/Dv0bgB+cBZj rQyKYZB+uqGOPGMhucHmKSmE+qWWsf7zu+NcLr3j8zHf/02JSsm9w7v/4uKO7plrpHgT4HioVX2nz B/sOfcjA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m3tn3-0030oU-0B; Thu, 15 Jul 2021 05:20:17 +0000 From: "Matthew Wilcox (Oracle)" To: linux-kernel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v14 128/138] iomap: Support multi-page folios in invalidatepage Date: Thu, 15 Jul 2021 04:36:54 +0100 Message-Id: <20210715033704.692967-129-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210715033704.692967-1-willy@infradead.org> References: <20210715033704.692967-1-willy@infradead.org> MIME-Version: 1.0 Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=o+I6Q5JO; spf=none (imf27.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspamd-Server: rspam05 X-Stat-Signature: 44x58jpoyut6b9j7spagxfcof3mchey7 X-Rspamd-Queue-Id: B100A700009D X-HE-Tag: 1626326484-852517 Content-Transfer-Encoding: quoted-printable 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: If we're punching a hole in a multi-page folio, we need to remove the per-page iomap data as the folio is about to be split and each page will need its own. This means that writepage can now come across a page with no iop allocated, so remove the assertion that there is already one, and just create one (with the uptodate bits set) if there isn't one. Signed-off-by: Matthew Wilcox (Oracle) --- fs/iomap/buffered-io.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 48de198c5603..7f78256fc0ba 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -474,13 +474,17 @@ iomap_invalidatepage(struct page *page, unsigned in= t offset, unsigned int len) trace_iomap_invalidatepage(folio->mapping->host, offset, len); =20 /* - * If we are invalidating the entire page, clear the dirty state from i= t - * and release it to avoid unnecessary buildup of the LRU. + * If we are invalidating the entire folio, clear the dirty state + * from it and release it to avoid unnecessary buildup of the LRU. */ if (offset =3D=3D 0 && len =3D=3D folio_size(folio)) { WARN_ON_ONCE(folio_test_writeback(folio)); folio_cancel_dirty(folio); iomap_page_release(folio); + } else if (folio_multi(folio)) { + /* Must release the iop so the page can be split */ + WARN_ON_ONCE(!folio_test_uptodate(folio) && folio_test_dirty(folio)); + iomap_page_release(folio); } } EXPORT_SYMBOL_GPL(iomap_invalidatepage); @@ -1300,7 +1304,7 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc= , struct writeback_control *wbc, struct inode *inode, struct folio *folio, loff_t end_pos) { - struct iomap_page *iop =3D to_iomap_page(folio); + struct iomap_page *iop =3D iomap_page_create(inode, folio); struct iomap_ioend *ioend, *next; unsigned len =3D i_blocksize(inode); unsigned nblocks =3D i_blocks_per_folio(inode, folio); @@ -1308,7 +1312,6 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc= , int error =3D 0, count =3D 0, i; LIST_HEAD(submit_list); =20 - WARN_ON_ONCE(nblocks > 1 && !iop); WARN_ON_ONCE(iop && atomic_read(&iop->write_bytes_pending) !=3D 0); =20 /* --=20 2.30.2