Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp310825rdh; Thu, 23 Nov 2023 04:53:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IGvxCol4WRg9DFo9+rPo/PDyKOj3KvZux8FQPPx6uF7XPw1Pq6oA0HhTXQcKlz/G3EIBEa/ X-Received: by 2002:a05:620a:1357:b0:77d:7850:fc4 with SMTP id c23-20020a05620a135700b0077d78500fc4mr475163qkl.23.1700743980923; Thu, 23 Nov 2023 04:53:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700743980; cv=none; d=google.com; s=arc-20160816; b=Jmt8NIOg+Ly2jA1zTx+RTdgekY+bprKdLPfYDAGyFuov9FUSS0RzcMQZvzkH2cXCGl 7Vyzcykmi4B75z2fXMT30eZk3xVFJtDv5rlj6dUuEK48aJlZMtz4rkdlE7o3m0Kha+4a 8Jk+ZI9ITbh/o41SrSmDO0Is28Cxb12Z/wPpsPhocwh6jtVDs+V75PMwCvbiCT0x0/mt 3PnsnVwVeAkRvBUbaJq3/WV5BGLDB4XfETX+RyE840tXMS5Xg89AimYXYYN/WnhpAzEQ N2Y00TT8aOrk2icChUnQQLF4a1WM9B7u226Ey41+7E6T6iMXQTPO24kGj9lxV8G2Nh7n XnFQ== 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=QLD0jG1klY3BJz7ltfQJYfVO5SY4o1bn7Yh4/HEFeV8=; fh=oXgJbFeK1mY0T4jBbK/Fs3Mi9F4SdMRqpoziDljuAF4=; b=isVGN2XdMR8pB84zuxD4YwsmDsZOMj8zQBHDfDusmlyXS4TxOEjPFA2ZdkNbybbAHQ LT3CzWfc0Xh1tH75GJaNYc5h/olhRxVM7EhNbyr1hXB2lAwFZTnfI3FGYBJ9qrZZcJpE VP5TxHroPSdHDfaodGvK5+hZIw3SyBkTR73YCi2agsThhu3yrsHvMSphCPDjzbXt7xZt vUGZrMoXaCUrIDDXVjip9LvU4nw3B1J4Cy1exFVny2XEETYH2+yc2+DH3CgPi4eRNA5X TKBRuVbs4m7xDnoji1yeI+LPqygU5qI/ba0lKd4OUvCmAv0wbwRsPkfJFciu1YO2hgqh Sk7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-115-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-115-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 4-20020a05620a048400b0077d747258e3si876415qkr.540.2023.11.23.04.53.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 04:53:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-115-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-115-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-115-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 822601C20F1E for ; Thu, 23 Nov 2023 12:53:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0FCEF2577C; Thu, 23 Nov 2023 12:52:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=none X-Original-To: linux-ext4@vger.kernel.org Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24C52D4A; Thu, 23 Nov 2023 04:52:07 -0800 (PST) Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4SbdKs6CLBz4f3kK0; Thu, 23 Nov 2023 20:52:01 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 950711A017D; Thu, 23 Nov 2023 20:52:04 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgDn6xHdSl9lSfnfBg--.20473S16; Thu, 23 Nov 2023 20:52:04 +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, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: [RFC PATCH 12/18] iomap: don't increase i_size if it's not a write operation Date: Thu, 23 Nov 2023 20:51:14 +0800 Message-Id: <20231123125121.4064694-13-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231123125121.4064694-1-yi.zhang@huaweicloud.com> References: <20231123125121.4064694-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:cCh0CgDn6xHdSl9lSfnfBg--.20473S16 X-Coremail-Antispam: 1UD129KBjvJXoW7Kr15ZFWfGFyfAw48ZrWfuFg_yoW8Xr4fpr Waka10kF9Yqr1qgr4kGF95Xa4jkan5Zr18CrW5Kry3uws8Ar13KrnYgay5uFW8JrnxAr4Y vr4kKayFq3W3CrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPI14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr 0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUQ SdkUUUUU= X-CM-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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index fd4d43bafd1b..3b9ba390dd1b 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -852,13 +852,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 ((iter->flags & IOMAP_WRITE) && 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 ((iter->flags & IOMAP_WRITE) && 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