Back to home page

OSCL-LXR

 
 

    


0001 ====================
0002 Changes since 2.5.0:
0003 ====================
0004 
0005 ---
0006 
0007 **recommended**
0008 
0009 New helpers: sb_bread(), sb_getblk(), sb_find_get_block(), set_bh(),
0010 sb_set_blocksize() and sb_min_blocksize().
0011 
0012 Use them.
0013 
0014 (sb_find_get_block() replaces 2.4's get_hash_table())
0015 
0016 ---
0017 
0018 **recommended**
0019 
0020 New methods: ->alloc_inode() and ->destroy_inode().
0021 
0022 Remove inode->u.foo_inode_i
0023 
0024 Declare::
0025 
0026         struct foo_inode_info {
0027                 /* fs-private stuff */
0028                 struct inode vfs_inode;
0029         };
0030         static inline struct foo_inode_info *FOO_I(struct inode *inode)
0031         {
0032                 return list_entry(inode, struct foo_inode_info, vfs_inode);
0033         }
0034 
0035 Use FOO_I(inode) instead of &inode->u.foo_inode_i;
0036 
0037 Add foo_alloc_inode() and foo_destroy_inode() - the former should allocate
0038 foo_inode_info and return the address of ->vfs_inode, the latter should free
0039 FOO_I(inode) (see in-tree filesystems for examples).
0040 
0041 Make them ->alloc_inode and ->destroy_inode in your super_operations.
0042 
0043 Keep in mind that now you need explicit initialization of private data
0044 typically between calling iget_locked() and unlocking the inode.
0045 
0046 At some point that will become mandatory.
0047 
0048 **mandatory**
0049 
0050 The foo_inode_info should always be allocated through alloc_inode_sb() rather
0051 than kmem_cache_alloc() or kmalloc() related to set up the inode reclaim context
0052 correctly.
0053 
0054 ---
0055 
0056 **mandatory**
0057 
0058 Change of file_system_type method (->read_super to ->get_sb)
0059 
0060 ->read_super() is no more.  Ditto for DECLARE_FSTYPE and DECLARE_FSTYPE_DEV.
0061 
0062 Turn your foo_read_super() into a function that would return 0 in case of
0063 success and negative number in case of error (-EINVAL unless you have more
0064 informative error value to report).  Call it foo_fill_super().  Now declare::
0065 
0066   int foo_get_sb(struct file_system_type *fs_type,
0067         int flags, const char *dev_name, void *data, struct vfsmount *mnt)
0068   {
0069         return get_sb_bdev(fs_type, flags, dev_name, data, foo_fill_super,
0070                            mnt);
0071   }
0072 
0073 (or similar with s/bdev/nodev/ or s/bdev/single/, depending on the kind of
0074 filesystem).
0075 
0076 Replace DECLARE_FSTYPE... with explicit initializer and have ->get_sb set as
0077 foo_get_sb.
0078 
0079 ---
0080 
0081 **mandatory**
0082 
0083 Locking change: ->s_vfs_rename_sem is taken only by cross-directory renames.
0084 Most likely there is no need to change anything, but if you relied on
0085 global exclusion between renames for some internal purpose - you need to
0086 change your internal locking.  Otherwise exclusion warranties remain the
0087 same (i.e. parents and victim are locked, etc.).
0088 
0089 ---
0090 
0091 **informational**
0092 
0093 Now we have the exclusion between ->lookup() and directory removal (by
0094 ->rmdir() and ->rename()).  If you used to need that exclusion and do
0095 it by internal locking (most of filesystems couldn't care less) - you
0096 can relax your locking.
0097 
0098 ---
0099 
0100 **mandatory**
0101 
0102 ->lookup(), ->truncate(), ->create(), ->unlink(), ->mknod(), ->mkdir(),
0103 ->rmdir(), ->link(), ->lseek(), ->symlink(), ->rename()
0104 and ->readdir() are called without BKL now.  Grab it on entry, drop upon return
0105 - that will guarantee the same locking you used to have.  If your method or its
0106 parts do not need BKL - better yet, now you can shift lock_kernel() and
0107 unlock_kernel() so that they would protect exactly what needs to be
0108 protected.
0109 
0110 ---
0111 
0112 **mandatory**
0113 
0114 BKL is also moved from around sb operations. BKL should have been shifted into
0115 individual fs sb_op functions.  If you don't need it, remove it.
0116 
0117 ---
0118 
0119 **informational**
0120 
0121 check for ->link() target not being a directory is done by callers.  Feel
0122 free to drop it...
0123 
0124 ---
0125 
0126 **informational**
0127 
0128 ->link() callers hold ->i_mutex on the object we are linking to.  Some of your
0129 problems might be over...
0130 
0131 ---
0132 
0133 **mandatory**
0134 
0135 new file_system_type method - kill_sb(superblock).  If you are converting
0136 an existing filesystem, set it according to ->fs_flags::
0137 
0138         FS_REQUIRES_DEV         -       kill_block_super
0139         FS_LITTER               -       kill_litter_super
0140         neither                 -       kill_anon_super
0141 
0142 FS_LITTER is gone - just remove it from fs_flags.
0143 
0144 ---
0145 
0146 **mandatory**
0147 
0148 FS_SINGLE is gone (actually, that had happened back when ->get_sb()
0149 went in - and hadn't been documented ;-/).  Just remove it from fs_flags
0150 (and see ->get_sb() entry for other actions).
0151 
0152 ---
0153 
0154 **mandatory**
0155 
0156 ->setattr() is called without BKL now.  Caller _always_ holds ->i_mutex, so
0157 watch for ->i_mutex-grabbing code that might be used by your ->setattr().
0158 Callers of notify_change() need ->i_mutex now.
0159 
0160 ---
0161 
0162 **recommended**
0163 
0164 New super_block field ``struct export_operations *s_export_op`` for
0165 explicit support for exporting, e.g. via NFS.  The structure is fully
0166 documented at its declaration in include/linux/fs.h, and in
0167 Documentation/filesystems/nfs/exporting.rst.
0168 
0169 Briefly it allows for the definition of decode_fh and encode_fh operations
0170 to encode and decode filehandles, and allows the filesystem to use
0171 a standard helper function for decode_fh, and provide file-system specific
0172 support for this helper, particularly get_parent.
0173 
0174 It is planned that this will be required for exporting once the code
0175 settles down a bit.
0176 
0177 **mandatory**
0178 
0179 s_export_op is now required for exporting a filesystem.
0180 isofs, ext2, ext3, resierfs, fat
0181 can be used as examples of very different filesystems.
0182 
0183 ---
0184 
0185 **mandatory**
0186 
0187 iget4() and the read_inode2 callback have been superseded by iget5_locked()
0188 which has the following prototype::
0189 
0190     struct inode *iget5_locked(struct super_block *sb, unsigned long ino,
0191                                 int (*test)(struct inode *, void *),
0192                                 int (*set)(struct inode *, void *),
0193                                 void *data);
0194 
0195 'test' is an additional function that can be used when the inode
0196 number is not sufficient to identify the actual file object. 'set'
0197 should be a non-blocking function that initializes those parts of a
0198 newly created inode to allow the test function to succeed. 'data' is
0199 passed as an opaque value to both test and set functions.
0200 
0201 When the inode has been created by iget5_locked(), it will be returned with the
0202 I_NEW flag set and will still be locked.  The filesystem then needs to finalize
0203 the initialization. Once the inode is initialized it must be unlocked by
0204 calling unlock_new_inode().
0205 
0206 The filesystem is responsible for setting (and possibly testing) i_ino
0207 when appropriate. There is also a simpler iget_locked function that
0208 just takes the superblock and inode number as arguments and does the
0209 test and set for you.
0210 
0211 e.g.::
0212 
0213         inode = iget_locked(sb, ino);
0214         if (inode->i_state & I_NEW) {
0215                 err = read_inode_from_disk(inode);
0216                 if (err < 0) {
0217                         iget_failed(inode);
0218                         return err;
0219                 }
0220                 unlock_new_inode(inode);
0221         }
0222 
0223 Note that if the process of setting up a new inode fails, then iget_failed()
0224 should be called on the inode to render it dead, and an appropriate error
0225 should be passed back to the caller.
0226 
0227 ---
0228 
0229 **recommended**
0230 
0231 ->getattr() finally getting used.  See instances in nfs, minix, etc.
0232 
0233 ---
0234 
0235 **mandatory**
0236 
0237 ->revalidate() is gone.  If your filesystem had it - provide ->getattr()
0238 and let it call whatever you had as ->revlidate() + (for symlinks that
0239 had ->revalidate()) add calls in ->follow_link()/->readlink().
0240 
0241 ---
0242 
0243 **mandatory**
0244 
0245 ->d_parent changes are not protected by BKL anymore.  Read access is safe
0246 if at least one of the following is true:
0247 
0248         * filesystem has no cross-directory rename()
0249         * we know that parent had been locked (e.g. we are looking at
0250           ->d_parent of ->lookup() argument).
0251         * we are called from ->rename().
0252         * the child's ->d_lock is held
0253 
0254 Audit your code and add locking if needed.  Notice that any place that is
0255 not protected by the conditions above is risky even in the old tree - you
0256 had been relying on BKL and that's prone to screwups.  Old tree had quite
0257 a few holes of that kind - unprotected access to ->d_parent leading to
0258 anything from oops to silent memory corruption.
0259 
0260 ---
0261 
0262 **mandatory**
0263 
0264 FS_NOMOUNT is gone.  If you use it - just set SB_NOUSER in flags
0265 (see rootfs for one kind of solution and bdev/socket/pipe for another).
0266 
0267 ---
0268 
0269 **recommended**
0270 
0271 Use bdev_read_only(bdev) instead of is_read_only(kdev).  The latter
0272 is still alive, but only because of the mess in drivers/s390/block/dasd.c.
0273 As soon as it gets fixed is_read_only() will die.
0274 
0275 ---
0276 
0277 **mandatory**
0278 
0279 ->permission() is called without BKL now. Grab it on entry, drop upon
0280 return - that will guarantee the same locking you used to have.  If
0281 your method or its parts do not need BKL - better yet, now you can
0282 shift lock_kernel() and unlock_kernel() so that they would protect
0283 exactly what needs to be protected.
0284 
0285 ---
0286 
0287 **mandatory**
0288 
0289 ->statfs() is now called without BKL held.  BKL should have been
0290 shifted into individual fs sb_op functions where it's not clear that
0291 it's safe to remove it.  If you don't need it, remove it.
0292 
0293 ---
0294 
0295 **mandatory**
0296 
0297 is_read_only() is gone; use bdev_read_only() instead.
0298 
0299 ---
0300 
0301 **mandatory**
0302 
0303 destroy_buffers() is gone; use invalidate_bdev().
0304 
0305 ---
0306 
0307 **mandatory**
0308 
0309 fsync_dev() is gone; use fsync_bdev().  NOTE: lvm breakage is
0310 deliberate; as soon as struct block_device * is propagated in a reasonable
0311 way by that code fixing will become trivial; until then nothing can be
0312 done.
0313 
0314 **mandatory**
0315 
0316 block truncatation on error exit from ->write_begin, and ->direct_IO
0317 moved from generic methods (block_write_begin, cont_write_begin,
0318 nobh_write_begin, blockdev_direct_IO*) to callers.  Take a look at
0319 ext2_write_failed and callers for an example.
0320 
0321 **mandatory**
0322 
0323 ->truncate is gone.  The whole truncate sequence needs to be
0324 implemented in ->setattr, which is now mandatory for filesystems
0325 implementing on-disk size changes.  Start with a copy of the old inode_setattr
0326 and vmtruncate, and the reorder the vmtruncate + foofs_vmtruncate sequence to
0327 be in order of zeroing blocks using block_truncate_page or similar helpers,
0328 size update and on finally on-disk truncation which should not fail.
0329 setattr_prepare (which used to be inode_change_ok) now includes the size checks
0330 for ATTR_SIZE and must be called in the beginning of ->setattr unconditionally.
0331 
0332 **mandatory**
0333 
0334 ->clear_inode() and ->delete_inode() are gone; ->evict_inode() should
0335 be used instead.  It gets called whenever the inode is evicted, whether it has
0336 remaining links or not.  Caller does *not* evict the pagecache or inode-associated
0337 metadata buffers; the method has to use truncate_inode_pages_final() to get rid
0338 of those. Caller makes sure async writeback cannot be running for the inode while
0339 (or after) ->evict_inode() is called.
0340 
0341 ->drop_inode() returns int now; it's called on final iput() with
0342 inode->i_lock held and it returns true if filesystems wants the inode to be
0343 dropped.  As before, generic_drop_inode() is still the default and it's been
0344 updated appropriately.  generic_delete_inode() is also alive and it consists
0345 simply of return 1.  Note that all actual eviction work is done by caller after
0346 ->drop_inode() returns.
0347 
0348 As before, clear_inode() must be called exactly once on each call of
0349 ->evict_inode() (as it used to be for each call of ->delete_inode()).  Unlike
0350 before, if you are using inode-associated metadata buffers (i.e.
0351 mark_buffer_dirty_inode()), it's your responsibility to call
0352 invalidate_inode_buffers() before clear_inode().
0353 
0354 NOTE: checking i_nlink in the beginning of ->write_inode() and bailing out
0355 if it's zero is not *and* *never* *had* *been* enough.  Final unlink() and iput()
0356 may happen while the inode is in the middle of ->write_inode(); e.g. if you blindly
0357 free the on-disk inode, you may end up doing that while ->write_inode() is writing
0358 to it.
0359 
0360 ---
0361 
0362 **mandatory**
0363 
0364 .d_delete() now only advises the dcache as to whether or not to cache
0365 unreferenced dentries, and is now only called when the dentry refcount goes to
0366 0. Even on 0 refcount transition, it must be able to tolerate being called 0,
0367 1, or more times (eg. constant, idempotent).
0368 
0369 ---
0370 
0371 **mandatory**
0372 
0373 .d_compare() calling convention and locking rules are significantly
0374 changed. Read updated documentation in Documentation/filesystems/vfs.rst (and
0375 look at examples of other filesystems) for guidance.
0376 
0377 ---
0378 
0379 **mandatory**
0380 
0381 .d_hash() calling convention and locking rules are significantly
0382 changed. Read updated documentation in Documentation/filesystems/vfs.rst (and
0383 look at examples of other filesystems) for guidance.
0384 
0385 ---
0386 
0387 **mandatory**
0388 
0389 dcache_lock is gone, replaced by fine grained locks. See fs/dcache.c
0390 for details of what locks to replace dcache_lock with in order to protect
0391 particular things. Most of the time, a filesystem only needs ->d_lock, which
0392 protects *all* the dcache state of a given dentry.
0393 
0394 ---
0395 
0396 **mandatory**
0397 
0398 Filesystems must RCU-free their inodes, if they can have been accessed
0399 via rcu-walk path walk (basically, if the file can have had a path name in the
0400 vfs namespace).
0401 
0402 Even though i_dentry and i_rcu share storage in a union, we will
0403 initialize the former in inode_init_always(), so just leave it alone in
0404 the callback.  It used to be necessary to clean it there, but not anymore
0405 (starting at 3.2).
0406 
0407 ---
0408 
0409 **recommended**
0410 
0411 vfs now tries to do path walking in "rcu-walk mode", which avoids
0412 atomic operations and scalability hazards on dentries and inodes (see
0413 Documentation/filesystems/path-lookup.txt). d_hash and d_compare changes
0414 (above) are examples of the changes required to support this. For more complex
0415 filesystem callbacks, the vfs drops out of rcu-walk mode before the fs call, so
0416 no changes are required to the filesystem. However, this is costly and loses
0417 the benefits of rcu-walk mode. We will begin to add filesystem callbacks that
0418 are rcu-walk aware, shown below. Filesystems should take advantage of this
0419 where possible.
0420 
0421 ---
0422 
0423 **mandatory**
0424 
0425 d_revalidate is a callback that is made on every path element (if
0426 the filesystem provides it), which requires dropping out of rcu-walk mode. This
0427 may now be called in rcu-walk mode (nd->flags & LOOKUP_RCU). -ECHILD should be
0428 returned if the filesystem cannot handle rcu-walk. See
0429 Documentation/filesystems/vfs.rst for more details.
0430 
0431 permission is an inode permission check that is called on many or all
0432 directory inodes on the way down a path walk (to check for exec permission). It
0433 must now be rcu-walk aware (mask & MAY_NOT_BLOCK).  See
0434 Documentation/filesystems/vfs.rst for more details.
0435 
0436 ---
0437 
0438 **mandatory**
0439 
0440 In ->fallocate() you must check the mode option passed in.  If your
0441 filesystem does not support hole punching (deallocating space in the middle of a
0442 file) you must return -EOPNOTSUPP if FALLOC_FL_PUNCH_HOLE is set in mode.
0443 Currently you can only have FALLOC_FL_PUNCH_HOLE with FALLOC_FL_KEEP_SIZE set,
0444 so the i_size should not change when hole punching, even when puching the end of
0445 a file off.
0446 
0447 ---
0448 
0449 **mandatory**
0450 
0451 ->get_sb() is gone.  Switch to use of ->mount().  Typically it's just
0452 a matter of switching from calling ``get_sb_``... to ``mount_``... and changing
0453 the function type.  If you were doing it manually, just switch from setting
0454 ->mnt_root to some pointer to returning that pointer.  On errors return
0455 ERR_PTR(...).
0456 
0457 ---
0458 
0459 **mandatory**
0460 
0461 ->permission() and generic_permission()have lost flags
0462 argument; instead of passing IPERM_FLAG_RCU we add MAY_NOT_BLOCK into mask.
0463 
0464 generic_permission() has also lost the check_acl argument; ACL checking
0465 has been taken to VFS and filesystems need to provide a non-NULL ->i_op->get_acl
0466 to read an ACL from disk.
0467 
0468 ---
0469 
0470 **mandatory**
0471 
0472 If you implement your own ->llseek() you must handle SEEK_HOLE and
0473 SEEK_DATA.  You can hanle this by returning -EINVAL, but it would be nicer to
0474 support it in some way.  The generic handler assumes that the entire file is
0475 data and there is a virtual hole at the end of the file.  So if the provided
0476 offset is less than i_size and SEEK_DATA is specified, return the same offset.
0477 If the above is true for the offset and you are given SEEK_HOLE, return the end
0478 of the file.  If the offset is i_size or greater return -ENXIO in either case.
0479 
0480 **mandatory**
0481 
0482 If you have your own ->fsync() you must make sure to call
0483 filemap_write_and_wait_range() so that all dirty pages are synced out properly.
0484 You must also keep in mind that ->fsync() is not called with i_mutex held
0485 anymore, so if you require i_mutex locking you must make sure to take it and
0486 release it yourself.
0487 
0488 ---
0489 
0490 **mandatory**
0491 
0492 d_alloc_root() is gone, along with a lot of bugs caused by code
0493 misusing it.  Replacement: d_make_root(inode).  On success d_make_root(inode)
0494 allocates and returns a new dentry instantiated with the passed in inode.
0495 On failure NULL is returned and the passed in inode is dropped so the reference
0496 to inode is consumed in all cases and failure handling need not do any cleanup
0497 for the inode.  If d_make_root(inode) is passed a NULL inode it returns NULL
0498 and also requires no further error handling. Typical usage is::
0499 
0500         inode = foofs_new_inode(....);
0501         s->s_root = d_make_root(inode);
0502         if (!s->s_root)
0503                 /* Nothing needed for the inode cleanup */
0504                 return -ENOMEM;
0505         ...
0506 
0507 ---
0508 
0509 **mandatory**
0510 
0511 The witch is dead!  Well, 2/3 of it, anyway.  ->d_revalidate() and
0512 ->lookup() do *not* take struct nameidata anymore; just the flags.
0513 
0514 ---
0515 
0516 **mandatory**
0517 
0518 ->create() doesn't take ``struct nameidata *``; unlike the previous
0519 two, it gets "is it an O_EXCL or equivalent?" boolean argument.  Note that
0520 local filesystems can ignore tha argument - they are guaranteed that the
0521 object doesn't exist.  It's remote/distributed ones that might care...
0522 
0523 ---
0524 
0525 **mandatory**
0526 
0527 FS_REVAL_DOT is gone; if you used to have it, add ->d_weak_revalidate()
0528 in your dentry operations instead.
0529 
0530 ---
0531 
0532 **mandatory**
0533 
0534 vfs_readdir() is gone; switch to iterate_dir() instead
0535 
0536 ---
0537 
0538 **mandatory**
0539 
0540 ->readdir() is gone now; switch to ->iterate()
0541 
0542 **mandatory**
0543 
0544 vfs_follow_link has been removed.  Filesystems must use nd_set_link
0545 from ->follow_link for normal symlinks, or nd_jump_link for magic
0546 /proc/<pid> style links.
0547 
0548 ---
0549 
0550 **mandatory**
0551 
0552 iget5_locked()/ilookup5()/ilookup5_nowait() test() callback used to be
0553 called with both ->i_lock and inode_hash_lock held; the former is *not*
0554 taken anymore, so verify that your callbacks do not rely on it (none
0555 of the in-tree instances did).  inode_hash_lock is still held,
0556 of course, so they are still serialized wrt removal from inode hash,
0557 as well as wrt set() callback of iget5_locked().
0558 
0559 ---
0560 
0561 **mandatory**
0562 
0563 d_materialise_unique() is gone; d_splice_alias() does everything you
0564 need now.  Remember that they have opposite orders of arguments ;-/
0565 
0566 ---
0567 
0568 **mandatory**
0569 
0570 f_dentry is gone; use f_path.dentry, or, better yet, see if you can avoid
0571 it entirely.
0572 
0573 ---
0574 
0575 **mandatory**
0576 
0577 never call ->read() and ->write() directly; use __vfs_{read,write} or
0578 wrappers; instead of checking for ->write or ->read being NULL, look for
0579 FMODE_CAN_{WRITE,READ} in file->f_mode.
0580 
0581 ---
0582 
0583 **mandatory**
0584 
0585 do _not_ use new_sync_{read,write} for ->read/->write; leave it NULL
0586 instead.
0587 
0588 ---
0589 
0590 **mandatory**
0591         ->aio_read/->aio_write are gone.  Use ->read_iter/->write_iter.
0592 
0593 ---
0594 
0595 **recommended**
0596 
0597 for embedded ("fast") symlinks just set inode->i_link to wherever the
0598 symlink body is and use simple_follow_link() as ->follow_link().
0599 
0600 ---
0601 
0602 **mandatory**
0603 
0604 calling conventions for ->follow_link() have changed.  Instead of returning
0605 cookie and using nd_set_link() to store the body to traverse, we return
0606 the body to traverse and store the cookie using explicit void ** argument.
0607 nameidata isn't passed at all - nd_jump_link() doesn't need it and
0608 nd_[gs]et_link() is gone.
0609 
0610 ---
0611 
0612 **mandatory**
0613 
0614 calling conventions for ->put_link() have changed.  It gets inode instead of
0615 dentry,  it does not get nameidata at all and it gets called only when cookie
0616 is non-NULL.  Note that link body isn't available anymore, so if you need it,
0617 store it as cookie.
0618 
0619 ---
0620 
0621 **mandatory**
0622 
0623 any symlink that might use page_follow_link_light/page_put_link() must
0624 have inode_nohighmem(inode) called before anything might start playing with
0625 its pagecache.  No highmem pages should end up in the pagecache of such
0626 symlinks.  That includes any preseeding that might be done during symlink
0627 creation.  page_symlink() will honour the mapping gfp flags, so once
0628 you've done inode_nohighmem() it's safe to use, but if you allocate and
0629 insert the page manually, make sure to use the right gfp flags.
0630 
0631 ---
0632 
0633 **mandatory**
0634 
0635 ->follow_link() is replaced with ->get_link(); same API, except that
0636 
0637         * ->get_link() gets inode as a separate argument
0638         * ->get_link() may be called in RCU mode - in that case NULL
0639           dentry is passed
0640 
0641 ---
0642 
0643 **mandatory**
0644 
0645 ->get_link() gets struct delayed_call ``*done`` now, and should do
0646 set_delayed_call() where it used to set ``*cookie``.
0647 
0648 ->put_link() is gone - just give the destructor to set_delayed_call()
0649 in ->get_link().
0650 
0651 ---
0652 
0653 **mandatory**
0654 
0655 ->getxattr() and xattr_handler.get() get dentry and inode passed separately.
0656 dentry might be yet to be attached to inode, so do _not_ use its ->d_inode
0657 in the instances.  Rationale: !@#!@# security_d_instantiate() needs to be
0658 called before we attach dentry to inode.
0659 
0660 ---
0661 
0662 **mandatory**
0663 
0664 symlinks are no longer the only inodes that do *not* have i_bdev/i_cdev/
0665 i_pipe/i_link union zeroed out at inode eviction.  As the result, you can't
0666 assume that non-NULL value in ->i_nlink at ->destroy_inode() implies that
0667 it's a symlink.  Checking ->i_mode is really needed now.  In-tree we had
0668 to fix shmem_destroy_callback() that used to take that kind of shortcut;
0669 watch out, since that shortcut is no longer valid.
0670 
0671 ---
0672 
0673 **mandatory**
0674 
0675 ->i_mutex is replaced with ->i_rwsem now.  inode_lock() et.al. work as
0676 they used to - they just take it exclusive.  However, ->lookup() may be
0677 called with parent locked shared.  Its instances must not
0678 
0679         * use d_instantiate) and d_rehash() separately - use d_add() or
0680           d_splice_alias() instead.
0681         * use d_rehash() alone - call d_add(new_dentry, NULL) instead.
0682         * in the unlikely case when (read-only) access to filesystem
0683           data structures needs exclusion for some reason, arrange it
0684           yourself.  None of the in-tree filesystems needed that.
0685         * rely on ->d_parent and ->d_name not changing after dentry has
0686           been fed to d_add() or d_splice_alias().  Again, none of the
0687           in-tree instances relied upon that.
0688 
0689 We are guaranteed that lookups of the same name in the same directory
0690 will not happen in parallel ("same" in the sense of your ->d_compare()).
0691 Lookups on different names in the same directory can and do happen in
0692 parallel now.
0693 
0694 ---
0695 
0696 **recommended**
0697 
0698 ->iterate_shared() is added; it's a parallel variant of ->iterate().
0699 Exclusion on struct file level is still provided (as well as that
0700 between it and lseek on the same struct file), but if your directory
0701 has been opened several times, you can get these called in parallel.
0702 Exclusion between that method and all directory-modifying ones is
0703 still provided, of course.
0704 
0705 Often enough ->iterate() can serve as ->iterate_shared() without any
0706 changes - it is a read-only operation, after all.  If you have any
0707 per-inode or per-dentry in-core data structures modified by ->iterate(),
0708 you might need something to serialize the access to them.  If you
0709 do dcache pre-seeding, you'll need to switch to d_alloc_parallel() for
0710 that; look for in-tree examples.
0711 
0712 Old method is only used if the new one is absent; eventually it will
0713 be removed.  Switch while you still can; the old one won't stay.
0714 
0715 ---
0716 
0717 **mandatory**
0718 
0719 ->atomic_open() calls without O_CREAT may happen in parallel.
0720 
0721 ---
0722 
0723 **mandatory**
0724 
0725 ->setxattr() and xattr_handler.set() get dentry and inode passed separately.
0726 The xattr_handler.set() gets passed the user namespace of the mount the inode
0727 is seen from so filesystems can idmap the i_uid and i_gid accordingly.
0728 dentry might be yet to be attached to inode, so do _not_ use its ->d_inode
0729 in the instances.  Rationale: !@#!@# security_d_instantiate() needs to be
0730 called before we attach dentry to inode and !@#!@##!@$!$#!@#$!@$!@$ smack
0731 ->d_instantiate() uses not just ->getxattr() but ->setxattr() as well.
0732 
0733 ---
0734 
0735 **mandatory**
0736 
0737 ->d_compare() doesn't get parent as a separate argument anymore.  If you
0738 used it for finding the struct super_block involved, dentry->d_sb will
0739 work just as well; if it's something more complicated, use dentry->d_parent.
0740 Just be careful not to assume that fetching it more than once will yield
0741 the same value - in RCU mode it could change under you.
0742 
0743 ---
0744 
0745 **mandatory**
0746 
0747 ->rename() has an added flags argument.  Any flags not handled by the
0748 filesystem should result in EINVAL being returned.
0749 
0750 ---
0751 
0752 
0753 **recommended**
0754 
0755 ->readlink is optional for symlinks.  Don't set, unless filesystem needs
0756 to fake something for readlink(2).
0757 
0758 ---
0759 
0760 **mandatory**
0761 
0762 ->getattr() is now passed a struct path rather than a vfsmount and
0763 dentry separately, and it now has request_mask and query_flags arguments
0764 to specify the fields and sync type requested by statx.  Filesystems not
0765 supporting any statx-specific features may ignore the new arguments.
0766 
0767 ---
0768 
0769 **mandatory**
0770 
0771 ->atomic_open() calling conventions have changed.  Gone is ``int *opened``,
0772 along with FILE_OPENED/FILE_CREATED.  In place of those we have
0773 FMODE_OPENED/FMODE_CREATED, set in file->f_mode.  Additionally, return
0774 value for 'called finish_no_open(), open it yourself' case has become
0775 0, not 1.  Since finish_no_open() itself is returning 0 now, that part
0776 does not need any changes in ->atomic_open() instances.
0777 
0778 ---
0779 
0780 **mandatory**
0781 
0782 alloc_file() has become static now; two wrappers are to be used instead.
0783 alloc_file_pseudo(inode, vfsmount, name, flags, ops) is for the cases
0784 when dentry needs to be created; that's the majority of old alloc_file()
0785 users.  Calling conventions: on success a reference to new struct file
0786 is returned and callers reference to inode is subsumed by that.  On
0787 failure, ERR_PTR() is returned and no caller's references are affected,
0788 so the caller needs to drop the inode reference it held.
0789 alloc_file_clone(file, flags, ops) does not affect any caller's references.
0790 On success you get a new struct file sharing the mount/dentry with the
0791 original, on failure - ERR_PTR().
0792 
0793 ---
0794 
0795 **mandatory**
0796 
0797 ->clone_file_range() and ->dedupe_file_range have been replaced with
0798 ->remap_file_range().  See Documentation/filesystems/vfs.rst for more
0799 information.
0800 
0801 ---
0802 
0803 **recommended**
0804 
0805 ->lookup() instances doing an equivalent of::
0806 
0807         if (IS_ERR(inode))
0808                 return ERR_CAST(inode);
0809         return d_splice_alias(inode, dentry);
0810 
0811 don't need to bother with the check - d_splice_alias() will do the
0812 right thing when given ERR_PTR(...) as inode.  Moreover, passing NULL
0813 inode to d_splice_alias() will also do the right thing (equivalent of
0814 d_add(dentry, NULL); return NULL;), so that kind of special cases
0815 also doesn't need a separate treatment.
0816 
0817 ---
0818 
0819 **strongly recommended**
0820 
0821 take the RCU-delayed parts of ->destroy_inode() into a new method -
0822 ->free_inode().  If ->destroy_inode() becomes empty - all the better,
0823 just get rid of it.  Synchronous work (e.g. the stuff that can't
0824 be done from an RCU callback, or any WARN_ON() where we want the
0825 stack trace) *might* be movable to ->evict_inode(); however,
0826 that goes only for the things that are not needed to balance something
0827 done by ->alloc_inode().  IOW, if it's cleaning up the stuff that
0828 might have accumulated over the life of in-core inode, ->evict_inode()
0829 might be a fit.
0830 
0831 Rules for inode destruction:
0832 
0833         * if ->destroy_inode() is non-NULL, it gets called
0834         * if ->free_inode() is non-NULL, it gets scheduled by call_rcu()
0835         * combination of NULL ->destroy_inode and NULL ->free_inode is
0836           treated as NULL/free_inode_nonrcu, to preserve the compatibility.
0837 
0838 Note that the callback (be it via ->free_inode() or explicit call_rcu()
0839 in ->destroy_inode()) is *NOT* ordered wrt superblock destruction;
0840 as the matter of fact, the superblock and all associated structures
0841 might be already gone.  The filesystem driver is guaranteed to be still
0842 there, but that's it.  Freeing memory in the callback is fine; doing
0843 more than that is possible, but requires a lot of care and is best
0844 avoided.
0845 
0846 ---
0847 
0848 **mandatory**
0849 
0850 DCACHE_RCUACCESS is gone; having an RCU delay on dentry freeing is the
0851 default.  DCACHE_NORCU opts out, and only d_alloc_pseudo() has any
0852 business doing so.
0853 
0854 ---
0855 
0856 **mandatory**
0857 
0858 d_alloc_pseudo() is internal-only; uses outside of alloc_file_pseudo() are
0859 very suspect (and won't work in modules).  Such uses are very likely to
0860 be misspelled d_alloc_anon().
0861 
0862 ---
0863 
0864 **mandatory**
0865 
0866 [should've been added in 2016] stale comment in finish_open() nonwithstanding,
0867 failure exits in ->atomic_open() instances should *NOT* fput() the file,
0868 no matter what.  Everything is handled by the caller.
0869 
0870 ---
0871 
0872 **mandatory**
0873 
0874 clone_private_mount() returns a longterm mount now, so the proper destructor of
0875 its result is kern_unmount() or kern_unmount_array().
0876 
0877 ---
0878 
0879 **mandatory**
0880 
0881 zero-length bvec segments are disallowed, they must be filtered out before
0882 passed on to an iterator.
0883 
0884 ---
0885 
0886 **mandatory**
0887 
0888 For bvec based itererators bio_iov_iter_get_pages() now doesn't copy bvecs but
0889 uses the one provided. Anyone issuing kiocb-I/O should ensure that the bvec and
0890 page references stay until I/O has completed, i.e. until ->ki_complete() has
0891 been called or returned with non -EIOCBQUEUED code.
0892 
0893 ---
0894 
0895 **mandatory**
0896 
0897 mnt_want_write_file() can now only be paired with mnt_drop_write_file(),
0898 whereas previously it could be paired with mnt_drop_write() as well.
0899 
0900 ---
0901 
0902 **mandatory**
0903 
0904 iov_iter_copy_from_user_atomic() is gone; use copy_page_from_iter_atomic().
0905 The difference is copy_page_from_iter_atomic() advances the iterator and
0906 you don't need iov_iter_advance() after it.  However, if you decide to use
0907 only a part of obtained data, you should do iov_iter_revert().
0908 
0909 ---
0910 
0911 **mandatory**
0912 
0913 Calling conventions for file_open_root() changed; now it takes struct path *
0914 instead of passing mount and dentry separately.  For callers that used to
0915 pass <mnt, mnt->mnt_root> pair (i.e. the root of given mount), a new helper
0916 is provided - file_open_root_mnt().  In-tree users adjusted.
0917 
0918 ---
0919 
0920 **mandatory**
0921 
0922 no_llseek is gone; don't set .llseek to that - just leave it NULL instead.
0923 Checks for "does that file have llseek(2), or should it fail with ESPIPE"
0924 should be done by looking at FMODE_LSEEK in file->f_mode.