Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp1473308lqb; Sun, 26 May 2024 02:42:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXC1HY1XavTOR45mN1NgcuCvbdRnk4fQfNBu6KziZOOLrTtvlHeVUCjGix9NxrwuLVO1QIQ8Aqh+XcboRsIzp+BUXcylvbWynEjgl344Q== X-Google-Smtp-Source: AGHT+IHHcDO8eiWibV8oBNJCIZ7msUfhKubGdEvGhSbWwDcz+lh9t9o9Su8+nmTYNBbIiQKrowA6 X-Received: by 2002:a05:6358:561c:b0:186:5cb:30d6 with SMTP id e5c5f4694b2df-197e50fea8bmr899930855d.10.1716716525259; Sun, 26 May 2024 02:42:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716716525; cv=pass; d=google.com; s=arc-20160816; b=yGn6erMAwqoop4z4SNaOqjBkFI7hCuXi5zvchIO5wh3O/fT3dM2k7PUV1Z/VEZQxHb iAYuM8yCis478iYY4bsGnShwL83jW9Y2pa/lGhmCWKIychHccgs8sAzeEnc93jIr+cZW FqW6Erg2h3Cza25rJ6CAfrWr2svZjnB2GbGz4xCHXt0uCcA9kDjZxfnbwlIaa2aJFdf8 lUyBMBTshUtslmwNDd23krAPW1QYkkSPHXqEOLLqgMDAimArtiQaBAgpc/Gc/zuablyF yQDD/sZAKqlIj6ds5mkxoDZBcTMxtxHrtC6eiOyklaDM4203TdTmdteJySUee/8M+OCz dC3Q== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=1hkxCUjpvbuGA7YoeNuJ1qTV9+7hqN6r8zx/PvmQp/M=; fh=gRhHGv71Q6ourw1KRizfg85vod5r8a0+BZlf9lUJass=; b=oW/mTyejmaUgNKTDZrfloW0HM6ehMM/x+O/Qaa41ALHeyo43F3ic3BeUAp4Hmhl0Ey LKfbs4f02yFntPSP4S5/QK5bOd7UdNCGWj9zCGQ/Ni/9FpS1XLoAnYyKVx+DpS64u0RC tXpPs76XPZctc0Ar7112X/uqCPdMd94AjNrRwp8e9ipoQ00oJVUb6IHWMgVu9ewzJVe2 ajrDHzu8Q/mm7Dl1LseAnf76nQ5XUXCR7znzhVReCtW03e8jn9zmqomIKLMeJdSw0ft5 DKKKUzH712rLPHycf5WBOt2IHzYKEHln30CZ+x4H7xKJikNMROtW7K9yM/NH8Dnzkw0O A+rQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t7bArF6+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-189642-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189642-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 41be03b00d2f7-68223279503si4438920a12.210.2024.05.26.02.42.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 02:42:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-189642-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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t7bArF6+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-189642-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189642-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 9E31A281240 for ; Sun, 26 May 2024 09:42:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 76C88B647; Sun, 26 May 2024 09:41:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="t7bArF6+" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 95D598BFA; Sun, 26 May 2024 09:41:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716716515; cv=none; b=hme4FW92LhWL0Y5uwRBeO13CVloAIMMvNHw1XsDUE1NjhmPRkO5VIsvVC3n7hWlgisLE1eu54BPaW9bTXVOwNvyA7eZnEWLuAk/L/LMV4J5XnDl0GrYvzrppxjvlOrrOBR5fSLOvb9R+2GthhaMv+aZw9s+K92lrG3pqONmxINQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716716515; c=relaxed/simple; bh=S2RStSnL+ZuHwDxLhADz//Rm4j2YtGbAYc1Mf+XV6h4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=n+BBeVOqaTsWZ2T++GIwgsBbZI+RIuvs96RXgUdOZzDnerGxtQilAfm1D6kISdHpOSJGpDFOdU3zlBkBqwNhs9Y0XzOPvpww7gXG8+TeLD2KUd9th0u744wXxGPLvZe8WSwyYmCRkYaPPfWWFAhvFyIjxXdXV5yjEabraqXyySY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=t7bArF6+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39D3EC2BD10; Sun, 26 May 2024 09:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716716515; bh=S2RStSnL+ZuHwDxLhADz//Rm4j2YtGbAYc1Mf+XV6h4=; h=From:To:Cc:Subject:Date:From; b=t7bArF6+fz5WHREY17OYj1k9bzGreSUbXzp6njZaSmYo7AeZCUwqxgfEY6Z0DVqBP 3iACUF854xcRz0v9DJzX07EWeu5xFfWAv5TuQtDVpnraPJCYJtU667+cEuAM2QLI3+ MhtrJYmJrP6lQk6DlNleBR6C0iHbjkXWLfSUmFNzMZK+Qqv2iWXVslWmCaxUyVgmpM uI+kBhjnqY5HXbKNsfakZlLiuMQtCYG7xFqdQC1jwQAGUUjMOZghxekHCFbOEcNOI+ 8mRxRtot7J6Vzv6RtZl/eohmy8DkDsbyMJcpNa9fh4PbT7pIRDQLAYC8W9WzwvckLY MNgBdnaD1EzRw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kemeng Shi , Jan Kara , Christian Brauner , Sasha Levin , viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org Subject: [PATCH AUTOSEL 6.9 01/15] fs/writeback: bail out if there is no more inodes for IO and queued once Date: Sun, 26 May 2024 05:41:33 -0400 Message-ID: <20240526094152.3412316-1-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.9.1 Content-Transfer-Encoding: 8bit From: Kemeng Shi [ Upstream commit d92109891f21cf367caa2cc6dff11a4411d917f4 ] 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 Link: https://lore.kernel.org/r/20240228091958.288260-3-shikemeng@huaweicloud.com Reviewed-by: Jan Kara [brauner@kernel.org: fold in memory corruption fix from Jan in [1]] Link: https://lore.kernel.org/r/20240405132346.bid7gibby3lxxhez@quack3 [1] Signed-off-by: Christian Brauner Signed-off-by: Sasha Levin --- 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 e4f17c53ddfcf..d31853032a931 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -2069,6 +2069,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 (;;) { @@ -2111,8 +2112,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 @@ -2127,7 +2130,7 @@ static long wb_writeback(struct bdi_writeback *wb, * mean the overall work is done. So we keep looping as long * as made some progress on cleaning pages or inodes. */ - if (progress) { + if (progress || !queued) { spin_unlock(&wb->list_lock); continue; } -- 2.43.0