Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp145065rdb; Thu, 8 Feb 2024 01:26:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUlN5KHnpTtvi6qCtQqxCgyOTa5eKxr1cBFvwlLYidAP/dKk1bdbXTJ1kGUQRCCYa9FraUfapCgzSnSa+7oVc3zpBWLEk7Dk9623mv6bQ== X-Google-Smtp-Source: AGHT+IEvX6Piiqx2mC/zXHGUcSQpj0LvLMJMfrIL/mUsLRGKwfw+TCiV/bjLpStITZBKHRPgkoVD X-Received: by 2002:a05:620a:13d9:b0:783:cc18:995a with SMTP id g25-20020a05620a13d900b00783cc18995amr8096934qkl.68.1707384375190; Thu, 08 Feb 2024 01:26:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707384375; cv=pass; d=google.com; s=arc-20160816; b=W3sD4e7w8hJr7254sydBAiHiRtufuy++zt0UUUNNM2TYXjG+Eey+ei4xuxGXQE9vo+ klU8ngjBHTTC3JpJqGmq25uOFkyxdAIeloIauFSS/rokDD+liO1uGmkRWW5lkWvZcQj5 9KE+EHx4U3Qewsaa7JKwfYh06ofdv2gilRW7PNtmIpChcNmNAHejGW/cv51d1us1bKOQ ZhNMmx6FKa+8ByIe0G52SUFTLKHxG5wQPsDz9xGfpmVGm6/aqSCZ1Voz7n1FT+UoDXCY I212hqwHcXwbjumWN4yogjbOYkXCGgTWF/gqat9GR4a6m1U2DPjFw42ZGAJfZXhQx51h 46uQ== 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=2mxSBJYuYMG6vdbu8HHidrvDlVlGrXNtMoc83GOkPY0=; fh=PBhGyExXJ0ny3EjbieTT0UiAsXXaV8OLoRTWlkyIcfQ=; b=e/jtKT6UmCeZHXKj7lsNExpHYlvowXdMwLpyyk4CPz1SAwiOzeKctdzmjid3dbpOVM hMGblqfXyqfvzFgeTgwiL2Lrv+lZO/oC3DmuI4227gevvJAFO8mOiPBcfP3gJEjPewF0 vIWwaTm2KiEMbI4+ZbK2i+lYseV6ctbWLM/B0b92QIfQ6bE6HNjgMWDsjydaPmJabIhC j997j/btx1/0qs5FJacM0a7U5kH79uFZquEXrx9OFiHfDp4JX/8dRFk5h1yETwr0VzNE LLsKFw8vdOYmR6K0AfjIcQ+bwRN9lrc01p8hVcJSzOyqckk75jn7WBP2lZSBu4UcC/mU Y6XQ==; 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-57732-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57732-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCWZ6IGoMnmKxf5cqExnRdO9NbxGOnM9HwChmRXKfoi6cFEb3dUNiM2MmVTYTxcnR3iwaDN+C+qRZ8iUiV97/IJ0d2kBNFw3U7j7m1LPOw== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id i15-20020a05620a144f00b0078562f9f819si2859781qkl.23.2024.02.08.01.26.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 01:26:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57732-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-57732-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57732-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id EAA3C1C251F7 for ; Thu, 8 Feb 2024 09:26:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BAD8D6F098; Thu, 8 Feb 2024 09:23: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 1076B6EB6D; Thu, 8 Feb 2024 09:23: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=1707384193; cv=none; b=A+GcOuQUivRro7pAOnVFRkAQuFi5pVZULECLNzAL3K9ukA3yn+63POmQnmjAVlT86ReqXrFEbPYYcMD4BLmwwh82CUKsOg1o8DE95g5m7KDpyV9baJXehv9gyjVNDHUYyOar4xI0eeqZ4JNOpfuDt2mMzglyGn7/QTuSqMtZnp4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707384193; c=relaxed/simple; bh=aCreZ5MUO5xBIYGsOG1qJHRg7BTL70NtVzxDdZwBTxc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oCGKZan12fwqyrv1cLAkfi7xnYvh9WlBStvT4ywUwb3S1WsC0ysS14IEu73ASHqgXcE5zZ2AScZkcnzZP83MasP0eGtYaJkpjAd/nC7S6XvUJJ0Je8sM1oQC03+mItaWCw2wKGx8jPIFG6+4aIzwALxJohnRaUbzWXMAoYKVEdI= 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.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4TVs382cnhz4f3mHl; Thu, 8 Feb 2024 17:23:00 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.75]) by mail.maildlp.com (Postfix) with ESMTP id 20A531A0232; Thu, 8 Feb 2024 17:23:07 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP2 (Coremail) with SMTP id Syh0CgAnSQx4ncRl3tGXDQ--.8574S4; Thu, 08 Feb 2024 17:23:06 +0800 (CST) From: Kemeng Shi To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/7] fs/writeback: bail out if there is no more inodes for IO and queued once Date: Fri, 9 Feb 2024 01:20:19 +0800 Message-Id: <20240208172024.23625-3-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240208172024.23625-1-shikemeng@huaweicloud.com> References: <20240208172024.23625-1-shikemeng@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:Syh0CgAnSQx4ncRl3tGXDQ--.8574S4 X-Coremail-Antispam: 1UD129KBjvJXoW7Zr1rArWxJry5ArWrZFykGrg_yoW8Gr47pF W5tryUtrWYv3yxurykCa42vw1Ygw4DtFW7XFyfua17trn3ZFWFgFy0gw10yr4xJ39xuFWS vrZYv3y8Jr1xt3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBjb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M2 8IrcIa0xkI8VA2jI8067AKxVWUXwA2048vs2IY020Ec7CjxVAFwI0_JFI_Gr1l8cAvFVAK 0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW5JVW7JwA2z4 x0Y4vE2Ix0cI8IcVCY1x0267AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2 z4x0Y4vEx4A2jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4 xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v2 6r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwI xGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480 Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7 IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k2 6cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxV AFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07jTQ6JUUUUU= X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ For case there is no more inodes for IO in io list from last wb_writeback, We may bail out early even there is inode in dirty list should be written back. Only bail out when we queued once to avoid missing dirtied inode. This is from code reading... Signed-off-by: Kemeng Shi --- fs/fs-writeback.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index a9a918972719..edb0cff51673 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -2086,6 +2086,7 @@ static long wb_writeback(struct bdi_writeback *wb, struct inode *inode; long progress; struct blk_plug plug; + bool queued = false; if (work->for_kupdate) filter_expired_io(wb); @@ -2131,8 +2132,10 @@ static long wb_writeback(struct bdi_writeback *wb, dirtied_before = jiffies; trace_writeback_start(wb, work); - if (list_empty(&wb->b_io)) + if (list_empty(&wb->b_io)) { queue_io(wb, work, dirtied_before); + queued = true; + } if (work->sb) progress = writeback_sb_inodes(work->sb, wb, work); else @@ -2155,7 +2158,7 @@ static long wb_writeback(struct bdi_writeback *wb, /* * No more inodes for IO, bail */ - if (list_empty(&wb->b_more_io)) { + if (list_empty(&wb->b_more_io) && queued) { spin_unlock(&wb->list_lock); break; } -- 2.30.0