From nobody Sat Feb 7 15:26:33 2026 Received: from mail-dy1-f195.google.com (mail-dy1-f195.google.com [74.125.82.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFE302DA77E for ; Wed, 7 Jan 2026 21:02:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767819739; cv=none; b=BFnD8cnj2zzAfxmuowWA3+OQpQ2yeZ9RHfSzaZLHKv9VG50QYILMQF71v24nhXRrDM7maSpYoJD5fLCJZ/D2H7gwezSQ76Rj48r7MgVwVg4C796+uPW8vVegpFzR4u3Wbw4q19k4c55AbnkwXgULmU0lAm8NE56fmMwI1+QIZTs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767819739; c=relaxed/simple; bh=UlXDD3O2ByrzfSkEqfgz2FOR/jMbTQQ8iVq+JeEXgDc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N87gQY0537boa77sD59OQnKJ/q45X80CxI42RoDRwWu6CUP/lzeXnr+4Pw0Jd4cB4Yicgv3frn+BJmB/oc51K+7cMnZQFi8i6mzS/n9KYiiuobRIUlvapzdO4BWG9hBWvrRxEeUYWplEtBTyPhPGRg1JDJ8bMwWk+lMc7PgppM8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=b3FNOgeq; arc=none smtp.client-ip=74.125.82.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b3FNOgeq" Received: by mail-dy1-f195.google.com with SMTP id 5a478bee46e88-2af41f558f5so1976402eec.1 for ; Wed, 07 Jan 2026 13:02:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767819736; x=1768424536; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=e+E7Trlvt0oiegK/dgvIiDdQeWGh3NduIxLv4xKGd34=; b=b3FNOgeqEarPgzh0wct33Y1wrKOZ1miaWPU/nztZTOTqcZr7PcghaAmBgw+y1OL6FA XEXuQIigvW86SJccUB9qltHFiMjGiulFeKoXorYR2nbJuAwPYfwGPvZYhK2qD8Cd+DLN vVlW8vmwOBFEiLCnRnxBX1VlamEEBuSnOjyb6jghbnfvDiMK+ai5VBVWNc0+CrAH3IZ5 IxWgvpJvEZMpX4mz0ccZIYLeMJikXunntT+D6XxaiCr5vi+Iu933v5GjQSCXPRu/BvJz ysvclVhiaDYHMkDeFwdiPLtwGc+hYE2wivF2cguF3qHeKSkqX1c21AhFGKoNUTusqthu iv9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767819736; x=1768424536; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=e+E7Trlvt0oiegK/dgvIiDdQeWGh3NduIxLv4xKGd34=; b=b8mGak+lGpKrUgRDjrd4Ra6p1BYZEoe5XJV36kad4zOjNEouCuF009ntdvYgpJ6V/l JKYi3LWCoeRMRqkie1TBVky6F+lDzVLeqyh3ymh/aoMVPB6Fn8vDBBFWQQBvP6fXWAXJ Pz21kzfy/xUJ0LgwG479A9GWpH2XZrAwCAEVh8SeeCC7/erdYrYgruaLUEx1XksjLtVH WSb/jfPSSTPwbNm109+pHjchlCOG2daWlvavREedJNemT4WRpg6bwkOC9gJW5uXq4A/+ hu6pw5DZWFv2uTW9VfmJ1DvtsqEszGZgGjbdCoXjdf3p6STHffVH7DCu/QQJ+74kkwea t9mg== X-Forwarded-Encrypted: i=1; AJvYcCVLoEyHfJ1OUVzmksOCOY113WvGQiWi+nMAlHqoDF6tDnfgTw+57HFToMukAqvbqz813o4rXtI3YyON20U=@vger.kernel.org X-Gm-Message-State: AOJu0YxKJtxZAkcA1xZ1xG0NP3BgiW11cNcI1Nf9BGFR9X7jS9EpgLFo tFOioIF1Ge5v+c8X8H31WQvYeMXRBgcN/xDAi0qarqWWIYOaBJLu5FfX X-Gm-Gg: AY/fxX40HJqLzj6d736I3Gc3K5kiKdb2g202dh0YaZoXEY1+AiyEeh0Slxy+RmjTqor J5NVKQ3iuIPn5ZQwMqajXeAfEnFx8eOMpC8SpxPOIf12vqVebd9eOiIGe7Br9vn+ATua5gp6OE9 iPJoOohjaYpTpUZ569oZH9CngP29Qbimmidqxnc3B4h7W3vi7GWFIDUlttBU0qFMLxYiwu46Hdb eD8CO4gf9JqqM21Wh51kinJkAyR/LxL5bznDEnCYNuorKG95XJ8t3WvgOZotaqsWMxyVO5H/YG+ nnCZRNaVYtw1MzOns8+sUas4t6eQ8ZhA/REl1sQ7t+4S7Px0OQCtiYpD8PtxWzWoFqPMWDx5Rq6 FMt7EaGdQe7wVaT20zjuC+qdPU60XxUzPN/+3GlOqXT4RjPnL/lpuy0/e/P0T/UO3fbxcCGCKD5 MCSxpk/OIoA0XESwsq2RFOM5J9x/JpBDUhcJVI4lB2cjhoA0A84PMr6MSbBLQf X-Google-Smtp-Source: AGHT+IGaYEwwyJ+xiqlKxx3u1rImT5in6vkJPBWncJFy16kWrM4JvVHkhraXPvmpqo2YoyQfBoyRDg== X-Received: by 2002:a05:7300:760a:b0:2af:b9af:ea7a with SMTP id 5a478bee46e88-2b17d226fb6mr3136216eec.3.1767819735571; Wed, 07 Jan 2026 13:02:15 -0800 (PST) Received: from celestia.turtle.lan (static-23-234-115-121.cust.tzulo.com. [23.234.115.121]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2b170673b2esm7730320eec.6.2026.01.07.13.02.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jan 2026 13:02:15 -0800 (PST) From: Sam Edwards X-Google-Original-From: Sam Edwards To: Xiubo Li , Ilya Dryomov Cc: Viacheslav Dubeyko , Christian Brauner , Milind Changire , Jeff Layton , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Sam Edwards Subject: [PATCH v2 5/6] ceph: Assert writeback loop invariants Date: Wed, 7 Jan 2026 13:01:38 -0800 Message-ID: <20260107210139.40554-6-CFSworks@gmail.com> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20260107210139.40554-1-CFSworks@gmail.com> References: <20260107210139.40554-1-CFSworks@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If `locked_pages` is zero, the page array must not be allocated: ceph_process_folio_batch() uses `locked_pages` to decide when to allocate `pages`, and redundant allocations trigger ceph_allocate_page_array()'s BUG_ON(), resulting in a worker oops (and writeback stall) or even a kernel panic. Consequently, the main loop in ceph_writepages_start() assumes that the lifetime of `pages` is confined to a single iteration. This expectation is currently not clear enough, as evidenced by two recent patches which fix oopses caused by `pages` persisting into the next loop iteration: - "ceph: Do not propagate page array emplacement errors as batch errors" - "ceph: Free page array when ceph_submit_write fails" Use an explicit BUG_ON() at the top of the loop to assert the loop's preexisting expectation that `pages` is cleaned up by the previous iteration. Because this is closely tied to `locked_pages`, also make it the previous iteration's responsibility to guarantee its reset, and verify with a second new BUG_ON() instead of handling (and masking) failures to do so. Signed-off-by: Sam Edwards --- fs/ceph/addr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 3becb13a09fe..f2db05b51a3b 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -1679,7 +1679,9 @@ static int ceph_writepages_start(struct address_space= *mapping, tag_pages_for_writeback(mapping, ceph_wbc.index, ceph_wbc.end); =20 while (!has_writeback_done(&ceph_wbc)) { - ceph_wbc.locked_pages =3D 0; + BUG_ON(ceph_wbc.locked_pages); + BUG_ON(ceph_wbc.pages); + ceph_wbc.max_pages =3D ceph_wbc.wsize >> PAGE_SHIFT; =20 get_more_pages: --=20 2.51.2