2019-07-26 12:51:28 +00:00
|
|
|
====================
|
|
|
|
|
Changes since 2.5.0:
|
|
|
|
|
====================
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**recommended**
|
|
|
|
|
|
|
|
|
|
New helpers: sb_bread(), sb_getblk(), sb_find_get_block(), set_bh(),
|
|
|
|
|
sb_set_blocksize() and sb_min_blocksize().
|
|
|
|
|
|
|
|
|
|
Use them.
|
|
|
|
|
|
|
|
|
|
(sb_find_get_block() replaces 2.4's get_hash_table())
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**recommended**
|
|
|
|
|
|
|
|
|
|
New methods: ->alloc_inode() and ->destroy_inode().
|
|
|
|
|
|
|
|
|
|
Remove inode->u.foo_inode_i
|
|
|
|
|
|
|
|
|
|
Declare::
|
|
|
|
|
|
|
|
|
|
struct foo_inode_info {
|
|
|
|
|
/* fs-private stuff */
|
|
|
|
|
struct inode vfs_inode;
|
|
|
|
|
};
|
|
|
|
|
static inline struct foo_inode_info *FOO_I(struct inode *inode)
|
|
|
|
|
{
|
|
|
|
|
return list_entry(inode, struct foo_inode_info, vfs_inode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Use FOO_I(inode) instead of &inode->u.foo_inode_i;
|
|
|
|
|
|
|
|
|
|
Add foo_alloc_inode() and foo_destroy_inode() - the former should allocate
|
|
|
|
|
foo_inode_info and return the address of ->vfs_inode, the latter should free
|
|
|
|
|
FOO_I(inode) (see in-tree filesystems for examples).
|
|
|
|
|
|
|
|
|
|
Make them ->alloc_inode and ->destroy_inode in your super_operations.
|
|
|
|
|
|
|
|
|
|
Keep in mind that now you need explicit initialization of private data
|
|
|
|
|
typically between calling iget_locked() and unlocking the inode.
|
|
|
|
|
|
|
|
|
|
At some point that will become mandatory.
|
|
|
|
|
|
2022-03-22 21:41:00 +00:00
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
The foo_inode_info should always be allocated through alloc_inode_sb() rather
|
|
|
|
|
than kmem_cache_alloc() or kmalloc() related to set up the inode reclaim context
|
|
|
|
|
correctly.
|
|
|
|
|
|
2019-07-26 12:51:28 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
Change of file_system_type method (->read_super to ->get_sb)
|
|
|
|
|
|
|
|
|
|
->read_super() is no more. Ditto for DECLARE_FSTYPE and DECLARE_FSTYPE_DEV.
|
|
|
|
|
|
|
|
|
|
Turn your foo_read_super() into a function that would return 0 in case of
|
|
|
|
|
success and negative number in case of error (-EINVAL unless you have more
|
|
|
|
|
informative error value to report). Call it foo_fill_super(). Now declare::
|
|
|
|
|
|
|
|
|
|
int foo_get_sb(struct file_system_type *fs_type,
|
|
|
|
|
int flags, const char *dev_name, void *data, struct vfsmount *mnt)
|
|
|
|
|
{
|
|
|
|
|
return get_sb_bdev(fs_type, flags, dev_name, data, foo_fill_super,
|
|
|
|
|
mnt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
(or similar with s/bdev/nodev/ or s/bdev/single/, depending on the kind of
|
|
|
|
|
filesystem).
|
|
|
|
|
|
|
|
|
|
Replace DECLARE_FSTYPE... with explicit initializer and have ->get_sb set as
|
|
|
|
|
foo_get_sb.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
Locking change: ->s_vfs_rename_sem is taken only by cross-directory renames.
|
|
|
|
|
Most likely there is no need to change anything, but if you relied on
|
|
|
|
|
global exclusion between renames for some internal purpose - you need to
|
|
|
|
|
change your internal locking. Otherwise exclusion warranties remain the
|
|
|
|
|
same (i.e. parents and victim are locked, etc.).
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**informational**
|
|
|
|
|
|
|
|
|
|
Now we have the exclusion between ->lookup() and directory removal (by
|
|
|
|
|
->rmdir() and ->rename()). If you used to need that exclusion and do
|
|
|
|
|
it by internal locking (most of filesystems couldn't care less) - you
|
|
|
|
|
can relax your locking.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->lookup(), ->truncate(), ->create(), ->unlink(), ->mknod(), ->mkdir(),
|
|
|
|
|
->rmdir(), ->link(), ->lseek(), ->symlink(), ->rename()
|
|
|
|
|
and ->readdir() are called without BKL now. Grab it on entry, drop upon return
|
|
|
|
|
- that will guarantee the same locking you used to have. If your method or its
|
|
|
|
|
parts do not need BKL - better yet, now you can shift lock_kernel() and
|
|
|
|
|
unlock_kernel() so that they would protect exactly what needs to be
|
|
|
|
|
protected.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
BKL is also moved from around sb operations. BKL should have been shifted into
|
|
|
|
|
individual fs sb_op functions. If you don't need it, remove it.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**informational**
|
|
|
|
|
|
|
|
|
|
check for ->link() target not being a directory is done by callers. Feel
|
|
|
|
|
free to drop it...
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**informational**
|
|
|
|
|
|
|
|
|
|
->link() callers hold ->i_mutex on the object we are linking to. Some of your
|
|
|
|
|
problems might be over...
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
new file_system_type method - kill_sb(superblock). If you are converting
|
|
|
|
|
an existing filesystem, set it according to ->fs_flags::
|
|
|
|
|
|
|
|
|
|
FS_REQUIRES_DEV - kill_block_super
|
|
|
|
|
FS_LITTER - kill_litter_super
|
|
|
|
|
neither - kill_anon_super
|
|
|
|
|
|
|
|
|
|
FS_LITTER is gone - just remove it from fs_flags.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
FS_SINGLE is gone (actually, that had happened back when ->get_sb()
|
|
|
|
|
went in - and hadn't been documented ;-/). Just remove it from fs_flags
|
|
|
|
|
(and see ->get_sb() entry for other actions).
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->setattr() is called without BKL now. Caller _always_ holds ->i_mutex, so
|
|
|
|
|
watch for ->i_mutex-grabbing code that might be used by your ->setattr().
|
|
|
|
|
Callers of notify_change() need ->i_mutex now.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**recommended**
|
|
|
|
|
|
|
|
|
|
New super_block field ``struct export_operations *s_export_op`` for
|
|
|
|
|
explicit support for exporting, e.g. via NFS. The structure is fully
|
|
|
|
|
documented at its declaration in include/linux/fs.h, and in
|
2019-07-31 20:27:56 +00:00
|
|
|
Documentation/filesystems/nfs/exporting.rst.
|
2019-07-26 12:51:28 +00:00
|
|
|
|
|
|
|
|
Briefly it allows for the definition of decode_fh and encode_fh operations
|
|
|
|
|
to encode and decode filehandles, and allows the filesystem to use
|
|
|
|
|
a standard helper function for decode_fh, and provide file-system specific
|
|
|
|
|
support for this helper, particularly get_parent.
|
|
|
|
|
|
|
|
|
|
It is planned that this will be required for exporting once the code
|
|
|
|
|
settles down a bit.
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
s_export_op is now required for exporting a filesystem.
|
2024-10-17 10:28:23 +00:00
|
|
|
isofs, ext2, ext3, fat
|
2019-07-26 12:51:28 +00:00
|
|
|
can be used as examples of very different filesystems.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
iget4() and the read_inode2 callback have been superseded by iget5_locked()
|
|
|
|
|
which has the following prototype::
|
|
|
|
|
|
|
|
|
|
struct inode *iget5_locked(struct super_block *sb, unsigned long ino,
|
|
|
|
|
int (*test)(struct inode *, void *),
|
|
|
|
|
int (*set)(struct inode *, void *),
|
|
|
|
|
void *data);
|
|
|
|
|
|
|
|
|
|
'test' is an additional function that can be used when the inode
|
|
|
|
|
number is not sufficient to identify the actual file object. 'set'
|
|
|
|
|
should be a non-blocking function that initializes those parts of a
|
|
|
|
|
newly created inode to allow the test function to succeed. 'data' is
|
|
|
|
|
passed as an opaque value to both test and set functions.
|
|
|
|
|
|
|
|
|
|
When the inode has been created by iget5_locked(), it will be returned with the
|
|
|
|
|
I_NEW flag set and will still be locked. The filesystem then needs to finalize
|
|
|
|
|
the initialization. Once the inode is initialized it must be unlocked by
|
|
|
|
|
calling unlock_new_inode().
|
|
|
|
|
|
|
|
|
|
The filesystem is responsible for setting (and possibly testing) i_ino
|
|
|
|
|
when appropriate. There is also a simpler iget_locked function that
|
|
|
|
|
just takes the superblock and inode number as arguments and does the
|
|
|
|
|
test and set for you.
|
|
|
|
|
|
|
|
|
|
e.g.::
|
|
|
|
|
|
|
|
|
|
inode = iget_locked(sb, ino);
|
2025-10-09 07:59:19 +00:00
|
|
|
if (inode_state_read_once(inode) & I_NEW) {
|
2019-07-26 12:51:28 +00:00
|
|
|
err = read_inode_from_disk(inode);
|
|
|
|
|
if (err < 0) {
|
|
|
|
|
iget_failed(inode);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
unlock_new_inode(inode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Note that if the process of setting up a new inode fails, then iget_failed()
|
|
|
|
|
should be called on the inode to render it dead, and an appropriate error
|
|
|
|
|
should be passed back to the caller.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**recommended**
|
|
|
|
|
|
|
|
|
|
->getattr() finally getting used. See instances in nfs, minix, etc.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->revalidate() is gone. If your filesystem had it - provide ->getattr()
|
|
|
|
|
and let it call whatever you had as ->revlidate() + (for symlinks that
|
|
|
|
|
had ->revalidate()) add calls in ->follow_link()/->readlink().
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->d_parent changes are not protected by BKL anymore. Read access is safe
|
|
|
|
|
if at least one of the following is true:
|
|
|
|
|
|
|
|
|
|
* filesystem has no cross-directory rename()
|
|
|
|
|
* we know that parent had been locked (e.g. we are looking at
|
|
|
|
|
->d_parent of ->lookup() argument).
|
|
|
|
|
* we are called from ->rename().
|
|
|
|
|
* the child's ->d_lock is held
|
|
|
|
|
|
|
|
|
|
Audit your code and add locking if needed. Notice that any place that is
|
|
|
|
|
not protected by the conditions above is risky even in the old tree - you
|
|
|
|
|
had been relying on BKL and that's prone to screwups. Old tree had quite
|
|
|
|
|
a few holes of that kind - unprotected access to ->d_parent leading to
|
|
|
|
|
anything from oops to silent memory corruption.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
FS_NOMOUNT is gone. If you use it - just set SB_NOUSER in flags
|
|
|
|
|
(see rootfs for one kind of solution and bdev/socket/pipe for another).
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**recommended**
|
|
|
|
|
|
|
|
|
|
Use bdev_read_only(bdev) instead of is_read_only(kdev). The latter
|
|
|
|
|
is still alive, but only because of the mess in drivers/s390/block/dasd.c.
|
|
|
|
|
As soon as it gets fixed is_read_only() will die.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->permission() is called without BKL now. Grab it on entry, drop upon
|
|
|
|
|
return - that will guarantee the same locking you used to have. If
|
|
|
|
|
your method or its parts do not need BKL - better yet, now you can
|
|
|
|
|
shift lock_kernel() and unlock_kernel() so that they would protect
|
|
|
|
|
exactly what needs to be protected.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->statfs() is now called without BKL held. BKL should have been
|
|
|
|
|
shifted into individual fs sb_op functions where it's not clear that
|
|
|
|
|
it's safe to remove it. If you don't need it, remove it.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
is_read_only() is gone; use bdev_read_only() instead.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
destroy_buffers() is gone; use invalidate_bdev().
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
fsync_dev() is gone; use fsync_bdev(). NOTE: lvm breakage is
|
|
|
|
|
deliberate; as soon as struct block_device * is propagated in a reasonable
|
|
|
|
|
way by that code fixing will become trivial; until then nothing can be
|
|
|
|
|
done.
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
2024-12-13 15:17:40 +00:00
|
|
|
block truncation on error exit from ->write_begin, and ->direct_IO
|
2019-07-26 12:51:28 +00:00
|
|
|
moved from generic methods (block_write_begin, cont_write_begin,
|
|
|
|
|
nobh_write_begin, blockdev_direct_IO*) to callers. Take a look at
|
|
|
|
|
ext2_write_failed and callers for an example.
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->truncate is gone. The whole truncate sequence needs to be
|
|
|
|
|
implemented in ->setattr, which is now mandatory for filesystems
|
|
|
|
|
implementing on-disk size changes. Start with a copy of the old inode_setattr
|
|
|
|
|
and vmtruncate, and the reorder the vmtruncate + foofs_vmtruncate sequence to
|
|
|
|
|
be in order of zeroing blocks using block_truncate_page or similar helpers,
|
|
|
|
|
size update and on finally on-disk truncation which should not fail.
|
|
|
|
|
setattr_prepare (which used to be inode_change_ok) now includes the size checks
|
|
|
|
|
for ATTR_SIZE and must be called in the beginning of ->setattr unconditionally.
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->clear_inode() and ->delete_inode() are gone; ->evict_inode() should
|
|
|
|
|
be used instead. It gets called whenever the inode is evicted, whether it has
|
|
|
|
|
remaining links or not. Caller does *not* evict the pagecache or inode-associated
|
|
|
|
|
metadata buffers; the method has to use truncate_inode_pages_final() to get rid
|
|
|
|
|
of those. Caller makes sure async writeback cannot be running for the inode while
|
|
|
|
|
(or after) ->evict_inode() is called.
|
|
|
|
|
|
|
|
|
|
->drop_inode() returns int now; it's called on final iput() with
|
|
|
|
|
inode->i_lock held and it returns true if filesystems wants the inode to be
|
2025-09-15 12:57:29 +00:00
|
|
|
dropped. As before, inode_generic_drop() is still the default and it's been
|
|
|
|
|
updated appropriately. inode_just_drop() is also alive and it consists
|
2019-07-26 12:51:28 +00:00
|
|
|
simply of return 1. Note that all actual eviction work is done by caller after
|
|
|
|
|
->drop_inode() returns.
|
|
|
|
|
|
|
|
|
|
As before, clear_inode() must be called exactly once on each call of
|
|
|
|
|
->evict_inode() (as it used to be for each call of ->delete_inode()). Unlike
|
|
|
|
|
before, if you are using inode-associated metadata buffers (i.e.
|
|
|
|
|
mark_buffer_dirty_inode()), it's your responsibility to call
|
|
|
|
|
invalidate_inode_buffers() before clear_inode().
|
|
|
|
|
|
|
|
|
|
NOTE: checking i_nlink in the beginning of ->write_inode() and bailing out
|
|
|
|
|
if it's zero is not *and* *never* *had* *been* enough. Final unlink() and iput()
|
|
|
|
|
may happen while the inode is in the middle of ->write_inode(); e.g. if you blindly
|
|
|
|
|
free the on-disk inode, you may end up doing that while ->write_inode() is writing
|
|
|
|
|
to it.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
.d_delete() now only advises the dcache as to whether or not to cache
|
|
|
|
|
unreferenced dentries, and is now only called when the dentry refcount goes to
|
|
|
|
|
0. Even on 0 refcount transition, it must be able to tolerate being called 0,
|
|
|
|
|
1, or more times (eg. constant, idempotent).
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
.d_compare() calling convention and locking rules are significantly
|
|
|
|
|
changed. Read updated documentation in Documentation/filesystems/vfs.rst (and
|
|
|
|
|
look at examples of other filesystems) for guidance.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
.d_hash() calling convention and locking rules are significantly
|
|
|
|
|
changed. Read updated documentation in Documentation/filesystems/vfs.rst (and
|
|
|
|
|
look at examples of other filesystems) for guidance.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
dcache_lock is gone, replaced by fine grained locks. See fs/dcache.c
|
|
|
|
|
for details of what locks to replace dcache_lock with in order to protect
|
|
|
|
|
particular things. Most of the time, a filesystem only needs ->d_lock, which
|
|
|
|
|
protects *all* the dcache state of a given dentry.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
Filesystems must RCU-free their inodes, if they can have been accessed
|
|
|
|
|
via rcu-walk path walk (basically, if the file can have had a path name in the
|
|
|
|
|
vfs namespace).
|
|
|
|
|
|
|
|
|
|
Even though i_dentry and i_rcu share storage in a union, we will
|
|
|
|
|
initialize the former in inode_init_always(), so just leave it alone in
|
|
|
|
|
the callback. It used to be necessary to clean it there, but not anymore
|
|
|
|
|
(starting at 3.2).
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**recommended**
|
|
|
|
|
|
|
|
|
|
vfs now tries to do path walking in "rcu-walk mode", which avoids
|
|
|
|
|
atomic operations and scalability hazards on dentries and inodes (see
|
|
|
|
|
Documentation/filesystems/path-lookup.txt). d_hash and d_compare changes
|
|
|
|
|
(above) are examples of the changes required to support this. For more complex
|
|
|
|
|
filesystem callbacks, the vfs drops out of rcu-walk mode before the fs call, so
|
|
|
|
|
no changes are required to the filesystem. However, this is costly and loses
|
|
|
|
|
the benefits of rcu-walk mode. We will begin to add filesystem callbacks that
|
|
|
|
|
are rcu-walk aware, shown below. Filesystems should take advantage of this
|
|
|
|
|
where possible.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
d_revalidate is a callback that is made on every path element (if
|
|
|
|
|
the filesystem provides it), which requires dropping out of rcu-walk mode. This
|
|
|
|
|
may now be called in rcu-walk mode (nd->flags & LOOKUP_RCU). -ECHILD should be
|
|
|
|
|
returned if the filesystem cannot handle rcu-walk. See
|
|
|
|
|
Documentation/filesystems/vfs.rst for more details.
|
|
|
|
|
|
|
|
|
|
permission is an inode permission check that is called on many or all
|
|
|
|
|
directory inodes on the way down a path walk (to check for exec permission). It
|
|
|
|
|
must now be rcu-walk aware (mask & MAY_NOT_BLOCK). See
|
|
|
|
|
Documentation/filesystems/vfs.rst for more details.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
In ->fallocate() you must check the mode option passed in. If your
|
|
|
|
|
filesystem does not support hole punching (deallocating space in the middle of a
|
|
|
|
|
file) you must return -EOPNOTSUPP if FALLOC_FL_PUNCH_HOLE is set in mode.
|
|
|
|
|
Currently you can only have FALLOC_FL_PUNCH_HOLE with FALLOC_FL_KEEP_SIZE set,
|
|
|
|
|
so the i_size should not change when hole punching, even when puching the end of
|
|
|
|
|
a file off.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->get_sb() is gone. Switch to use of ->mount(). Typically it's just
|
|
|
|
|
a matter of switching from calling ``get_sb_``... to ``mount_``... and changing
|
|
|
|
|
the function type. If you were doing it manually, just switch from setting
|
|
|
|
|
->mnt_root to some pointer to returning that pointer. On errors return
|
|
|
|
|
ERR_PTR(...).
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->permission() and generic_permission()have lost flags
|
|
|
|
|
argument; instead of passing IPERM_FLAG_RCU we add MAY_NOT_BLOCK into mask.
|
|
|
|
|
|
|
|
|
|
generic_permission() has also lost the check_acl argument; ACL checking
|
2022-09-22 15:17:00 +00:00
|
|
|
has been taken to VFS and filesystems need to provide a non-NULL
|
|
|
|
|
->i_op->get_inode_acl to read an ACL from disk.
|
2019-07-26 12:51:28 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
If you implement your own ->llseek() you must handle SEEK_HOLE and
|
2023-08-14 21:28:22 +00:00
|
|
|
SEEK_DATA. You can handle this by returning -EINVAL, but it would be nicer to
|
2019-07-26 12:51:28 +00:00
|
|
|
support it in some way. The generic handler assumes that the entire file is
|
|
|
|
|
data and there is a virtual hole at the end of the file. So if the provided
|
|
|
|
|
offset is less than i_size and SEEK_DATA is specified, return the same offset.
|
|
|
|
|
If the above is true for the offset and you are given SEEK_HOLE, return the end
|
|
|
|
|
of the file. If the offset is i_size or greater return -ENXIO in either case.
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
If you have your own ->fsync() you must make sure to call
|
|
|
|
|
filemap_write_and_wait_range() so that all dirty pages are synced out properly.
|
|
|
|
|
You must also keep in mind that ->fsync() is not called with i_mutex held
|
|
|
|
|
anymore, so if you require i_mutex locking you must make sure to take it and
|
|
|
|
|
release it yourself.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
d_alloc_root() is gone, along with a lot of bugs caused by code
|
|
|
|
|
misusing it. Replacement: d_make_root(inode). On success d_make_root(inode)
|
|
|
|
|
allocates and returns a new dentry instantiated with the passed in inode.
|
|
|
|
|
On failure NULL is returned and the passed in inode is dropped so the reference
|
|
|
|
|
to inode is consumed in all cases and failure handling need not do any cleanup
|
|
|
|
|
for the inode. If d_make_root(inode) is passed a NULL inode it returns NULL
|
|
|
|
|
and also requires no further error handling. Typical usage is::
|
|
|
|
|
|
|
|
|
|
inode = foofs_new_inode(....);
|
|
|
|
|
s->s_root = d_make_root(inode);
|
|
|
|
|
if (!s->s_root)
|
|
|
|
|
/* Nothing needed for the inode cleanup */
|
|
|
|
|
return -ENOMEM;
|
|
|
|
|
...
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
The witch is dead! Well, 2/3 of it, anyway. ->d_revalidate() and
|
|
|
|
|
->lookup() do *not* take struct nameidata anymore; just the flags.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->create() doesn't take ``struct nameidata *``; unlike the previous
|
|
|
|
|
two, it gets "is it an O_EXCL or equivalent?" boolean argument. Note that
|
2023-08-14 21:28:22 +00:00
|
|
|
local filesystems can ignore this argument - they are guaranteed that the
|
2019-07-26 12:51:28 +00:00
|
|
|
object doesn't exist. It's remote/distributed ones that might care...
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
FS_REVAL_DOT is gone; if you used to have it, add ->d_weak_revalidate()
|
|
|
|
|
in your dentry operations instead.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
vfs_readdir() is gone; switch to iterate_dir() instead
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
vfs: get rid of old '->iterate' directory operation
All users now just use '->iterate_shared()', which only takes the
directory inode lock for reading.
Filesystems that never got convered to shared mode now instead use a
wrapper that drops the lock, re-takes it in write mode, calls the old
function, and then downgrades the lock back to read mode.
This way the VFS layer and other callers no longer need to care about
filesystems that never got converted to the modern era.
The filesystems that use the new wrapper are ceph, coda, exfat, jfs,
ntfs, ocfs2, overlayfs, and vboxsf.
Honestly, several of them look like they really could just iterate their
directories in shared mode and skip the wrapper entirely, but the point
of this change is to not change semantics or fix filesystems that
haven't been fixed in the last 7+ years, but to finally get rid of the
dual iterators.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
2023-08-05 19:25:01 +00:00
|
|
|
->readdir() is gone now; switch to ->iterate_shared()
|
2019-07-26 12:51:28 +00:00
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
vfs_follow_link has been removed. Filesystems must use nd_set_link
|
|
|
|
|
from ->follow_link for normal symlinks, or nd_jump_link for magic
|
|
|
|
|
/proc/<pid> style links.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
iget5_locked()/ilookup5()/ilookup5_nowait() test() callback used to be
|
|
|
|
|
called with both ->i_lock and inode_hash_lock held; the former is *not*
|
|
|
|
|
taken anymore, so verify that your callbacks do not rely on it (none
|
|
|
|
|
of the in-tree instances did). inode_hash_lock is still held,
|
|
|
|
|
of course, so they are still serialized wrt removal from inode hash,
|
|
|
|
|
as well as wrt set() callback of iget5_locked().
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
d_materialise_unique() is gone; d_splice_alias() does everything you
|
|
|
|
|
need now. Remember that they have opposite orders of arguments ;-/
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
f_dentry is gone; use f_path.dentry, or, better yet, see if you can avoid
|
|
|
|
|
it entirely.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
never call ->read() and ->write() directly; use __vfs_{read,write} or
|
|
|
|
|
wrappers; instead of checking for ->write or ->read being NULL, look for
|
|
|
|
|
FMODE_CAN_{WRITE,READ} in file->f_mode.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
do _not_ use new_sync_{read,write} for ->read/->write; leave it NULL
|
|
|
|
|
instead.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
->aio_read/->aio_write are gone. Use ->read_iter/->write_iter.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**recommended**
|
|
|
|
|
|
|
|
|
|
for embedded ("fast") symlinks just set inode->i_link to wherever the
|
|
|
|
|
symlink body is and use simple_follow_link() as ->follow_link().
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
calling conventions for ->follow_link() have changed. Instead of returning
|
|
|
|
|
cookie and using nd_set_link() to store the body to traverse, we return
|
|
|
|
|
the body to traverse and store the cookie using explicit void ** argument.
|
|
|
|
|
nameidata isn't passed at all - nd_jump_link() doesn't need it and
|
|
|
|
|
nd_[gs]et_link() is gone.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
calling conventions for ->put_link() have changed. It gets inode instead of
|
|
|
|
|
dentry, it does not get nameidata at all and it gets called only when cookie
|
|
|
|
|
is non-NULL. Note that link body isn't available anymore, so if you need it,
|
|
|
|
|
store it as cookie.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
any symlink that might use page_follow_link_light/page_put_link() must
|
|
|
|
|
have inode_nohighmem(inode) called before anything might start playing with
|
|
|
|
|
its pagecache. No highmem pages should end up in the pagecache of such
|
|
|
|
|
symlinks. That includes any preseeding that might be done during symlink
|
2022-02-22 14:40:54 +00:00
|
|
|
creation. page_symlink() will honour the mapping gfp flags, so once
|
2019-07-26 12:51:28 +00:00
|
|
|
you've done inode_nohighmem() it's safe to use, but if you allocate and
|
|
|
|
|
insert the page manually, make sure to use the right gfp flags.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->follow_link() is replaced with ->get_link(); same API, except that
|
|
|
|
|
|
|
|
|
|
* ->get_link() gets inode as a separate argument
|
|
|
|
|
* ->get_link() may be called in RCU mode - in that case NULL
|
|
|
|
|
dentry is passed
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->get_link() gets struct delayed_call ``*done`` now, and should do
|
|
|
|
|
set_delayed_call() where it used to set ``*cookie``.
|
|
|
|
|
|
|
|
|
|
->put_link() is gone - just give the destructor to set_delayed_call()
|
|
|
|
|
in ->get_link().
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->getxattr() and xattr_handler.get() get dentry and inode passed separately.
|
|
|
|
|
dentry might be yet to be attached to inode, so do _not_ use its ->d_inode
|
|
|
|
|
in the instances. Rationale: !@#!@# security_d_instantiate() needs to be
|
|
|
|
|
called before we attach dentry to inode.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
symlinks are no longer the only inodes that do *not* have i_bdev/i_cdev/
|
|
|
|
|
i_pipe/i_link union zeroed out at inode eviction. As the result, you can't
|
|
|
|
|
assume that non-NULL value in ->i_nlink at ->destroy_inode() implies that
|
|
|
|
|
it's a symlink. Checking ->i_mode is really needed now. In-tree we had
|
|
|
|
|
to fix shmem_destroy_callback() that used to take that kind of shortcut;
|
|
|
|
|
watch out, since that shortcut is no longer valid.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->i_mutex is replaced with ->i_rwsem now. inode_lock() et.al. work as
|
|
|
|
|
they used to - they just take it exclusive. However, ->lookup() may be
|
|
|
|
|
called with parent locked shared. Its instances must not
|
|
|
|
|
|
|
|
|
|
* use d_instantiate) and d_rehash() separately - use d_add() or
|
|
|
|
|
d_splice_alias() instead.
|
|
|
|
|
* use d_rehash() alone - call d_add(new_dentry, NULL) instead.
|
|
|
|
|
* in the unlikely case when (read-only) access to filesystem
|
|
|
|
|
data structures needs exclusion for some reason, arrange it
|
|
|
|
|
yourself. None of the in-tree filesystems needed that.
|
|
|
|
|
* rely on ->d_parent and ->d_name not changing after dentry has
|
|
|
|
|
been fed to d_add() or d_splice_alias(). Again, none of the
|
|
|
|
|
in-tree instances relied upon that.
|
|
|
|
|
|
|
|
|
|
We are guaranteed that lookups of the same name in the same directory
|
|
|
|
|
will not happen in parallel ("same" in the sense of your ->d_compare()).
|
|
|
|
|
Lookups on different names in the same directory can and do happen in
|
|
|
|
|
parallel now.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
vfs: get rid of old '->iterate' directory operation
All users now just use '->iterate_shared()', which only takes the
directory inode lock for reading.
Filesystems that never got convered to shared mode now instead use a
wrapper that drops the lock, re-takes it in write mode, calls the old
function, and then downgrades the lock back to read mode.
This way the VFS layer and other callers no longer need to care about
filesystems that never got converted to the modern era.
The filesystems that use the new wrapper are ceph, coda, exfat, jfs,
ntfs, ocfs2, overlayfs, and vboxsf.
Honestly, several of them look like they really could just iterate their
directories in shared mode and skip the wrapper entirely, but the point
of this change is to not change semantics or fix filesystems that
haven't been fixed in the last 7+ years, but to finally get rid of the
dual iterators.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
2023-08-05 19:25:01 +00:00
|
|
|
**mandatory**
|
2019-07-26 12:51:28 +00:00
|
|
|
|
vfs: get rid of old '->iterate' directory operation
All users now just use '->iterate_shared()', which only takes the
directory inode lock for reading.
Filesystems that never got convered to shared mode now instead use a
wrapper that drops the lock, re-takes it in write mode, calls the old
function, and then downgrades the lock back to read mode.
This way the VFS layer and other callers no longer need to care about
filesystems that never got converted to the modern era.
The filesystems that use the new wrapper are ceph, coda, exfat, jfs,
ntfs, ocfs2, overlayfs, and vboxsf.
Honestly, several of them look like they really could just iterate their
directories in shared mode and skip the wrapper entirely, but the point
of this change is to not change semantics or fix filesystems that
haven't been fixed in the last 7+ years, but to finally get rid of the
dual iterators.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
2023-08-05 19:25:01 +00:00
|
|
|
->iterate_shared() is added.
|
2019-07-26 12:51:28 +00:00
|
|
|
Exclusion on struct file level is still provided (as well as that
|
|
|
|
|
between it and lseek on the same struct file), but if your directory
|
|
|
|
|
has been opened several times, you can get these called in parallel.
|
|
|
|
|
Exclusion between that method and all directory-modifying ones is
|
|
|
|
|
still provided, of course.
|
|
|
|
|
|
vfs: get rid of old '->iterate' directory operation
All users now just use '->iterate_shared()', which only takes the
directory inode lock for reading.
Filesystems that never got convered to shared mode now instead use a
wrapper that drops the lock, re-takes it in write mode, calls the old
function, and then downgrades the lock back to read mode.
This way the VFS layer and other callers no longer need to care about
filesystems that never got converted to the modern era.
The filesystems that use the new wrapper are ceph, coda, exfat, jfs,
ntfs, ocfs2, overlayfs, and vboxsf.
Honestly, several of them look like they really could just iterate their
directories in shared mode and skip the wrapper entirely, but the point
of this change is to not change semantics or fix filesystems that
haven't been fixed in the last 7+ years, but to finally get rid of the
dual iterators.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
2023-08-05 19:25:01 +00:00
|
|
|
If you have any per-inode or per-dentry in-core data structures modified
|
|
|
|
|
by ->iterate_shared(), you might need something to serialize the access
|
|
|
|
|
to them. If you do dcache pre-seeding, you'll need to switch to
|
|
|
|
|
d_alloc_parallel() for that; look for in-tree examples.
|
2019-07-26 12:51:28 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->atomic_open() calls without O_CREAT may happen in parallel.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->setxattr() and xattr_handler.set() get dentry and inode passed separately.
|
2021-01-21 13:19:27 +00:00
|
|
|
The xattr_handler.set() gets passed the user namespace of the mount the inode
|
|
|
|
|
is seen from so filesystems can idmap the i_uid and i_gid accordingly.
|
2019-07-26 12:51:28 +00:00
|
|
|
dentry might be yet to be attached to inode, so do _not_ use its ->d_inode
|
|
|
|
|
in the instances. Rationale: !@#!@# security_d_instantiate() needs to be
|
|
|
|
|
called before we attach dentry to inode and !@#!@##!@$!$#!@#$!@$!@$ smack
|
|
|
|
|
->d_instantiate() uses not just ->getxattr() but ->setxattr() as well.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->d_compare() doesn't get parent as a separate argument anymore. If you
|
|
|
|
|
used it for finding the struct super_block involved, dentry->d_sb will
|
|
|
|
|
work just as well; if it's something more complicated, use dentry->d_parent.
|
|
|
|
|
Just be careful not to assume that fetching it more than once will yield
|
|
|
|
|
the same value - in RCU mode it could change under you.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->rename() has an added flags argument. Any flags not handled by the
|
|
|
|
|
filesystem should result in EINVAL being returned.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
**recommended**
|
|
|
|
|
|
|
|
|
|
->readlink is optional for symlinks. Don't set, unless filesystem needs
|
|
|
|
|
to fake something for readlink(2).
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->getattr() is now passed a struct path rather than a vfsmount and
|
|
|
|
|
dentry separately, and it now has request_mask and query_flags arguments
|
|
|
|
|
to specify the fields and sync type requested by statx. Filesystems not
|
|
|
|
|
supporting any statx-specific features may ignore the new arguments.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->atomic_open() calling conventions have changed. Gone is ``int *opened``,
|
|
|
|
|
along with FILE_OPENED/FILE_CREATED. In place of those we have
|
|
|
|
|
FMODE_OPENED/FMODE_CREATED, set in file->f_mode. Additionally, return
|
|
|
|
|
value for 'called finish_no_open(), open it yourself' case has become
|
|
|
|
|
0, not 1. Since finish_no_open() itself is returning 0 now, that part
|
|
|
|
|
does not need any changes in ->atomic_open() instances.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
alloc_file() has become static now; two wrappers are to be used instead.
|
|
|
|
|
alloc_file_pseudo(inode, vfsmount, name, flags, ops) is for the cases
|
|
|
|
|
when dentry needs to be created; that's the majority of old alloc_file()
|
|
|
|
|
users. Calling conventions: on success a reference to new struct file
|
|
|
|
|
is returned and callers reference to inode is subsumed by that. On
|
|
|
|
|
failure, ERR_PTR() is returned and no caller's references are affected,
|
|
|
|
|
so the caller needs to drop the inode reference it held.
|
|
|
|
|
alloc_file_clone(file, flags, ops) does not affect any caller's references.
|
|
|
|
|
On success you get a new struct file sharing the mount/dentry with the
|
|
|
|
|
original, on failure - ERR_PTR().
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->clone_file_range() and ->dedupe_file_range have been replaced with
|
|
|
|
|
->remap_file_range(). See Documentation/filesystems/vfs.rst for more
|
|
|
|
|
information.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**recommended**
|
|
|
|
|
|
|
|
|
|
->lookup() instances doing an equivalent of::
|
|
|
|
|
|
|
|
|
|
if (IS_ERR(inode))
|
|
|
|
|
return ERR_CAST(inode);
|
|
|
|
|
return d_splice_alias(inode, dentry);
|
|
|
|
|
|
|
|
|
|
don't need to bother with the check - d_splice_alias() will do the
|
|
|
|
|
right thing when given ERR_PTR(...) as inode. Moreover, passing NULL
|
|
|
|
|
inode to d_splice_alias() will also do the right thing (equivalent of
|
|
|
|
|
d_add(dentry, NULL); return NULL;), so that kind of special cases
|
|
|
|
|
also doesn't need a separate treatment.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**strongly recommended**
|
|
|
|
|
|
|
|
|
|
take the RCU-delayed parts of ->destroy_inode() into a new method -
|
|
|
|
|
->free_inode(). If ->destroy_inode() becomes empty - all the better,
|
|
|
|
|
just get rid of it. Synchronous work (e.g. the stuff that can't
|
|
|
|
|
be done from an RCU callback, or any WARN_ON() where we want the
|
|
|
|
|
stack trace) *might* be movable to ->evict_inode(); however,
|
|
|
|
|
that goes only for the things that are not needed to balance something
|
|
|
|
|
done by ->alloc_inode(). IOW, if it's cleaning up the stuff that
|
|
|
|
|
might have accumulated over the life of in-core inode, ->evict_inode()
|
|
|
|
|
might be a fit.
|
|
|
|
|
|
|
|
|
|
Rules for inode destruction:
|
|
|
|
|
|
|
|
|
|
* if ->destroy_inode() is non-NULL, it gets called
|
|
|
|
|
* if ->free_inode() is non-NULL, it gets scheduled by call_rcu()
|
|
|
|
|
* combination of NULL ->destroy_inode and NULL ->free_inode is
|
|
|
|
|
treated as NULL/free_inode_nonrcu, to preserve the compatibility.
|
|
|
|
|
|
|
|
|
|
Note that the callback (be it via ->free_inode() or explicit call_rcu()
|
|
|
|
|
in ->destroy_inode()) is *NOT* ordered wrt superblock destruction;
|
|
|
|
|
as the matter of fact, the superblock and all associated structures
|
|
|
|
|
might be already gone. The filesystem driver is guaranteed to be still
|
|
|
|
|
there, but that's it. Freeing memory in the callback is fine; doing
|
|
|
|
|
more than that is possible, but requires a lot of care and is best
|
|
|
|
|
avoided.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
DCACHE_RCUACCESS is gone; having an RCU delay on dentry freeing is the
|
|
|
|
|
default. DCACHE_NORCU opts out, and only d_alloc_pseudo() has any
|
|
|
|
|
business doing so.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
d_alloc_pseudo() is internal-only; uses outside of alloc_file_pseudo() are
|
|
|
|
|
very suspect (and won't work in modules). Such uses are very likely to
|
|
|
|
|
be misspelled d_alloc_anon().
|
2020-03-12 22:25:20 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
2024-04-29 22:55:27 +00:00
|
|
|
[should've been added in 2016] stale comment in finish_open() notwithstanding,
|
2020-03-12 22:25:20 +00:00
|
|
|
failure exits in ->atomic_open() instances should *NOT* fput() the file,
|
|
|
|
|
no matter what. Everything is handled by the caller.
|
2020-06-04 08:48:19 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
clone_private_mount() returns a longterm mount now, so the proper destructor of
|
|
|
|
|
its result is kern_unmount() or kern_unmount_array().
|
2021-01-09 16:02:58 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
zero-length bvec segments are disallowed, they must be filtered out before
|
|
|
|
|
passed on to an iterator.
|
2021-01-09 16:03:03 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
For bvec based itererators bio_iov_iter_get_pages() now doesn't copy bvecs but
|
|
|
|
|
uses the one provided. Anyone issuing kiocb-I/O should ensure that the bvec and
|
|
|
|
|
page references stay until I/O has completed, i.e. until ->ki_complete() has
|
|
|
|
|
been called or returned with non -EIOCBQUEUED code.
|
2021-02-27 16:07:12 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
2020-09-22 16:44:18 +00:00
|
|
|
mnt_want_write_file() can now only be paired with mnt_drop_write_file(),
|
|
|
|
|
whereas previously it could be paired with mnt_drop_write() as well.
|
2021-04-30 14:26:41 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
iov_iter_copy_from_user_atomic() is gone; use copy_page_from_iter_atomic().
|
|
|
|
|
The difference is copy_page_from_iter_atomic() advances the iterator and
|
|
|
|
|
you don't need iov_iter_advance() after it. However, if you decide to use
|
|
|
|
|
only a part of obtained data, you should do iov_iter_revert().
|
2021-07-03 18:41:14 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
2021-04-01 23:00:57 +00:00
|
|
|
Calling conventions for file_open_root() changed; now it takes struct path *
|
|
|
|
|
instead of passing mount and dentry separately. For callers that used to
|
|
|
|
|
pass <mnt, mnt->mnt_root> pair (i.e. the root of given mount), a new helper
|
|
|
|
|
is provided - file_open_root_mnt(). In-tree users adjusted.
|
2022-06-29 13:07:00 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
no_llseek is gone; don't set .llseek to that - just leave it NULL instead.
|
|
|
|
|
Checks for "does that file have llseek(2), or should it fail with ESPIPE"
|
|
|
|
|
should be done by looking at FMODE_LSEEK in file->f_mode.
|
2022-08-16 15:57:56 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
*mandatory*
|
|
|
|
|
|
|
|
|
|
filldir_t (readdir callbacks) calling conventions have changed. Instead of
|
|
|
|
|
returning 0 or -E... it returns bool now. false means "no more" (as -E... used
|
|
|
|
|
to) and true - "keep going" (as 0 in old calling conventions). Rationale:
|
vfs: get rid of old '->iterate' directory operation
All users now just use '->iterate_shared()', which only takes the
directory inode lock for reading.
Filesystems that never got convered to shared mode now instead use a
wrapper that drops the lock, re-takes it in write mode, calls the old
function, and then downgrades the lock back to read mode.
This way the VFS layer and other callers no longer need to care about
filesystems that never got converted to the modern era.
The filesystems that use the new wrapper are ceph, coda, exfat, jfs,
ntfs, ocfs2, overlayfs, and vboxsf.
Honestly, several of them look like they really could just iterate their
directories in shared mode and skip the wrapper entirely, but the point
of this change is to not change semantics or fix filesystems that
haven't been fixed in the last 7+ years, but to finally get rid of the
dual iterators.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
2023-08-05 19:25:01 +00:00
|
|
|
callers never looked at specific -E... values anyway. -> iterate_shared()
|
|
|
|
|
instances require no changes at all, all filldir_t ones in the tree
|
|
|
|
|
converted.
|
2022-10-11 02:45:17 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2022-09-24 05:00:00 +00:00
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
Calling conventions for ->tmpfile() have changed. It now takes a struct
|
|
|
|
|
file pointer instead of struct dentry pointer. d_tmpfile() is similarly
|
|
|
|
|
changed to simplify callers. The passed file is in a non-open state and on
|
|
|
|
|
success must be opened before returning (e.g. by calling
|
|
|
|
|
finish_open_simple()).
|
2023-08-18 20:23:34 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
Calling convention for ->huge_fault has changed. It now takes a page
|
|
|
|
|
order instead of an enum page_entry_size, and it may be called without the
|
|
|
|
|
mmap_lock held. All in-tree users have been audited and do not seem to
|
|
|
|
|
depend on the mmap_lock being held, but out of tree users should verify
|
|
|
|
|
for themselves. If they do need it, they can return VM_FAULT_RETRY to
|
|
|
|
|
be called with the mmap_lock held.
|
2023-09-15 14:01:02 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
The order of opening block devices and matching or creating superblocks has
|
|
|
|
|
changed.
|
|
|
|
|
|
|
|
|
|
The old logic opened block devices first and then tried to find a
|
|
|
|
|
suitable superblock to reuse based on the block device pointer.
|
|
|
|
|
|
|
|
|
|
The new logic tries to find a suitable superblock first based on the device
|
|
|
|
|
number, and opening the block device afterwards.
|
|
|
|
|
|
|
|
|
|
Since opening block devices cannot happen under s_umount because of lock
|
|
|
|
|
ordering requirements s_umount is now dropped while opening block devices and
|
|
|
|
|
reacquired before calling fill_super().
|
|
|
|
|
|
|
|
|
|
In the old logic concurrent mounters would find the superblock on the list of
|
|
|
|
|
superblocks for the filesystem type. Since the first opener of the block device
|
|
|
|
|
would hold s_umount they would wait until the superblock became either born or
|
|
|
|
|
was discarded due to initialization failure.
|
|
|
|
|
|
|
|
|
|
Since the new logic drops s_umount concurrent mounters could grab s_umount and
|
|
|
|
|
would spin. Instead they are now made to wait using an explicit wait-wake
|
|
|
|
|
mechanism without having to hold s_umount.
|
2023-09-15 14:01:40 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
The holder of a block device is now the superblock.
|
|
|
|
|
|
|
|
|
|
The holder of a block device used to be the file_system_type which wasn't
|
|
|
|
|
particularly useful. It wasn't possible to go from block device to owning
|
|
|
|
|
superblock without matching on the device pointer stored in the superblock.
|
|
|
|
|
This mechanism would only work for a single device so the block layer couldn't
|
|
|
|
|
find the owning superblock of any additional devices.
|
|
|
|
|
|
|
|
|
|
In the old mechanism reusing or creating a superblock for a racing mount(2) and
|
2024-04-29 22:55:27 +00:00
|
|
|
umount(2) relied on the file_system_type as the holder. This was severely
|
2023-09-15 14:01:40 +00:00
|
|
|
underdocumented however:
|
|
|
|
|
|
|
|
|
|
(1) Any concurrent mounter that managed to grab an active reference on an
|
|
|
|
|
existing superblock was made to wait until the superblock either became
|
|
|
|
|
ready or until the superblock was removed from the list of superblocks of
|
|
|
|
|
the filesystem type. If the superblock is ready the caller would simple
|
|
|
|
|
reuse it.
|
|
|
|
|
|
|
|
|
|
(2) If the mounter came after deactivate_locked_super() but before
|
|
|
|
|
the superblock had been removed from the list of superblocks of the
|
|
|
|
|
filesystem type the mounter would wait until the superblock was shutdown,
|
|
|
|
|
reuse the block device and allocate a new superblock.
|
|
|
|
|
|
|
|
|
|
(3) If the mounter came after deactivate_locked_super() and after
|
|
|
|
|
the superblock had been removed from the list of superblocks of the
|
|
|
|
|
filesystem type the mounter would reuse the block device and allocate a new
|
|
|
|
|
superblock (the bd_holder point may still be set to the filesystem type).
|
|
|
|
|
|
|
|
|
|
Because the holder of the block device was the file_system_type any concurrent
|
|
|
|
|
mounter could open the block devices of any superblock of the same
|
|
|
|
|
file_system_type without risking seeing EBUSY because the block device was
|
|
|
|
|
still in use by another superblock.
|
|
|
|
|
|
|
|
|
|
Making the superblock the owner of the block device changes this as the holder
|
|
|
|
|
is now a unique superblock and thus block devices associated with it cannot be
|
|
|
|
|
reused by concurrent mounters. So a concurrent mounter in (2) could suddenly
|
|
|
|
|
see EBUSY when trying to open a block device whose holder was a different
|
|
|
|
|
superblock.
|
|
|
|
|
|
|
|
|
|
The new logic thus waits until the superblock and the devices are shutdown in
|
|
|
|
|
->kill_sb(). Removal of the superblock from the list of superblocks of the
|
|
|
|
|
filesystem type is now moved to a later point when the devices are closed:
|
|
|
|
|
|
|
|
|
|
(1) Any concurrent mounter managing to grab an active reference on an existing
|
|
|
|
|
superblock is made to wait until the superblock is either ready or until
|
|
|
|
|
the superblock and all devices are shutdown in ->kill_sb(). If the
|
|
|
|
|
superblock is ready the caller will simply reuse it.
|
|
|
|
|
|
|
|
|
|
(2) If the mounter comes after deactivate_locked_super() but before
|
|
|
|
|
the superblock has been removed from the list of superblocks of the
|
|
|
|
|
filesystem type the mounter is made to wait until the superblock and the
|
|
|
|
|
devices are shut down in ->kill_sb() and the superblock is removed from the
|
|
|
|
|
list of superblocks of the filesystem type. The mounter will allocate a new
|
|
|
|
|
superblock and grab ownership of the block device (the bd_holder pointer of
|
|
|
|
|
the block device will be set to the newly allocated superblock).
|
|
|
|
|
|
|
|
|
|
(3) This case is now collapsed into (2) as the superblock is left on the list
|
|
|
|
|
of superblocks of the filesystem type until all devices are shutdown in
|
|
|
|
|
->kill_sb(). In other words, if the superblock isn't on the list of
|
|
|
|
|
superblock of the filesystem type anymore then it has given up ownership of
|
|
|
|
|
all associated block devices (the bd_holder pointer is NULL).
|
|
|
|
|
|
|
|
|
|
As this is a VFS level change it has no practical consequences for filesystems
|
|
|
|
|
other than that all of them must use one of the provided kill_litter_super(),
|
|
|
|
|
kill_anon_super(), or kill_block_super() helpers.
|
2023-10-18 10:26:20 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
Lock ordering has been changed so that s_umount ranks above open_mutex again.
|
|
|
|
|
All places where s_umount was taken under open_mutex have been fixed up.
|
2023-11-07 20:11:26 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
2023-10-23 18:07:59 +00:00
|
|
|
export_operations ->encode_fh() no longer has a default implementation to
|
|
|
|
|
encode FILEID_INO32_GEN* file handles.
|
|
|
|
|
Filesystems that used the default implementation may use the generic helper
|
|
|
|
|
generic_encode_ino32_fh() explicitly.
|
2023-10-24 13:01:15 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
rename(): fix the locking of subdirectories
We should never lock two subdirectories without having taken
->s_vfs_rename_mutex; inode pointer order or not, the "order" proposed
in 28eceeda130f "fs: Lock moved directories" is not transitive, with
the usual consequences.
The rationale for locking renamed subdirectory in all cases was
the possibility of race between rename modifying .. in a subdirectory to
reflect the new parent and another thread modifying the same subdirectory.
For a lot of filesystems that's not a problem, but for some it can lead
to trouble (e.g. the case when short directory contents is kept in the
inode, but creating a file in it might push it across the size limit
and copy its contents into separate data block(s)).
However, we need that only in case when the parent does change -
otherwise ->rename() doesn't need to do anything with .. entry in the
first place. Some instances are lazy and do a tautological update anyway,
but it's really not hard to avoid.
Amended locking rules for rename():
find the parent(s) of source and target
if source and target have the same parent
lock the common parent
else
lock ->s_vfs_rename_mutex
lock both parents, in ancestor-first order; if neither
is an ancestor of another, lock the parent of source
first.
find the source and target.
if source and target have the same parent
if operation is an overwriting rename of a subdirectory
lock the target subdirectory
else
if source is a subdirectory
lock the source
if target is a subdirectory
lock the target
lock non-directories involved, in inode pointer order if both
source and target are such.
That way we are guaranteed that parents are locked (for obvious reasons),
that any renamed non-directory is locked (nfsd relies upon that),
that any victim is locked (emptiness check needs that, among other things)
and subdirectory that changes parent is locked (needed to protect the update
of .. entries). We are also guaranteed that any operation locking more
than one directory either takes ->s_vfs_rename_mutex or locks a parent
followed by its child.
Cc: stable@vger.kernel.org
Fixes: 28eceeda130f "fs: Lock moved directories"
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2023-11-20 01:25:58 +00:00
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
If ->rename() update of .. on cross-directory move needs an exclusion with
|
|
|
|
|
directory modifications, do *not* lock the subdirectory in question in your
|
|
|
|
|
->rename() - it's done by the caller now [that item should've been added in
|
|
|
|
|
28eceeda130f "fs: Lock moved directories"].
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
On same-directory ->rename() the (tautological) update of .. is not protected
|
|
|
|
|
by any locks; just don't do it if the old parent is the same as the new one.
|
|
|
|
|
We really can't lock two subdirectories in same-directory rename - not without
|
|
|
|
|
deadlocks.
|
2023-11-21 01:02:11 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
lock_rename() and lock_rename_child() may fail in cross-directory case, if
|
|
|
|
|
their arguments do not have a common ancestor. In that case ERR_PTR(-EXDEV)
|
|
|
|
|
is returned, with no locks taken. In-tree users updated; out-of-tree ones
|
|
|
|
|
would need to do so.
|
2024-01-12 04:00:22 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2024-01-12 04:11:35 +00:00
|
|
|
**mandatory**
|
|
|
|
|
|
2023-11-07 07:00:39 +00:00
|
|
|
The list of children anchored in parent dentry got turned into hlist now.
|
|
|
|
|
Field names got changed (->d_children/->d_sib instead of ->d_subdirs/->d_child
|
|
|
|
|
for anchor/entries resp.), so any affected places will be immediately caught
|
|
|
|
|
by compiler.
|
2023-10-30 05:09:50 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->d_delete() instances are now called for dentries with ->d_lock held
|
|
|
|
|
and refcount equal to 0. They are not permitted to drop/regain ->d_lock.
|
|
|
|
|
None of in-tree instances did anything of that sort. Make sure yours do not...
|
__dentry_kill(): new locking scheme
Currently we enter __dentry_kill() with parent (along with the victim
dentry and victim's inode) held locked. Then we
mark dentry refcount as dead
call ->d_prune()
remove dentry from hash
remove it from the parent's list of children
unlock the parent, don't need it from that point on
detach dentry from inode, unlock dentry and drop the inode
(via ->d_iput())
call ->d_release()
regain the lock on dentry
check if it's on a shrink list (in which case freeing its empty husk
has to be left to shrink_dentry_list()) or not (in which case we can free it
ourselves). In the former case, mark it as an empty husk, so that
shrink_dentry_list() would know it can free the sucker.
drop the lock on dentry
... and usually the caller proceeds to drop a reference on the parent,
possibly retaking the lock on it.
That is painful for a bunch of reasons, starting with the need to take locks
out of order, but not limited to that - the parent of positive dentry can
change if we drop its ->d_lock, so getting these locks has to be done with
care. Moreover, as soon as dentry is out of the parent's list of children,
shrink_dcache_for_umount() won't see it anymore, making it appear as if
the parent is inexplicably busy. We do work around that by having
shrink_dentry_list() decrement the parent's refcount first and put it on
shrink list to be evicted once we are done with __dentry_kill() of child,
but that may in some cases lead to ->d_iput() on child called after the
parent got killed. That doesn't happen in cases where in-tree ->d_iput()
instances might want to look at the parent, but that's brittle as hell.
Solution: do removal from the parent's list of children in the very
end of __dentry_kill(). As the result, the callers do not need to
lock the parent and by the time we really need the parent locked,
dentry is negative and is guaranteed not to be moved around.
It does mean that ->d_prune() will be called with parent not locked.
It also means that we might see dentries in process of being torn
down while going through the parent's list of children; those dentries
will be unhashed, negative and with refcount marked dead. In practice,
that's enough for in-tree code that looks through the list of children
to do the right thing as-is. Out-of-tree code might need to be adjusted.
Calling conventions: __dentry_kill(dentry) is called with dentry->d_lock
held, along with ->i_lock of its inode (if any). It either returns
the parent (locked, with refcount decremented to 0) or NULL (if there'd
been no parent or if refcount decrement for parent hadn't reached 0).
lock_for_kill() is adjusted for new requirements - it doesn't touch
the parent's ->d_lock at all.
Callers adjusted. Note that for dput() we don't need to bother with
fast_dput() for the parent - we just need to check retain_dentry()
for it, since its ->d_lock is still held since the moment when
__dentry_kill() had taken it to remove the victim from the list of
children.
The kludge with early decrement of parent's refcount in
shrink_dentry_list() is no longer needed - shrink_dcache_for_umount()
sees the half-killed dentries in the list of children for as long
as they are pinning the parent. They are easily recognized and
accounted for by select_collect(), so we know we are not done yet.
As the result, we always have the expected ordering for ->d_iput()/->d_release()
vs. __dentry_kill() of the parent, no exceptions. Moreover, the current
rules for shrink lists (one must make sure that shrink_dcache_for_umount()
won't happen while any dentries from the superblock in question are on
any shrink lists) are gone - shrink_dcache_for_umount() will do the
right thing in all cases, taking such dentries out. Their empty
husks (memory occupied by struct dentry itself + its external name,
if any) will remain on the shrink lists, but they are no obstacles
to filesystem shutdown. And such husks will get freed as soon as
shrink_dentry_list() of the list they are on gets to them.
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2023-11-07 21:14:08 +00:00
|
|
|
|
2024-01-12 04:11:35 +00:00
|
|
|
---
|
__dentry_kill(): new locking scheme
Currently we enter __dentry_kill() with parent (along with the victim
dentry and victim's inode) held locked. Then we
mark dentry refcount as dead
call ->d_prune()
remove dentry from hash
remove it from the parent's list of children
unlock the parent, don't need it from that point on
detach dentry from inode, unlock dentry and drop the inode
(via ->d_iput())
call ->d_release()
regain the lock on dentry
check if it's on a shrink list (in which case freeing its empty husk
has to be left to shrink_dentry_list()) or not (in which case we can free it
ourselves). In the former case, mark it as an empty husk, so that
shrink_dentry_list() would know it can free the sucker.
drop the lock on dentry
... and usually the caller proceeds to drop a reference on the parent,
possibly retaking the lock on it.
That is painful for a bunch of reasons, starting with the need to take locks
out of order, but not limited to that - the parent of positive dentry can
change if we drop its ->d_lock, so getting these locks has to be done with
care. Moreover, as soon as dentry is out of the parent's list of children,
shrink_dcache_for_umount() won't see it anymore, making it appear as if
the parent is inexplicably busy. We do work around that by having
shrink_dentry_list() decrement the parent's refcount first and put it on
shrink list to be evicted once we are done with __dentry_kill() of child,
but that may in some cases lead to ->d_iput() on child called after the
parent got killed. That doesn't happen in cases where in-tree ->d_iput()
instances might want to look at the parent, but that's brittle as hell.
Solution: do removal from the parent's list of children in the very
end of __dentry_kill(). As the result, the callers do not need to
lock the parent and by the time we really need the parent locked,
dentry is negative and is guaranteed not to be moved around.
It does mean that ->d_prune() will be called with parent not locked.
It also means that we might see dentries in process of being torn
down while going through the parent's list of children; those dentries
will be unhashed, negative and with refcount marked dead. In practice,
that's enough for in-tree code that looks through the list of children
to do the right thing as-is. Out-of-tree code might need to be adjusted.
Calling conventions: __dentry_kill(dentry) is called with dentry->d_lock
held, along with ->i_lock of its inode (if any). It either returns
the parent (locked, with refcount decremented to 0) or NULL (if there'd
been no parent or if refcount decrement for parent hadn't reached 0).
lock_for_kill() is adjusted for new requirements - it doesn't touch
the parent's ->d_lock at all.
Callers adjusted. Note that for dput() we don't need to bother with
fast_dput() for the parent - we just need to check retain_dentry()
for it, since its ->d_lock is still held since the moment when
__dentry_kill() had taken it to remove the victim from the list of
children.
The kludge with early decrement of parent's refcount in
shrink_dentry_list() is no longer needed - shrink_dcache_for_umount()
sees the half-killed dentries in the list of children for as long
as they are pinning the parent. They are easily recognized and
accounted for by select_collect(), so we know we are not done yet.
As the result, we always have the expected ordering for ->d_iput()/->d_release()
vs. __dentry_kill() of the parent, no exceptions. Moreover, the current
rules for shrink lists (one must make sure that shrink_dcache_for_umount()
won't happen while any dentries from the superblock in question are on
any shrink lists) are gone - shrink_dcache_for_umount() will do the
right thing in all cases, taking such dentries out. Their empty
husks (memory occupied by struct dentry itself + its external name,
if any) will remain on the shrink lists, but they are no obstacles
to filesystem shutdown. And such husks will get freed as soon as
shrink_dentry_list() of the list they are on gets to them.
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2023-11-07 21:14:08 +00:00
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
->d_prune() instances are now called without ->d_lock held on the parent.
|
|
|
|
|
->d_lock on dentry itself is still held; if you need per-parent exclusions (none
|
|
|
|
|
of the in-tree instances did), use your own spinlock.
|
|
|
|
|
|
|
|
|
|
->d_iput() and ->d_release() are called with victim dentry still in the
|
|
|
|
|
list of parent's children. It is still unhashed, marked killed, etc., just not
|
|
|
|
|
removed from parent's ->d_children yet.
|
|
|
|
|
|
|
|
|
|
Anyone iterating through the list of children needs to be aware of the
|
|
|
|
|
half-killed dentries that might be seen there; taking ->d_lock on those will
|
|
|
|
|
see them negative, unhashed and with negative refcount, which means that most
|
|
|
|
|
of the in-kernel users would've done the right thing anyway without any adjustment.
|
2024-01-12 04:11:35 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2023-10-24 13:01:15 +00:00
|
|
|
**recommended**
|
|
|
|
|
|
|
|
|
|
Block device freezing and thawing have been moved to holder operations.
|
|
|
|
|
|
|
|
|
|
Before this change, get_active_super() would only be able to find the
|
|
|
|
|
superblock of the main block device, i.e., the one stored in sb->s_bdev. Block
|
|
|
|
|
device freezing now works for any block device owned by a given superblock, not
|
|
|
|
|
just the main block device. The get_active_super() helper and bd_fsfreeze_sb
|
|
|
|
|
pointer are gone.
|
2024-05-02 21:36:32 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
set_blocksize() takes opened struct file instead of struct block_device now
|
|
|
|
|
and it *must* be opened exclusive.
|
Pass parent directory inode and expected name to ->d_revalidate()
->d_revalidate() often needs to access dentry parent and name; that has
to be done carefully, since the locking environment varies from caller
to caller. We are not guaranteed that dentry in question will not be
moved right under us - not unless the filesystem is such that nothing
on it ever gets renamed.
It can be dealt with, but that results in boilerplate code that isn't
even needed - the callers normally have just found the dentry via dcache
lookup and want to verify that it's in the right place; they already
have the values of ->d_parent and ->d_name stable. There is a couple
of exceptions (overlayfs and, to less extent, ecryptfs), but for the
majority of calls that song and dance is not needed at all.
It's easier to make ecryptfs and overlayfs find and pass those values if
there's a ->d_revalidate() instance to be called, rather than doing that
in the instances.
This commit only changes the calling conventions; making use of supplied
values is left to followups.
NOTE: some instances need more than just the parent - things like CIFS
may need to build an entire path from filesystem root, so they need
more precautions than the usual boilerplate. This series doesn't
do anything to that need - these filesystems have to keep their locking
mechanisms (rename_lock loops, use of dentry_path_raw(), private rwsem
a-la v9fs).
One thing to keep in mind when using name is that name->name will normally
point into the pathname being resolved; the filename in question occupies
name->len bytes starting at name->name, and there is NUL somewhere after it,
but it the next byte might very well be '/' rather than '\0'. Do not
ignore name->len.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Gabriel Krisman Bertazi <gabriel@krisman.be>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2024-12-08 05:28:51 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2025-03-24 17:47:14 +00:00
|
|
|
**mandatory**
|
Pass parent directory inode and expected name to ->d_revalidate()
->d_revalidate() often needs to access dentry parent and name; that has
to be done carefully, since the locking environment varies from caller
to caller. We are not guaranteed that dentry in question will not be
moved right under us - not unless the filesystem is such that nothing
on it ever gets renamed.
It can be dealt with, but that results in boilerplate code that isn't
even needed - the callers normally have just found the dentry via dcache
lookup and want to verify that it's in the right place; they already
have the values of ->d_parent and ->d_name stable. There is a couple
of exceptions (overlayfs and, to less extent, ecryptfs), but for the
majority of calls that song and dance is not needed at all.
It's easier to make ecryptfs and overlayfs find and pass those values if
there's a ->d_revalidate() instance to be called, rather than doing that
in the instances.
This commit only changes the calling conventions; making use of supplied
values is left to followups.
NOTE: some instances need more than just the parent - things like CIFS
may need to build an entire path from filesystem root, so they need
more precautions than the usual boilerplate. This series doesn't
do anything to that need - these filesystems have to keep their locking
mechanisms (rename_lock loops, use of dentry_path_raw(), private rwsem
a-la v9fs).
One thing to keep in mind when using name is that name->name will normally
point into the pathname being resolved; the filename in question occupies
name->len bytes starting at name->name, and there is NUL somewhere after it,
but it the next byte might very well be '/' rather than '\0'. Do not
ignore name->len.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Gabriel Krisman Bertazi <gabriel@krisman.be>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2024-12-08 05:28:51 +00:00
|
|
|
|
|
|
|
|
->d_revalidate() gets two extra arguments - inode of parent directory and
|
|
|
|
|
name our dentry is expected to have. Both are stable (dir is pinned in
|
|
|
|
|
non-RCU case and will stay around during the call in RCU case, and name
|
|
|
|
|
is guaranteed to stay unchanging). Your instance doesn't have to use
|
|
|
|
|
either, but it often helps to avoid a lot of painful boilerplate.
|
|
|
|
|
Note that while name->name is stable and NUL-terminated, it may (and
|
|
|
|
|
often will) have name->name[name->len] equal to '/' rather than '\0' -
|
|
|
|
|
in normal case it points into the pathname being looked up.
|
|
|
|
|
NOTE: if you need something like full path from the root of filesystem,
|
|
|
|
|
you are still on your own - this assists with simple cases, but it's not
|
|
|
|
|
magic.
|
2025-03-07 14:43:19 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2025-03-24 17:47:14 +00:00
|
|
|
**recommended**
|
2025-02-17 00:27:20 +00:00
|
|
|
|
|
|
|
|
kern_path_locked() and user_path_locked() no longer return a negative
|
|
|
|
|
dentry so this doesn't need to be checked. If the name cannot be found,
|
|
|
|
|
ERR_PTR(-ENOENT) is returned.
|
2025-02-17 00:27:21 +00:00
|
|
|
|
2025-03-24 17:47:14 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**recommended**
|
2025-02-17 00:27:21 +00:00
|
|
|
|
|
|
|
|
lookup_one_qstr_excl() is changed to return errors in more cases, so
|
|
|
|
|
these conditions don't require explicit checks:
|
|
|
|
|
|
|
|
|
|
- if LOOKUP_CREATE is NOT given, then the dentry won't be negative,
|
|
|
|
|
ERR_PTR(-ENOENT) is returned instead
|
|
|
|
|
- if LOOKUP_EXCL IS given, then the dentry won't be positive,
|
|
|
|
|
ERR_PTR(-EEXIST) is rreturned instread
|
|
|
|
|
|
|
|
|
|
LOOKUP_EXCL now means "target must not exist". It can be combined with
|
|
|
|
|
LOOK_CREATE or LOOKUP_RENAME_TARGET.
|
Change inode_operations.mkdir to return struct dentry *
Some filesystems, such as NFS, cifs, ceph, and fuse, do not have
complete control of sequencing on the actual filesystem (e.g. on a
different server) and may find that the inode created for a mkdir
request already exists in the icache and dcache by the time the mkdir
request returns. For example, if the filesystem is mounted twice the
directory could be visible on the other mount before it is on the
original mount, and a pair of name_to_handle_at(), open_by_handle_at()
calls could instantiate the directory inode with an IS_ROOT() dentry
before the first mkdir returns.
This means that the dentry passed to ->mkdir() may not be the one that
is associated with the inode after the ->mkdir() completes. Some
callers need to interact with the inode after the ->mkdir completes and
they currently need to perform a lookup in the (rare) case that the
dentry is no longer hashed.
This lookup-after-mkdir requires that the directory remains locked to
avoid races. Planned future patches to lock the dentry rather than the
directory will mean that this lookup cannot be performed atomically with
the mkdir.
To remove this barrier, this patch changes ->mkdir to return the
resulting dentry if it is different from the one passed in.
Possible returns are:
NULL - the directory was created and no other dentry was used
ERR_PTR() - an error occurred
non-NULL - this other dentry was spliced in
This patch only changes file-systems to return "ERR_PTR(err)" instead of
"err" or equivalent transformations. Subsequent patches will make
further changes to some file-systems to return a correct dentry.
Not all filesystems reliably result in a positive hashed dentry:
- NFS, cifs, hostfs will sometimes need to perform a lookup of
the name to get inode information. Races could result in this
returning something different. Note that this lookup is
non-atomic which is what we are trying to avoid. Placing the
lookup in filesystem code means it only happens when the filesystem
has no other option.
- kernfs and tracefs leave the dentry negative and the ->revalidate
operation ensures that lookup will be called to correctly populate
the dentry. This could be fixed but I don't think it is important
to any of the users of vfs_mkdir() which look at the dentry.
The recommendation to use
d_drop();d_splice_alias()
is ugly but fits with current practice. A planned future patch will
change this.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: NeilBrown <neilb@suse.de>
Link: https://lore.kernel.org/r/20250227013949.536172-2-neilb@suse.de
Signed-off-by: Christian Brauner <brauner@kernel.org>
2025-02-27 01:32:53 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2025-03-24 17:47:14 +00:00
|
|
|
**mandatory**
|
2025-03-07 14:43:19 +00:00
|
|
|
invalidate_inodes() is gone use evict_inodes() instead.
|
2025-03-24 17:47:14 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
Change inode_operations.mkdir to return struct dentry *
Some filesystems, such as NFS, cifs, ceph, and fuse, do not have
complete control of sequencing on the actual filesystem (e.g. on a
different server) and may find that the inode created for a mkdir
request already exists in the icache and dcache by the time the mkdir
request returns. For example, if the filesystem is mounted twice the
directory could be visible on the other mount before it is on the
original mount, and a pair of name_to_handle_at(), open_by_handle_at()
calls could instantiate the directory inode with an IS_ROOT() dentry
before the first mkdir returns.
This means that the dentry passed to ->mkdir() may not be the one that
is associated with the inode after the ->mkdir() completes. Some
callers need to interact with the inode after the ->mkdir completes and
they currently need to perform a lookup in the (rare) case that the
dentry is no longer hashed.
This lookup-after-mkdir requires that the directory remains locked to
avoid races. Planned future patches to lock the dentry rather than the
directory will mean that this lookup cannot be performed atomically with
the mkdir.
To remove this barrier, this patch changes ->mkdir to return the
resulting dentry if it is different from the one passed in.
Possible returns are:
NULL - the directory was created and no other dentry was used
ERR_PTR() - an error occurred
non-NULL - this other dentry was spliced in
This patch only changes file-systems to return "ERR_PTR(err)" instead of
"err" or equivalent transformations. Subsequent patches will make
further changes to some file-systems to return a correct dentry.
Not all filesystems reliably result in a positive hashed dentry:
- NFS, cifs, hostfs will sometimes need to perform a lookup of
the name to get inode information. Races could result in this
returning something different. Note that this lookup is
non-atomic which is what we are trying to avoid. Placing the
lookup in filesystem code means it only happens when the filesystem
has no other option.
- kernfs and tracefs leave the dentry negative and the ->revalidate
operation ensures that lookup will be called to correctly populate
the dentry. This could be fixed but I don't think it is important
to any of the users of vfs_mkdir() which look at the dentry.
The recommendation to use
d_drop();d_splice_alias()
is ugly but fits with current practice. A planned future patch will
change this.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: NeilBrown <neilb@suse.de>
Link: https://lore.kernel.org/r/20250227013949.536172-2-neilb@suse.de
Signed-off-by: Christian Brauner <brauner@kernel.org>
2025-02-27 01:32:53 +00:00
|
|
|
|
2025-02-28 10:34:57 +00:00
|
|
|
->mkdir() now returns a dentry. If the created inode is found to
|
|
|
|
|
already be in cache and have a dentry (often IS_ROOT()), it will need to
|
|
|
|
|
be spliced into the given name in place of the given dentry. That dentry
|
|
|
|
|
now needs to be returned. If the original dentry is used, NULL should
|
|
|
|
|
be returned. Any error should be returned with ERR_PTR().
|
Change inode_operations.mkdir to return struct dentry *
Some filesystems, such as NFS, cifs, ceph, and fuse, do not have
complete control of sequencing on the actual filesystem (e.g. on a
different server) and may find that the inode created for a mkdir
request already exists in the icache and dcache by the time the mkdir
request returns. For example, if the filesystem is mounted twice the
directory could be visible on the other mount before it is on the
original mount, and a pair of name_to_handle_at(), open_by_handle_at()
calls could instantiate the directory inode with an IS_ROOT() dentry
before the first mkdir returns.
This means that the dentry passed to ->mkdir() may not be the one that
is associated with the inode after the ->mkdir() completes. Some
callers need to interact with the inode after the ->mkdir completes and
they currently need to perform a lookup in the (rare) case that the
dentry is no longer hashed.
This lookup-after-mkdir requires that the directory remains locked to
avoid races. Planned future patches to lock the dentry rather than the
directory will mean that this lookup cannot be performed atomically with
the mkdir.
To remove this barrier, this patch changes ->mkdir to return the
resulting dentry if it is different from the one passed in.
Possible returns are:
NULL - the directory was created and no other dentry was used
ERR_PTR() - an error occurred
non-NULL - this other dentry was spliced in
This patch only changes file-systems to return "ERR_PTR(err)" instead of
"err" or equivalent transformations. Subsequent patches will make
further changes to some file-systems to return a correct dentry.
Not all filesystems reliably result in a positive hashed dentry:
- NFS, cifs, hostfs will sometimes need to perform a lookup of
the name to get inode information. Races could result in this
returning something different. Note that this lookup is
non-atomic which is what we are trying to avoid. Placing the
lookup in filesystem code means it only happens when the filesystem
has no other option.
- kernfs and tracefs leave the dentry negative and the ->revalidate
operation ensures that lookup will be called to correctly populate
the dentry. This could be fixed but I don't think it is important
to any of the users of vfs_mkdir() which look at the dentry.
The recommendation to use
d_drop();d_splice_alias()
is ugly but fits with current practice. A planned future patch will
change this.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: NeilBrown <neilb@suse.de>
Link: https://lore.kernel.org/r/20250227013949.536172-2-neilb@suse.de
Signed-off-by: Christian Brauner <brauner@kernel.org>
2025-02-27 01:32:53 +00:00
|
|
|
|
|
|
|
|
In general, filesystems which use d_instantiate_new() to install the new
|
|
|
|
|
inode can safely return NULL. Filesystems which may not have an I_NEW inode
|
|
|
|
|
should use d_drop();d_splice_alias() and return the result of the latter.
|
|
|
|
|
|
|
|
|
|
If a positive dentry cannot be returned for some reason, in-kernel
|
|
|
|
|
clients such as cachefiles, nfsd, smb/server may not perform ideally but
|
|
|
|
|
will fail-safe.
|
2025-03-19 03:01:32 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
** mandatory**
|
|
|
|
|
|
|
|
|
|
lookup_one(), lookup_one_unlocked(), lookup_one_positive_unlocked() now
|
|
|
|
|
take a qstr instead of a name and len. These, not the "one_len"
|
|
|
|
|
versions, should be used whenever accessing a filesystem from outside
|
|
|
|
|
that filesysmtem, through a mount point - which will have a mnt_idmap.
|
2025-03-19 03:01:35 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
** mandatory**
|
|
|
|
|
|
|
|
|
|
Functions try_lookup_one_len(), lookup_one_len(),
|
|
|
|
|
lookup_one_len_unlocked() and lookup_positive_unlocked() have been
|
|
|
|
|
renamed to try_lookup_noperm(), lookup_noperm(),
|
|
|
|
|
lookup_noperm_unlocked(), lookup_noperm_positive_unlocked(). They now
|
|
|
|
|
take a qstr instead of separate name and length. QSTR() can be used
|
|
|
|
|
when strlen() is needed for the length.
|
|
|
|
|
|
|
|
|
|
These function no longer do any permission checking - they previously
|
|
|
|
|
checked that the caller has 'X' permission on the parent. They must
|
|
|
|
|
ONLY be used internally by a filesystem on itself when it knows that
|
|
|
|
|
permissions are irrelevant or in a context where permission checks have
|
|
|
|
|
already been performed such as after vfs_path_parent_lookup()
|
2025-03-19 03:01:36 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
** mandatory**
|
|
|
|
|
|
|
|
|
|
d_hash_and_lookup() is no longer exported or available outside the VFS.
|
|
|
|
|
Use try_lookup_noperm() instead. This adds name validation and takes
|
|
|
|
|
arguments in the opposite order but is otherwise identical.
|
|
|
|
|
|
|
|
|
|
Using try_lookup_noperm() will require linux/namei.h to be included.
|
|
|
|
|
|
2025-05-30 22:38:29 +00:00
|
|
|
---
|
|
|
|
|
|
2025-04-24 05:45:05 +00:00
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
Calling conventions for ->d_automount() have changed; we should *not* grab
|
|
|
|
|
an extra reference to new mount - it should be returned with refcount 1.
|
replace collect_mounts()/drop_collected_mounts() with a safer variant
collect_mounts() has several problems - one can't iterate over the results
directly, so it has to be done with callback passed to iterate_mounts();
it has an oopsable race with d_invalidate(); it creates temporary clones
of mounts invisibly for sync umount (IOW, you can have non-lazy umount
succeed leaving filesystem not mounted anywhere and yet still busy).
A saner approach is to give caller an array of struct path that would pin
every mount in a subtree, without cloning any mounts.
* collect_mounts()/drop_collected_mounts()/iterate_mounts() is gone
* collect_paths(where, preallocated, size) gives either ERR_PTR(-E...) or
a pointer to array of struct path, one for each chunk of tree visible under
'where' (i.e. the first element is a copy of where, followed by (mount,root)
for everything mounted under it - the same set collect_mounts() would give).
Unlike collect_mounts(), the mounts are *not* cloned - we just get pinning
references to the roots of subtrees in the caller's namespace.
Array is terminated by {NULL, NULL} struct path. If it fits into
preallocated array (on-stack, normally), that's where it goes; otherwise
it's allocated by kmalloc_array(). Passing 0 as size means that 'preallocated'
is ignored (and expected to be NULL).
* drop_collected_paths(paths, preallocated) is given the array returned
by an earlier call of collect_paths() and the preallocated array passed to that
call. All mount/dentry references are dropped and array is kfree'd if it's not
equal to 'preallocated'.
* instead of iterate_mounts(), users should just iterate over array
of struct path - nothing exotic is needed for that. Existing users (all in
audit_tree.c) are converted.
[folded a fix for braino reported by Venkat Rao Bagalkote <venkat88@linux.ibm.com>]
Fixes: 80b5dce8c59b0 ("vfs: Add a function to lazily unmount all mounts from any dentry")
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2025-06-17 04:09:51 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
collect_mounts()/drop_collected_mounts()/iterate_mounts() are gone now.
|
|
|
|
|
Replacement is collect_paths()/drop_collected_path(), with no special
|
|
|
|
|
iterator needed. Instead of a cloned mount tree, the new interface returns
|
|
|
|
|
an array of struct path, one for each mount collect_mounts() would've
|
|
|
|
|
created. These struct path point to locations in the caller's namespace
|
|
|
|
|
that would be roots of the cloned mounts.
|
Current exclusion rules for ->d_flags stores are rather unpleasant.
The basic rules are simple:
* stores to dentry->d_flags are OK under dentry->d_lock.
* stores to dentry->d_flags are OK in the dentry constructor, before
becomes potentially visible to other threads.
Unfortunately, there's a couple of exceptions to that, and that's where the
headache comes from.
Main PITA comes from d_set_d_op(); that primitive sets ->d_op
of dentry and adjusts the flags that correspond to presence of individual
methods. It's very easy to misuse; existing uses _are_ safe, but proof
of correctness is brittle.
Use in __d_alloc() is safe (we are within a constructor), but we
might as well precalculate the initial value of ->d_flags when we set
the default ->d_op for given superblock and set ->d_flags directly
instead of messing with that helper.
The reasons why other uses are safe are bloody convoluted; I'm not going
to reproduce it here. See https://lore.kernel.org/all/20250224010624.GT1977892@ZenIV/
for gory details, if you care. The critical part is using d_set_d_op() only
just prior to d_splice_alias(), which makes a combination of d_splice_alias()
with setting ->d_op, etc. a natural replacement primitive. Better yet, if
we go that way, it's easy to take setting ->d_op and modifying ->d_flags
under ->d_lock, which eliminates the headache as far as ->d_flags exclusion
rules are concerned. Other exceptions are minor and easy to deal with.
What this series does:
* d_set_d_op() is no longer available; new primitive (d_splice_alias_ops())
is provided, equivalent to combination of d_set_d_op() and d_splice_alias().
* new field of struct super_block - ->s_d_flags. Default value of ->d_flags
to be used when allocating dentries on this filesystem.
* new primitive for setting ->s_d_op: set_default_d_op(). Replaces stores
to ->s_d_op at mount time. All in-tree filesystems converted; out-of-tree
ones will get caught by compiler (->s_d_op is renamed, so stores to it will
be caught). ->s_d_flags is set by the same primitive to match the ->s_d_op.
* a lot of filesystems had ->s_d_op->d_delete equal to always_delete_dentry;
that is equivalent to setting DCACHE_DONTCACHE in ->d_flags, so such filesystems
can bloody well set that bit in ->s_d_flags and drop ->d_delete() from
dentry_operations. In quite a few cases that results in empty dentry_operations,
which means that we can get rid of those.
* kill simple_dentry_operations - not needed anymore.
* massage d_alloc_parallel() to get rid of the other exception wrt ->d_flags
stores - we can set DCACHE_PAR_LOOKUP as soon as we allocate the new dentry;
no need to delay that until we commit to using the sucker.
As the result, ->d_flags stores are all either under ->d_lock or done before
the dentry becomes visible in any shared data structures.
-----BEGIN PGP SIGNATURE-----
iHUEABYIAB0WIQQqUNBr3gm4hGXdBJlZ7Krx/gZQ6wUCaIQ/tQAKCRBZ7Krx/gZQ
66AhAQDgQ+S224x5YevNXc9mDoGUBMF4OG0n0fIla9rfdL4I6wEAqpOWMNDcVPCZ
GwYOvJ9YuqNdz+MyprAI18Yza4GOmgs=
=rTYB
-----END PGP SIGNATURE-----
Merge tag 'pull-dcache' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull dentry d_flags updates from Al Viro:
"The current exclusion rules for dentry->d_flags stores are rather
unpleasant. The basic rules are simple:
- stores to dentry->d_flags are OK under dentry->d_lock
- stores to dentry->d_flags are OK in the dentry constructor, before
becomes potentially visible to other threads
Unfortunately, there's a couple of exceptions to that, and that's
where the headache comes from.
The main PITA comes from d_set_d_op(); that primitive sets ->d_op of
dentry and adjusts the flags that correspond to presence of individual
methods. It's very easy to misuse; existing uses _are_ safe, but proof
of correctness is brittle.
Use in __d_alloc() is safe (we are within a constructor), but we might
as well precalculate the initial value of 'd_flags' when we set the
default ->d_op for given superblock and set 'd_flags' directly instead
of messing with that helper.
The reasons why other uses are safe are bloody convoluted; I'm not
going to reproduce it here. See [1] for gory details, if you care. The
critical part is using d_set_d_op() only just prior to
d_splice_alias(), which makes a combination of d_splice_alias() with
setting ->d_op, etc a natural replacement primitive.
Better yet, if we go that way, it's easy to take setting ->d_op and
modifying 'd_flags' under ->d_lock, which eliminates the headache as
far as 'd_flags' exclusion rules are concerned. Other exceptions are
minor and easy to deal with.
What this series does:
- d_set_d_op() is no longer available; instead a new primitive
(d_splice_alias_ops()) is provided, equivalent to combination of
d_set_d_op() and d_splice_alias().
- new field of struct super_block - 's_d_flags'. This sets the
default value of 'd_flags' to be used when allocating dentries on
this filesystem.
- new primitive for setting 's_d_op': set_default_d_op(). This
replaces stores to 's_d_op' at mount time.
All in-tree filesystems converted; out-of-tree ones will get caught
by the compiler ('s_d_op' is renamed, so stores to it will be
caught). 's_d_flags' is set by the same primitive to match the
's_d_op'.
- a lot of filesystems had sb->s_d_op->d_delete equal to
always_delete_dentry; that is equivalent to setting
DCACHE_DONTCACHE in 'd_flags', so such filesystems can bloody well
set that bit in 's_d_flags' and drop 'd_delete()' from
dentry_operations.
In quite a few cases that results in empty dentry_operations, which
means that we can get rid of those.
- kill simple_dentry_operations - not needed anymore
- massage d_alloc_parallel() to get rid of the other exception wrt
'd_flags' stores - we can set DCACHE_PAR_LOOKUP as soon as we
allocate the new dentry; no need to delay that until we commit to
using the sucker.
As the result, 'd_flags' stores are all either under ->d_lock or done
before the dentry becomes visible in any shared data structures"
Link: https://lore.kernel.org/all/20250224010624.GT1977892@ZenIV/ [1]
* tag 'pull-dcache' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (21 commits)
configfs: use DCACHE_DONTCACHE
debugfs: use DCACHE_DONTCACHE
efivarfs: use DCACHE_DONTCACHE instead of always_delete_dentry()
9p: don't bother with always_delete_dentry
ramfs, hugetlbfs, mqueue: set DCACHE_DONTCACHE
kill simple_dentry_operations
devpts, sunrpc, hostfs: don't bother with ->d_op
shmem: no dentry retention past the refcount reaching zero
d_alloc_parallel(): set DCACHE_PAR_LOOKUP earlier
make d_set_d_op() static
simple_lookup(): just set DCACHE_DONTCACHE
tracefs: Add d_delete to remove negative dentries
set_default_d_op(): calculate the matching value for ->d_flags
correct the set of flags forbidden at d_set_d_op() time
split d_flags calculation out of d_set_d_op()
new helper: set_default_d_op()
fuse: no need for special dentry_operations for root dentry
switch procfs from d_set_d_op() to d_splice_alias_ops()
new helper: d_splice_alias_ops()
procfs: kill ->proc_dops
...
2025-07-28 16:17:57 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2025-02-24 00:39:47 +00:00
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
If your filesystem sets the default dentry_operations, use set_default_d_op()
|
|
|
|
|
rather than manually setting sb->s_d_op.
|
2025-02-24 01:18:15 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
d_set_d_op() is no longer exported (or public, for that matter); _if_
|
|
|
|
|
your filesystem really needed that, make use of d_splice_alias_ops()
|
|
|
|
|
to have them set. Better yet, think hard whether you need different
|
|
|
|
|
->d_op for different dentries - if not, just use set_default_d_op()
|
|
|
|
|
at mount time and be done with that. Currently procfs is the only
|
|
|
|
|
thing that really needs ->d_op varying between dentries.
|
vfs-6.17-rc1.mmap_prepare
-----BEGIN PGP SIGNATURE-----
iHUEABYKAB0WIQRAhzRXHqcMeLMyaSiRxhvAZXjcogUCaINCgQAKCRCRxhvAZXjc
os+nAP9LFHUwWO6EBzHJJGEVjJvvzsbzqeYrRFamYiMc5ulPJwD+KW4RIgJa/MWO
pcYE40CacaekD8rFWwYUyszpgmv6ewc=
=wCwp
-----END PGP SIGNATURE-----
Merge tag 'vfs-6.17-rc1.mmap_prepare' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull mmap_prepare updates from Christian Brauner:
"Last cycle we introduce f_op->mmap_prepare() in c84bf6dd2b83 ("mm:
introduce new .mmap_prepare() file callback").
This is preferred to the existing f_op->mmap() hook as it does require
a VMA to be established yet, thus allowing the mmap logic to invoke
this hook far, far earlier, prior to inserting a VMA into the virtual
address space, or performing any other heavy handed operations.
This allows for much simpler unwinding on error, and for there to be a
single attempt at merging a VMA rather than having to possibly
reattempt a merge based on potentially altered VMA state.
Far more importantly, it prevents inappropriate manipulation of
incompletely initialised VMA state, which is something that has been
the cause of bugs and complexity in the past.
The intent is to gradually deprecate f_op->mmap, and in that vein this
series coverts the majority of file systems to using f_op->mmap_prepare.
Prerequisite steps are taken - firstly ensuring all checks for mmap
capabilities use the file_has_valid_mmap_hooks() helper rather than
directly checking for f_op->mmap (which is now not a valid check) and
secondly updating daxdev_mapping_supported() to not require a VMA
parameter to allow ext4 and xfs to be converted.
Commit bb666b7c2707 ("mm: add mmap_prepare() compatibility layer for
nested file systems") handles the nasty edge-case of nested file
systems like overlayfs, which introduces a compatibility shim to allow
f_op->mmap_prepare() to be invoked from an f_op->mmap() callback.
This allows for nested filesystems to continue to function correctly
with all file systems regardless of which callback is used. Once we
finally convert all file systems, this shim can be removed.
As a result, ecryptfs, fuse, and overlayfs remain unaltered so they
can nest all other file systems.
We additionally do not update resctl - as this requires an update to
remap_pfn_range() (or an alternative to it) which we defer to a later
series, equally we do not update cramfs which needs a mixed mapping
insertion with the same issue, nor do we update procfs, hugetlbfs,
syfs or kernfs all of which require VMAs for internal state and hooks.
We shall return to all of these later"
* tag 'vfs-6.17-rc1.mmap_prepare' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs:
doc: update porting, vfs documentation to describe mmap_prepare()
fs: replace mmap hook with .mmap_prepare for simple mappings
fs: convert most other generic_file_*mmap() users to .mmap_prepare()
fs: convert simple use of generic_file_*_mmap() to .mmap_prepare()
mm/filemap: introduce generic_file_*_mmap_prepare() helpers
fs/xfs: transition from deprecated .mmap hook to .mmap_prepare
fs/ext4: transition from deprecated .mmap hook to .mmap_prepare
fs/dax: make it possible to check dev dax support without a VMA
fs: consistently use can_mmap_file() helper
mm/nommu: use file_has_valid_mmap_hooks() helper
mm: rename call_mmap/mmap_prepare to vfs_mmap/mmap_prepare
2025-07-28 20:43:25 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2025-07-23 12:30:36 +00:00
|
|
|
**highly recommended**
|
|
|
|
|
|
|
|
|
|
The file operations mmap() callback is deprecated in favour of
|
|
|
|
|
mmap_prepare(). This passes a pointer to a vm_area_desc to the callback
|
|
|
|
|
rather than a VMA, as the VMA at this stage is not yet valid.
|
|
|
|
|
|
|
|
|
|
The vm_area_desc provides the minimum required information for a filesystem
|
|
|
|
|
to initialise state upon memory mapping of a file-backed region, and output
|
|
|
|
|
parameters for the file system to set this state.
|
2025-09-22 04:29:52 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
Several functions are renamed:
|
|
|
|
|
|
|
|
|
|
- kern_path_locked -> start_removing_path
|
|
|
|
|
- kern_path_create -> start_creating_path
|
|
|
|
|
- user_path_create -> start_creating_user_path
|
|
|
|
|
- user_path_locked_at -> start_removing_user_path_at
|
|
|
|
|
- done_path_create -> end_creating_path
|
2025-10-03 17:51:44 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
2025-06-28 15:37:30 +00:00
|
|
|
Calling conventions for vfs_parse_fs_string() have changed; it does *not*
|
|
|
|
|
take length anymore (value ? strlen(value) : 0 is used). If you want
|
|
|
|
|
a different length, use
|
|
|
|
|
|
|
|
|
|
vfs_parse_fs_qstr(fc, key, &QSTR_LEN(value, len))
|
|
|
|
|
|
|
|
|
|
instead.
|
2025-11-13 00:18:37 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
**mandatory**
|
|
|
|
|
|
|
|
|
|
vfs_mkdir() now returns a dentry - the one returned by ->mkdir(). If
|
|
|
|
|
that dentry is different from the dentry passed in, including if it is
|
|
|
|
|
an IS_ERR() dentry pointer, the original dentry is dput().
|
|
|
|
|
|
|
|
|
|
When vfs_mkdir() returns an error, and so both dputs() the original
|
|
|
|
|
dentry and doesn't provide a replacement, it also unlocks the parent.
|
|
|
|
|
Consequently the return value from vfs_mkdir() can be passed to
|
|
|
|
|
end_creating() and the parent will be unlocked precisely when necessary.
|