* [PATCH] ceph: avoid pending truncate during nonblocking cap acquire
@ 2026-09-04 10:33 Max Kellermann
2026-09-05 1:18 ` Xiubo Li
0 siblings, 1 reply; 2+ messages in thread
From: Max Kellermann @ 2026-09-04 10:33 UTC (permalink / raw)
To: idryomov, amarkuze, xiubo.li, ceph-devel, linux-kernel
Cc: Max Kellermann, stable
Readahead acquires caps while the folios are locked. This can
deadlock when processing a pending truncate; truncate_pagecache() can
then attempt to a folio that is already locked.
Return -EAGAIN instead when `NON_BLOCKING` is set, causing the
readahead to be abandoned.
Fixes: 49870056005c ("ceph: convert ceph_readpages to ceph_readahead")
Cc: stable@vger.kernel.org
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
fs/ceph/caps.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index bcb04c6cb92c..86e195c5fd32 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -2889,6 +2889,10 @@ static int try_get_cap_refs(struct inode *inode, int need, int want,
}
/* finish pending truncate */
+ if (ci->i_truncate_pending && (flags & NON_BLOCKING)) {
+ ret = -EAGAIN;
+ goto out_unlock;
+ }
while (ci->i_truncate_pending) {
spin_unlock(&ci->i_ceph_lock);
if (snap_rwsem_locked) {
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] ceph: avoid pending truncate during nonblocking cap acquire
2026-09-04 10:33 [PATCH] ceph: avoid pending truncate during nonblocking cap acquire Max Kellermann
@ 2026-09-05 1:18 ` Xiubo Li
0 siblings, 0 replies; 2+ messages in thread
From: Xiubo Li @ 2026-09-05 1:18 UTC (permalink / raw)
To: Max Kellermann; +Cc: idryomov, amarkuze, ceph-devel, linux-kernel, stable
LGTM.
Reviewed-by: Xiubo Li <xiubo.li@clyso.com>
On Fri, 4 Sept 2026 at 03:33, Max Kellermann <max.kellermann@ionos.com> wrote:
>
> Readahead acquires caps while the folios are locked. This can
> deadlock when processing a pending truncate; truncate_pagecache() can
> then attempt to a folio that is already locked.
>
> Return -EAGAIN instead when `NON_BLOCKING` is set, causing the
> readahead to be abandoned.
>
> Fixes: 49870056005c ("ceph: convert ceph_readpages to ceph_readahead")
> Cc: stable@vger.kernel.org
> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
> ---
> fs/ceph/caps.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
> index bcb04c6cb92c..86e195c5fd32 100644
> --- a/fs/ceph/caps.c
> +++ b/fs/ceph/caps.c
> @@ -2889,6 +2889,10 @@ static int try_get_cap_refs(struct inode *inode, int need, int want,
> }
>
> /* finish pending truncate */
> + if (ci->i_truncate_pending && (flags & NON_BLOCKING)) {
> + ret = -EAGAIN;
> + goto out_unlock;
> + }
> while (ci->i_truncate_pending) {
> spin_unlock(&ci->i_ceph_lock);
> if (snap_rwsem_locked) {
> --
> 2.47.3
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-05 1:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-04 10:33 [PATCH] ceph: avoid pending truncate during nonblocking cap acquire Max Kellermann
2026-09-05 1:18 ` Xiubo Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®