Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp588553lqt; Mon, 18 Mar 2024 18:19:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUY0TyQ7OQqJS94/UOXGlvCOk++TBc1/w2OPp/MChqGwk0UWLWcp7EmKGxV6eCmHBmSdaojSlJrGeZylhIbVjTic6z2zO6vtOGMtSeQww== X-Google-Smtp-Source: AGHT+IEhqdjghzj2UOuPvQ9IFw94M2hf4DMSZRJ09hkLsZveRbcvfMELuVwM8LwmXMcHriyL9GO1 X-Received: by 2002:a05:6808:3a0b:b0:3c3:9600:8789 with SMTP id gr11-20020a0568083a0b00b003c396008789mr854720oib.8.1710811187319; Mon, 18 Mar 2024 18:19:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710811187; cv=pass; d=google.com; s=arc-20160816; b=B8dsByGZ2f+N43fwSy1biYeH8hsocpSpKAaaXFBQyiyf9XO7TLl96Jm+z1ZpH9UDVU GW5dGmw88iVxndEZutw+ulbgSTzdBsBqPu6Du7w/KfXDYUGnPwSufTK5CkDdoqwOMdFJ SvhTIONmOnV1EO2rQhYJey7NK5kRPFBlyEKO9uprMA/PM7g8FwpkjFqkYiJQsIfJUzyZ Bq873wXs4Pw4/xhG1OeS5L/zD3QWzunL4zkMD1Hcfp6PFmHuFmqMxY40fHq4LKV3zGDB QFK8cv9281yztimXEhmbfzGqcjgqRc2No2k95m2oQ1G53DvguZySCXtrTNlPdHaaRnDY Hqlg== 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=tuwgi9nQK7SlPlkkW8VwycxWYTzYSPqFnGPvGdfAUsY=; fh=5dB93T9RUScPXiJBPgMY9ddAKXpKWIKqxrLOkZR5g5k=; b=x3DNyKpW5a02PoMebutJ8WazFEG5Runk1AfXGBmlma9Ce5wflArSiUo6O3Km+kJpPT KpWG9PpxAbqFKzJ8dYCPEb7ajJnvGaCoo66JG/9MrK2JKiV4w5F/KhBq9BGtUNb+A2P/ SSW0RQcMytGBuFEOqVfkl0BUxXwAPCPKOMk5vtiiu1niBJ/X5pmabWkG/SW+yN9M0Yk9 WqBEehIq+B6FEghNeictecuAFSEvxFICikPmhB3aJTQWK0D/2MrXQMOJWN917bZ27eab xCOwfLzQZ3bgUTMEr+Dfb8bMGOxGdcrBB2QrNsbBboAk5DyqZOFWwHAQbY3IBa+UwBTS mlQQ==; 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-106882-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106882-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 c5-20020a631c45000000b005dc97ac8afesi9109354pgm.37.2024.03.18.18.19.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 18:19:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106882-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-106882-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106882-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 EF12B2820E9 for ; Tue, 19 Mar 2024 01:19:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 275311C6AD; Tue, 19 Mar 2024 01:18:48 +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 B7FC3847C; Tue, 19 Mar 2024 01:18:45 +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=1710811127; cv=none; b=BwfDUMle8XgolXM1+WhoJjuMm0CYc7OhPj3qBp+dIjZ4GPzUPaiAb2QUCMZPsCiCLsMGUAfBeOWZduRMI2gDfKHLqCzStX3bybhAbMx5651+hhue99DE1zga5Y7a2SLUyRnT8tpm0DUHdz+ex7nlXRRRqi9hD4SmzBjaPtvrVQ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710811127; c=relaxed/simple; bh=MMrbMRAxlRdrfAR82H7F/UOhyfZI3AaGwXVLWaHdmc8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DyTha109+1a2DR+TBoH0adNZYIFhfrczAtlaUNmDmp3SKg0Hj0Z2hsxOed/esWf3K2KwFq4LAQkGEk8HDj1yR+H0t2+BfHqcGl+LYoIA3e51u48Rer+5FV6FsGW9e80TNZhbXkjXdk0sChQTncFVHaYB42G/xvXc30N4PEHhJoY= 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 4TzDPf6qNKz4f3kFp; Tue, 19 Mar 2024 09:18:30 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id DC0C91A017A; Tue, 19 Mar 2024 09:18:36 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAn9g7O5_hlUIGNHQ--.34497S13; Tue, 19 Mar 2024 09:18:36 +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 9/9] iomap: do some small logical cleanup in buffered write Date: Tue, 19 Mar 2024 09:11:02 +0800 Message-Id: <20240319011102.2929635-10-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--.34497S13 X-Coremail-Antispam: 1UD129KBjvJXoW7ZrykWry8urWrArWUZr4xJFb_yoW8Jw43pr nxKay8CrW0qwsruF1kAF9ruFyjya97Gry7GrWUGw45urs8ArWYgFy0gayjv3W8XrZ3C34S vr4vy348Jw15ArJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPI14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr 0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUQ SdkUUUUU= X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ From: Zhang Yi Since iomap_write_end() can never return a partial write length, the comperation between written, copied and bytes becomes useless, just merge them with the unwritten branch. Signed-off-by: Zhang Yi Reviewed-by: Christoph Hellwig --- 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 004673ea8bc1..f2fb89056259 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -937,11 +937,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)) { @@ -951,6 +946,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