Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp761635lqb; Fri, 15 Mar 2024 06:03:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXXPFsqyh4fMf5Q0YQgw3DyFYuKKG/ebpMWjXUcmH3mT0vGaFbBdk5ECg1nVrHzSn73+kLMY6WZC6lAqAFALW84TIMGyu9CCSVzZrj1Sw== X-Google-Smtp-Source: AGHT+IG53LhdjC24WlxNcge925h5BeRJfS2g+IsOPHZKLRCzDR9bT9di1R/w4iMN6X6Bz9FoqIC8 X-Received: by 2002:a67:e3a6:0:b0:476:589f:ac85 with SMTP id j6-20020a67e3a6000000b00476589fac85mr3098838vsm.7.1710507793501; Fri, 15 Mar 2024 06:03:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710507793; cv=pass; d=google.com; s=arc-20160816; b=CgChisD5v/s64/JqviLZFcTPPJNDkom/4MXJ+eAvYZY9M/luQL3fvLlQJWeWPTLzQM xWRYgQZ/9ILO30NbaYvV9FT6HHz9pGqpn9GyNGn6EBuET6njRcJvOWraKTapzpiLE3t5 d4/YZ1qXIM2dfPNdYLmX2kOgW7Znmpeu2YvSPbQgJ3gEkYxQzPGhFdJiKZ/I4q/PQU/y ttfSVlhMW191H/4t72leJskPdHmhrOB+c4LGiPKU8nKgDLlzQMbPhd3S3ruWI73NG8oh +OKcgbk64FHqMCyaVQI3ki03yHz/2cBEel/AcJ/yXrYrIFI0O33rgJgNyxLy00PcMaHw iYDA== ARC-Message-Signature: i=2; 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=orKnq6bp325Pidlg4dtMZ0kxHSM64MWk8RH0PcgKW8g=; fh=5dB93T9RUScPXiJBPgMY9ddAKXpKWIKqxrLOkZR5g5k=; b=xmM/purSCXusn6Rb1aUJ0RHJmRZo79NYFqe3fj4uUx5h+OIIU7U62ck5IFFqc7bt4E lBP9HaaOWzdcDHOjpR65JHav8MsgMR1gjw++/aDBYe+QBtxCcDi3kUpK5FSJNuVeYbpB IRuiJZ83PIgK/JzsE07rX7K1G0D8ZTcw9pQrdl8zhwxUTM0CzuYJdjU39bSReHyMGeS5 Fh4MC6fZjqVnUlvifU2GOBbB+7lpfwmvb4+7QPY0EnRsBdYctm4M61vU6AOKwWmhm1T+ yHZpXKxOH2s7/kben6nv58uABDWU1g4yLdVu3/X5gNXJ5ThNBGYHbzC1PXZwtyUKy/w7 QDFA==; 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-104427-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104427-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 x23-20020a67eb57000000b00474c70cf1b8si508488vso.680.2024.03.15.06.03.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 06:03:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-104427-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; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-104427-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104427-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 E0B5E1C21D44 for ; Fri, 15 Mar 2024 13:02:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B7873F8E4; Fri, 15 Mar 2024 13:01:13 +0000 (UTC) Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (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 4E46924B52; Fri, 15 Mar 2024 13:01:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710507671; cv=none; b=Nb21CW/RLA2Uj5mHmFgh5qZ1fi+6jAr3P8ooRdQDetWRW+8d0s2CKxvtimTnB2LO3JEh2h7VUUH5NEHnpyJV95mCvtANciBWYWjS6JVZ2Y/fpjvqRqRE+/vIYe0MHDIC0Irmons4U8PoqsPjzwABPM90wJN6x4tG+U5L3664Tvc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710507671; c=relaxed/simple; bh=JfovSRICGTZ9ZriaIuolViU7gmL3XgHTj4nvWZySKmk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TTKpQnZBAm0IbXZCTceVKhJWjvaP8bWllg6avMRHCtQaoiF3tx1ENd2cagGwkojE6BPVIxwuQGNpxhp5HNC1n4qe8okQel7q1/HoMebbVbjAcF+zLA+U+fV/qtD4RI7U5bXp8t1x57VEhC5aAJ/wvAUX8QtY2s+jUN8V78swigc= 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.51 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.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Tx4B040XZz4f3m7Y; Fri, 15 Mar 2024 21:00:56 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 531751A0172; Fri, 15 Mar 2024 21:01:04 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgCXaBF9RvRldVMfHA--.12032S10; Fri, 15 Mar 2024 21:01:04 +0800 (CST) From: Zhang Yi To: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, djwong@kernel.org, hch@infradead.org, brauner@kernel.org, david@fromorbit.com, tytso@mit.edu, jack@suse.cz, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: [PATCH v2 06/10] iomap: drop the write failure handles when unsharing and zeroing Date: Fri, 15 Mar 2024 20:53:50 +0800 Message-Id: <20240315125354.2480344-7-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240315125354.2480344-1-yi.zhang@huaweicloud.com> References: <20240315125354.2480344-1-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-Transfer-Encoding: 8bit X-CM-TRANSID:cCh0CgCXaBF9RvRldVMfHA--.12032S10 X-Coremail-Antispam: 1UD129KBjvJXoWxJr43GryfJw13AF1DKw1DGFg_yoW8Cr45pr 98K3ykCFWxJF47uF1kJFyDuFyYyFZ7KrW7CrWUGw43ZF4DAr42gF18KayYvF1kJ3s7ArWS qF4vya4rX3WUAr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPF14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJV W8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUOBTY UUUUU X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ From: Zhang Yi Unsharing and zeroing can only happen within EOF, so there is never a need to perform posteof pagecache truncation if write begin fails, also partial write could never theoretically happened from iomap_write_end(), so remove both of them. Signed-off-by: Zhang Yi --- fs/iomap/buffered-io.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 093c4515b22a..7e32a204650b 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -786,7 +786,6 @@ static int iomap_write_begin(struct iomap_iter *iter, loff_t pos, out_unlock: __iomap_put_folio(iter, pos, 0, folio); - iomap_write_failed(iter->inode, pos, len); return status; } @@ -863,8 +862,6 @@ static size_t iomap_write_end(struct iomap_iter *iter, loff_t pos, size_t len, if (old_size < pos) pagecache_isize_extended(iter->inode, old_size, pos); - if (ret < len) - iomap_write_failed(iter->inode, pos + ret, len - ret); return ret; } @@ -912,8 +909,10 @@ static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i) } status = iomap_write_begin(iter, pos, bytes, &folio); - if (unlikely(status)) + if (unlikely(status)) { + iomap_write_failed(iter->inode, pos, bytes); break; + } if (iter->iomap.flags & IOMAP_F_STALE) break; @@ -927,6 +926,9 @@ static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i) copied = copy_folio_from_iter_atomic(folio, offset, bytes, i); status = iomap_write_end(iter, pos, bytes, copied, folio); + if (status < bytes) + iomap_write_failed(iter->inode, pos + status, + bytes - status); if (unlikely(copied != status)) iov_iter_revert(i, copied - status); -- 2.39.2