Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp845907pxk; Thu, 3 Sep 2020 14:13:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUnPx8h2jXW62loSoLJI8ZpSa1n0sT4AVfdQLx9fA52nae2PcMucK+WlHbQ4H7xx11o0pL X-Received: by 2002:a17:907:2456:: with SMTP id yw22mr4067196ejb.337.1599167594045; Thu, 03 Sep 2020 14:13:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599167594; cv=none; d=google.com; s=arc-20160816; b=uCDXyWOrWruXl92xiGEj7BwKDYdetajj/rremIlI4lxjajUXicbLhI4oBsgIskKiqw 1qMz3bgKrzejZCXw2BSnVRarjuFW8E87Ye7Gpu5pSVt1Ur1aCgg0qFYDvxbUN5AMGJWq AOf7pHU79WtlATnQb44y/IvhxPfSIGOaHFAxPVEUVX4X+iELDnXoXkJlaXvDq11LZNvR M9l7h/QZHxiFzSHrw1fmUxUad+TsYOojsAmVq3q4JNJieHdksDYQe/Ko1B0W32MbrIS2 qaZCns9/KM3UnpbbTZq5T/yK6DdgfdvwDW38RNjPi9K/8rDn1MvZuk1u1JsnrJ27rdRQ m3oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:subject:from:references:cc:to; bh=seoRoUwBiXCgP72lOw42pSRNqixaX2MenKm2GIPrZJg=; b=H3b5hm6EVke25EM53Q1n7qBQE1PoxXugjBAvuaDka465NPvlz1yarTSAEcfynbkL3f KK4ARTuhOsh0diOcQE7p8FtfB4XiRb6NktnqQhdn17cgU3Y6nfDRki42FnojYvpX9XuV 5aV313Zs+UPjejx8YOt6Ljvt+irmOcJypL6pPOW92s+Fu+22QeTn6qkwi//F3pYNeAPK XcmFIpp+5BfTQ3tge0NeLoeVssuYlK/s/e+cnBbgLBynjjfpi+4IGdohvF7zd/66tzZN l5AoQYfSD6d0GQnDgRCWPAzlKbNSPAFf/41tYSF2mYBnS/Q9y/ewSzNR1b1HhrrNwyl/ sI4w== 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 gz7si2874977ejb.441.2020.09.03.14.12.40; Thu, 03 Sep 2020 14:13:14 -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 S1728288AbgICVMf (ORCPT + 99 others); Thu, 3 Sep 2020 17:12:35 -0400 Received: from sandeen.net ([63.231.237.45]:41628 "EHLO sandeen.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726323AbgICVMf (ORCPT ); Thu, 3 Sep 2020 17:12:35 -0400 Received: from liberator.sandeen.net (liberator.sandeen.net [10.0.0.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by sandeen.net (Postfix) with ESMTPSA id D94902ACC; Thu, 3 Sep 2020 16:12:09 -0500 (CDT) To: Andreas Gruenbacher , Christoph Hellwig , "Darrick J. Wong" Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, cluster-devel@redhat.com, linux-ext4@vger.kernel.org References: <20200903165632.1338996-1-agruenba@redhat.com> From: Eric Sandeen Subject: Re: [PATCH] iomap: Fix direct I/O write consistency check Message-ID: <695a418c-ba6d-d3e9-f521-7dfa059764db@sandeen.net> Date: Thu, 3 Sep 2020 16:12:33 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.2.1 MIME-Version: 1.0 In-Reply-To: <20200903165632.1338996-1-agruenba@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 9/3/20 11:56 AM, Andreas Gruenbacher wrote: > When a direct I/O write falls back to buffered I/O entirely, dio->size > will be 0 in iomap_dio_complete. Function invalidate_inode_pages2_range > will try to invalidate the rest of the address space. (Because if ->size == 0 and offset == 0, then invalidating up to (0+0-1) will invalidate the entire range.) err = invalidate_inode_pages2_range(inode->i_mapping, offset >> PAGE_SHIFT, (offset + dio->size - 1) >> PAGE_SHIFT); so I guess this behavior is unique to writing to a hole at offset 0? FWIW, this same test yields the same results on ext3 when it falls back to buffered. -Eric > If there are any > dirty pages in that range, the write will fail and a "Page cache > invalidation failure on direct I/O" error will be logged. > > On gfs2, this can be reproduced as follows: > > xfs_io \ > -c "open -ft foo" -c "pwrite 4k 4k" -c "close" \ > -c "open -d foo" -c "pwrite 0 4k" > > Fix this by recognizing 0-length writes. > > Signed-off-by: Andreas Gruenbacher > --- > fs/iomap/direct-io.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c > index c1aafb2ab990..c9d6b4eecdb7 100644 > --- a/fs/iomap/direct-io.c > +++ b/fs/iomap/direct-io.c > @@ -108,7 +108,7 @@ static ssize_t iomap_dio_complete(struct iomap_dio *dio) > * ->end_io() when necessary, otherwise a racing buffer read would cache > * zeros from unwritten extents. > */ > - if (!dio->error && > + if (!dio->error && dio->size && > (dio->flags & IOMAP_DIO_WRITE) && inode->i_mapping->nrpages) { > int err; > err = invalidate_inode_pages2_range(inode->i_mapping, >