From nobody Tue Sep 29 05:34:55 2026 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 31F63352010; Wed, 12 Aug 2026 07:37:11 +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=1786520231; cv=none; b=lyaTe85UW/EC1NN/o80Idl4V+LnT7S28CguhvkpGD+AlXonuuHsWv6z213/aVag/iWOL4T0jWrwu2JhlwE2pFEwtTpmZIlLkKjRndiCwNfh8EHGjYgx29XFOJKl6Lt8FtHaf0DO0SxoMNsaHv4o1VWICB+MhMuuaGTwgXFZkyIo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786520231; c=relaxed/simple; bh=skjiBnbamJVZ+JXGpDfVX2zwPyN41yjBBcbtxaclJv4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DlYd+1EPD7M57Nh8S+CCu42Uq8uWrwv21sqECylIDgkLlwKoBGLqkxB2z0uQoaJJkLPV6shKxRyVVZ/PvEqyaJct4cg7quJvwpm5HkEVwJF0S0lX/rvls1b4rEzr57IdQAFIQVmuZ7Wn13vQeaNZX+fEs5aNMxhXJf9w9PqBIZk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GCq6ib/1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GCq6ib/1" Received: by smtp.kernel.org (Postfix) with ESMTPS id ADFD4C2BCF7; Wed, 12 Aug 2026 07:37:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1786520230; bh=skjiBnbamJVZ+JXGpDfVX2zwPyN41yjBBcbtxaclJv4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=GCq6ib/1nCxc98C32Y/4y7wi1rR6lS6ZoO3YG1WikL7GeyD58BujYkX8J2W0JmhzA RpTVqX1kGqwr9M+B9Qa52+Hc5Eh81bACfnhzmObL9XbtQTjWYFyt3Cg1ZfwvkWge5h uhE5KSNud/XKfH5J+Ey4v7kl9/2yhk5DrsqTGXAE0aMI1ecN661U43Z8CbMuXsl1Xr lNeo9adDTg6plGBqXbi0B+2VDVrxnaai7JP7DFftFa0KXZVxRYlSIGdGH6/MFkLquY sDQzm4doKn0mu747QvsJUh4h2p6hcE6spHL5Q8WlLXlJHE3C4wP0dr53tLrpo5qTJy 4ooOcI2WGpewg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90131C5B56A; Wed, 12 Aug 2026 07:37:10 +0000 (UTC) From: Xiubo Li via B4 Relay Date: Wed, 12 Aug 2026 00:36:25 -0700 Subject: [PATCH v2 1/2] ceph: use GFP_NOFS for cap flush allocation in writeback path Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260812-b4-gfp_nofs-v2-1-9574af8a417d@clyso.com> References: <20260812-b4-gfp_nofs-v2-0-9574af8a417d@clyso.com> In-Reply-To: <20260812-b4-gfp_nofs-v2-0-9574af8a417d@clyso.com> To: Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko Cc: ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Xiubo Li X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1786520227; l=1682; i=xiubo.li@clyso.com; s=20260625; h=from:subject:message-id; bh=ZrpOLLgIzASawCWfTKDXlCq3HzO5pZbOM91CKtXE5rg=; b=qQMe7Ztk2zNiZG7RoGSa5/D3k5SB+nAFvpLr9XdWLUIxKZjRIlrYLxu8vEM8ummbjX8arKwiF aS37qyBgIMQALI/LG0GQuGUrGAwA+mNFRQ3lC+itPf8UAFVj3V2LTKe X-Developer-Key: i=xiubo.li@clyso.com; a=ed25519; pk=V3NGr0AgAopiUhaLY51ipBkLN5LlcLhjOEfLEq1RoZ8= X-Endpoint-Received: by B4 Relay for xiubo.li@clyso.com/20260625 with auth_id=840 X-Original-From: Xiubo Li Reply-To: xiubo.li@clyso.com From: Xiubo Li ceph_alloc_cap_flush() is called from ceph_writepages_start() inside the writeback layer, where other allocations in the same path (ceph_osdc_alloc_request, ceph_osdc_alloc_messages) already use GFP_NOFS. A GFP_KERNEL allocation here can trigger direct reclaim that recursively enters the filesystem writeback path: ceph_writepages_start() // inode A writeback ceph_alloc_cap_flush() kmem_cache_alloc(..., GFP_KERNEL) [direct reclaim] try_to_free_pages() shrink_slab() super_cache_scan() prune_icache_sb() inode_lru_isolate() iput() -> evict(inode_B) [inode_B has dirty pages] filemap_flush() ceph_writepages_start() // re-enters writeback ceph_alloc_cap_flush() -> RECURSION / STACK OVERFLOW All 11 callers of ceph_alloc_cap_flush() are in write or writeback contexts: writepages (x2), write_iter, fallocate, copy_file_range, setxattr, setattr, and page_mkwrite. Signed-off-by: Xiubo Li --- fs/ceph/caps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index f8d898ad091e..cbaebeac06f7 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -1875,7 +1875,7 @@ struct ceph_cap_flush *ceph_alloc_cap_flush(void) { struct ceph_cap_flush *cf; =20 - cf =3D kmem_cache_alloc(ceph_cap_flush_cachep, GFP_KERNEL); + cf =3D kmem_cache_alloc(ceph_cap_flush_cachep, GFP_NOFS); if (!cf) return NULL; =20 --=20 2.53.0 From nobody Tue Sep 29 05:34:55 2026 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 31E7F34D929; Wed, 12 Aug 2026 07:37:11 +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=1786520231; cv=none; b=jFtpe+jm31CESvbUHG9s/pq6l2DAh13mZOcd6pwXv+A1esICc8uVvCBkHOjqK1GdYX6N3zaelRgear4l0XQOnO3zNxWVp27nMMJmHOq7XkRZAEwsC84IRgdaFcqYmropSNMPhh/SLIqDyXGI6Ufo1AJ7AV5yVwPHOkdibBwNahM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786520231; c=relaxed/simple; bh=YBIwIpnaDgUbjzux7FN1A/184Gl+eeadciai1SEc6so=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Xm9HfiQ5Am8yV+vZbKi71YnEyFiXlUEEicpY7wdobxXf0ZHs3yjmKFBuOTlcEwquYS/6a5pLxlv0fdhMHh8ddcnf8FZVNTihnLhLQ1IgIw8VrtqJXtsQBjrqSiokkqBj6CYKxjm0Ro5L2OvUgOqUWUtAVELj3UZp4ecuUan1C1g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XNchVvsX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XNchVvsX" Received: by smtp.kernel.org (Postfix) with ESMTPS id B9C19C2BCF4; Wed, 12 Aug 2026 07:37:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1786520230; bh=YBIwIpnaDgUbjzux7FN1A/184Gl+eeadciai1SEc6so=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=XNchVvsXvsnNfYTV6OyIZ2Cw/B3FTj69aSY0udbU5vKWPTp23Pj/ouKS2m3z0IlQs HgM1YT+5VvHTnLUeK3JhP9Q5VJoZkfby1p052vLyB/afmkr5ybYTxlNZExhGnO/+MO DVgLZpxHIaQrwh/EhZa42yPhzCbhkbLpj9BtpFnrcYteW2e0rTnFFGKZtD1rZXZLWv GWCdgjGPfpFtsqbT9U+LcRDtS20MZUEGd2LzlY+K88tZwUTKuECvvYZOrP9uqqcdqO uLMJFeQbuPtlnFIsgeHhNtb/aSu8GIkImbrY7MACmUnzX/zGXvsTLB1R0uSCy81x2E lvOxuHUoVIgGw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D7D1C5CFDB; Wed, 12 Aug 2026 07:37:10 +0000 (UTC) From: Xiubo Li via B4 Relay Date: Wed, 12 Aug 2026 00:36:26 -0700 Subject: [PATCH v2 2/2] ceph: use GFP_KERNEL consistently in __ceph_pool_perm_get() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260812-b4-gfp_nofs-v2-2-9574af8a417d@clyso.com> References: <20260812-b4-gfp_nofs-v2-0-9574af8a417d@clyso.com> In-Reply-To: <20260812-b4-gfp_nofs-v2-0-9574af8a417d@clyso.com> To: Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko Cc: ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Xiubo Li X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1786520227; l=2293; i=xiubo.li@clyso.com; s=20260625; h=from:subject:message-id; bh=t65MUA8RDPniD/z/fS7QaPun27tPX+DNMHXeSlQgYew=; b=MNc89SwKGOeJZneDMP4ikd4abzX8rANwDsg58TXjLXj2FXwnN3SnJPwGYp9+GRQ8+HIPvh/cA Cmc+LG3tc5qBrGAuURhdsaQE7LtEpyU8x3KPu6oMdB/NKR+KpeyR7mo X-Developer-Key: i=xiubo.li@clyso.com; a=ed25519; pk=V3NGr0AgAopiUhaLY51ipBkLN5LlcLhjOEfLEq1RoZ8= X-Endpoint-Received: by B4 Relay for xiubo.li@clyso.com/20260625 with auth_id=840 X-Original-From: Xiubo Li Reply-To: xiubo.li@clyso.com From: Xiubo Li __ceph_pool_perm_get() has six allocations for building OSD STAT requests, five of which used GFP_NOFS and one (the page vector allocation) used GFP_KERNEL, making them inconsistent. The function is only called from ceph_try_get_caps() and __ceph_get_caps(), both of which are in the user I/O path (read, write, fallocate, mmap fault), not in the writeback path. There is no risk of recursive writeback, so GFP_NOFS is unnecessarily restrictive. Use GFP_KERNEL consistently for all six allocations. Signed-off-by: Xiubo Li --- fs/ceph/addr.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index e2da3ab9f808..9ea6be704820 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -2466,7 +2466,7 @@ static int __ceph_pool_perm_get(struct ceph_inode_inf= o *ci, } =20 rd_req =3D ceph_osdc_alloc_request(&fsc->client->osdc, NULL, - 1, false, GFP_NOFS); + 1, false, GFP_KERNEL); if (!rd_req) { err =3D -ENOMEM; goto out_unlock; @@ -2479,12 +2479,12 @@ static int __ceph_pool_perm_get(struct ceph_inode_i= nfo *ci, rd_req->r_base_oloc.pool_ns =3D ceph_get_string(pool_ns); ceph_oid_printf(&rd_req->r_base_oid, "%llx.00000000", ci->i_vino.ino); =20 - err =3D ceph_osdc_alloc_messages(rd_req, GFP_NOFS); + err =3D ceph_osdc_alloc_messages(rd_req, GFP_KERNEL); if (err) goto out_unlock; =20 wr_req =3D ceph_osdc_alloc_request(&fsc->client->osdc, NULL, - 1, false, GFP_NOFS); + 1, false, GFP_KERNEL); if (!wr_req) { err =3D -ENOMEM; goto out_unlock; @@ -2495,7 +2495,7 @@ static int __ceph_pool_perm_get(struct ceph_inode_inf= o *ci, ceph_oloc_copy(&wr_req->r_base_oloc, &rd_req->r_base_oloc); ceph_oid_copy(&wr_req->r_base_oid, &rd_req->r_base_oid); =20 - err =3D ceph_osdc_alloc_messages(wr_req, GFP_NOFS); + err =3D ceph_osdc_alloc_messages(wr_req, GFP_KERNEL); if (err) goto out_unlock; =20 @@ -2534,7 +2534,7 @@ static int __ceph_pool_perm_get(struct ceph_inode_inf= o *ci, } =20 pool_ns_len =3D pool_ns ? pool_ns->len : 0; - perm =3D kmalloc_flex(*perm, pool_ns, pool_ns_len + 1, GFP_NOFS); + perm =3D kmalloc_flex(*perm, pool_ns, pool_ns_len + 1, GFP_KERNEL); if (!perm) { err =3D -ENOMEM; goto out_unlock; --=20 2.53.0