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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A3F4C433F5 for ; Fri, 7 Jan 2022 15:53:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A44676B0072; Fri, 7 Jan 2022 10:53:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9CBA46B0073; Fri, 7 Jan 2022 10:53:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 86D206B0074; Fri, 7 Jan 2022 10:53:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0067.hostedemail.com [216.40.44.67]) by kanga.kvack.org (Postfix) with ESMTP id 70F986B0072 for ; Fri, 7 Jan 2022 10:53:17 -0500 (EST) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 0681018215F96 for ; Fri, 7 Jan 2022 15:53:17 +0000 (UTC) X-FDA: 79003935234.31.3D5FED9 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf19.hostedemail.com (Postfix) with ESMTP id 12C7F1A000B for ; Fri, 7 Jan 2022 15:53:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=b2yd3jqrlE4paTEK5U5zvhRDmcYO7C7R5TS2BGFojms=; b=cDraS37wLiLvalAuiDZqRYXJYy pmHdeL8lH1erKsxET3rHEEuTxqZeQ4zc1/JRK2jvcVepQZb2kr+7emVo/t+Yg9nht+M9/Y0+e6lda 0x0lm6hNiF5rzH+cHQkqjPYOu967HdHwu0sFQdroZaCfumFmd9Bu7TxvnI5wbkEhF9syXhEFQNj+C kjzoB77cJ2WpeIIqZZFGo5IfgJHqYQB+hYbsLjkpWldINReLcMeQpmWatMzd9ZaCLjsjyjvZg6mtf F6l3/JafJhlOJQ373xk0mF1w2obGMOBJmcCszb1HBCL5FgM5Y0Hfq9neGt5R6OzRwFWXO/VAcp6Hk e8LHQdOg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5rY7-00GT4o-2z; Fri, 07 Jan 2022 15:53:03 +0000 Date: Fri, 7 Jan 2022 15:53:03 +0000 From: Matthew Wilcox To: Hugh Dickins Cc: Andrew Morton , Christoph Hellwig , Jan Kara , William Kucharski , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH next 2/3] shmem: Fix data loss when folio truncated Message-ID: References: <24d53dac-d58d-6bb9-82af-c472922e4a31@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <24d53dac-d58d-6bb9-82af-c472922e4a31@google.com> X-Rspamd-Queue-Id: 12C7F1A000B X-Stat-Signature: ys8wq1nfuya4e1xxuibhkmx3ropf8gyd Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=cDraS37w; dmarc=none; spf=none (imf19.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspamd-Server: rspam02 X-HE-Tag: 1641570795-111475 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: On Sun, Jan 02, 2022 at 05:34:05PM -0800, Hugh Dickins wrote: > xfstests generic 098 214 263 286 412 used to pass on huge tmpfs (well, > three of those _require_odirect, enabled by a shmem_direct_IO() stub), > but still fail even with the partial_end fix. > > generic/098 output mismatch shows actual data loss: > --- tests/generic/098.out > +++ /home/hughd/xfstests/results//generic/098.out.bad > @@ -4,9 +4,7 @@ > wrote 32768/32768 bytes at offset 262144 > XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) > File content after remount: > -0000000 aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa > -* > -0400000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > +0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > ... generic/098 is passing for me ;-( I'm using 'always' for THPs. I'll have to try harder. Regardless, I think your fix is good ... > +static struct folio *shmem_get_partial_folio(struct inode *inode, pgoff_t index) Love the better calling convention. > + folio = __filemap_get_folio(inode->i_mapping, index, > + FGP_ENTRY | FGP_LOCK, 0); > + if (!folio || !xa_is_value(folio)) > + return folio; That first '!folio' is redundant. xa_is_value(NULL) is false.