From nobody Sat Feb 7 08:42:36 2026 Received: from mail-dl1-f49.google.com (mail-dl1-f49.google.com [74.125.82.49]) (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 61C0A285C96 for ; Mon, 26 Jan 2026 02:31:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769394668; cv=none; b=juPujXOsHtXEqmiKyo4bM3ynYjLrWvKN7tWR2hL++Z/ZB2HQeyHgTyj+bFmxt2oMkyhWccQQ8Xha+FAuRdFWt0+Jzc/mUtKnafJuya2UlpW1P4Kbu62q559+cxQLGo4HTinzA2MD6KqeaqwsLDJrhY4MhvevTmQCr/C/lQ7zoPU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769394668; c=relaxed/simple; bh=2r3QgcjH7GZMruE67ZsjvUp6p/exK5sB1NKVz9e2BfM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SfmDfucZPgnJyHibtS5+MbwHi96aKCNSC17e+FWEeq9nthMysxi0VoMOxe+ZpsyBjug8HKglu4DG5+SXo2DHMATkqmWi788YXL5JSN/yLkHa+Q1+mlb8XTKLHUXjVXzcGDKpgtaSLnkEE7elyHcNQt4rdi+R1BhC/UVHDj5KbE0= 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=PAHZ408s; arc=none smtp.client-ip=74.125.82.49 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="PAHZ408s" Received: by mail-dl1-f49.google.com with SMTP id a92af1059eb24-1232d9f25e9so769389c88.0 for ; Sun, 25 Jan 2026 18:31:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769394666; x=1769999466; 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=0m877IielwhZYxUtpH2DsnWNPP6T5OXQthZEWEyOygI=; b=PAHZ408sgWRqlfTkQMqroDt+XD+0tL/RZvpJPYvVjIgKYJJ29l/xASZO6X8WVHQ3Aq 0lEdfQQdp/ti6HvGzKgLbEFKXGSA1+s35Xw//2Lv9zu5CW1fizPPwzmVtG08GMufBOZA Q8T0mp5xTCpN8THVp7Ej0y+W+WRzq2CXVcUtrqbxj7v5DyAMWcOgjx63fNh7oVfsNlGM Y4+yWkk/jMoxbb0CDLGEAxuEPSlVRp+sJ4gqE3553l4wdESAckyHDuIlab58NVXWRoqg cmYKvsk4sfbklu/760JBvlpU+PWJHgV3cm2d1aVfHyiCBoiMfgfd7Lh3oQMUOfQz3OIE cQhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769394666; x=1769999466; 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=0m877IielwhZYxUtpH2DsnWNPP6T5OXQthZEWEyOygI=; b=f4278wp/73Uor0rWCEff9LcVwX26rEj4b7cc7kqR638htfvV+ebe28j9bi7+h9SeGA b0vOxHWru6WPn7NR2EYEyOj/A5gZynAb8OgNlk/PH2lrN07vSJoI8xWbBJhPC+cDn1rq ZSr5z4YtzJNwyOxQyOk3YVhASBTpytmD/hllqsqO3SlvT9ys92kht9AUR9GyYMJKCGLy coCTnW2IwEnjWMIYupref2uL/wBq0e41/81ls9EMfljLY6QCX9xl2Lc3koCflhFiWFGV nZy6PpweXKGqsZdlfE8izs6dIkO+D4IP5w8vBxtmoJj/fxkzCvkpC172Yb9Ab5TgFqbo fhKw== X-Forwarded-Encrypted: i=1; AJvYcCUh76eMsxBtIB+elU16b02LXF4EJ5xJXXsfnNsZsINzA9X7NTc5rZD0gOBEoLHPY+6vmxoaGZ1nnCa1tJo=@vger.kernel.org X-Gm-Message-State: AOJu0YztiQKqL2+tk6f+2zhNetuRrmbjhAptNcAf6d8dZI/CvR4VqWLN fn0FF0Q4uYAOPL3HyBi1w+QXiqpzeNbRVMDYehFomJx7YmO6LpokJRPx X-Gm-Gg: AZuq6aLtMN8wxR8aNqsQsJAmGRfYzz2TxguLOlE+jDG/9O2/LcBQUKO5ukCCfOadUPC uIalll3cv8HCOj/pSKlNFgG2ix51LgkFtrotL7Kqk9j0yYosCejxN+fzxGacSwtJ8smBjpHBHTr l06zpwmUrZt6ikCRc/d+QOAGM8FQeXZ+XpaPB4/ZcRL4Yl4XVROcV6pwQ60d/zj0p7ydUn/5P2y p/g7KGogdO48xGhmw5g3GGMvgmvTMDZ1uc76FeHBsGCTfNUGWWoqofW84Reqa5KfkWsCHbK5gM3 MFvQ/le06q3QiivXORhENcQ8s2vbKCx6GVyx6PbsdwtlvFZ5oPtOsuUVfW38ACpDgyAcKgPAsYL ROi/cfdDV7M3EYxxe82rr7D3sAiNisTiOKxavMYtWaSoj2ts1KAg74NlZzzuHyU1wLL8QNvq5ux i4JsRMKPt5rmGRANGdgPemL9ahhr7LcwZJ8XniI6ViRriKFgsZPkk3 X-Received: by 2002:a05:7022:6183:b0:123:3356:7abb with SMTP id a92af1059eb24-1248ec87252mr1826327c88.46.1769394666463; Sun, 25 Jan 2026 18:31:06 -0800 (PST) Received: from luna.turtle.lan (static-23-234-93-211.cust.tzulo.com. [23.234.93.211]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1247d91c52bsm17212277c88.6.2026.01.25.18.31.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jan 2026 18:31:06 -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 , stable@vger.kernel.org Subject: [PATCH v3 1/4] ceph: do not propagate page array emplacement errors as batch errors Date: Sun, 25 Jan 2026 18:30:52 -0800 Message-ID: <20260126023055.405401-2-CFSworks@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260126023055.405401-1-CFSworks@gmail.com> References: <20260126023055.405401-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" When fscrypt is enabled, move_dirty_folio_in_page_array() may fail because it needs to allocate bounce buffers to store the encrypted versions of each folio. Each folio beyond the first allocates its bounce buffer with GFP_NOWAIT. Failures are common (and expected) under this allocation mode; they should flush (not abort) the batch. However, ceph_process_folio_batch() uses the same `rc` variable for its own return code and for capturing the return codes of its routine calls; failing to reset `rc` back to 0 results in the error being propagated out to the main writeback loop, which cannot actually tolerate any errors here: once `ceph_wbc.pages` is allocated, it must be passed to ceph_submit_write() to be freed. If it survives until the next iteration (e.g. due to the goto being followed), ceph_allocate_page_array()'s BUG_ON() will oops the worker. Note that this failure mode is currently masked due to another bug (addressed next in this series) that prevents multiple encrypted folios from being selected for the same write. For now, just reset `rc` when redirtying the folio to prevent errors in move_dirty_folio_in_page_array() from propagating. Note that move_dirty_folio_in_page_array() is careful never to return errors on the first folio, so there is no need to check for that. After this change, ceph_process_folio_batch() no longer returns errors; its only remaining failure indicator is `locked_pages =3D=3D 0`, which the caller already handles correctly. Fixes: ce80b76dd327 ("ceph: introduce ceph_process_folio_batch() method") Cc: stable@vger.kernel.org Signed-off-by: Sam Edwards --- fs/ceph/addr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 63b75d214210..3462df35d245 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -1369,6 +1369,7 @@ int ceph_process_folio_batch(struct address_space *ma= pping, rc =3D move_dirty_folio_in_page_array(mapping, wbc, ceph_wbc, folio); if (rc) { + rc =3D 0; folio_redirty_for_writepage(wbc, folio); folio_unlock(folio); break; --=20 2.52.0 From nobody Sat Feb 7 08:42:36 2026 Received: from mail-dl1-f43.google.com (mail-dl1-f43.google.com [74.125.82.43]) (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 165A0299A90 for ; Mon, 26 Jan 2026 02:31:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769394670; cv=none; b=V4ApQZhqaRAmKf79a7+qYg2R6Fpbecxftkpxftg8Rc6C6LIuhUTGuL9WAdL9JyJUpFQLaf8SFGK8hVlT5DiywF46XAioRX7+Vzta6dnyXHUkG95Qs+GdKMi81ddbUbhGbt7/VI7Mz2CwoOL4EoGSUaDN3zIJGnT7z8UyI1ZbRNo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769394670; c=relaxed/simple; bh=xreigetpjHdKa6OZ71uh6zOcPjuDFrwATx0og6exOHo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NKhPCp3XVskoAY7c1GBmt2WkwLc25VvG+JGkcIdoqaALuB8StikEYRAfIyInwmLm1nnxZ/bzyR5iV0hAaWWq9gita5xw4Yv3IhnpFwNW+VInkHoj+lLq1sR3J7xuHxfU9DOrG8afTrZp7GnrMpMRv6kkSwie4yKyCsQDiIAyLBc= 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=a5sQpun3; arc=none smtp.client-ip=74.125.82.43 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="a5sQpun3" Received: by mail-dl1-f43.google.com with SMTP id a92af1059eb24-1233b172f02so5691861c88.0 for ; Sun, 25 Jan 2026 18:31:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769394668; x=1769999468; 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=7OeqEToDWh87NKXAJBkWa10HlZtuXDj/TYqt7IVavaQ=; b=a5sQpun34domUif7GnfgZYl25NskFflCpMYZekv2FE2b3UNFQ4ca3mDL5YQP2bydJn kLFIsU5x7RKY0qNA7WxGTaZTfCmihrhBOdW2uAVR4ZlHZfMrZDqhDi5gRZ0EOjw7N9Ub kKD4UbMTvpzdVMFMlWwVD7zAbxnCjQrhSAAVQKjJPyPAHxtqTTjaNgUWaAOzYAUBd6p0 h2VgjQbGGjmZgjYh4zKp1zbohqaB32CrsMMJC0MT6E3ebMiMybed73hcnyshhvFdsHeB vuHk7m9RFow6+pWpimROCROmWP9k7Jw/Rfhb4SEHmx1g691eb3P7Wi26tRBoVmrmpkS/ DpXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769394668; x=1769999468; 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=7OeqEToDWh87NKXAJBkWa10HlZtuXDj/TYqt7IVavaQ=; b=W2c+s0NmIKa/IYmMVOS7LDe2FwmDHAdqrS3wLJzzNGI9nci39V1yD+JpCPEG1jks5Z rEPICjDYEGFbrv44Zt6oj2zdaANmLfzqKxBYTEsaKkn4FQLGtTnwb4weDBG0qPglZ49g qHe0fMXxaNAWdr/8qG0Eci3TbF3kGEPt10KAWbhiYu6aQSfJkBWtbmbmEIFPlg8mkh5x i7w6gtx3yZ1LV4uzV1DOSCAlTXEVHga+69wl1DoIhoGKoIUP7+7eRPCxgS2e7U27iLll IqG02a5ZzMd54P2tYWxjTt+ec5HDhbst1C3uSG8HJAhIF8DOLY1WHM/689p6MGdvvIel cASw== X-Forwarded-Encrypted: i=1; AJvYcCVCq17LHjtQZ8apurXpix0XkE7hX130QE5faknhnXiIqAslj/flZznz1Y2mWCvZT+Y6D+LOyVkdM9ZEyjQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yw2rWCyL0Zm2MGtR4JRLSfiHGWl11k2/k+uJfm/aGRt+yV2REUr 7wOkrMRVkM3NOhyvkzE8gpgxN6eJaTXZ8+FWfM/P03nk26VwVUzlAce1 X-Gm-Gg: AZuq6aIak2t0S4TqtFrDf0JuOjhPeV7TI1XtLhN9K3/Q/9h7nKQw+bJI72qsONYv6kg 3L76x48eYVlgvJfAZDvUMswHhxx9rvgTVAjiK8QQL3+ofb7BPoGyYn6Vs6ImykcumLCsf4HLguk wd7pnhLGH+RAPjgRW4Q0TtvWVvrmn2BhOGOLCu6d95gzKX15LM6GCVChRzlokFe9WQPQ+YfTlDL gf7BTl1pTyNTAuwRX43xl2rSVEV6tcHkR8RUhGmKus2EjWyEF3gI34FFUVP7MnbTX7GF6B3Hbh+ OztjlnPeqOd2jrPiAAtZwqsQl10Ciz+ZUoTy8MbBk5zSSHu4C8YMuthI3Vt9ah20NJu8SFYHOkE 3XSOB1YUZG6bPGVyA4HRX16t+8bZetLyjov2h/dKAZclCpYnj5FVQEIZQvA4prEt9OjH9rogDEE 4G7CPd82KTJu4WkV4A4VhDin4rm29oebeExh9yKKP4QfrVtugrec1g X-Received: by 2002:a05:7022:238d:b0:119:e56b:98a1 with SMTP id a92af1059eb24-1248ebe99acmr1414133c88.8.1769394668050; Sun, 25 Jan 2026 18:31:08 -0800 (PST) Received: from luna.turtle.lan (static-23-234-93-211.cust.tzulo.com. [23.234.93.211]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1247d91c52bsm17212277c88.6.2026.01.25.18.31.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jan 2026 18:31:07 -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 , stable@vger.kernel.org Subject: [PATCH v3 2/4] ceph: fix write storm on fscrypted files Date: Sun, 25 Jan 2026 18:30:53 -0800 Message-ID: <20260126023055.405401-3-CFSworks@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260126023055.405401-1-CFSworks@gmail.com> References: <20260126023055.405401-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" CephFS stores file data across multiple RADOS objects. An object is the atomic unit of storage, so the writeback code must clean only folios that belong to the same object with each OSD request. CephFS also supports RAID0-style striping of file contents: if enabled, each object stores multiple unbroken "stripe units" covering different portions of the file; if disabled, a "stripe unit" is simply the whole object. The stripe unit is (usually) reported as the inode's block size. Though the writeback logic could, in principle, lock all dirty folios belonging to the same object, its current design is to lock only a single stripe unit at a time. Ever since this code was first written, it has determined this size by checking the inode's block size. However, the relatively-new fscrypt support needed to reduce the block size for encrypted inodes to the crypto block size (see 'fixes' commit), which causes an unnecessarily high number of write operations (~1024x as many, with 4MiB objects) and correspondingly degraded performance. Fix this (and clarify intent) by using i_layout.stripe_unit directly in ceph_define_write_size() so that encrypted inodes are written back with the same number of operations as if they were unencrypted. This patch depends on the preceding commit ("ceph: do not propagate page array emplacement errors as batch errors") for correctness. While it applies cleanly on its own, applying it alone will introduce a regression. This dependency is only relevant for kernels where ce80b76dd327 ("ceph: introduce ceph_process_folio_batch() method") has been applied; stable kernels without that commit are unaffected. Fixes: 94af0470924c ("ceph: add some fscrypt guardrails") Cc: stable@vger.kernel.org Signed-off-by: Sam Edwards --- fs/ceph/addr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 3462df35d245..39064893f35b 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -1000,7 +1000,8 @@ unsigned int ceph_define_write_size(struct address_sp= ace *mapping) { struct inode *inode =3D mapping->host; struct ceph_fs_client *fsc =3D ceph_inode_to_fs_client(inode); - unsigned int wsize =3D i_blocksize(inode); + struct ceph_inode_info *ci =3D ceph_inode(inode); + unsigned int wsize =3D ci->i_layout.stripe_unit; =20 if (fsc->mount_options->wsize < wsize) wsize =3D fsc->mount_options->wsize; --=20 2.52.0 From nobody Sat Feb 7 08:42:36 2026 Received: from mail-dl1-f49.google.com (mail-dl1-f49.google.com [74.125.82.49]) (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 9D1F82C3260 for ; Mon, 26 Jan 2026 02:31:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769394673; cv=none; b=jC9yPUa24CDuZkySer+UpBT4vGlywKNQaUpZA5p3NVxRLV+J0j/F8E2wXdF7Q57YmhtqeelISrtCkuybGGE6j2vxvyDuZhytBU1yVTSK95UQAW3ruzyGHZ4aDck32/ZZcwOu8FvwGstlFxWFCwbvIIG+3l5vXUZv06BES3wedzs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769394673; c=relaxed/simple; bh=kIfp2aymoeUL8Vy4cuQ54skcXO7OD2rR6MpqfXG/nX8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YZQQXetocp8rRmOr7DrVPCqXjNuQAEH1g1JxZ8nxrcxxicj5EF2RYq2I4gdsh7YMuCIh9WRy6p9nSe7NnYEO9c8wsasupRi5Q35ft8BjB/mnv+SRmEzoMUzgywI+JeknVtRUnBVHMW6hvFo7TDlD+LOllMAo+gb72PfDTjB9ujE= 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=T+4gBNoa; arc=none smtp.client-ip=74.125.82.49 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="T+4gBNoa" Received: by mail-dl1-f49.google.com with SMTP id a92af1059eb24-12332910300so6694325c88.0 for ; Sun, 25 Jan 2026 18:31:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769394670; x=1769999470; 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=eOLQh9MA9MhTdiXC4zX1NuDh2cfiEEMs3r95tMeAbNQ=; b=T+4gBNoaQrB48jeM4EELu+E0yjUU4C6hwNw5rgeg0cMSMmFMiIL4NswpdDYWrzSDCp cXRezwgX8VDh+aJFd1nymctgsQlw7dswZ1mivpH3yWl9ugqgPwdyuOSTZi6MU+jSb9uK kAVB6Y5mEFG5Mk5It0yr/Z0ayxYbThg7hkPJ0GPllAC+LeEAU/c5njiyAJfOKOldzzc+ dAzdidYUCqhodFIO4KwHC4yllNQZoEUpHwf4IcUX8rKpHeewDWP2LVACyU3B+NvSDtav Wn3hIzM5Iy69XR6MuuCOaND8DeIYgW6hi3SotEew113N/zUzoech6KRdE7raCdNHHeaw p4kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769394670; x=1769999470; 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=eOLQh9MA9MhTdiXC4zX1NuDh2cfiEEMs3r95tMeAbNQ=; b=eKdF1qjFPD728t1qByxD9H9bmTCD37WNDXEkIipOf0cd4V7g343DaOc/7eF309udia wKmj5SCug+0pCUzmQ1/1UA2B5yfZItnUk3ujxFTdmmdzKUa7Ky7SvWclEyz8je8wHVrl nCx6CUcyWPtI/pnplA++uzMrCJ+JJqGoswhRtjfoqVJd3Qy20ELPmNObCGfhoxPpzvA+ /PCvNAjVygnJ8aeO7Ub0rgMFTkrfeCAgcdGYbNYI9CCEgwpwwWO7iz/hRxbZQCggGTVy mrwo4pVn2xfpiyZRPLMTs0fRvlP7qVJxJA4ovSKlEBmiClNErQPzvN2HeLkqFHtLmeyh ZZZw== X-Forwarded-Encrypted: i=1; AJvYcCViFbuhjXAHe1W0n4v+/cs4oLpsM6VIJVhQZpg3QuohwY9FsP2lrUnz0YTht6mrw/npuoQj4URbfwlm0aE=@vger.kernel.org X-Gm-Message-State: AOJu0Yw3gYr9Ag3jqOHVCKZBmGmmjjyHaykDaN+Alb/iWWJRN2BKGh+F sxwoFdLggxAKP7uPWTJVK+OKLLzeLJLCPU/S7XQnHcO20ozHJL0bvJ7i X-Gm-Gg: AZuq6aKpfem2/p+gZw2HJFPSBqBIMKHPt6QdBxIpG4+mKBsL6+BujukKYQKuvoJ3qLy XVtHWoPhajVppT9jaTl8vKnD/KF1HhQ/iCP4os4kwWGZlMciJNl5kbu/q2utM64LhWk8QawVCYC NgNrJC4fkWQ/5zEQUJ79tQ4Q/DYwvDlmwyOVLO/KEz8qI/75VPZ+yN1h5ZXrxrHFgDl9XN2RMdr /pV34rrhWvIl/vyrh6EfJYlPfhPC125TU9OKgQ5Tonh/QAaLafqd7bJRTi9A0EjyVK3yHNuJDfO X3Gbv4+jImoV8ewBJikHzD/WfkWIozlumTV9TPpaNJvbnHOlBeJMuDNd1BC0/Mnaq4g5ky8hXKk /UgSGp+b6BpCSSZ7NNeg6REWC3N9m+PMuo3YzAvb3qwOBSEjg4JHdCh8a15Imv/3tNyiIvl6rjF CEbMqjkFDt0f2dkHbDAl4X6JWoMl+1/mwhrmjjuDo5WNuZZmie8gsA X-Received: by 2002:a05:7022:923:b0:119:e569:fb91 with SMTP id a92af1059eb24-1248eb39492mr1853278c88.0.1769394669588; Sun, 25 Jan 2026 18:31:09 -0800 (PST) Received: from luna.turtle.lan (static-23-234-93-211.cust.tzulo.com. [23.234.93.211]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1247d91c52bsm17212277c88.6.2026.01.25.18.31.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jan 2026 18:31:09 -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 v3 3/4] ceph: remove error return from ceph_process_folio_batch() Date: Sun, 25 Jan 2026 18:30:54 -0800 Message-ID: <20260126023055.405401-4-CFSworks@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260126023055.405401-1-CFSworks@gmail.com> References: <20260126023055.405401-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" Following an earlier commit, ceph_process_folio_batch() no longer returns errors because the writeback loop cannot handle them. Since this function already indicates failure to lock any pages by leaving `ceph_wbc.locked_pages =3D=3D 0`, and the writeback loop has no way to handle abandonment of a locked batch, change the return type of ceph_process_folio_batch() to `void` and remove the pathological goto in the writeback loop. The lack of a return code emphasizes that ceph_process_folio_batch() is designed to be abort-free: that is, once it commits a folio for writeback, it will not later abandon it or propagate an error for that folio. Any future changes requiring "abort" logic should follow this invariant by cleaning up its array and resetting ceph_wbc.locked_pages appropriately. Signed-off-by: Sam Edwards --- fs/ceph/addr.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 39064893f35b..cdf11288d6b7 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -1284,16 +1284,16 @@ static inline int move_dirty_folio_in_page_array(st= ruct address_space *mapping, } =20 static -int ceph_process_folio_batch(struct address_space *mapping, - struct writeback_control *wbc, - struct ceph_writeback_ctl *ceph_wbc) +void ceph_process_folio_batch(struct address_space *mapping, + struct writeback_control *wbc, + struct ceph_writeback_ctl *ceph_wbc) { struct inode *inode =3D mapping->host; struct ceph_fs_client *fsc =3D ceph_inode_to_fs_client(inode); struct ceph_client *cl =3D fsc->client; struct folio *folio =3D NULL; unsigned i; - int rc =3D 0; + int rc; =20 for (i =3D 0; can_next_page_be_processed(ceph_wbc, i); i++) { folio =3D ceph_wbc->fbatch.folios[i]; @@ -1323,12 +1323,10 @@ int ceph_process_folio_batch(struct address_space *= mapping, rc =3D ceph_check_page_before_write(mapping, wbc, ceph_wbc, folio); if (rc =3D=3D -ENODATA) { - rc =3D 0; folio_unlock(folio); ceph_wbc->fbatch.folios[i] =3D NULL; continue; } else if (rc =3D=3D -E2BIG) { - rc =3D 0; folio_unlock(folio); ceph_wbc->fbatch.folios[i] =3D NULL; break; @@ -1370,7 +1368,6 @@ int ceph_process_folio_batch(struct address_space *ma= pping, rc =3D move_dirty_folio_in_page_array(mapping, wbc, ceph_wbc, folio); if (rc) { - rc =3D 0; folio_redirty_for_writepage(wbc, folio); folio_unlock(folio); break; @@ -1381,8 +1378,6 @@ int ceph_process_folio_batch(struct address_space *ma= pping, } =20 ceph_wbc->processed_in_fbatch =3D i; - - return rc; } =20 static inline @@ -1686,10 +1681,8 @@ static int ceph_writepages_start(struct address_spac= e *mapping, break; =20 process_folio_batch: - rc =3D ceph_process_folio_batch(mapping, wbc, &ceph_wbc); + ceph_process_folio_batch(mapping, wbc, &ceph_wbc); ceph_shift_unused_folios_left(&ceph_wbc.fbatch); - if (rc) - goto release_folios; =20 /* did we get anything? */ if (!ceph_wbc.locked_pages) --=20 2.52.0 From nobody Sat Feb 7 08:42:36 2026 Received: from mail-dl1-f65.google.com (mail-dl1-f65.google.com [74.125.82.65]) (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 355C52D46D9 for ; Mon, 26 Jan 2026 02:31:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769394674; cv=none; b=cTZCnn8+kpx6POWfpVvPBVedGius3cx4Y3+fE6WRNECRTyYx4Srkdl/DnfzfbIEEGibXzCZlgalUxpzHbRErDovZo2RLaTRU99oBIUMtIRSTKs0eNdNOcr3XeVpMilZQAh5O0hFHern+4nHG3sZzax0nbd9x108xEbIjVK+i+Cg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769394674; c=relaxed/simple; bh=LEM4dAMdc0CIh1pUicq2+gOIh05/dvfUnzW1HBv6u1c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F38QktESqVCLWYnkkCT+LOQJ/O0qHYuQDkXq2/oB5cDOsVsVAWtv+WYuJxKBnfjE8ZSC00VDi6tp1/XXqBry1nhyWD/PaOX56aJJP8pmG8pakt64eDxHOtcXz9Hjnu1/oon7zYpeKMpLI8yeet6LV1/XOubydrKKeb8Jw/r4DYE= 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=JM9sa9O/; arc=none smtp.client-ip=74.125.82.65 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="JM9sa9O/" Received: by mail-dl1-f65.google.com with SMTP id a92af1059eb24-1248d27f293so2367707c88.0 for ; Sun, 25 Jan 2026 18:31:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769394672; x=1769999472; 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=ymnLBLi8khxZIsCQL9bJnfvhV+yX6mpInM8DP2CqmnI=; b=JM9sa9O/2Tjk3oFtofm64g2or4VsGlgB8RCbWr8ZfzTdEaAIE8xguDRdBfbtt8R81g FPKJ6BNrE7NYz1aGQb1S+hyAuPhrI2L9rQp9k3eN0SahWodcB00MOvn/065Ec+5kSjRw LVoRiYBO3hTY6gbYBYpxcmQZxmSThR08aQEIvivhCsvoF0J45P3JQXlTr1Bfg5FLmYMJ xagCoAyLTDE5dJArR8j67EoBe0YqrHzmwrcLBc+SxaL4iwxu0COCcaTtJurXCNLSM2si ql8oRk3ibHKp6ahEMgP6kieoqcF4NPJhVDGYIS6BcPMfg2xfEV9XhPfz9tNLixDUhSa5 KE9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769394672; x=1769999472; 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=ymnLBLi8khxZIsCQL9bJnfvhV+yX6mpInM8DP2CqmnI=; b=pHxK8mEI/zDFILWN/FeL+XwPJtrVoExWuAxVympsU0z2RElNI5mFLmbZ7P7Cp+Al2B Qhw4CXleO8NufQhyHYncuoRSSswWpAfKEXDgj9RJmCTIJk3ERIoiuaAgzuVMny8+PaTz XQXis/vI2G/nW9LktCZm2a5hebruDhSTEWSDG9Jgkyqr4Hz9278NQAEH3dd+dxfbB/T9 qcKC14u85HsqKUJpyLcl85JsAK3SRD3xljD7+mCIu2xJb85dK+o/C7iRVAKC9I72t2GJ VzVfLa6OicA9+LIq4s90Hz2iY6Psml8OMXaqQHbIqvMZ7ycQkAyjtvrZtgr2JIjjfRms 2Npw== X-Forwarded-Encrypted: i=1; AJvYcCWOzstlS/HyUqmOfaoC09pgMn6XYz7JNEHvL7iO9Y2VomuUQ5scslZiEZDzIEX8P3GUi3Um7MvDZMs6gAk=@vger.kernel.org X-Gm-Message-State: AOJu0Yy3PGkhvqwcRv2RjDHia5wRvxvtWEX8ZzpZ3HOr+SVGvbkSaDbt HEJJ5aJpGdLKKvyJaOxdRm6OfTvwo2QBdYs8bJ9me2kSNQ4oNafe+Z2A X-Gm-Gg: AZuq6aKdDEuhvXOGAlhvHRYuJYTp6N6IZFScPHg8vcO+Rzg638lE0FtJTE3eT+HhuKh AmdPwJGTXt4JzIDzgaKNXmmqbz9fi/0HFW6NVY6fXtYy+AjLP/SD2SvKgMJYNPpMR0Z2p1XxeHz ovXOQXWftWCPBc+xr6nx1iJUTZ0LvewU9bBp4FNbU5i7/Frkk9mYs6DHtwD1guzmboFFj3q+Q+n Nx+14jvQPT9VG4+I88lVA7dgEIylXOM0uutwmvWB6HVdcAKM9ow9C6Fvo6+plQK25vZ13swCrhR vU62Vdgxl/7n+uYzCI6n8PjlKWXKpudkflMvxnDWQ/9XTJttbyH4ZYNeyjdFF//rIz+Z7+XA27F 1WcIZp8OWw+FDZ6v/akmS+gurioAKGElHFkvzYEW1V1gSBWQDssaEYCYw5dzmbFT5QN8Koa/Pcy OLbt7jdkSxMlO/1TIMNLmESJM2BU5YOxhF9iNZv0A40rYRbko0tEEX4QhBf25ECBw= X-Received: by 2002:a05:7022:6285:b0:11b:bf3f:5240 with SMTP id a92af1059eb24-1248ec0e28amr1564767c88.9.1769394672048; Sun, 25 Jan 2026 18:31:12 -0800 (PST) Received: from luna.turtle.lan (static-23-234-93-211.cust.tzulo.com. [23.234.93.211]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1247d91c52bsm17212277c88.6.2026.01.25.18.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jan 2026 18:31:11 -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 v3 4/4] ceph: assert writeback loop invariants Date: Sun, 25 Jan 2026 18:30:55 -0800 Message-ID: <20260126023055.405401-5-CFSworks@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260126023055.405401-1-CFSworks@gmail.com> References: <20260126023055.405401-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. This patch does not change invariants, behavior, or failure modes. The added BUG_ON() lines catch conditions that would already trigger oops, but do so earlier for easier debugging and programmer clarity. 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 cdf11288d6b7..4e392fc70d33 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -1663,7 +1663,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.52.0