cachefiles: resend an open request if the read request's object is closed
authorJia Zhu <zhujia.zj@bytedance.com>
Mon, 20 Nov 2023 04:14:20 +0000 (12:14 +0800)
committerChristian Brauner <brauner@kernel.org>
Sat, 25 Nov 2023 15:03:57 +0000 (16:03 +0100)
commit0a7e54c1959c0feb2de23397ec09c7692364313e
tree4d6bceca99dd84ec6d147ddbca849ada35732871
parent3c5ecfe16e7699011c12c2d44e55437415331fa3
cachefiles: resend an open request if the read request's object is closed

When an anonymous fd is closed by user daemon, if there is a new read
request for this file comes up, the anonymous fd should be re-opened
to handle that read request rather than fail it directly.

1. Introduce reopening state for objects that are closed but have
   inflight/subsequent read requests.
2. No longer flush READ requests but only CLOSE requests when anonymous
   fd is closed.
3. Enqueue the reopen work to workqueue, thus user daemon could get rid
   of daemon_read context and handle that request smoothly. Otherwise,
   the user daemon will send a reopen request and wait for itself to
   process the request.

Signed-off-by: Jia Zhu <zhujia.zj@bytedance.com>
Link: https://lore.kernel.org/r/20231120041422.75170-4-zhujia.zj@bytedance.com
Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com>
Reviewed-by: David Howells <dhowells@redhat.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/cachefiles/internal.h
fs/cachefiles/ondemand.c