]> git.ipfire.org Git - thirdparty/linux.git/blame - Documentation/filesystems/porting
typo fix: it's d_make_root, not d_make_inode...
[thirdparty/linux.git] / Documentation / filesystems / porting
CommitLineData
1da177e4
LT
1Changes since 2.5.0:
2
3eb43f68 3---
1da177e4
LT
4[recommended]
5
6New helpers: sb_bread(), sb_getblk(), sb_find_get_block(), set_bh(),
7 sb_set_blocksize() and sb_min_blocksize().
8
9Use them.
10
11(sb_find_get_block() replaces 2.4's get_hash_table())
12
3eb43f68 13---
1da177e4
LT
14[recommended]
15
16New methods: ->alloc_inode() and ->destroy_inode().
17
18Remove inode->u.foo_inode_i
19Declare
20 struct foo_inode_info {
21 /* fs-private stuff */
22 struct inode vfs_inode;
23 };
24 static inline struct foo_inode_info *FOO_I(struct inode *inode)
25 {
26 return list_entry(inode, struct foo_inode_info, vfs_inode);
27 }
28
29Use FOO_I(inode) instead of &inode->u.foo_inode_i;
30
3eb43f68 31Add foo_alloc_inode() and foo_destroy_inode() - the former should allocate
1da177e4
LT
32foo_inode_info and return the address of ->vfs_inode, the latter should free
33FOO_I(inode) (see in-tree filesystems for examples).
34
35Make them ->alloc_inode and ->destroy_inode in your super_operations.
36
12debc42
DH
37Keep in mind that now you need explicit initialization of private data
38typically between calling iget_locked() and unlocking the inode.
1da177e4
LT
39
40At some point that will become mandatory.
41
42---
43[mandatory]
44
45Change of file_system_type method (->read_super to ->get_sb)
46
47->read_super() is no more. Ditto for DECLARE_FSTYPE and DECLARE_FSTYPE_DEV.
48
49Turn your foo_read_super() into a function that would return 0 in case of
50success and negative number in case of error (-EINVAL unless you have more
51informative error value to report). Call it foo_fill_super(). Now declare
52
454e2398
DH
53int foo_get_sb(struct file_system_type *fs_type,
54 int flags, const char *dev_name, void *data, struct vfsmount *mnt)
1da177e4 55{
454e2398
DH
56 return get_sb_bdev(fs_type, flags, dev_name, data, foo_fill_super,
57 mnt);
1da177e4
LT
58}
59
60(or similar with s/bdev/nodev/ or s/bdev/single/, depending on the kind of
61filesystem).
62
63Replace DECLARE_FSTYPE... with explicit initializer and have ->get_sb set as
64foo_get_sb.
65
66---
67[mandatory]
68
69Locking change: ->s_vfs_rename_sem is taken only by cross-directory renames.
70Most likely there is no need to change anything, but if you relied on
71global exclusion between renames for some internal purpose - you need to
72change your internal locking. Otherwise exclusion warranties remain the
73same (i.e. parents and victim are locked, etc.).
74
75---
76[informational]
77
78Now we have the exclusion between ->lookup() and directory removal (by
79->rmdir() and ->rename()). If you used to need that exclusion and do
80it by internal locking (most of filesystems couldn't care less) - you
81can relax your locking.
82
83---
84[mandatory]
85
86->lookup(), ->truncate(), ->create(), ->unlink(), ->mknod(), ->mkdir(),
87->rmdir(), ->link(), ->lseek(), ->symlink(), ->rename()
88and ->readdir() are called without BKL now. Grab it on entry, drop upon return
89- that will guarantee the same locking you used to have. If your method or its
90parts do not need BKL - better yet, now you can shift lock_kernel() and
91unlock_kernel() so that they would protect exactly what needs to be
92protected.
93
94---
95[mandatory]
96
34e5053f
AB
97BKL is also moved from around sb operations. BKL should have been shifted into
98individual fs sb_op functions. If you don't need it, remove it.
1da177e4
LT
99
100---
101[informational]
102
103check for ->link() target not being a directory is done by callers. Feel
104free to drop it...
105
106---
107[informational]
108
c2b38989 109->link() callers hold ->i_mutex on the object we are linking to. Some of your
1da177e4
LT
110problems might be over...
111
112---
113[mandatory]
114
115new file_system_type method - kill_sb(superblock). If you are converting
116an existing filesystem, set it according to ->fs_flags:
117 FS_REQUIRES_DEV - kill_block_super
118 FS_LITTER - kill_litter_super
119 neither - kill_anon_super
120FS_LITTER is gone - just remove it from fs_flags.
121
122---
123[mandatory]
124
125 FS_SINGLE is gone (actually, that had happened back when ->get_sb()
126went in - and hadn't been documented ;-/). Just remove it from fs_flags
127(and see ->get_sb() entry for other actions).
128
129---
130[mandatory]
131
c2b38989
JJS
132->setattr() is called without BKL now. Caller _always_ holds ->i_mutex, so
133watch for ->i_mutex-grabbing code that might be used by your ->setattr().
134Callers of notify_change() need ->i_mutex now.
1da177e4
LT
135
136---
137[recommended]
138
139New super_block field "struct export_operations *s_export_op" for
140explicit support for exporting, e.g. via NFS. The structure is fully
141documented at its declaration in include/linux/fs.h, and in
dc7a0816 142Documentation/filesystems/nfs/Exporting.
1da177e4
LT
143
144Briefly it allows for the definition of decode_fh and encode_fh operations
145to encode and decode filehandles, and allows the filesystem to use
146a standard helper function for decode_fh, and provide file-system specific
147support for this helper, particularly get_parent.
148
149It is planned that this will be required for exporting once the code
150settles down a bit.
151
152[mandatory]
153
154s_export_op is now required for exporting a filesystem.
155isofs, ext2, ext3, resierfs, fat
156can be used as examples of very different filesystems.
157
158---
159[mandatory]
160
161iget4() and the read_inode2 callback have been superseded by iget5_locked()
162which has the following prototype,
163
164 struct inode *iget5_locked(struct super_block *sb, unsigned long ino,
165 int (*test)(struct inode *, void *),
166 int (*set)(struct inode *, void *),
167 void *data);
168
169'test' is an additional function that can be used when the inode
170number is not sufficient to identify the actual file object. 'set'
171should be a non-blocking function that initializes those parts of a
172newly created inode to allow the test function to succeed. 'data' is
173passed as an opaque value to both test and set functions.
174
12debc42
DH
175When the inode has been created by iget5_locked(), it will be returned with the
176I_NEW flag set and will still be locked. The filesystem then needs to finalize
177the initialization. Once the inode is initialized it must be unlocked by
178calling unlock_new_inode().
1da177e4
LT
179
180The filesystem is responsible for setting (and possibly testing) i_ino
181when appropriate. There is also a simpler iget_locked function that
182just takes the superblock and inode number as arguments and does the
183test and set for you.
184
185e.g.
b46980fe
DH
186 inode = iget_locked(sb, ino);
187 if (inode->i_state & I_NEW) {
188 err = read_inode_from_disk(inode);
189 if (err < 0) {
190 iget_failed(inode);
191 return err;
192 }
193 unlock_new_inode(inode);
194 }
195
196Note that if the process of setting up a new inode fails, then iget_failed()
197should be called on the inode to render it dead, and an appropriate error
198should be passed back to the caller.
1da177e4
LT
199
200---
201[recommended]
202
203->getattr() finally getting used. See instances in nfs, minix, etc.
204
205---
206[mandatory]
207
208->revalidate() is gone. If your filesystem had it - provide ->getattr()
209and let it call whatever you had as ->revlidate() + (for symlinks that
210had ->revalidate()) add calls in ->follow_link()/->readlink().
211
212---
213[mandatory]
214
215->d_parent changes are not protected by BKL anymore. Read access is safe
216if at least one of the following is true:
217 * filesystem has no cross-directory rename()
1da177e4
LT
218 * we know that parent had been locked (e.g. we are looking at
219->d_parent of ->lookup() argument).
220 * we are called from ->rename().
221 * the child's ->d_lock is held
222Audit your code and add locking if needed. Notice that any place that is
223not protected by the conditions above is risky even in the old tree - you
224had been relying on BKL and that's prone to screwups. Old tree had quite
225a few holes of that kind - unprotected access to ->d_parent leading to
226anything from oops to silent memory corruption.
227
228---
229[mandatory]
230
e462ec50 231 FS_NOMOUNT is gone. If you use it - just set SB_NOUSER in flags
1da177e4
LT
232(see rootfs for one kind of solution and bdev/socket/pipe for another).
233
234---
235[recommended]
236
237 Use bdev_read_only(bdev) instead of is_read_only(kdev). The latter
238is still alive, but only because of the mess in drivers/s390/block/dasd.c.
239As soon as it gets fixed is_read_only() will die.
240
241---
242[mandatory]
243
244->permission() is called without BKL now. Grab it on entry, drop upon
245return - that will guarantee the same locking you used to have. If
246your method or its parts do not need BKL - better yet, now you can
247shift lock_kernel() and unlock_kernel() so that they would protect
248exactly what needs to be protected.
249
250---
251[mandatory]
252
253->statfs() is now called without BKL held. BKL should have been
254shifted into individual fs sb_op functions where it's not clear that
255it's safe to remove it. If you don't need it, remove it.
256
257---
258[mandatory]
259
260 is_read_only() is gone; use bdev_read_only() instead.
261
262---
263[mandatory]
264
265 destroy_buffers() is gone; use invalidate_bdev().
266
267---
268[mandatory]
269
270 fsync_dev() is gone; use fsync_bdev(). NOTE: lvm breakage is
271deliberate; as soon as struct block_device * is propagated in a reasonable
272way by that code fixing will become trivial; until then nothing can be
273done.
1e231735
CH
274
275[mandatory]
276
277 block truncatation on error exit from ->write_begin, and ->direct_IO
278moved from generic methods (block_write_begin, cont_write_begin,
279nobh_write_begin, blockdev_direct_IO*) to callers. Take a look at
280ext2_write_failed and callers for an example.
281
282[mandatory]
283
b9f61c3c 284 ->truncate is gone. The whole truncate sequence needs to be
1e231735
CH
285implemented in ->setattr, which is now mandatory for filesystems
286implementing on-disk size changes. Start with a copy of the old inode_setattr
287and vmtruncate, and the reorder the vmtruncate + foofs_vmtruncate sequence to
288be in order of zeroing blocks using block_truncate_page or similar helpers,
289size update and on finally on-disk truncation which should not fail.
31051c85
JK
290setattr_prepare (which used to be inode_change_ok) now includes the size checks
291for ATTR_SIZE and must be called in the beginning of ->setattr unconditionally.
336fb3b9
AV
292
293[mandatory]
294
295 ->clear_inode() and ->delete_inode() are gone; ->evict_inode() should
296be used instead. It gets called whenever the inode is evicted, whether it has
297remaining links or not. Caller does *not* evict the pagecache or inode-associated
91b0abe3
JW
298metadata buffers; the method has to use truncate_inode_pages_final() to get rid
299of those. Caller makes sure async writeback cannot be running for the inode while
300(or after) ->evict_inode() is called.
f283c86a
DC
301
302 ->drop_inode() returns int now; it's called on final iput() with
303inode->i_lock held and it returns true if filesystems wants the inode to be
304dropped. As before, generic_drop_inode() is still the default and it's been
305updated appropriately. generic_delete_inode() is also alive and it consists
306simply of return 1. Note that all actual eviction work is done by caller after
307->drop_inode() returns.
308
dbd5768f
JK
309 As before, clear_inode() must be called exactly once on each call of
310->evict_inode() (as it used to be for each call of ->delete_inode()). Unlike
311before, if you are using inode-associated metadata buffers (i.e.
312mark_buffer_dirty_inode()), it's your responsibility to call
313invalidate_inode_buffers() before clear_inode().
336fb3b9
AV
314
315 NOTE: checking i_nlink in the beginning of ->write_inode() and bailing out
316if it's zero is not *and* *never* *had* *been* enough. Final unlink() and iput()
317may happen while the inode is in the middle of ->write_inode(); e.g. if you blindly
318free the on-disk inode, you may end up doing that while ->write_inode() is writing
319to it.
fe15ce44
NP
320
321---
322[mandatory]
323
324 .d_delete() now only advises the dcache as to whether or not to cache
325unreferenced dentries, and is now only called when the dentry refcount goes to
3260. Even on 0 refcount transition, it must be able to tolerate being called 0,
3271, or more times (eg. constant, idempotent).
621e155a
NP
328
329---
330[mandatory]
331
332 .d_compare() calling convention and locking rules are significantly
333changed. Read updated documentation in Documentation/filesystems/vfs.txt (and
334look at examples of other filesystems) for guidance.
b1e6a015
NP
335
336---
337[mandatory]
338
339 .d_hash() calling convention and locking rules are significantly
340changed. Read updated documentation in Documentation/filesystems/vfs.txt (and
341look at examples of other filesystems) for guidance.
b5c84bf6
NP
342
343---
344[mandatory]
345 dcache_lock is gone, replaced by fine grained locks. See fs/dcache.c
346for details of what locks to replace dcache_lock with in order to protect
347particular things. Most of the time, a filesystem only needs ->d_lock, which
348protects *all* the dcache state of a given dentry.
fa0d7e3d
NP
349
350--
351[mandatory]
352
353 Filesystems must RCU-free their inodes, if they can have been accessed
354via rcu-walk path walk (basically, if the file can have had a path name in the
355vfs namespace).
356
049b3c10
AV
357 Even though i_dentry and i_rcu share storage in a union, we will
358initialize the former in inode_init_always(), so just leave it alone in
359the callback. It used to be necessary to clean it there, but not anymore
360(starting at 3.2).
34286d66
NP
361
362--
363[recommended]
364 vfs now tries to do path walking in "rcu-walk mode", which avoids
365atomic operations and scalability hazards on dentries and inodes (see
a82416da
NP
366Documentation/filesystems/path-lookup.txt). d_hash and d_compare changes
367(above) are examples of the changes required to support this. For more complex
34286d66
NP
368filesystem callbacks, the vfs drops out of rcu-walk mode before the fs call, so
369no changes are required to the filesystem. However, this is costly and loses
370the benefits of rcu-walk mode. We will begin to add filesystem callbacks that
371are rcu-walk aware, shown below. Filesystems should take advantage of this
372where possible.
373
374--
375[mandatory]
376 d_revalidate is a callback that is made on every path element (if
377the filesystem provides it), which requires dropping out of rcu-walk mode. This
378may now be called in rcu-walk mode (nd->flags & LOOKUP_RCU). -ECHILD should be
379returned if the filesystem cannot handle rcu-walk. See
b74c79e9
NP
380Documentation/filesystems/vfs.txt for more details.
381
47016077
AG
382 permission is an inode permission check that is called on many or all
383directory inodes on the way down a path walk (to check for exec permission). It
384must now be rcu-walk aware (mask & MAY_NOT_BLOCK). See
385Documentation/filesystems/vfs.txt for more details.
92424157
JB
386
387--
388[mandatory]
389 In ->fallocate() you must check the mode option passed in. If your
390filesystem does not support hole punching (deallocating space in the middle of a
391file) you must return -EOPNOTSUPP if FALLOC_FL_PUNCH_HOLE is set in mode.
392Currently you can only have FALLOC_FL_PUNCH_HOLE with FALLOC_FL_KEEP_SIZE set,
393so the i_size should not change when hole punching, even when puching the end of
394a file off.
1a102ff9
AV
395
396--
397[mandatory]
398 ->get_sb() is gone. Switch to use of ->mount(). Typically it's just
399a matter of switching from calling get_sb_... to mount_... and changing the
400function type. If you were doing it manually, just switch from setting ->mnt_root
401to some pointer to returning that pointer. On errors return ERR_PTR(...).
76fe3276
AV
402
403--
404[mandatory]
4e34e719 405 ->permission() and generic_permission()have lost flags
76fe3276 406argument; instead of passing IPERM_FLAG_RCU we add MAY_NOT_BLOCK into mask.
4e34e719
CH
407 generic_permission() has also lost the check_acl argument; ACL checking
408has been taken to VFS and filesystems need to provide a non-NULL ->i_op->get_acl
409to read an ACL from disk.
982d8165
JB
410
411--
412[mandatory]
413 If you implement your own ->llseek() you must handle SEEK_HOLE and
414SEEK_DATA. You can hanle this by returning -EINVAL, but it would be nicer to
415support it in some way. The generic handler assumes that the entire file is
416data and there is a virtual hole at the end of the file. So if the provided
417offset is less than i_size and SEEK_DATA is specified, return the same offset.
418If the above is true for the offset and you are given SEEK_HOLE, return the end
419of the file. If the offset is i_size or greater return -ENXIO in either case.
02c24a82
JB
420
421[mandatory]
422 If you have your own ->fsync() you must make sure to call
423filemap_write_and_wait_range() so that all dirty pages are synced out properly.
424You must also keep in mind that ->fsync() is not called with i_mutex held
425anymore, so if you require i_mutex locking you must make sure to take it and
426release it yourself.
32991ab3
AV
427
428--
429[mandatory]
430 d_alloc_root() is gone, along with a lot of bugs caused by code
8811249f
IK
431misusing it. Replacement: d_make_root(inode). On success d_make_root(inode)
432allocates and returns a new dentry instantiated with the passed in inode.
433On failure NULL is returned and the passed in inode is dropped so the reference
434to inode is consumed in all cases and failure handling need not do any cleanup
435for the inode. If d_make_root(inode) is passed a NULL inode it returns NULL
436and also requires no further error handling. Typical usage is:
437
438 inode = foofs_new_inode(....);
1b03bc5c 439 s->s_root = d_make_root(inode);
8811249f
IK
440 if (!s->s_root)
441 /* Nothing needed for the inode cleanup */
442 return -ENOMEM;
443 ...
0b728e19
AV
444
445--
446[mandatory]
00cd8dd3
AV
447 The witch is dead! Well, 2/3 of it, anyway. ->d_revalidate() and
448->lookup() do *not* take struct nameidata anymore; just the flags.
ebfc3b49
AV
449--
450[mandatory]
451 ->create() doesn't take struct nameidata *; unlike the previous
452two, it gets "is it an O_EXCL or equivalent?" boolean argument. Note that
453local filesystems can ignore tha argument - they are guaranteed that the
454object doesn't exist. It's remote/distributed ones that might care...
ecf3d1f1
JL
455--
456[mandatory]
457 FS_REVAL_DOT is gone; if you used to have it, add ->d_weak_revalidate()
458in your dentry operations instead.
5c0ba4e0
AV
459--
460[mandatory]
461 vfs_readdir() is gone; switch to iterate_dir() instead
2233f31a
AV
462--
463[mandatory]
464 ->readdir() is gone now; switch to ->iterate()
4aa32895
CH
465[mandatory]
466 vfs_follow_link has been removed. Filesystems must use nd_set_link
467 from ->follow_link for normal symlinks, or nd_jump_link for magic
468 /proc/<pid> style links.
5a3cd992
AV
469--
470[mandatory]
471 iget5_locked()/ilookup5()/ilookup5_nowait() test() callback used to be
472 called with both ->i_lock and inode_hash_lock held; the former is *not*
473 taken anymore, so verify that your callbacks do not rely on it (none
474 of the in-tree instances did). inode_hash_lock is still held,
475 of course, so they are still serialized wrt removal from inode hash,
476 as well as wrt set() callback of iget5_locked().
41d28bca
AV
477--
478[mandatory]
479 d_materialise_unique() is gone; d_splice_alias() does everything you
480 need now. Remember that they have opposite orders of arguments ;-/
78d28e65
AV
481--
482[mandatory]
483 f_dentry is gone; use f_path.dentry, or, better yet, see if you can avoid
484 it entirely.
5d5d5689
AV
485--
486[mandatory]
487 never call ->read() and ->write() directly; use __vfs_{read,write} or
488 wrappers; instead of checking for ->write or ->read being NULL, look for
489 FMODE_CAN_{WRITE,READ} in file->f_mode.
490--
491[mandatory]
492 do _not_ use new_sync_{read,write} for ->read/->write; leave it NULL
493 instead.
84363182
AV
494--
495[mandatory]
496 ->aio_read/->aio_write are gone. Use ->read_iter/->write_iter.
203bc643
AV
497---
498[recommended]
499 for embedded ("fast") symlinks just set inode->i_link to wherever the
500 symlink body is and use simple_follow_link() as ->follow_link().
501--
502[mandatory]
503 calling conventions for ->follow_link() have changed. Instead of returning
504 cookie and using nd_set_link() to store the body to traverse, we return
505 the body to traverse and store the cookie using explicit void ** argument.
506 nameidata isn't passed at all - nd_jump_link() doesn't need it and
507 nd_[gs]et_link() is gone.
508--
509[mandatory]
510 calling conventions for ->put_link() have changed. It gets inode instead of
511 dentry, it does not get nameidata at all and it gets called only when cookie
512 is non-NULL. Note that link body isn't available anymore, so if you need it,
513 store it as cookie.
8a81252b 514--
21fc61c7
AV
515[mandatory]
516 any symlink that might use page_follow_link_light/page_put_link() must
517 have inode_nohighmem(inode) called before anything might start playing with
e8ecde25
AV
518 its pagecache. No highmem pages should end up in the pagecache of such
519 symlinks. That includes any preseeding that might be done during symlink
520 creation. __page_symlink() will honour the mapping gfp flags, so once
521 you've done inode_nohighmem() it's safe to use, but if you allocate and
522 insert the page manually, make sure to use the right gfp flags.
6b255391
AV
523--
524[mandatory]
525 ->follow_link() is replaced with ->get_link(); same API, except that
526 * ->get_link() gets inode as a separate argument
527 * ->get_link() may be called in RCU mode - in that case NULL
528 dentry is passed
fceef393
AV
529--
530[mandatory]
531 ->get_link() gets struct delayed_call *done now, and should do
532 set_delayed_call() where it used to set *cookie.
533 ->put_link() is gone - just give the destructor to set_delayed_call()
534 in ->get_link().
ce23e640
AV
535--
536[mandatory]
537 ->getxattr() and xattr_handler.get() get dentry and inode passed separately.
538 dentry might be yet to be attached to inode, so do _not_ use its ->d_inode
539 in the instances. Rationale: !@#!@# security_d_instantiate() needs to be
540 called before we attach dentry to inode.
84e710da
AV
541--
542[mandatory]
543 symlinks are no longer the only inodes that do *not* have i_bdev/i_cdev/
544 i_pipe/i_link union zeroed out at inode eviction. As the result, you can't
545 assume that non-NULL value in ->i_nlink at ->destroy_inode() implies that
546 it's a symlink. Checking ->i_mode is really needed now. In-tree we had
547 to fix shmem_destroy_callback() that used to take that kind of shortcut;
548 watch out, since that shortcut is no longer valid.
9902af79
AV
549--
550[mandatory]
551 ->i_mutex is replaced with ->i_rwsem now. inode_lock() et.al. work as
552 they used to - they just take it exclusive. However, ->lookup() may be
553 called with parent locked shared. Its instances must not
554 * use d_instantiate) and d_rehash() separately - use d_add() or
555 d_splice_alias() instead.
556 * use d_rehash() alone - call d_add(new_dentry, NULL) instead.
557 * in the unlikely case when (read-only) access to filesystem
558 data structures needs exclusion for some reason, arrange it
559 yourself. None of the in-tree filesystems needed that.
560 * rely on ->d_parent and ->d_name not changing after dentry has
561 been fed to d_add() or d_splice_alias(). Again, none of the
562 in-tree instances relied upon that.
563 We are guaranteed that lookups of the same name in the same directory
564 will not happen in parallel ("same" in the sense of your ->d_compare()).
565 Lookups on different names in the same directory can and do happen in
566 parallel now.
61922694
AV
567--
568[recommended]
569 ->iterate_shared() is added; it's a parallel variant of ->iterate().
570 Exclusion on struct file level is still provided (as well as that
571 between it and lseek on the same struct file), but if your directory
572 has been opened several times, you can get these called in parallel.
573 Exclusion between that method and all directory-modifying ones is
574 still provided, of course.
575
576 Often enough ->iterate() can serve as ->iterate_shared() without any
577 changes - it is a read-only operation, after all. If you have any
578 per-inode or per-dentry in-core data structures modified by ->iterate(),
579 you might need something to serialize the access to them. If you
580 do dcache pre-seeding, you'll need to switch to d_alloc_parallel() for
581 that; look for in-tree examples.
582
583 Old method is only used if the new one is absent; eventually it will
584 be removed. Switch while you still can; the old one won't stay.
9cf843e3
AV
585--
586[mandatory]
587 ->atomic_open() calls without O_CREAT may happen in parallel.
3767e255
AV
588--
589[mandatory]
590 ->setxattr() and xattr_handler.set() get dentry and inode passed separately.
591 dentry might be yet to be attached to inode, so do _not_ use its ->d_inode
592 in the instances. Rationale: !@#!@# security_d_instantiate() needs to be
593 called before we attach dentry to inode and !@#!@##!@$!$#!@#$!@$!@$ smack
594 ->d_instantiate() uses not just ->getxattr() but ->setxattr() as well.
6fa67e70
AV
595--
596[mandatory]
597 ->d_compare() doesn't get parent as a separate argument anymore. If you
598 used it for finding the struct super_block involved, dentry->d_sb will
599 work just as well; if it's something more complicated, use dentry->d_parent.
600 Just be careful not to assume that fetching it more than once will yield
601 the same value - in RCU mode it could change under you.
aadfa801
MS
602--
603[mandatory]
604 ->rename() has an added flags argument. Any flags not handled by the
605 filesystem should result in EINVAL being returned.
76fca90e
MS
606--
607[recommended]
608 ->readlink is optional for symlinks. Don't set, unless filesystem needs
609 to fake something for readlink(2).
75dd7e4b
EB
610--
611[mandatory]
612 ->getattr() is now passed a struct path rather than a vfsmount and
613 dentry separately, and it now has request_mask and query_flags arguments
614 to specify the fields and sync type requested by statx. Filesystems not
615 supporting any statx-specific features may ignore the new arguments.
6c9b1de1
AV
616--
617[mandatory]
618 ->atomic_open() calling conventions have changed. Gone is int *opened,
619 along with FILE_OPENED/FILE_CREATED. In place of those we have
620 FMODE_OPENED/FMODE_CREATED, set in file->f_mode. Additionally, return
621 value for 'called finish_no_open(), open it yourself' case has become
622 0, not 1. Since finish_no_open() itself is returning 0 now, that part
623 does not need any changes in ->atomic_open() instances.
5014c2f3
AV
624--
625[mandatory]
626 alloc_file() has become static now; two wrappers are to be used instead.
627 alloc_file_pseudo(inode, vfsmount, name, flags, ops) is for the cases
628 when dentry needs to be created; that's the majority of old alloc_file()
629 users. Calling conventions: on success a reference to new struct file
630 is returned and callers reference to inode is subsumed by that. On
631 failure, ERR_PTR() is returned and no caller's references are affected,
632 so the caller needs to drop the inode reference it held.
633 alloc_file_clone(file, flags, ops) does not affect any caller's references.
634 On success you get a new struct file sharing the mount/dentry with the
635 original, on failure - ERR_PTR().
1a16dbaf 636--
2e5dfc99
DW
637[mandatory]
638 ->clone_file_range() and ->dedupe_file_range have been replaced with
639 ->remap_file_range(). See Documentation/filesystems/vfs.txt for more
640 information.
c2aa1a44 641--
1a16dbaf
AV
642[recommended]
643 ->lookup() instances doing an equivalent of
644 if (IS_ERR(inode))
645 return ERR_CAST(inode);
646 return d_splice_alias(inode, dentry);
647 don't need to bother with the check - d_splice_alias() will do the
648 right thing when given ERR_PTR(...) as inode. Moreover, passing NULL
649 inode to d_splice_alias() will also do the right thing (equivalent of
650 d_add(dentry, NULL); return NULL;), so that kind of special cases
651 also doesn't need a separate treatment.
fdb0da89
AV
652--
653[strongly recommended]
654 take the RCU-delayed parts of ->destroy_inode() into a new method -
655 ->free_inode(). If ->destroy_inode() becomes empty - all the better,
656 just get rid of it. Synchronous work (e.g. the stuff that can't
657 be done from an RCU callback, or any WARN_ON() where we want the
658 stack trace) *might* be movable to ->evict_inode(); however,
659 that goes only for the things that are not needed to balance something
660 done by ->alloc_inode(). IOW, if it's cleaning up the stuff that
661 might have accumulated over the life of in-core inode, ->evict_inode()
662 might be a fit.
663
664 Rules for inode destruction:
665 * if ->destroy_inode() is non-NULL, it gets called
666 * if ->free_inode() is non-NULL, it gets scheduled by call_rcu()
667 * combination of NULL ->destroy_inode and NULL ->free_inode is
668 treated as NULL/free_inode_nonrcu, to preserve the compatibility.
669
670 Note that the callback (be it via ->free_inode() or explicit call_rcu()
671 in ->destroy_inode()) is *NOT* ordered wrt superblock destruction;
672 as the matter of fact, the superblock and all associated structures
673 might be already gone. The filesystem driver is guaranteed to be still
674 there, but that's it. Freeing memory in the callback is fine; doing
675 more than that is possible, but requires a lot of care and is best
676 avoided.
78438ce1 677--
5467a68c
AV
678[mandatory]
679 DCACHE_RCUACCESS is gone; having an RCU delay on dentry freeing is the
680 default. DCACHE_NORCU opts out, and only d_alloc_pseudo() has any
681 business doing so.
ab1152dd
AV
682--
683[mandatory]
684 d_alloc_pseudo() is internal-only; uses outside of alloc_file_pseudo() are
685 very suspect (and won't work in modules). Such uses are very likely to
686 be misspelled d_alloc_anon().