From patchwork Wed Feb 28 09:19:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 207566 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3071492dyb; Tue, 27 Feb 2024 17:25:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCURxioMqnkjpxhjP53/i67sl9CoLVMBBUp1cZK4+7yg8CRLY2yF3V8mE6P3+jBXzPLd+kMUycsSOmaz9XhdxjPBc9+Jwg== X-Google-Smtp-Source: AGHT+IGs/l2RaiLSEiciovEK27uSqjolO3x/SaGm89ISEmLgVF29RnfzoIpwoZCvxWgXdw0T2Se+ X-Received: by 2002:a05:6808:164c:b0:3c1:a512:ad25 with SMTP id az12-20020a056808164c00b003c1a512ad25mr3541386oib.1.1709083507904; Tue, 27 Feb 2024 17:25:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709083507; cv=pass; d=google.com; s=arc-20160816; b=eYMby4w3f7/tm2R9nZ0cdRdwlLFQceu0H5jYAshRnQwMcUY0k3M2U4M0AKoM/6Sls7 WyjU9BFGUyB+3D3GXIDAdOC974448CErlQkOp7ktsooa4+PDGXzDIna5V6jjk6y4YYe/ okZhIvnfnva/KrlBqj3G5MZAbr9/zHSiz3ApZXV7NseDUSY7QSFH7VOWF53Y/0/amBxn pr4Ortx+hUVCSs9ipP3LXX2xyB8qTrdQkD5lgVnl5oC5yT/pLg5gRrbvFZysna0jlyFm ryFFQKlZyyUWly73CUa9onZTPvp/bd3EgfZ2w/xEiV1NAeqhhGpaO+MPGyJSu8Ci6Ne1 rNEg== 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=mi1HwO9ZVrjm1TI2p0dtz0Yr2d+fpdKSiDBuVcb1jgk=; fh=y/7Wtt5UOSj/SCUlHdmMQBdr226cA96uA6lTOGta4DA=; b=IG/YgnSxB4B4zT0umKcBBCbpK1ufI031YCb6mDDxjEvcX4zp/uq8HY4xAQsAOZcmUo yl7/IxY/UmmMjuDnFtMtO5Py4P47oG+atooH7bpAhMrb42xIliD08gKfVJ4baRvCjEMb qvPGjpRjdeBrO7BUh/3oB8PaYScgmVK8HvPO+UiJjcl5qQKFtbyxOmWqhuHUnR/hUGZ1 QLSmmWmpm5YmXaBHtNrbKu27nuLV+hi+K3loYcI/YzFn2a3/WqcsrZVeyHXSu+E/vPc0 gaWOOjWgpmxUn1Q+ZBy9AC5IqC8Z8w4I3X9OdqlWbodPg8ql2dUKTwI02cIQ1h1PBSSR Yhpg==; 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-84326-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84326-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id m129-20020a633f87000000b005cec8ea155bsi6375695pga.842.2024.02.27.17.25.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 17:25:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84326-ouuuleilei=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-84326-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84326-ouuuleilei=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 B0752282DFC for ; Wed, 28 Feb 2024 01:25:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1DC4120B28; Wed, 28 Feb 2024 01:23:17 +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 77E9AF9F7; Wed, 28 Feb 2024 01:23:13 +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=1709083395; cv=none; b=atP9zetar42mMKs/OhJW7DwWXW9+DaPhrVDYD+d2RSlE6lBxDmeOWmUTsCDP6b7eLmVarIWkJDnuoio63rU46+PC+pGSJJR2kU8m6DTxuGzgo3DsTIs8+0pbjb289aZhRuk7Cgo7rudUoAv7SDBdhNtBwuFceeJe1QdujJRYsZM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709083395; c=relaxed/simple; bh=p9MYk0CCIVQD2VoyNlRvo5eEoCALxgQBIh8yNfbihSE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gnAB72w3mhY/gH8d5Nx9DVM0URqeuOsy2/abyfCIzBLHGqSxLs+62F8/h9UlRAhvaPAYSyXjt7BzrY81qn8EdY8keRH3WLfVBqWnI3R3lTUXvvBAkelkYEtiVBzdP5ZcAYcCW2CJTZRy67ipMnEfXGGLn/thNXh/1Qp2v41ggQI= 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 4TkxS648Rqz4f3m76; Wed, 28 Feb 2024 09:23:02 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id E06021A0DEB; Wed, 28 Feb 2024 09:23:09 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP1 (Coremail) with SMTP id cCh0CgDX8gv7it5lqQx6FQ--.57137S4; Wed, 28 Feb 2024 09:23:09 +0800 (CST) From: Kemeng Shi To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, tim.c.chen@linux.intel.com Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/6] fs/writeback: bail out if there is no more inodes for IO and queued once Date: Wed, 28 Feb 2024 17:19:54 +0800 Message-Id: <20240228091958.288260-3-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240228091958.288260-1-shikemeng@huaweicloud.com> References: <20240228091958.288260-1-shikemeng@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: cCh0CgDX8gv7it5lqQx6FQ--.57137S4 X-Coremail-Antispam: 1UD129KBjvJXoW7Zr1rArW7Kw4DGr13ur1xKrg_yoW8GrW7pF 45tryUtrWjv3yxurykCa42qw15Kw4DtFW7XFyxua17trn3XFWj9Fy0gw10yr48J39xuFWI vrsYyrW8Jr1Iy3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUB0b4IE77IF4wAFF20E14v26ryj6rWUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M2 8IrcIa0xkI8VA2jI8067AKxVWUXwA2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK 0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4 x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l 84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I 8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AK xVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64 vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8G jcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2I x0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK 8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I 0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxU3K9-UUUUU X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792103948332044450 X-GMAIL-MSGID: 1792103948332044450 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 Reviewed-by: Jan Kara --- 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 4e6166e07eaf..6fa623277d75 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -2076,6 +2076,7 @@ static long wb_writeback(struct bdi_writeback *wb, struct inode *inode; long progress; struct blk_plug plug; + bool queued = false; blk_start_plug(&plug); for (;;) { @@ -2118,8 +2119,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 @@ -2142,7 +2145,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; }