Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp761782lqb; Fri, 15 Mar 2024 06:03:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW+i64E4v3F5JPrKfx1HTi2hPjjTt9K/fVt344SSpuaYe3jLDV9j1gU8E0Tk+5nCqk/JQrZZ+PDz1gu+P8T260se4lagIM169r48qcL+Q== X-Google-Smtp-Source: AGHT+IFC3VVtyNTI2SqK1CPLX/iFnn2LWFgtxGKPA5BDVy3H7G+5H1ZFvxuefhaAls4SWHaD3VjB X-Received: by 2002:a17:907:8e9a:b0:a46:5f6c:e04b with SMTP id tx26-20020a1709078e9a00b00a465f6ce04bmr4084983ejc.52.1710507802439; Fri, 15 Mar 2024 06:03:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710507802; cv=pass; d=google.com; s=arc-20160816; b=zVGtl7oR3tPtGuQhz7WvOXDcAwmV2nJpEkEbnnS7UnPcIT5IfkOyOIvI4mQeaehE6Y EoP1+rt0GCcZ7M5+PbZtqkuCT0uSy10K4/2fGLzQAbb6wcsecIglVHetY3CmYonHWuVK 4Z1DD5H64gxYe8TeIcA+VxZWUKpWS9adlUzp4CY75pv5WGVoMrN27Tg2PVMjcJV0YZAj W+vv0/AXPi2Zz2jMWfE5sxYw9xrP/y5ns1ik86R2PSnhdwjtRpyVnvj2Q6YfUpapOKXW 5bMAVUjyrGfKSk0CuLpR9dsBjH1KYeoaL7T4LD41h7vqPCjBicS9Q7e92cvvoPxj+WjQ ttBw== 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=Gw7GyuQVoIjkyucbx2l0wS22qkTPHvvnXM0ldJgYwOg=; fh=5dB93T9RUScPXiJBPgMY9ddAKXpKWIKqxrLOkZR5g5k=; b=lUSpxGIwXvv17wep3HQyM6+ZcMZqG+oNZfdwk38vZsb6fGUFAszlmwxIexqa0ZfPAd /SFcwGO12VfafpNuynd6FE1UCHMG5CvBR0vACFMvbLEqeITdZAg/9STJkTAAYCZNWEI/ FntGc9Loc1YHFLJbk63Krap2hfdog2lx8761eqWbUzdsdw9cnj4oaLHoekMXpLtNoAvO JGX3OS0XoNIeGZuy9sPjZg/r1iEJ8aimBaJzCsq/bJu9c6RqpwVQLu7diPXWmrcb4qWY OUJisJ6ay7SlckM4lGhH/i1CyJzEuAyg614zjhcis96DCjtX3qV4v2neFWIsXwTG6Wut Djjw==; 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-104429-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104429-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f17-20020a17090624d100b00a45fefe5bf2si1779674ejb.265.2024.03.15.06.03.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 06:03:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-104429-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-104429-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104429-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 28AE11F220BA for ; Fri, 15 Mar 2024 13:03:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BEBA340C04; Fri, 15 Mar 2024 13:01:13 +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 853BD2E634; Fri, 15 Mar 2024 13:01:10 +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=1710507672; cv=none; b=FGRr9+w/sx7KqwcNSwISVZVNeZfb093DILk4QSAnYY1Z500Pq6Ch637hhu4+NPb3qEquHUUggmIjQ2UNvLeL/xl0L6+2CFP9fmtPZk0tXYnkLW5XM7IgE/0iU6qinLVWfz+DxsP45JrmXyhtq7WlmlOvf/HIeKSP6cbZy5kvK64= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710507672; c=relaxed/simple; bh=yzLyf4DBqbGBUB3Jr9bqLKZhlCgORpswVgEGEoIqS1w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=V3Film1okiBHLFCLCVrZyRr+bYERWE11UmyPA0h2SirNKv8DKBCwTDF8HPrx9AhLnG5Cu1Gi3xG9C1V0n0N73N07FmMfWjm4Ec0jResHdKd/f8swuDjGUWTMH1AZ8BDqGsoe1+gwqamC7iBKSldqvNuO+Cjwd7GqMAxPvSB5ar4= 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.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Tx4B64sRRz4f3jqB; Fri, 15 Mar 2024 21:01:02 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 6AC1B1A017A; Fri, 15 Mar 2024 21:01:06 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgCXaBF9RvRldVMfHA--.12032S14; Fri, 15 Mar 2024 21:01:06 +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 10/10] iomap: do some small logical cleanup in buffered write Date: Fri, 15 Mar 2024 20:53:54 +0800 Message-Id: <20240315125354.2480344-11-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--.12032S14 X-Coremail-Antispam: 1UD129KBjvJXoW7ZrykWry8urWrAr1xCr48Zwb_yoW8JF43pF nxKayvk3y0qwsruF1kAF9ruFyjya93GFy7GrWUGw45Zrs8A3yYgFy09ayYv3W8XFZ3CryS vr4vy348W3W5ArJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPI14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_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 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 --- 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