Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6512467rdb; Tue, 2 Jan 2024 04:43:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IGqlWBeDsi6vubIrssD+TUnnCgi1UPqlVBGiOU1Z7IvyMm6L1WOVSgVBTP74wAFnRy9F8l3 X-Received: by 2002:a17:902:e84d:b0:1d4:35b7:35f9 with SMTP id t13-20020a170902e84d00b001d435b735f9mr19351834plg.34.1704199403794; Tue, 02 Jan 2024 04:43:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704199403; cv=none; d=google.com; s=arc-20160816; b=JoIWMtRsPbuXd2YGPd94p9qEeXa05dBHXv6okC9+nGhzGX1NC0hmgbOmEG9a9WzGYV 8FaOABPHV/6IEmHvI0l/VqtesBt1XoS8XvYaczRfpFw41JIMSl6FTG2FE7lL8bi2382H +PCEg/gHDFGyAGECuHRAd2aMgBKRmIv/SgkV/TWLMN3iRUokEJBfbnMUHcp4EfyJT5Mp uaCI9KVxHKw3ghvtTy0m6uSFn3naLVGp7iKI5dO+DUOwood10/Lt5pQ594Y+qXsF413c I5UEIBDzqergwFDol3E8p9R5KfmBgiGtdbVDwbsqstdh2ahoAfpejTuT9mZDqzrInxi+ hjZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=K6sqmlZYi61Z1fs3T4NiLF3x2szeJ78wmkIIrXojy3M=; fh=yWWoL3IRufgA/+2kSpO6uyfw9eN3ZOO7zvul0qbDPkA=; b=cMg7D4NIdNZMhhFgQYqvz8eXzGnqpAmE0/JB0Ma7nJNxnCILu3+q6qjHbvBDpORbXO UMrU2XFK6dFAmgj+mnnMTs/ZMYZULW1/EqCnb0GppWu59wTLxKziKbYu79avOC/Fw52H eThSoMn6TKPcQcSWZIC5yFi6ZLeWiQ0Q1ov6ZxasYEvnSctZp3EIXwaYdkzsS7IdEGvB HX3XMMnP0zHibM+KvuOoEyL0g92RxVZc8QZOc9QwLfpS+JzIOZZwU1Ai4c6/McH6fSKN 04gbV1MylgOTkfIBhlT5I0LM429XK7z7IctR+BD2K7E9M92PXhUhQpOkAunzHJGN6QIA 0zIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-601-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-ext4+bounces-601-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d11-20020a170902c18b00b001d08d137423si19758892pld.65.2024.01.02.04.43.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 04:43:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-601-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-601-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-ext4+bounces-601-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 B6012B21CED for ; Tue, 2 Jan 2024 12:43:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E103125DA; Tue, 2 Jan 2024 12:42:14 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from dggsgout12.his.huawei.com (unknown [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 46A91101C5; Tue, 2 Jan 2024 12:42:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4T4CCx6bBmz4f3kFq; Tue, 2 Jan 2024 20:42:05 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 2DC731A6C6B; Tue, 2 Jan 2024 20:42:09 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgBnwUGUBJRl+EvDFQ--.31823S11; Tue, 02 Jan 2024 20:42:08 +0800 (CST) From: Zhang Yi To: linux-ext4@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, ritesh.list@gmail.com, hch@infradead.org, djwong@kernel.org, willy@infradead.org, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, chengzhihao1@huawei.com, yukuai3@huawei.com, wangkefeng.wang@huawei.com Subject: [RFC PATCH v2 07/25] iomap: don't increase i_size if it's not a write operation Date: Tue, 2 Jan 2024 20:39:00 +0800 Message-Id: <20240102123918.799062-8-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240102123918.799062-1-yi.zhang@huaweicloud.com> References: <20240102123918.799062-1-yi.zhang@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:gCh0CgBnwUGUBJRl+EvDFQ--.31823S11 X-Coremail-Antispam: 1UD129KBjvJXoW7Kr15ZFWfGFyfAw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M-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ From: Zhang Yi Increase i_size in iomap_zero_range() looks not needed, the caller should handle it. Especially, when truncate partial block, we should not increase i_size beyond the new EOF here. It dosn't affect xfs and gfs2 now because they reset the new file size after zero out, it doesn't matter that a brief increase in i_size. But it will affect ext4 because it set file size before truncate, so avoid increasing if it's not a write path. Signed-off-by: Zhang Yi --- fs/iomap/buffered-io.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index e0c9cede82ee..293ba00e4bc0 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -887,6 +887,7 @@ static size_t iomap_write_end(struct iomap_iter *iter, loff_t pos, size_t len, { const struct iomap *srcmap = iomap_iter_srcmap(iter); loff_t old_size = iter->inode->i_size; + bool update_size = iter->flags & IOMAP_WRITE; size_t ret; if (srcmap->type == IOMAP_INLINE) { @@ -903,13 +904,13 @@ static size_t iomap_write_end(struct iomap_iter *iter, loff_t pos, size_t len, * cache. It's up to the file system to write the updated size to disk, * preferably after I/O completion so that no stale data is exposed. */ - if (pos + ret > old_size) { + if (update_size && pos + ret > old_size) { i_size_write(iter->inode, pos + ret); iter->iomap.flags |= IOMAP_F_SIZE_CHANGED; } __iomap_put_folio(iter, pos, ret, folio); - if (old_size < pos) + if (update_size && old_size < pos) pagecache_isize_extended(iter->inode, old_size, pos); if (ret < len) iomap_write_failed(iter->inode, pos + ret, len - ret); -- 2.39.2