Received: by 2002:ab2:3c46:0:b0:1f5:f2ab:c469 with SMTP id x6csp100167lqf; Fri, 26 Apr 2024 00:18:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXgF08r8HRML2pCKSld+CzymZiP8d6HiTZcvUByc4lZW9haaq2ttkPMTjg8B6aYJJj5axXQLPYFjrjPNMVKJ5SOlaQTk5F5LVqGO5eFqg== X-Google-Smtp-Source: AGHT+IFCXBwTQOUbRVVs0ZLiAllWnlUxngQUlGlf/V5k7wkevo6R6x7yU+Lml18BvKtvkm+CFQTT X-Received: by 2002:a9d:748e:0:b0:6ea:27c3:6353 with SMTP id t14-20020a9d748e000000b006ea27c36353mr2417407otk.13.1714115924830; Fri, 26 Apr 2024 00:18:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714115924; cv=pass; d=google.com; s=arc-20160816; b=g9tF5zxTHZ7RZFrYx/73foyDWB+fxvH7h1k6gDBAoU/MNPww/vuR1GiSG+aw2tSOrW 6K7scWX2A5+343G/Rxid/mTyxuiC78ezGwr1S+IXwYH+LgYNUPpLKnrIcMeDCzgw2VdV WOsGjXh/+UgycpzdF6djF48HulTlrJykqSvfa8oZ3SqIpof1v0vC/9IBUVQ3p9yASz1o U3bLtdgXpbyRgDXsCTYa/rGCcuYcgPwL8ZOyZTcXBkIv4/t3HxuMpqMWFzhW0M70Yx52 0xsPlTIlVvGVGtPUDfktqU1fI0FjWXcPdFka2JprjtLgzbxHOVwLW1uOmxthhUCptLFs fI4A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:user-agent:date :message-id:from:references:cc:to:subject; bh=p5nrK9evsyghubbQj9fKRNPA5z+9z51xn4hjKIJxqWA=; fh=oO9urCl7eJP2xBAA85azXSw7QBNylZRuJwxwIQWPjXI=; b=SlbsvvEfvRH0rTzG+fJ0bo3RXi9bKLSIOTNydxa2oTplUgtSoNaJlY2fyrKgKiiPec MTO61FPVkATbydFfV67vMoy1lcxY/47/HRSI/jcVGASpqeFJP7kMT8b0NGRo+1o1m28E f3QmZI/GNY9gOLfbXUNOwAcCGFyOlxqzwQqT3AqCXXfWHAUOr38P0PBLlCaQQ5LK3kSe xhejqxOFjFTdxhh6cRxzOcpktsn3evuhC3m11PmpezE0WoDSRX4JpDYbdwb4pto6Y3nO ALo3Y60t4iT5fVtbVT8VSsOq33t9v+GAhe7nOH6Cfsz2bVnis/YO6E4nn0LKZ5Vhvzjd iXDA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-159622-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159622-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l193-20020a633eca000000b005cdacf9065fsi12957662pga.720.2024.04.26.00.18.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 00:18:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159622-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-159622-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159622-linux.lists.archive=gmail.com@vger.kernel.org" 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id EB95DB22627 for ; Fri, 26 Apr 2024 07:18:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 556B713BC36; Fri, 26 Apr 2024 07:18:29 +0000 (UTC) Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5AA8513AD33; Fri, 26 Apr 2024 07:18:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714115908; cv=none; b=O77Aux72EoStra9NtVK1WBhK0USG+T9w4YZAWNhwFtOMn0tDW5esjDQCJ6stR+hFBWRr7/RKA2uRq554WxWqIotzGXhSVeIWo0AVQoHPnTj42PHCikCpBuYTif9GABARFZTu+lKxkTEyMDBG5g5K46//gJjDxU0GjXml+jlg364= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714115908; c=relaxed/simple; bh=WTCpI6h/TMPgfa/2HXkNHaaRz2yWWL9Ipkowo/sAKNE=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=CWlNKA5N0chVEn0+rh0lygQwORuhlX4p0isHSWpOPlj1khgm0i+7TZmDY6CG33EE0rdPtSpWD3RaKVutO8iToQ1Iz0hqvb77s2ssFkQi66HhURXBXxXAZfSLP+MqLEifED+fSUCZr9wxfenwbwUlOTq/O2+diDzrgRhgBxhQQas= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4VQkbC05Mwz4f3jdD; Fri, 26 Apr 2024 15:18:15 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id A20D31A1340; Fri, 26 Apr 2024 15:18:22 +0800 (CST) Received: from [10.174.176.34] (unknown [10.174.176.34]) by APP4 (Coremail) with SMTP id gCh0CgAXHG45VStmmbjILA--.23366S3; Fri, 26 Apr 2024 15:18:19 +0800 (CST) Subject: Re: [PATCH v5 4/9] xfs: convert delayed extents to unwritten when zeroing post eof blocks To: Christoph Hellwig Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, brauner@kernel.org, david@fromorbit.com, chandanbabu@kernel.org, tytso@mit.edu, jack@suse.cz, yi.zhang@huawei.com, chengzhihao1@huawei.com, yukuai3@huawei.com References: <20240425131335.878454-1-yi.zhang@huaweicloud.com> <20240425131335.878454-5-yi.zhang@huaweicloud.com> <20240425182904.GA360919@frogsfrogsfrogs> <3be86418-e629-c7e6-fd73-f59f97a73a89@huaweicloud.com> From: Zhang Yi Message-ID: <5b6228ce-c553-3387-dfc4-2db78e3bd810@huaweicloud.com> Date: Fri, 26 Apr 2024 15:18:17 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CM-TRANSID:gCh0CgAXHG45VStmmbjILA--.23366S3 X-Coremail-Antispam: 1UD129KBjvJXoW7Cw45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/4/26 14:33, Christoph Hellwig wrote: > On Fri, Apr 26, 2024 at 02:24:19PM +0800, Zhang Yi wrote: >> Yeah, it looks more reasonable. But from the original scene, the >> xfs_bmap_extsize_align() aligned the new extent that added to the cow fork >> could overlaps the unreflinked range, IIUC, I guess that spare range is >> useless exactly, is there any situation that would use it? > > I've just started staring at this (again) half an hour ago, and I fail > to understand the (pre-existing) logic in xfs_reflink_zero_posteof. > > We obviously need to ensure data between i_size and the end of the > block that i_size sits in is zeroed (but IIRC we already do that > in write and truncate anyway). But what is the point of zeroing > any speculative preallocation beyond the last block that actually > contains data? Just truncating the preallocation and freeing > the delalloc and unwritten blocks seems like it would be way > more efficient. > I've had the same idea before, I asked Dave and he explained that Linux could leak data beyond EOF page for some cases, e.g. mmap() can write to the EOF page beyond EOF without failing, and the data in that EOF page could be non-zeroed by mmap(), so the zeroing is still needed now. OTOH, if we free the delalloc and unwritten blocks beyond EOF blocks, he said it could lead to some performance problems and make thinks complicated to deal with the trimming of EOF block. Please see [1] for details and maybe Dave could explain more. [1] https://lore.kernel.org/linux-xfs/ZeERAob9Imwh01bG@dread.disaster.area/ Thanks, Yi.