Received: by 2002:a17:90a:37e8:0:0:0:0 with SMTP id v95csp4242468pjb; Mon, 21 Oct 2019 02:20:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwN9B0DJYSktwNpTMDOxbAe8+m5z5gtTl4aVxY0ymQ/nz84S6sprXHs+sKtjf3KaQBAqVqS X-Received: by 2002:a05:6402:b38:: with SMTP id bo24mr24439748edb.103.1571649632611; Mon, 21 Oct 2019 02:20:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571649632; cv=none; d=google.com; s=arc-20160816; b=wYc6+BmyjodQ31R2tZg4LMOo1x0nGs3xcbp+sgNlLtEF9bSDJWm4IJR9tJlDEcXWIe 0LAkVsdn7JTyZOimgsyANRziVxkEQxo/TAuq6/IvVPoMBko6lJg80QCaUR56Ky+KKn7j EDexsrm+fjNN21mrXEHnPZyx6InmiLx7klehaORRU3h+FOhdzyl/IXb8wRjemXA9l4k7 iuK9qWroa5IUA459y8U3Pn4mHuwb9kBb4J107+DQfuqGMFSLuupMTRA1xWrsx/uV83c2 bY1PKykpX7SRgGEXW+lH0dlNG4Tp43l25c/y19eTXopTQYRW0aDPpL9k2FjH1m3LGZq0 75Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=kFIVgO2YksXRjD5tda5/UJj64Ei0B+eEt7Hnd2mM3NY=; b=HvDt5nYgnd/ZeVx0J9FmoxkFrNhm3iJoBv4NX9x61tllPSpTsnG+SBom3hc9Wq64Zh Hl1pXMbvMXpVxZZCVmJUzn5NhWuwhBlXmllQHzvYXaFqfxS07rp6nLdJ0r+p8DTHyr+U ++rLPN/d72vF47rQSS3srgK1b8obUd+2VuLf4LcwqgZpob8qH6Qg1ip59KFJsjzSNMtv ifdhsMDHO81kv8OdT+Mt0G+iKXLyVJIbZgHsJTJ6rx/9wbK7+jqyi4i/y3GgP1j4GYrW z47Q+OnEexM068gZ8PLK9YhYbnSZq9R4mljG8CN36IcZE3+Y8HDzWP7jwkQbs2oMHR2A Z7DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mbobrowski-org.20150623.gappssmtp.com header.s=20150623 header.b=Uo3zr7tr; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e18si8857404eds.68.2019.10.21.02.20.07; Mon, 21 Oct 2019 02:20:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@mbobrowski-org.20150623.gappssmtp.com header.s=20150623 header.b=Uo3zr7tr; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727040AbfJUJRx (ORCPT + 99 others); Mon, 21 Oct 2019 05:17:53 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:33155 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726955AbfJUJRx (ORCPT ); Mon, 21 Oct 2019 05:17:53 -0400 Received: by mail-pl1-f196.google.com with SMTP id d22so6333093pls.0 for ; Mon, 21 Oct 2019 02:17:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mbobrowski-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=kFIVgO2YksXRjD5tda5/UJj64Ei0B+eEt7Hnd2mM3NY=; b=Uo3zr7trKThC4pmfsXo30OGjFMvRyOBOVdnMVnzyxgz2PNeDwuKSNMjNzhP1JVRO3W MF54hl2lXse3UsGhdKYKNTAVNk2aH4tjd6aWqSpIpxDwnQCH9qBA2fTAdzDyyH9Tikbd EdR6BqYdnhlA/uo6f+8qJxN4/dz56qfhN1dnUCKYCiLiZEftc13fgDcEP57tRr8jiw7J pMydu2grPOc/myDJbKQNxQ5xOO3Pgd8SFcRalfg1KqQ5Trwi1mMd38z/xfnCLZnPGfa0 2q+upjp9dF9gNjb3x+C5yU5aIxG+w7TVv6d5LuPxLwsebYxK7ldnBlp/o/OyaeG6rwoG 5/3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=kFIVgO2YksXRjD5tda5/UJj64Ei0B+eEt7Hnd2mM3NY=; b=dgNYTKwf4W0bkcXbbFPQK4bmADysSIh0zQzwUuvXI+BirB/kLVaFYh2bS6UbEffIQx aSv9leuj+elnMIt6DG7vjBQMPHhU97fXDQ/SGbHwLCMCTmA/dzSVPSJeNViYx0Twr2NR smGssUhgjIbsxn40sfDZuBUSEBo7Dc+p8SAhaLPB8as9DTx7TifB+q6FwjYJ/WrYeGmC +kvJjId+VUU9wS/n1V7Emrg3snLtDZQXNSYkbDgqSAPT5i23MW1poWjeUOn5YPuGZuao fES+EaeY6gIsAg4JN2PjVg9t7LZuErAe7nryABEmJKa9hHiSMxW6I9hh/xz4pYsH5TPS IGZQ== X-Gm-Message-State: APjAAAWTnUaLRsBJ6OOz1IWvrMNNj6xFnM5H0P6i5o3rYW8FGpkQwh6K VCEDk3Gp/p5wvqdBZawby1PQ X-Received: by 2002:a17:902:9002:: with SMTP id a2mr24448909plp.147.1571649472765; Mon, 21 Oct 2019 02:17:52 -0700 (PDT) Received: from athena.bobrowski.net (n1-41-199-60.bla2.nsw.optusnet.com.au. [1.41.199.60]) by smtp.gmail.com with ESMTPSA id t125sm17210797pfc.80.2019.10.21.02.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 02:17:51 -0700 (PDT) Date: Mon, 21 Oct 2019 20:17:46 +1100 From: Matthew Bobrowski To: tytso@mit.edu, jack@suse.cz, adilger.kernel@dilger.ca Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, hch@infradead.org, david@fromorbit.com, darrick.wong@oracle.com Subject: [PATCH v5 02/12] ext4: iomap that extends beyond EOF should be marked dirty Message-ID: <995387be9841bde2151c85880555c18bec68a641.1571647179.git.mbobrowski@mbobrowski.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org This patch is effectively addressed what Dave Chinner had found and fixed within this commit: 8a23414ee345. Justification for needing this modification has been provided below: When doing a direct IO that spans the current EOF, and there are written blocks beyond EOF that extend beyond the current write, the only metadata update that needs to be done is a file size extension. However, we don't mark such iomaps as IOMAP_F_DIRTY to indicate that there is IO completion metadata updates required, and hence we may fail to correctly sync file size extensions made in IO completion when O_DSYNC writes are being used and the hardware supports FUA. Hence when setting IOMAP_F_DIRTY, we need to also take into account whether the iomap spans the current EOF. If it does, then we need to mark it dirty so that IO completion will call generic_write_sync() to flush the inode size update to stable storage correctly. Signed-off-by: Matthew Bobrowski --- fs/ext4/inode.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 158eea9a1944..0dd29ae5cc8c 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3412,8 +3412,14 @@ static void ext4_set_iomap(struct inode *inode, struct iomap *iomap, { u8 blkbits = inode->i_blkbits; + /* + * Writes that span EOF might trigger an I/O size update on completion, + * so consider them to be dirty for the purposes of O_DSYNC, even if + * there is no other metadata changes being made or are pending here. + */ iomap->flags = 0; - if (ext4_inode_datasync_dirty(inode)) + if (ext4_inode_datasync_dirty(inode) || + offset + length > i_size_read(inode)) iomap->flags |= IOMAP_F_DIRTY; if (map->m_flags & EXT4_MAP_NEW) -- 2.20.1 ----