Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp801815pxy; Thu, 22 Apr 2021 13:53:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIFo+MPzNacSn0ugVJB5R2TyCTOmqtOIffrcf6jotJjf5kwZq+JYhbnHVskT7L+IW+JEhZ X-Received: by 2002:a17:906:9990:: with SMTP id af16mr562346ejc.195.1619124812689; Thu, 22 Apr 2021 13:53:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619124812; cv=none; d=google.com; s=arc-20160816; b=a+YR4lYJsvQH6bQ2UNgC59eH/zwb4lqn+xPIVAHtYc9qceCcHwUj/9UBo8D1OittqL wGj2R0pfkl3DtFAsmv1w4uEkyUaLLRAJePNuTUk3lLKPchNVMLMhFnb1PHIzse+qbDtw cdl0LrmCCpY2OTJ2rw0UCCSQskDPmhCCG7HN1bPMnNmXPyh963Mr8BRFm+UHMDpgOqSV BpuTCSkfmRp50lg5t9N8gU1wJtXb5/xGrfc4chOmxcn1KrXVisufE80sFo/+uVjsQqxm yE2diRyTB2MWMK3/HK0m5Y2+gS4T4x4Fhiwrtfyqvu9VlSI9E2LtpjMsRKtK3QDHCZfl Pptg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=7QAmK0XNyGIRfSErpa2zVNnLaQO9Mc+V5O5+Ae48MH0=; b=RX4Ky1jluLENJnbo6QK9U1hgBUx3nNlNUyazlrV+nPjXd5lKWaUlPcWK72gETMeqVf QSia+S0tlCAyxAQ61GCIOcyn4KqWHHA1Df5VZ5SFEj6D372UFdGfqMHmpdbRyokU8tIs JUvZmGHPUiTBalKDsbaPzbWPNAAIfrGfWjXdkZDriWSG6Wk1Zln24eQtRToq9qR4TkjM mQwrnVMRUXyJZzbPQFGZZcclkfUZqXD4WhONTMy+r2lzNv956fRTwHaL0D7/XWxoLLdh ypL2x5QyPcjyAychxqCOJO/UZyFqA/+Z3h7QFVqffJQ6EdY6Z6nVPlpn/7AgEXI5VbZL wY1A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n7si3211006ejl.155.2021.04.22.13.53.03; Thu, 22 Apr 2021 13:53:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239440AbhDVUw4 (ORCPT + 99 others); Thu, 22 Apr 2021 16:52:56 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:50542 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239406AbhDVUwz (ORCPT ); Thu, 22 Apr 2021 16:52:55 -0400 Received: from cwcc.thunk.org (pool-72-74-133-215.bstnma.fios.verizon.net [72.74.133.215]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 13MKqFTI003582 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 22 Apr 2021 16:52:16 -0400 Received: by cwcc.thunk.org (Postfix, from userid 15806) id 6BCAD15C3B0D; Thu, 22 Apr 2021 16:52:15 -0400 (EDT) Date: Thu, 22 Apr 2021 16:52:15 -0400 From: "Theodore Ts'o" To: Jan Kara Cc: linux-ext4@vger.kernel.org, Eric Whitney , stable@vger.kernel.org Subject: Re: [PATCH v3] ext4: Fix occasional generic/418 failure Message-ID: References: <20210415155417.4734-1-jack@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210415155417.4734-1-jack@suse.cz> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu, Apr 15, 2021 at 05:54:17PM +0200, Jan Kara wrote: > Eric has noticed that after pagecache read rework, generic/418 is > occasionally failing for ext4 when blocksize < pagesize. In fact, the > pagecache rework just made hard to hit race in ext4 more likely. The > problem is that since ext4 conversion of direct IO writes to iomap > framework (commit 378f32bab371), we update inode size after direct IO > write only after invalidating page cache. Thus if buffered read sneaks > at unfortunate moment like: > > CPU1 - write at offset 1k CPU2 - read from offset 0 > iomap_dio_rw(..., IOMAP_DIO_FORCE_WAIT); > ext4_readpage(); > ext4_handle_inode_extension() > > the read will zero out tail of the page as it still sees smaller inode > size and thus page cache becomes inconsistent with on-disk contents with > all the consequences. > > Fix the problem by moving inode size update into end_io handler which > gets called before the page cache is invalidated. > > Reported-and-tested-by: Eric Whitney > Fixes: 378f32bab371 ("ext4: introduce direct I/O write using iomap infrastructure") > CC: stable@vger.kernel.org > Signed-off-by: Jan Kara Thanks, applied. - Ted