linux/fs/ocfs2
Linus Torvalds 7cd122b552 Some filesystems use a kinda-sorta controlled dentry refcount leak to pin
dentries of created objects in dcache (and undo it when removing those).
 Reference is grabbed and not released, but it's not actually _stored_
 anywhere.  That works, but it's hard to follow and verify; among other
 things, we have no way to tell _which_ of the increments is intended
 to be an unpaired one.  Worse, on removal we need to decide whether
 the reference had already been dropped, which can be non-trivial if
 that removal is on umount and we need to figure out if this dentry is
 pinned due to e.g. unlink() not done.  Usually that is handled by using
 kill_litter_super() as ->kill_sb(), but there are open-coded special
 cases of the same (consider e.g. /proc/self).
 
 Things get simpler if we introduce a new dentry flag (DCACHE_PERSISTENT)
 marking those "leaked" dentries.  Having it set claims responsibility
 for +1 in refcount.
 
 The end result this series is aiming for:
 
 * get these unbalanced dget() and dput() replaced with new primitives that
   would, in addition to adjusting refcount, set and clear persistency flag.
 * instead of having kill_litter_super() mess with removing the remaining
   "leaked" references (e.g. for all tmpfs files that hadn't been removed
   prior to umount), have the regular shrink_dcache_for_umount() strip
   DCACHE_PERSISTENT of all dentries, dropping the corresponding
   reference if it had been set.  After that kill_litter_super() becomes
   an equivalent of kill_anon_super().
 
 Doing that in a single step is not feasible - it would affect too many places
 in too many filesystems.  It has to be split into a series.
 
 This work has really started early in 2024; quite a few preliminary pieces
 have already gone into mainline.  This chunk is finally getting to the
 meat of that stuff - infrastructure and most of the conversions to it.
 
 Some pieces are still sitting in the local branches, but the bulk of
 that stuff is here.
 
 Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQQqUNBr3gm4hGXdBJlZ7Krx/gZQ6wUCaTEq1wAKCRBZ7Krx/gZQ
 643uAQC1rRslhw5l7OjxEpIYbGG4M+QaadN4Nf5Sr2SuTRaPJQD/W4oj/u4C2eCw
 Dd3q071tqyvm/PXNgN2EEnIaxlFUlwc=
 =rKq+
 -----END PGP SIGNATURE-----

Merge tag 'pull-persistency' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull persistent dentry infrastructure and conversion from Al Viro:
 "Some filesystems use a kinda-sorta controlled dentry refcount leak to
  pin dentries of created objects in dcache (and undo it when removing
  those). A reference is grabbed and not released, but it's not actually
  _stored_ anywhere.

  That works, but it's hard to follow and verify; among other things, we
  have no way to tell _which_ of the increments is intended to be an
  unpaired one. Worse, on removal we need to decide whether the
  reference had already been dropped, which can be non-trivial if that
  removal is on umount and we need to figure out if this dentry is
  pinned due to e.g. unlink() not done. Usually that is handled by using
  kill_litter_super() as ->kill_sb(), but there are open-coded special
  cases of the same (consider e.g. /proc/self).

  Things get simpler if we introduce a new dentry flag
  (DCACHE_PERSISTENT) marking those "leaked" dentries. Having it set
  claims responsibility for +1 in refcount.

  The end result this series is aiming for:

   - get these unbalanced dget() and dput() replaced with new primitives
     that would, in addition to adjusting refcount, set and clear
     persistency flag.

   - instead of having kill_litter_super() mess with removing the
     remaining "leaked" references (e.g. for all tmpfs files that hadn't
     been removed prior to umount), have the regular
     shrink_dcache_for_umount() strip DCACHE_PERSISTENT of all dentries,
     dropping the corresponding reference if it had been set. After that
     kill_litter_super() becomes an equivalent of kill_anon_super().

  Doing that in a single step is not feasible - it would affect too many
  places in too many filesystems. It has to be split into a series.

  This work has really started early in 2024; quite a few preliminary
  pieces have already gone into mainline. This chunk is finally getting
  to the meat of that stuff - infrastructure and most of the conversions
  to it.

  Some pieces are still sitting in the local branches, but the bulk of
  that stuff is here"

* tag 'pull-persistency' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (54 commits)
  d_make_discardable(): warn if given a non-persistent dentry
  kill securityfs_recursive_remove()
  convert securityfs
  get rid of kill_litter_super()
  convert rust_binderfs
  convert nfsctl
  convert rpc_pipefs
  convert hypfs
  hypfs: swich hypfs_create_u64() to returning int
  hypfs: switch hypfs_create_str() to returning int
  hypfs: don't pin dentries twice
  convert gadgetfs
  gadgetfs: switch to simple_remove_by_name()
  convert functionfs
  functionfs: switch to simple_remove_by_name()
  functionfs: fix the open/removal races
  functionfs: need to cancel ->reset_work in ->kill_sb()
  functionfs: don't bother with ffs->ref in ffs_data_{opened,closed}()
  functionfs: don't abuse ffs_data_closed() on fs shutdown
  convert selinuxfs
  ...
2025-12-05 14:36:21 -08:00
..
cluster net: Convert proto_ops connect() callbacks to use sockaddr_unsized 2025-11-04 19:10:32 -08:00
dlm Patch series in this pull request: 2025-10-02 18:44:54 -07:00
dlmfs convert dlmfs 2025-11-16 01:35:03 -05:00
Kconfig
Makefile
acl.c fs: inline current_umask() and move it to fs_struct.h 2025-11-05 22:51:23 +01:00
acl.h
alloc.c filemap: Add folio_next_pos() 2025-10-31 13:11:37 +01:00
alloc.h ocfs2: convert ocfs2_map_and_dirty_page() to ocfs2_map_and_dirty_folio() 2025-01-12 20:21:13 -08:00
aops.c Significant patch series in this pull request: 2025-08-03 16:23:09 -07:00
aops.h ocfs2: remove ocfs2_start_walk_page_trans() prototype 2025-01-12 20:21:13 -08:00
blockcheck.c
blockcheck.h
buffer_head_io.c ocfs2: fix possible null-ptr-deref in ocfs2_set_buffer_uptodate 2024-09-09 15:15:54 -07:00
buffer_head_io.h
dcache.c ocfs2_dentry_revalidate(): use stable parent inode and name passed by caller 2025-01-27 19:25:24 -05:00
dcache.h
dir.c ocfs2: avoid NULL pointer dereference in dx_dir_lookup_rec() 2025-07-19 19:08:27 -07:00
dir.h
dlmglue.c Coccinelle-based conversion to use ->i_state accessors 2025-10-20 20:22:26 +02:00
dlmglue.h ocfs2: convert ocfs2_inode_lock_with_page() to ocfs2_inode_lock_with_folio() 2025-01-12 20:21:10 -08:00
export.c exportfs: Remove EXPORT_OP_ASYNC_LOCK 2024-10-01 17:01:08 +02:00
export.h
extent_map.c ocfs2: fix recursive semaphore deadlock in fiemap call 2025-09-08 23:45:11 -07:00
extent_map.h
file.c fs: replace mmap hook with .mmap_prepare for simple mappings 2025-06-19 13:56:59 +02:00
file.h ocfs2: store cookie in private data 2024-09-12 11:58:44 +02:00
filecheck.c ocfs2: simplify return statement in ocfs2_filecheck_attr_store() 2025-05-11 17:54:08 -07:00
filecheck.h
heartbeat.c
heartbeat.h
inode.c Coccinelle-based conversion to use ->i_state accessors 2025-10-20 20:22:26 +02:00
inode.h ocfs2: retire ocfs2_drop_inode() and I_WILL_FREE usage 2025-10-20 20:22:25 +02:00
ioctl.c ocfs2: avoid extra calls to strlen() after ocfs2_sprintf_system_inode_name() 2025-09-22 20:11:00 -07:00
ioctl.h tree-wide: s/struct fileattr/struct file_kattr/g 2025-07-04 16:14:39 +02:00
journal.c ocfs2: don't opencode filemap_fdatawrite_range in ocfs2_journal_submit_inode_data_buffers 2025-10-29 15:50:41 +01:00
journal.h ocfs2: stop quota recovery before disabling quotas 2025-05-07 23:39:40 -07:00
localalloc.c ocfs2: fix the space leak in LA when releasing LA 2024-12-18 19:04:41 -08:00
localalloc.h
locks.c ocfs2: adapt to breakup of struct file_lock 2024-02-05 13:11:43 +01:00
locks.h
mmap.c fs: replace mmap hook with .mmap_prepare for simple mappings 2025-06-19 13:56:59 +02:00
mmap.h fs: replace mmap hook with .mmap_prepare for simple mappings 2025-06-19 13:56:59 +02:00
move_extents.c ocfs2: clear extent cache after moving/defragmenting extents 2025-10-15 13:24:33 -07:00
move_extents.h
namei.c ocfs2: update d_splice_alias() return code checking 2025-07-09 22:57:57 -07:00
namei.h
ocfs1_fs_compat.h
ocfs2.h ocfs2: stop quota recovery before disabling quotas 2025-05-07 23:39:40 -07:00
ocfs2_fs.h ocfs2: fix super block reserved field offset comment 2025-09-13 17:32:49 -07:00
ocfs2_ioctl.h ocfs2: miscellaneous spelling fixes 2025-01-12 20:21:07 -08:00
ocfs2_lockid.h ocfs2: miscellaneous spelling fixes 2025-01-12 20:21:07 -08:00
ocfs2_lockingver.h
ocfs2_trace.h ocfs2: retire ocfs2_drop_inode() and I_WILL_FREE usage 2025-10-20 20:22:25 +02:00
quota.h ocfs2: remove unused declaration in header file 2024-11-05 17:12:26 -08:00
quota_global.c ocfs2: remove reference to bh->b_page 2025-03-16 23:24:13 -07:00
quota_local.c ocfs2: fix possible memory leak in ocfs2_finish_quota_recovery 2025-05-11 17:54:11 -07:00
refcounttree.c VFS: rename kern_path_locked() and related functions. 2025-09-23 12:37:36 +02:00
refcounttree.h
reservations.c ocfs2: correctly use ocfs2_find_next_zero_bit() 2024-04-25 21:07:01 -07:00
reservations.h ocfs2: miscellaneous spelling fixes 2025-01-12 20:21:07 -08:00
resize.c ocfs2: uncache inode which has failed entering the group 2024-11-14 22:43:48 -08:00
resize.h
slot_map.c ocfs2: Annotate struct ocfs2_slot_info with __counted_by 2023-10-02 09:48:52 -07:00
slot_map.h
stack_o2cb.c ocfs2: miscellaneous spelling fixes 2025-01-12 20:21:07 -08:00
stack_user.c Patch series in this pull request: 2025-10-02 18:44:54 -07:00
stackglue.c ocfs2: remove unnecessary NULL check before unregister_sysctl_table() 2025-05-11 17:54:11 -07:00
stackglue.h ocfs2: miscellaneous spelling fixes 2025-01-12 20:21:07 -08:00
suballoc.c ocfs2: fix the issue with discontiguous allocation in the global_bitmap 2025-05-07 23:39:37 -07:00
suballoc.h ocfs2: fix the issue with discontiguous allocation in the global_bitmap 2025-05-07 23:39:37 -07:00
super.c ocfs2: retire ocfs2_drop_inode() and I_WILL_FREE usage 2025-10-20 20:22:25 +02:00
super.h
symlink.c ocfs2: use a folio in ocfs2_fast_symlink_read_folio() 2025-01-12 20:21:13 -08:00
symlink.h
sysfile.c ocfs2: avoid extra calls to strlen() after ocfs2_sprintf_system_inode_name() 2025-09-22 20:11:00 -07:00
sysfile.h
uptodate.c
uptodate.h
xattr.c ocfs2: miscellaneous spelling fixes 2025-01-12 20:21:07 -08:00
xattr.h ocfs2: move ocfs2_xattr_handlers and ocfs2_xattr_handler_map to .rodata 2023-10-09 16:24:20 +02:00