Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1437989lqt; Wed, 20 Mar 2024 04:15:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWrsYOOLEzFLox/4meYixhrdQnKNhjd8cgjWxDD3Pp8UpedMfhAyvXfctIo5Xa6uoNHY7Osg28hmP79L4QLval9niUBj/XTJjuBGBAnuQ== X-Google-Smtp-Source: AGHT+IHo8A4h5xb6FnZqrMqhbW8MZpXauJqYHhkuvJs7eJzADrVvR+8oncSoqf6jZ6postbDmuVZ X-Received: by 2002:a05:6359:4592:b0:17b:f4e9:7093 with SMTP id no18-20020a056359459200b0017bf4e97093mr5905305rwb.11.1710933338412; Wed, 20 Mar 2024 04:15:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710933338; cv=pass; d=google.com; s=arc-20160816; b=aglONesvkVL6pvxfKh0PF17sbWi/HSvGkkm7ChUnOEGSGD0q5k8UpDUtzG6c9G2CK9 VAjVUWE0YJ/juKFQq91OOAZkx2aj2jPmk8Llhpx8K70Pf1wnv0oDPMyjNp7Dv1DWzZGr TRsFAW6JG1vm+NbnHBbSDkmu+9gQYH9q4EoTfk5AucwE2+18AIKu1DPkHNkY/QTAgtrJ Nj3uqywk/162z47tmASulprDo7/HXlE3H/o5fsXPEwMYLMO3Ptz88xAyKzOTD0GuO9i6 RYfFlryg43BxgmvL1osH6Fwak6V/fyOSC6u0JJh3UEXy2qiNNXWiZS6xQler37O3ySjk nlTg== 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=yHKPKl3AFOeMbOubOMyKVm2SriSxkvBqpQHm0veAjdo=; fh=5dB93T9RUScPXiJBPgMY9ddAKXpKWIKqxrLOkZR5g5k=; b=AFUINbM0v3zQ9Z2Uq0KTGc1+OnCMSsMtk4ED8qmi6SqqTpouR26KtBUvNipSEkBOyB 2qlIk7di26JsWlbd8HsfNANUh6/MSEpY4t7B6q9kWRsUiTA/x96jE7JaFFcbu1Xcxvv6 1W24w7ekjkDN+WMQ/h/0up2Pt5LEAivhCBIlKAGqXG5g3ux70TnAmTiNjyYGfkl/XwKo jUEf0P6u8MqRU100n/qzg0NtpAnyW8M5+v567As+uUQADJVLe+iNP6QR0wwk684haMsS 9b1sjvsDNzYD3TdfisXTrB7PIJKIX1PWpY9SqmM6ccA+BuznQUU/XWx9KJOK7x3rmOn6 5RtQ==; 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-108834-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108834-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ca17-20020a056a02069100b005e838ba3449si9147720pgb.860.2024.03.20.04.15.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 04:15:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108834-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-108834-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108834-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 170FE285163 for ; Wed, 20 Mar 2024 11:15:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8F7DC4AEC9; Wed, 20 Mar 2024 11:13:18 +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 BD6213FB85; Wed, 20 Mar 2024 11:13:15 +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=1710933197; cv=none; b=X+NkiRYvR9OQBklImjARKR75y1OYiiJriNVKUM+IXgxoCkKn4KfN9mSGbD4iqytgneAnjQtCeRqZQgBagMyWifz9sJkmY0j3D7Jsrafar7J1LKgVYC3kgN8WfOWpDbgNdZgyIMI4qyWKDRiCSJ/NmnjNJ16xOrEMdqKPViYxdBU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710933197; c=relaxed/simple; bh=qgIE2jFp9im9LqSBP/kwSYaRQY8JGtGSjb9/WzRyD+E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WVajRWAc7TTF5bohaTAamfIHZ4TT/LiirWUbTMHEeTWb8MjCjbmvbFJ8+qYfsxF3qV/y0q/CldzuVjqc6+jrl0dT3plab/4a28NKuIoaGTSOxqdYtoGqSet4ppxh1FZQF1NbTG0I0o1P//cMrC9WTPXD8ofHmJNdmNKuk+8G2Zk= 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.93.142]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4V05YG6lmzz4f3kpW; Wed, 20 Mar 2024 19:13:06 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id E6B451A016E; Wed, 20 Mar 2024 19:13:12 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBXKBG5xPplGX0fHg--.18516S13; Wed, 20 Mar 2024 19:13:12 +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 v4 9/9] iomap: do some small logical cleanup in buffered write Date: Wed, 20 Mar 2024 19:05:48 +0800 Message-Id: <20240320110548.2200662-10-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240320110548.2200662-1-yi.zhang@huaweicloud.com> References: <20240320110548.2200662-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:cCh0CgBXKBG5xPplGX0fHg--.18516S13 X-Coremail-Antispam: 1UD129KBjvJXoW7ZrykWry8urWrAFW5Cr4fGrg_yoW8GrWkpF nxKaykurW0qw17u3WkAF9ruFWjya93Kry7GrW8Gw45urs8ArWYgFy09ayYv3W8Xr97CryS yr4vy348W3W5ArJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPI14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr 0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUl 2NtUUUUU= 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 dc863a76c72a..a111e8b816df 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