Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1110253lqd; Thu, 25 Apr 2024 06:26:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXUUXRDedqk1C3BRt23y7OCKgoqKRsAN8/NAIf+qrw1biAZwQE6h37mVQlAeug8ZkrJ/OF52gXAv2xzOrcs4ujOJaPA7q5/had3qbjdsg== X-Google-Smtp-Source: AGHT+IEj2Yn8lh6IlIiGfmfi8GweGSkxqCgyU9VXB1irVMJMZWQrGOiT19skOMFXGhF3DoLMNH6h X-Received: by 2002:a05:6a21:3384:b0:1a9:4570:2d3b with SMTP id yy4-20020a056a21338400b001a945702d3bmr6316706pzb.7.1714051588926; Thu, 25 Apr 2024 06:26:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714051588; cv=pass; d=google.com; s=arc-20160816; b=lxqHQUxgxAiU00SGubFdvHD7Rz8GL+l3SKjMmUa0+NN/homhQLIEqIILBKQkDQLVm8 Q/hQ6uVVqG3oMULKSju2CObVZj1Mv9ONas7cgJbFA+zvOtjsb3IHgk07R8Tu1IiZLQ6b 04C+wWOm25aj48un3zitap0oEydw/bDlL6FYEuHMtGPLw0P+FyN8rNFCxaZ9us5cxf2Q eonqwJ+Nav6hIP+hVsVCaoPdFxylPldVlHiUUs13tArRFqoEZ9wg2B9L0Kqewc9r5lzb jdL0OEh9QJeaion2HXQsPu1LW5SyDHgoGfBE1g73BsacQWI+pgb3yE2HA4eZBGyx1a/s sUYw== 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=vj4vP9g++Pp9mzRm0vbT3oXMduzuHcvAYCfanMqMLmY=; fh=gVqSn+gMOZkzbuzl7fujuMh2YVkiKU3c6mFoNhCnODI=; b=XqXyVHjQ6DedtVYsBpZ+1ocqMCERg0uzWFh/hocVFVr7JMeawUqmnY/TkEA4pe78ep hokHHwtXrHX0lBzBoLvavHHMnNgAf7Fy89Hevpsmv0d6HH41qDn7lDEr7q04xnq4J9hC JhRnPxChW+oK+Oo4KRZNi0E/oWjRtjSVgWD4ujRswceeMYeHOrvCZl847fSlxAnIi5lU EaZfJLqjphhmyXo/b4wcjfVeD9b0SAGiiD7MNU04o3gStLk+fnnQBkjaMSMRFotc3Lqk D0vSEDS8fZbnMqNz8PwWUPvwkZfvIQ6G8A409SesLdV9s4nQnG5VKu1XiGVoHJulpoEx Yjfw==; 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-158592-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158592-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 b11-20020a631b4b000000b005f0a525e9a9si13602134pgm.541.2024.04.25.06.26.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 06:26:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158592-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-158592-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158592-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 3A9B2284242 for ; Thu, 25 Apr 2024 13:25:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D5F8B14C59D; Thu, 25 Apr 2024 13:23:12 +0000 (UTC) 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 94E7E14A614; Thu, 25 Apr 2024 13:23:10 +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=1714051392; cv=none; b=aBkN7WKflfE6WU4j8eOEQUrh8fjLJRBDoB2CMeusP/9iOFn2DTHYMJKuu0+1JSEFyPbDo29inyaKgYngx8vNTdkcZGikmLAQHAVoFXHuLbLFa07qFdSkhbnM+Xd1U8CXrd943Rq3URjw3qV6WtdxGjX+dhmRktv0gHGDAn2SlGc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714051392; c=relaxed/simple; bh=3EKUU7VAvYU4nPbBt7h9Nh4luL9rsU127qF3CpGr1m4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GlLqDrnxt4jRFE1QNbFIMKm5iU2yNAqddVHiIdk8JBLjulSH7MV5sQEVx5/428fL37cK3wYR7nzntbQRBMmkStKy5lE2R3Spxhz/gNn3bfkWbaMjOzFb9ufyuOQmFPTDywfe0T1TG2nuMTfTlZXRz3KXBCsN2e8bM+KL1AZDZoQ= 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 4VQGkX39Qjz4f3kjM; Thu, 25 Apr 2024 21:23:00 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 04D9D1A0F87; Thu, 25 Apr 2024 21:23:08 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgCXaBEqWSpmHu+2Kw--.61462S13; Thu, 25 Apr 2024 21:23:07 +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, chandanbabu@kernel.org, tytso@mit.edu, jack@suse.cz, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: [PATCH v5 9/9] iomap: do some small logical cleanup in buffered write Date: Thu, 25 Apr 2024 21:13:35 +0800 Message-Id: <20240425131335.878454-10-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240425131335.878454-1-yi.zhang@huaweicloud.com> References: <20240425131335.878454-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:cCh0CgCXaBEqWSpmHu+2Kw--.61462S13 X-Coremail-Antispam: 1UD129KBjvJXoW7ZrykWry8urWrAFW5Kr18Grg_yoW8GrWkpF nxKaykurW0qwsruF1kAFnruFWqya93Gry7GrW8Gw45urs8ArWYgFy0gayj9a48Jr93CryS vr4qy348J3W5Ar7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPI14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr 0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUQ SdkUUUUU= X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ From: Zhang Yi Since iomap_write_end() can never return a partial write length, the comparison between written, copied and bytes becomes useless, just merge them with the unwritten branch. Signed-off-by: Zhang Yi Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/iomap/buffered-io.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 176a9ea502ba..0926d216a5af 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -975,11 +975,6 @@ static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i) if (old_size < pos) pagecache_isize_extended(iter->inode, old_size, pos); - if (written < bytes) - iomap_write_failed(iter->inode, pos + written, - bytes - written); - if (unlikely(copied != written)) - iov_iter_revert(i, copied - written); cond_resched(); if (unlikely(written == 0)) { @@ -989,6 +984,9 @@ static loff_t iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i) * halfway through, might be a race with munmap, * might be severe memory pressure. */ + iomap_write_failed(iter->inode, pos, bytes); + iov_iter_revert(i, copied); + if (chunk > PAGE_SIZE) chunk /= 2; if (copied) { -- 2.39.2