linux/fs/cachefiles
Jeffle Xu d11b0b043b cachefiles: unbind cachefiles gracefully in on-demand mode
Add a refcount to avoid the deadlock in on-demand read mode. The
on-demand read mode will pin the corresponding cachefiles object for
each anonymous fd. The cachefiles object is unpinned when the anonymous
fd gets closed. When the user daemon exits and the fd of
"/dev/cachefiles" device node gets closed, it will wait for all
cahcefiles objects getting withdrawn. Then if there's any anonymous fd
getting closed after the fd of the device node, the user daemon will
hang forever, waiting for all objects getting withdrawn.

To fix this, add a refcount indicating if there's any object pinned by
anonymous fds. The cachefiles cache gets unbound and withdrawn when the
refcount is decreased to 0. It won't change the behaviour of the
original mode, in which case the cachefiles cache gets unbound and
withdrawn as long as the fd of the device node gets closed.

Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20220509074028.74954-4-jefflexu@linux.alibaba.com
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
2022-05-18 00:11:17 +08:00
..
cache.c cachefiles: Check that the backing filesystem supports tmpfiles 2022-01-21 21:36:28 +00:00
daemon.c cachefiles: unbind cachefiles gracefully in on-demand mode 2022-05-18 00:11:17 +08:00
error_inject.c cachefiles: Add some error injection support 2022-01-07 13:40:56 +00:00
interface.c cachefiles: Fix incorrect length to fallocate() 2022-03-03 11:35:21 -08:00
internal.h cachefiles: unbind cachefiles gracefully in on-demand mode 2022-05-18 00:11:17 +08:00
io.c cachefiles: extract write routine 2022-05-18 00:11:17 +08:00
Kconfig cachefiles: notify the user daemon when looking up cookie 2022-05-18 00:11:17 +08:00
key.c cachefiles: Implement key to filename encoding 2022-01-07 13:42:16 +00:00
main.c cachefiles: Implement object lifecycle funcs 2022-01-07 13:42:08 +00:00
Makefile cachefiles: notify the user daemon when looking up cookie 2022-05-18 00:11:17 +08:00
namei.c cachefiles: notify the user daemon when looking up cookie 2022-05-18 00:11:17 +08:00
ondemand.c cachefiles: unbind cachefiles gracefully in on-demand mode 2022-05-18 00:11:17 +08:00
security.c cachefiles: Add security derivation 2022-01-07 13:41:14 +00:00
volume.c fscache, cachefiles: Store the volume coherency data 2022-01-07 13:43:03 +00:00
xattr.c cachefiles: Fix KASAN slab-out-of-bounds in cachefiles_set_volume_xattr 2022-04-08 23:32:40 +01:00