Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp593761lqt; Mon, 18 Mar 2024 18:38:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWYSE8IRpwg9odotLiOACc+RWbFTXErE9dIQTj0RWeKpE2615d8va88vXcbDsqneK+mxiDAHc45YZZodinfm/RJgsuBJ6uJKFCjMhdWgQ== X-Google-Smtp-Source: AGHT+IGUwTWgezKWz6gMn2MKKCfgGgqnV/3mbsHM+6D83Vtolp5q+ncdx81SlTnc0ZnRzrfPX+BW X-Received: by 2002:a05:6a20:918b:b0:1a3:72d2:c49b with SMTP id v11-20020a056a20918b00b001a372d2c49bmr372527pzd.58.1710812288299; Mon, 18 Mar 2024 18:38:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710812288; cv=pass; d=google.com; s=arc-20160816; b=sVX7KKR4mZzYfEnIV21Rh0zuhmeFyZfl5FO2iYq6062/GnKO7L/IMP6En4x8i/wueq JWDGgsttemcNuet2mBPSneVfI3WR2n9ti5nuxMkAD4Oh+gZ4y7wO+v2X6b2rYNQvWzEN FNuwzI3eQ0jZANEBJTsUNecQ5mTuRpdOxoeqexjbw/jbQ48pGm02VJVj5EZt0xuVNSFd uL62vIFs4X+3w45waWUIhosN/0+oTrUf4J+8sl/oHSWQfYdgMpWjGoZtsjPYlGkkejqk OCF4VKP4SNc2YB+lOEFafNMpgtJZn39bOYMr4PXkJ8ALruvKt9AHWcMRZMyyxWh/FOFs 9lUQ== 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=j+hlnHe9RhHKd+JXQj7dnMhdgOHf3oA32Jc7icvlqQc=; fh=5dB93T9RUScPXiJBPgMY9ddAKXpKWIKqxrLOkZR5g5k=; b=jg7w7KZCjFz9hvQdgvFh7tuG7rVRgroWKKAHQMziAMdiv7lpUxAiTWy80zVJO1w2B+ YNt35VKBG5hnj0Y4iGEAtOEo5ltIrB7A/zLVkCcvgyonAazftlq1YqddyLa7yO5FXL7D DjyF8gCI2wY0uJfZ6NP8oy6Oqu1ayzEep4M/lbft2sLfMO0Ld/WO9B0Uk7yY4oavck5L AokSbF8Vh8Gyqt6/zg75MMZ8zGreUUWQtLLaIHcFSpUqJupoG5feUg1mjl0lF4F1mpxG o0Yp1snOyldcimAHKKRzVLrEu0QjwQxO5k76nMGh9WNsDZZaAwZ3sfkpPFJmKxuu//LA GIxA==; 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-106892-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106892-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id gc18-20020a17090b311200b0029be3ac2a24si9158697pjb.21.2024.03.18.18.38.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 18:38:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106892-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; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-106892-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106892-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 02550280789 for ; Tue, 19 Mar 2024 01:38:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7BFEC664BC; Tue, 19 Mar 2024 01:36:31 +0000 (UTC) Received: from dggsgout11.his.huawei.com (unknown [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 24CC164CE1; Tue, 19 Mar 2024 01:36:28 +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=1710812191; cv=none; b=AWUOqd44WABHB2mjIo/uNUJJOICxefsGwsgiQ1hKgwFBjAzxM4TIpbXnkTZAYwatfQia8rqpXZc8eoqIAiXTwyjNslaFjjRKDaejns2WfX1Mc2gSsv28Ro7JnuCYf/pEdXto2Fd2DUI/mJnpRTnR77TIBKA8O752tC6CxSWNfjQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710812191; c=relaxed/simple; bh=wimlVWMEYy0ZqLSFzFdGg5qY3yf0+KGT2+0cviYnems=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dEDnUxAx+Qka3Ebv+cWcPQ5B0phJYWo9s067SGmnjSkeL4jbIrt/T5QTtlCwy43vjojttC/BMMLNJqEsVEqtZ1mnrUlA3MUz8wrjwx1P5rtbj119uedPv6fslAPr7o6lQiqH9AejV5iN6nZZmsEK5QcaAMrehq96AkYCQ/7DPxU= 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 4TzDPZ6CNRz4f3mJ3; Tue, 19 Mar 2024 09:18:26 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id B82071A016E; Tue, 19 Mar 2024 09:18:34 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAn9g7O5_hlUIGNHQ--.34497S9; Tue, 19 Mar 2024 09:18:34 +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 v3 5/9] iomap: drop the write failure handles when unsharing and zeroing Date: Tue, 19 Mar 2024 09:10:58 +0800 Message-Id: <20240319011102.2929635-6-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240319011102.2929635-1-yi.zhang@huaweicloud.com> References: <20240319011102.2929635-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:cCh0CgAn9g7O5_hlUIGNHQ--.34497S9 X-Coremail-Antispam: 1UD129KBjvJXoWxJr43GryfJw13AF1DKw1DGFg_yoW8CF45pr 9xKaykCFWxJF47uF1kJF98uFyYyFZ7KrW7CrWUGw43ZF4DAr42gF18KayYvF1DJ3s7ArWS qF4vyFyrX3WUAr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPF14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_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 Reviewed-by: Christoph Hellwig --- 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