Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp639940lqj; Sun, 2 Jun 2024 15:23:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU3mXPT1P5GRYRLlEvGAex2kYEQDwmIFQV/xlx0kVmKi/KpF9v6Caito2ArJh93F9ahbPSFEyQYAKAME2dasalOEE91eqmmyvMFe/G1+A== X-Google-Smtp-Source: AGHT+IH+Qt8AptyYm8kNKCByR69xpcCnoEAG2RWqozKJkb7XyyEIuMGrPSIws7s4VlcTcQIlSgba X-Received: by 2002:a17:902:ea11:b0:1f5:e796:f279 with SMTP id d9443c01a7336-1f636ff527emr96890735ad.9.1717366996156; Sun, 02 Jun 2024 15:23:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717366996; cv=pass; d=google.com; s=arc-20160816; b=F3R0WxiQK6BNcfJrpikdbmLDx9UocmZYP4vLJPumZrGDX3+W5R3EBeLc4VA090lqMv draoCigCS4bYRr/33RHhYjHsQCO+2Kg/i38LdQlRUMuYdmyZxs+Bj7at1757n+cJe1xs EdBKGSN4XYvu+TPBWF3K3CXR7QeQmXcPIAWITSJ8YtkpZnsRT0WpG+euOOTjWI1MNAae VhRB153xY44RpzxVp6FlLS8qeNXmR9lNcwLQoMtaZ8xCa3aUjb0cYfH3ktZRiBySF8QI Nr8xH60y4V2A5bBY19fTE07tNK81Cen2WmoBQt1bx0SNMTnPEbuBqhwZX/nCZRI1p5rU MPPA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=r+qHiu1fDaio4iw1wa2Jj3WFs3uLLPp8LW1eRWXiQiw=; fh=3KPBTMeCbGx4mH1NyaMott3lyF2dYDihRcsXBuxEKwg=; b=C6mVSsuscIuzlfTBtIPSxFlPSvN9r4tWrzu6hmmTDupHmqhK4CFAG+MLIc2C7gXTd0 U5lJTxncGz8ViUtb6zrJbk531hOHzgP1aNBSBcmE1J/Js+yY/xw82QTegF5U9939rZQj lgNOR8wSD2Zlv4JlnlM/YBcoNtKTfwzXaLGOnfMVnUijX90zGCtX5x9+WEu94KSMbxmS Lwy+VjM09n496M46TKcqku+FvqirpdaJ0AzC4W6rr6Eo+hHIuAZwc9msnImMDTlBDCt/ e8G8MpEWDEkhXSaleZJJ7RrbhEwfyRjRopHETC8R250H80eESHrWqoBwHHhrD4q0Uu5T 3tkA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=xYsymsIj; arc=pass (i=1 spf=pass spfdomain=fromorbit.com dkim=pass dkdomain=fromorbit-com.20230601.gappssmtp.com dmarc=pass fromdomain=fromorbit.com); spf=pass (google.com: domain of linux-kernel+bounces-198455-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198455-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=fromorbit.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f63233eea0si52526815ad.65.2024.06.02.15.23.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jun 2024 15:23:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-198455-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=xYsymsIj; arc=pass (i=1 spf=pass spfdomain=fromorbit.com dkim=pass dkdomain=fromorbit-com.20230601.gappssmtp.com dmarc=pass fromdomain=fromorbit.com); spf=pass (google.com: domain of linux-kernel+bounces-198455-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198455-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=fromorbit.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 622AF280F6A for ; Sun, 2 Jun 2024 22:23:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 37B0578C69; Sun, 2 Jun 2024 22:23:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fromorbit-com.20230601.gappssmtp.com header.i=@fromorbit-com.20230601.gappssmtp.com header.b="xYsymsIj" Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DDA952943F for ; Sun, 2 Jun 2024 22:23:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717366985; cv=none; b=an5YidJPTlfHMX5Kvo2An2pMYcV7udNNQwo64Ud3Au4bk64Cl76+n3Y2JnR9P+HD33yhOs7MkOd6WA+KvAdehdHVmhs3osT07c84sQh3Zll2CnOuvFIpGrHctj/AVUc20pYwMDZFEB9aBODa5iXAfDSMUnWHyXZTSWVkbkSHHb4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717366985; c=relaxed/simple; bh=Mr00QLpO9fhnocd3iU/6Fo0RO4Ha+r/BVCnA46PTjNw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bX3bxSTP1aBLklIxJ6ZhLTcj+ZgD82/Jn5vxoTW/VyIK0kSiWtkmsplx+08/sL+06baz/Dc2n5FWIr4/TO1ZPODvyIRjQqFeBvkbtuhPMq/mnlsCT0qaEh20aXUCiubaUwoqaA+FTqXTPFotTBwEYk1hGFGPYC8nezF1hrDSpnI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fromorbit.com; spf=pass smtp.mailfrom=fromorbit.com; dkim=pass (2048-bit key) header.d=fromorbit-com.20230601.gappssmtp.com header.i=@fromorbit-com.20230601.gappssmtp.com header.b=xYsymsIj; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fromorbit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fromorbit.com Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-701ae8698d8so2840305b3a.0 for ; Sun, 02 Jun 2024 15:23:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20230601.gappssmtp.com; s=20230601; t=1717366983; x=1717971783; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=r+qHiu1fDaio4iw1wa2Jj3WFs3uLLPp8LW1eRWXiQiw=; b=xYsymsIjgQQ4SImF4UsQ8LiDYHY2Jrcjbd+APZ/ar9UOse2vEAD5DUQkYggC83uFNU vT9MzDV4W/X56ScTzMKBrxPyHVSFuxv7qYmfBuTXm/SojS+yBWGiASThN1knBPnhptn8 bIBQThcWWmIMIL9FFkbx0r2B22AduZJhEWlEYp8b0aMIJxeGEdsipcjmN/TSJTUAu+z5 BYfjBCEa8dXYWF9PpBpgyCmNGNFWwKoo6ggMhB/4+81yr35GEQuIGEYgnPE4uogRSr9t Rcn56RenSfb/ioyI/Gv3Q2//gbZevgjQ19f9pIaF+lbOn7PBJLiAskWnKKEe4j6RJmRj woNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717366983; x=1717971783; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=r+qHiu1fDaio4iw1wa2Jj3WFs3uLLPp8LW1eRWXiQiw=; b=JgCfxeXpRQ/iPxQeXQXutVtt/zbLFI9wQAV/Tu2nSntiYuGP1VJ+1qis7e7yneSlZr lgvBbp2FeYwzODtxU8fOMEEJ0rNgif1IQR7F8uVpmKfPfLaOdVDSIbE0O8kv9Y9n9hfj 2czC9DIdPO5kndPdlckYbYqxk6Q0do1DwXgt+B4ypYNAXAJ+Parbmx5P62qUWubE31Uo C85OQGYuBOh2Ej1rQV7m8Qez1MUEQvWiqk7TdpXnz83zEcBmBKKlSOUZMJD4NqMA/+0o eavcn8ePmgT1UhkgA2XJoY9ZES+ZVzAW2hGsAi1w9V0WianiQctL42h0DdG6W3ETUsfB QP5A== X-Forwarded-Encrypted: i=1; AJvYcCUx2IoynytiWNBKG21nPxrcetIMKjzpgJhI43qkELJPZP/1uFnmKW17EhrxlQVqXvsFCTEeuffj/wkl6lnGlM3JOGAJxTppUUWl4AAq X-Gm-Message-State: AOJu0Yz+pJVmK9ecTdJ5MQfVnaLVHNwNMUmY+7JDz8Mnjup6hpVoVGoO NeXBg6p/e3mewbhYH5PU8HdAQ38qbixoP9JRwa2Eqc/mD8etaHp3UXpQ33wn66k= X-Received: by 2002:a05:6a00:4b53:b0:702:6022:ff8b with SMTP id d2e1a72fcca58-7026023009dmr3771225b3a.30.1717366982930; Sun, 02 Jun 2024 15:23:02 -0700 (PDT) Received: from dread.disaster.area (pa49-179-32-121.pa.nsw.optusnet.com.au. [49.179.32.121]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70242b300e8sm4340433b3a.210.2024.06.02.15.23.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jun 2024 15:23:02 -0700 (PDT) Received: from dave by dread.disaster.area with local (Exim 4.96) (envelope-from ) id 1sDtbO-002AE0-1s; Mon, 03 Jun 2024 08:22:58 +1000 Date: Mon, 3 Jun 2024 08:22:58 +1000 From: Dave Chinner To: Christoph Hellwig Cc: Zhang Yi , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, djwong@kernel.org, brauner@kernel.org, chandanbabu@kernel.org, jack@suse.cz, willy@infradead.org, yi.zhang@huawei.com, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: Re: [RFC PATCH v4 1/8] iomap: zeroing needs to be pagecache aware Message-ID: References: <20240529095206.2568162-1-yi.zhang@huaweicloud.com> <20240529095206.2568162-2-yi.zhang@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, May 31, 2024 at 06:11:25AM -0700, Christoph Hellwig wrote: > On Wed, May 29, 2024 at 05:51:59PM +0800, Zhang Yi wrote: > > XXX: how do we detect a iomap containing a cow mapping over a hole > > in iomap_zero_iter()? The XFS code implies this case also needs to > > zero the page cache if there is data present, so trigger for page > > cache lookup only in iomap_zero_iter() needs to handle this case as > > well. > > If there is no data in the page cache and either a whole or unwritten > extent it really should not matter what is in the COW fork, a there > obviously isn't any data we could zero. > > If there is data in the page cache for something that is marked as > a hole in the srcmap, but we have data in the COW fork due to > COW extsize preallocation we'd need to zero it, but as the > xfs iomap ops don't return a separate srcmap for that case we > should be fine. Or am I missing something? If the data extent is a hole, xfs_buffered_write_iomap_begin() doesn't even check the cow fork for extents if IOMAP_ZERO is being done. Hence if there is a pending COW extent that extends over a data fork hole (cow fork preallocation can do that, right?), then we may have data in the page cache over an unwritten extent in the COW fork. This code: /* We never need to allocate blocks for zeroing or unsharing a hole. */ if ((flags & (IOMAP_UNSHARE | IOMAP_ZERO)) && imap.br_startoff > offset_fsb) { xfs_hole_to_iomap(ip, iomap, offset_fsb, imap.br_startoff); goto out_unlock; } The comment, IMO, indicates the issue here: we're not going to allocate blocks in IOMAP_ZERO, but we do need to map anything that might contain page cache data for the IOMAP_ZERO case. If "data hole, COW unwritten, page cache dirty" can exist as the comment in xfs_setattr_size() implies, then this code is broken and needs fixing. I don't know what that fix looks like yet - I suspect that all we need to do for IOMAP_ZERO is to return the COW extent in the srcmap, and then the zeroing code should do the right thing if it's an unwritten COW extent... -Dave. -- Dave Chinner david@fromorbit.com