← Documents Documentation/filesystems/porting.rst GitHub 원문 ↗

Linux 6.18.37 · Filesystems

Filesystem porting guide

Linux 2.5.0 이후 VFS callback, locking, inode·dentry 수명과 최신 path helper 변경을 누적한 porting guide의 전문 번역입니다.

Source pathDocumentation/filesystems/porting.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

porting.rst:1-1311

이 문서는 Linux 2.5.0 이후 VFS와 filesystem callback의 변경 사항을 누적한 porting checklist다. 최신 API만 설명하는 단일 시점의 설계 문서가 아니라, BKL 제거부터 RCU pathname walk, parallel directory lookup, block-device holder, qstr lookup, `mmap_prepare()`까지 여러 세대의 migration 기록을 시간순으로 보존한다.

각 항목의 `mandatory`, `recommended`, `informational`, `strongly recommended`, `highly recommended` 등급을 원문 그대로 유지했다. 함수명, callback signature, lock 보유 조건, reference 소유권, 오류 반환값은 driver porting에서 직접 사용되는 계약이므로 번역에서도 symbol을 바꾸지 않았다.

핵심 흐름은 전역 잠금과 암묵적 수명 보장을 제거하고, 객체별 lock·RCU 지연 해제·명시적 caller 책임으로 옮기는 것이다. 오래된 중간 API도 현재 source에 남아 있는 역사적 migration 단계로서 생략하지 않았으며, 실제 새 코드는 현재 `Documentation/filesystems/vfs.rst`와 각 선언을 함께 확인해야 한다.

Filesystem porting의 큰 흐름
BKL과 전역 dcache lock 제거inode·dentry 전용 allocator와 RCU 수명 도입mount·lookup·symlink callback signature 정리parallel lookup·iterate·atomic_open 허용block device ownership을 superblock에 귀속qstr·path·descriptor 중심 helper로 전환

암묵적 전역 규약을 명시적인 객체 수명·반환값·병렬성 계약으로 바꿔 왔다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 ====================
2 Changes since 2.5.0:
3 ====================
4
5 ---
6
7 **recommended**
8
9 New helpers: sb_bread(), sb_getblk(), sb_find_get_block(), set_bh(),
10 sb_set_blocksize() and sb_min_blocksize().
11
12 Use them.
13
14 (sb_find_get_block() replaces 2.4's get_hash_table())
15
16 ---
17
18 **recommended**
19
20 New methods: ->alloc_inode() and ->destroy_inode().
21
22 Remove inode->u.foo_inode_i
23
24 Declare::
25
26 struct foo_inode_info {
27 /* fs-private stuff */
28 struct inode vfs_inode;
29 };
30 static inline struct foo_inode_info *FOO_I(struct inode *inode)
31 {
32 return list_entry(inode, struct foo_inode_info, vfs_inode);
33 }
34
35 Use FOO_I(inode) instead of &inode->u.foo_inode_i;
36
37 Add foo_alloc_inode() and foo_destroy_inode() - the former should allocate
38 foo_inode_info and return the address of ->vfs_inode, the latter should free
39 FOO_I(inode) (see in-tree filesystems for examples).
40
41 Make them ->alloc_inode and ->destroy_inode in your super_operations.
42
43 Keep in mind that now you need explicit initialization of private data
44 typically between calling iget_locked() and unlocking the inode.
45
46 At some point that will become mandatory.
47
48 **mandatory**
49
50 The foo_inode_info should always be allocated through alloc_inode_sb() rather
51 than kmem_cache_alloc() or kmalloc() related to set up the inode reclaim context
52 correctly.
53
54 ---
55
56 **mandatory**
57
58 Change of file_system_type method (->read_super to ->get_sb)
59
60 ->read_super() is no more. Ditto for DECLARE_FSTYPE and DECLARE_FSTYPE_DEV.
61
62 Turn your foo_read_super() into a function that would return 0 in case of
63 success and negative number in case of error (-EINVAL unless you have more
64 informative error value to report). Call it foo_fill_super(). Now declare::
65
66 int foo_get_sb(struct file_system_type *fs_type,
67 int flags, const char *dev_name, void *data, struct vfsmount *mnt)
68 {
69 return get_sb_bdev(fs_type, flags, dev_name, data, foo_fill_super,
70 mnt);
71 }
72
73 (or similar with s/bdev/nodev/ or s/bdev/single/, depending on the kind of
74 filesystem).
75
76 Replace DECLARE_FSTYPE... with explicit initializer and have ->get_sb set as
77 foo_get_sb.
78
79 ---
80
81 **mandatory**
82
83 Locking change: ->s_vfs_rename_sem is taken only by cross-directory renames.
84 Most likely there is no need to change anything, but if you relied on
85 global exclusion between renames for some internal purpose - you need to
86 change your internal locking. Otherwise exclusion warranties remain the
87 same (i.e. parents and victim are locked, etc.).
88
89 ---
90
91 **informational**
92
93 Now we have the exclusion between ->lookup() and directory removal (by
94 ->rmdir() and ->rename()). If you used to need that exclusion and do
95 it by internal locking (most of filesystems couldn't care less) - you
96 can relax your locking.
97
98 ---
99
100 **mandatory**
101
102 ->lookup(), ->truncate(), ->create(), ->unlink(), ->mknod(), ->mkdir(),
103 ->rmdir(), ->link(), ->lseek(), ->symlink(), ->rename()
104 and ->readdir() are called without BKL now. Grab it on entry, drop upon return
105 - that will guarantee the same locking you used to have. If your method or its
106 parts do not need BKL - better yet, now you can shift lock_kernel() and
107 unlock_kernel() so that they would protect exactly what needs to be
108 protected.
109
110 ---
111
112 **mandatory**
113
114 BKL is also moved from around sb operations. BKL should have been shifted into
115 individual fs sb_op functions. If you don't need it, remove it.
116
117 ---
118
119 **informational**
120
121 check for ->link() target not being a directory is done by callers. Feel
122 free to drop it...
123
124 ---
125
126 **informational**
127
128 ->link() callers hold ->i_mutex on the object we are linking to. Some of your
129 problems might be over...
130
131 ---
132
133 **mandatory**
134
135 new file_system_type method - kill_sb(superblock). If you are converting
136 an existing filesystem, set it according to ->fs_flags::
137
138 FS_REQUIRES_DEV - kill_block_super
139 FS_LITTER - kill_litter_super
140 neither - kill_anon_super
141
142 FS_LITTER is gone - just remove it from fs_flags.
143
144 ---
145
146 **mandatory**
147
148 FS_SINGLE is gone (actually, that had happened back when ->get_sb()
149 went in - and hadn't been documented ;-/). Just remove it from fs_flags
150 (and see ->get_sb() entry for other actions).
151
152 ---
153
154 **mandatory**
155
156 ->setattr() is called without BKL now. Caller _always_ holds ->i_mutex, so
157 watch for ->i_mutex-grabbing code that might be used by your ->setattr().
158 Callers of notify_change() need ->i_mutex now.
159
160 ---
161
162 **recommended**
163
164 New super_block field ``struct export_operations *s_export_op`` for
165 explicit support for exporting, e.g. via NFS. The structure is fully
166 documented at its declaration in include/linux/fs.h, and in
167 Documentation/filesystems/nfs/exporting.rst.
168
169 Briefly it allows for the definition of decode_fh and encode_fh operations
170 to encode and decode filehandles, and allows the filesystem to use
171 a standard helper function for decode_fh, and provide file-system specific
172 support for this helper, particularly get_parent.
173
174 It is planned that this will be required for exporting once the code
175 settles down a bit.
176
177 **mandatory**
178
179 s_export_op is now required for exporting a filesystem.
180 isofs, ext2, ext3, fat
181 can be used as examples of very different filesystems.
182
183 ---
184
185 **mandatory**
186
187 iget4() and the read_inode2 callback have been superseded by iget5_locked()
188 which has the following prototype::
189
190 struct inode *iget5_locked(struct super_block *sb, unsigned long ino,
191 int (*test)(struct inode *, void *),
192 int (*set)(struct inode *, void *),
193 void *data);
194
195 'test' is an additional function that can be used when the inode
196 number is not sufficient to identify the actual file object. 'set'
197 should be a non-blocking function that initializes those parts of a
198 newly created inode to allow the test function to succeed. 'data' is
199 passed as an opaque value to both test and set functions.
200
201 When the inode has been created by iget5_locked(), it will be returned with the
202 I_NEW flag set and will still be locked. The filesystem then needs to finalize
203 the initialization. Once the inode is initialized it must be unlocked by
204 calling unlock_new_inode().
205
206 The filesystem is responsible for setting (and possibly testing) i_ino
207 when appropriate. There is also a simpler iget_locked function that
208 just takes the superblock and inode number as arguments and does the
209 test and set for you.
210
211 e.g.::
212
213 inode = iget_locked(sb, ino);
214 if (inode->i_state & I_NEW) {
215 err = read_inode_from_disk(inode);
216 if (err < 0) {
217 iget_failed(inode);
218 return err;
219 }
220 unlock_new_inode(inode);
221 }
222
223 Note that if the process of setting up a new inode fails, then iget_failed()
224 should be called on the inode to render it dead, and an appropriate error
225 should be passed back to the caller.
226
227 ---
228
229 **recommended**
230
231 ->getattr() finally getting used. See instances in nfs, minix, etc.
232
233 ---
234
235 **mandatory**
236
237 ->revalidate() is gone. If your filesystem had it - provide ->getattr()
238 and let it call whatever you had as ->revlidate() + (for symlinks that
239 had ->revalidate()) add calls in ->follow_link()/->readlink().
240
241 ---
242
243 **mandatory**
244
245 ->d_parent changes are not protected by BKL anymore. Read access is safe
246 if at least one of the following is true:
247
248 * filesystem has no cross-directory rename()
249 * we know that parent had been locked (e.g. we are looking at
250 ->d_parent of ->lookup() argument).
251 * we are called from ->rename().
252 * the child's ->d_lock is held
253
254 Audit your code and add locking if needed. Notice that any place that is
255 not protected by the conditions above is risky even in the old tree - you
256 had been relying on BKL and that's prone to screwups. Old tree had quite
257 a few holes of that kind - unprotected access to ->d_parent leading to
258 anything from oops to silent memory corruption.
259
260 ---
261
262 **mandatory**
263
264 FS_NOMOUNT is gone. If you use it - just set SB_NOUSER in flags
265 (see rootfs for one kind of solution and bdev/socket/pipe for another).
266
267 ---
268
269 **recommended**
270
271 Use bdev_read_only(bdev) instead of is_read_only(kdev). The latter
272 is still alive, but only because of the mess in drivers/s390/block/dasd.c.
273 As soon as it gets fixed is_read_only() will die.
274
275 ---
276
277 **mandatory**
278
279 ->permission() is called without BKL now. Grab it on entry, drop upon
280 return - that will guarantee the same locking you used to have. If
281 your method or its parts do not need BKL - better yet, now you can
282 shift lock_kernel() and unlock_kernel() so that they would protect
283 exactly what needs to be protected.
284
285 ---
286
287 **mandatory**
288
289 ->statfs() is now called without BKL held. BKL should have been
290 shifted into individual fs sb_op functions where it's not clear that
291 it's safe to remove it. If you don't need it, remove it.
292
293 ---
294
295 **mandatory**
296
297 is_read_only() is gone; use bdev_read_only() instead.
298
299 ---
300
301 **mandatory**
302
303 destroy_buffers() is gone; use invalidate_bdev().
304
305 ---
306
307 **mandatory**
308
309 fsync_dev() is gone; use fsync_bdev(). NOTE: lvm breakage is
310 deliberate; as soon as struct block_device * is propagated in a reasonable
311 way by that code fixing will become trivial; until then nothing can be
312 done.
313
314 **mandatory**
315
316 block truncation on error exit from ->write_begin, and ->direct_IO
317 moved from generic methods (block_write_begin, cont_write_begin,
318 nobh_write_begin, blockdev_direct_IO*) to callers. Take a look at
319 ext2_write_failed and callers for an example.
320
321 **mandatory**
322
323 ->truncate is gone. The whole truncate sequence needs to be
324 implemented in ->setattr, which is now mandatory for filesystems
325 implementing on-disk size changes. Start with a copy of the old inode_setattr
326 and vmtruncate, and the reorder the vmtruncate + foofs_vmtruncate sequence to
327 be in order of zeroing blocks using block_truncate_page or similar helpers,
328 size update and on finally on-disk truncation which should not fail.
329 setattr_prepare (which used to be inode_change_ok) now includes the size checks
330 for ATTR_SIZE and must be called in the beginning of ->setattr unconditionally.
331
332 **mandatory**
333
334 ->clear_inode() and ->delete_inode() are gone; ->evict_inode() should
335 be used instead. It gets called whenever the inode is evicted, whether it has
336 remaining links or not. Caller does *not* evict the pagecache or inode-associated
337 metadata buffers; the method has to use truncate_inode_pages_final() to get rid
338 of those. Caller makes sure async writeback cannot be running for the inode while
339 (or after) ->evict_inode() is called.
340
341 ->drop_inode() returns int now; it's called on final iput() with
342 inode->i_lock held and it returns true if filesystems wants the inode to be
343 dropped. As before, inode_generic_drop() is still the default and it's been
344 updated appropriately. inode_just_drop() is also alive and it consists
345 simply of return 1. Note that all actual eviction work is done by caller after
346 ->drop_inode() returns.
347
348 As before, clear_inode() must be called exactly once on each call of
349 ->evict_inode() (as it used to be for each call of ->delete_inode()). Unlike
350 before, if you are using inode-associated metadata buffers (i.e.
351 mark_buffer_dirty_inode()), it's your responsibility to call
352 invalidate_inode_buffers() before clear_inode().
353
354 NOTE: checking i_nlink in the beginning of ->write_inode() and bailing out
355 if it's zero is not *and* *never* *had* *been* enough. Final unlink() and iput()
356 may happen while the inode is in the middle of ->write_inode(); e.g. if you blindly
357 free the on-disk inode, you may end up doing that while ->write_inode() is writing
358 to it.
359
360 ---
361
362 **mandatory**
363
364 .d_delete() now only advises the dcache as to whether or not to cache
365 unreferenced dentries, and is now only called when the dentry refcount goes to
366 0. Even on 0 refcount transition, it must be able to tolerate being called 0,
367 1, or more times (eg. constant, idempotent).
368
369 ---
370
371 **mandatory**
372
373 .d_compare() calling convention and locking rules are significantly
374 changed. Read updated documentation in Documentation/filesystems/vfs.rst (and
375 look at examples of other filesystems) for guidance.
376
377 ---
378
379 **mandatory**
380
381 .d_hash() calling convention and locking rules are significantly
382 changed. Read updated documentation in Documentation/filesystems/vfs.rst (and
383 look at examples of other filesystems) for guidance.
384
385 ---
386
387 **mandatory**
388
389 dcache_lock is gone, replaced by fine grained locks. See fs/dcache.c
390 for details of what locks to replace dcache_lock with in order to protect
391 particular things. Most of the time, a filesystem only needs ->d_lock, which
392 protects *all* the dcache state of a given dentry.
393
394 ---
395
396 **mandatory**
397
398 Filesystems must RCU-free their inodes, if they can have been accessed
399 via rcu-walk path walk (basically, if the file can have had a path name in the
400 vfs namespace).
401
402 Even though i_dentry and i_rcu share storage in a union, we will
403 initialize the former in inode_init_always(), so just leave it alone in
404 the callback. It used to be necessary to clean it there, but not anymore
405 (starting at 3.2).
406
407 ---
408
409 **recommended**
410
411 vfs now tries to do path walking in "rcu-walk mode", which avoids
412 atomic operations and scalability hazards on dentries and inodes (see
413 Documentation/filesystems/path-lookup.txt). d_hash and d_compare changes
414 (above) are examples of the changes required to support this. For more complex
415 filesystem callbacks, the vfs drops out of rcu-walk mode before the fs call, so
416 no changes are required to the filesystem. However, this is costly and loses
417 the benefits of rcu-walk mode. We will begin to add filesystem callbacks that
418 are rcu-walk aware, shown below. Filesystems should take advantage of this
419 where possible.
420
421 ---
422
423 **mandatory**
424
425 d_revalidate is a callback that is made on every path element (if
426 the filesystem provides it), which requires dropping out of rcu-walk mode. This
427 may now be called in rcu-walk mode (nd->flags & LOOKUP_RCU). -ECHILD should be
428 returned if the filesystem cannot handle rcu-walk. See
429 Documentation/filesystems/vfs.rst for more details.
430
431 permission is an inode permission check that is called on many or all
432 directory inodes on the way down a path walk (to check for exec permission). It
433 must now be rcu-walk aware (mask & MAY_NOT_BLOCK). See
434 Documentation/filesystems/vfs.rst for more details.
435
436 ---
437
438 **mandatory**
439
440 In ->fallocate() you must check the mode option passed in. If your
441 filesystem does not support hole punching (deallocating space in the middle of a
442 file) you must return -EOPNOTSUPP if FALLOC_FL_PUNCH_HOLE is set in mode.
443 Currently you can only have FALLOC_FL_PUNCH_HOLE with FALLOC_FL_KEEP_SIZE set,
444 so the i_size should not change when hole punching, even when puching the end of
445 a file off.
446
447 ---
448
449 **mandatory**
450
451 ->get_sb() is gone. Switch to use of ->mount(). Typically it's just
452 a matter of switching from calling ``get_sb_``... to ``mount_``... and changing
453 the function type. If you were doing it manually, just switch from setting
454 ->mnt_root to some pointer to returning that pointer. On errors return
455 ERR_PTR(...).
456
457 ---
458
459 **mandatory**
460
461 ->permission() and generic_permission()have lost flags
462 argument; instead of passing IPERM_FLAG_RCU we add MAY_NOT_BLOCK into mask.
463
464 generic_permission() has also lost the check_acl argument; ACL checking
465 has been taken to VFS and filesystems need to provide a non-NULL
466 ->i_op->get_inode_acl to read an ACL from disk.
467
468 ---
469
470 **mandatory**
471
472 If you implement your own ->llseek() you must handle SEEK_HOLE and
473 SEEK_DATA. You can handle this by returning -EINVAL, but it would be nicer to
474 support it in some way. The generic handler assumes that the entire file is
475 data and there is a virtual hole at the end of the file. So if the provided
476 offset is less than i_size and SEEK_DATA is specified, return the same offset.
477 If the above is true for the offset and you are given SEEK_HOLE, return the end
478 of the file. If the offset is i_size or greater return -ENXIO in either case.
479
480 **mandatory**
481
482 If you have your own ->fsync() you must make sure to call
483 filemap_write_and_wait_range() so that all dirty pages are synced out properly.
484 You must also keep in mind that ->fsync() is not called with i_mutex held
485 anymore, so if you require i_mutex locking you must make sure to take it and
486 release it yourself.
487
488 ---
489
490 **mandatory**
491
492 d_alloc_root() is gone, along with a lot of bugs caused by code
493 misusing it. Replacement: d_make_root(inode). On success d_make_root(inode)
494 allocates and returns a new dentry instantiated with the passed in inode.
495 On failure NULL is returned and the passed in inode is dropped so the reference
496 to inode is consumed in all cases and failure handling need not do any cleanup
497 for the inode. If d_make_root(inode) is passed a NULL inode it returns NULL
498 and also requires no further error handling. Typical usage is::
499
500 inode = foofs_new_inode(....);
501 s->s_root = d_make_root(inode);
502 if (!s->s_root)
503 /* Nothing needed for the inode cleanup */
504 return -ENOMEM;
505 ...
506
507 ---
508
509 **mandatory**
510
511 The witch is dead! Well, 2/3 of it, anyway. ->d_revalidate() and
512 ->lookup() do *not* take struct nameidata anymore; just the flags.
513
514 ---
515
516 **mandatory**
517
518 ->create() doesn't take ``struct nameidata *``; unlike the previous
519 two, it gets "is it an O_EXCL or equivalent?" boolean argument. Note that
520 local filesystems can ignore this argument - they are guaranteed that the
521 object doesn't exist. It's remote/distributed ones that might care...
522
523 ---
524
525 **mandatory**
526
527 FS_REVAL_DOT is gone; if you used to have it, add ->d_weak_revalidate()
528 in your dentry operations instead.
529
530 ---
531
532 **mandatory**
533
534 vfs_readdir() is gone; switch to iterate_dir() instead
535
536 ---
537
538 **mandatory**
539
540 ->readdir() is gone now; switch to ->iterate_shared()
541
542 **mandatory**
543
544 vfs_follow_link has been removed. Filesystems must use nd_set_link
545 from ->follow_link for normal symlinks, or nd_jump_link for magic
546 /proc/<pid> style links.
547
548 ---
549
550 **mandatory**
551
552 iget5_locked()/ilookup5()/ilookup5_nowait() test() callback used to be
553 called with both ->i_lock and inode_hash_lock held; the former is *not*
554 taken anymore, so verify that your callbacks do not rely on it (none
555 of the in-tree instances did). inode_hash_lock is still held,
556 of course, so they are still serialized wrt removal from inode hash,
557 as well as wrt set() callback of iget5_locked().
558
559 ---
560
561 **mandatory**
562
563 d_materialise_unique() is gone; d_splice_alias() does everything you
564 need now. Remember that they have opposite orders of arguments ;-/
565
566 ---
567
568 **mandatory**
569
570 f_dentry is gone; use f_path.dentry, or, better yet, see if you can avoid
571 it entirely.
572
573 ---
574
575 **mandatory**
576
577 never call ->read() and ->write() directly; use __vfs_{read,write} or
578 wrappers; instead of checking for ->write or ->read being NULL, look for
579 FMODE_CAN_{WRITE,READ} in file->f_mode.
580
581 ---
582
583 **mandatory**
584
585 do _not_ use new_sync_{read,write} for ->read/->write; leave it NULL
586 instead.
587
588 ---
589
590 **mandatory**
591 ->aio_read/->aio_write are gone. Use ->read_iter/->write_iter.
592
593 ---
594
595 **recommended**
596
597 for embedded ("fast") symlinks just set inode->i_link to wherever the
598 symlink body is and use simple_follow_link() as ->follow_link().
599
600 ---
601
602 **mandatory**
603
604 calling conventions for ->follow_link() have changed. Instead of returning
605 cookie and using nd_set_link() to store the body to traverse, we return
606 the body to traverse and store the cookie using explicit void ** argument.
607 nameidata isn't passed at all - nd_jump_link() doesn't need it and
608 nd_[gs]et_link() is gone.
609
610 ---
611
612 **mandatory**
613
614 calling conventions for ->put_link() have changed. It gets inode instead of
615 dentry, it does not get nameidata at all and it gets called only when cookie
616 is non-NULL. Note that link body isn't available anymore, so if you need it,
617 store it as cookie.
618
619 ---
620
621 **mandatory**
622
623 any symlink that might use page_follow_link_light/page_put_link() must
624 have inode_nohighmem(inode) called before anything might start playing with
625 its pagecache. No highmem pages should end up in the pagecache of such
626 symlinks. That includes any preseeding that might be done during symlink
627 creation. page_symlink() will honour the mapping gfp flags, so once
628 you've done inode_nohighmem() it's safe to use, but if you allocate and
629 insert the page manually, make sure to use the right gfp flags.
630
631 ---
632
633 **mandatory**
634
635 ->follow_link() is replaced with ->get_link(); same API, except that
636
637 * ->get_link() gets inode as a separate argument
638 * ->get_link() may be called in RCU mode - in that case NULL
639 dentry is passed
640
641 ---
642
643 **mandatory**
644
645 ->get_link() gets struct delayed_call ``*done`` now, and should do
646 set_delayed_call() where it used to set ``*cookie``.
647
648 ->put_link() is gone - just give the destructor to set_delayed_call()
649 in ->get_link().
650
651 ---
652
653 **mandatory**
654
655 ->getxattr() and xattr_handler.get() get dentry and inode passed separately.
656 dentry might be yet to be attached to inode, so do _not_ use its ->d_inode
657 in the instances. Rationale: !@#!@# security_d_instantiate() needs to be
658 called before we attach dentry to inode.
659
660 ---
661
662 **mandatory**
663
664 symlinks are no longer the only inodes that do *not* have i_bdev/i_cdev/
665 i_pipe/i_link union zeroed out at inode eviction. As the result, you can't
666 assume that non-NULL value in ->i_nlink at ->destroy_inode() implies that
667 it's a symlink. Checking ->i_mode is really needed now. In-tree we had
668 to fix shmem_destroy_callback() that used to take that kind of shortcut;
669 watch out, since that shortcut is no longer valid.
670
671 ---
672
673 **mandatory**
674
675 ->i_mutex is replaced with ->i_rwsem now. inode_lock() et.al. work as
676 they used to - they just take it exclusive. However, ->lookup() may be
677 called with parent locked shared. Its instances must not
678
679 * use d_instantiate) and d_rehash() separately - use d_add() or
680 d_splice_alias() instead.
681 * use d_rehash() alone - call d_add(new_dentry, NULL) instead.
682 * in the unlikely case when (read-only) access to filesystem
683 data structures needs exclusion for some reason, arrange it
684 yourself. None of the in-tree filesystems needed that.
685 * rely on ->d_parent and ->d_name not changing after dentry has
686 been fed to d_add() or d_splice_alias(). Again, none of the
687 in-tree instances relied upon that.
688
689 We are guaranteed that lookups of the same name in the same directory
690 will not happen in parallel ("same" in the sense of your ->d_compare()).
691 Lookups on different names in the same directory can and do happen in
692 parallel now.
693
694 ---
695
696 **mandatory**
697
698 ->iterate_shared() is added.
699 Exclusion on struct file level is still provided (as well as that
700 between it and lseek on the same struct file), but if your directory
701 has been opened several times, you can get these called in parallel.
702 Exclusion between that method and all directory-modifying ones is
703 still provided, of course.
704
705 If you have any per-inode or per-dentry in-core data structures modified
706 by ->iterate_shared(), you might need something to serialize the access
707 to them. If you do dcache pre-seeding, you'll need to switch to
708 d_alloc_parallel() for that; look for in-tree examples.
709
710 ---
711
712 **mandatory**
713
714 ->atomic_open() calls without O_CREAT may happen in parallel.
715
716 ---
717
718 **mandatory**
719
720 ->setxattr() and xattr_handler.set() get dentry and inode passed separately.
721 The xattr_handler.set() gets passed the user namespace of the mount the inode
722 is seen from so filesystems can idmap the i_uid and i_gid accordingly.
723 dentry might be yet to be attached to inode, so do _not_ use its ->d_inode
724 in the instances. Rationale: !@#!@# security_d_instantiate() needs to be
725 called before we attach dentry to inode and !@#!@##!@$!$#!@#$!@$!@$ smack
726 ->d_instantiate() uses not just ->getxattr() but ->setxattr() as well.
727
728 ---
729
730 **mandatory**
731
732 ->d_compare() doesn't get parent as a separate argument anymore. If you
733 used it for finding the struct super_block involved, dentry->d_sb will
734 work just as well; if it's something more complicated, use dentry->d_parent.
735 Just be careful not to assume that fetching it more than once will yield
736 the same value - in RCU mode it could change under you.
737
738 ---
739
740 **mandatory**
741
742 ->rename() has an added flags argument. Any flags not handled by the
743 filesystem should result in EINVAL being returned.
744
745 ---
746
747
748 **recommended**
749
750 ->readlink is optional for symlinks. Don't set, unless filesystem needs
751 to fake something for readlink(2).
752
753 ---
754
755 **mandatory**
756
757 ->getattr() is now passed a struct path rather than a vfsmount and
758 dentry separately, and it now has request_mask and query_flags arguments
759 to specify the fields and sync type requested by statx. Filesystems not
760 supporting any statx-specific features may ignore the new arguments.
761
762 ---
763
764 **mandatory**
765
766 ->atomic_open() calling conventions have changed. Gone is ``int *opened``,
767 along with FILE_OPENED/FILE_CREATED. In place of those we have
768 FMODE_OPENED/FMODE_CREATED, set in file->f_mode. Additionally, return
769 value for 'called finish_no_open(), open it yourself' case has become
770 0, not 1. Since finish_no_open() itself is returning 0 now, that part
771 does not need any changes in ->atomic_open() instances.
772
773 ---
774
775 **mandatory**
776
777 alloc_file() has become static now; two wrappers are to be used instead.
778 alloc_file_pseudo(inode, vfsmount, name, flags, ops) is for the cases
779 when dentry needs to be created; that's the majority of old alloc_file()
780 users. Calling conventions: on success a reference to new struct file
781 is returned and callers reference to inode is subsumed by that. On
782 failure, ERR_PTR() is returned and no caller's references are affected,
783 so the caller needs to drop the inode reference it held.
784 alloc_file_clone(file, flags, ops) does not affect any caller's references.
785 On success you get a new struct file sharing the mount/dentry with the
786 original, on failure - ERR_PTR().
787
788 ---
789
790 **mandatory**
791
792 ->clone_file_range() and ->dedupe_file_range have been replaced with
793 ->remap_file_range(). See Documentation/filesystems/vfs.rst for more
794 information.
795
796 ---
797
798 **recommended**
799
800 ->lookup() instances doing an equivalent of::
801
802 if (IS_ERR(inode))
803 return ERR_CAST(inode);
804 return d_splice_alias(inode, dentry);
805
806 don't need to bother with the check - d_splice_alias() will do the
807 right thing when given ERR_PTR(...) as inode. Moreover, passing NULL
808 inode to d_splice_alias() will also do the right thing (equivalent of
809 d_add(dentry, NULL); return NULL;), so that kind of special cases
810 also doesn't need a separate treatment.
811
812 ---
813
814 **strongly recommended**
815
816 take the RCU-delayed parts of ->destroy_inode() into a new method -
817 ->free_inode(). If ->destroy_inode() becomes empty - all the better,
818 just get rid of it. Synchronous work (e.g. the stuff that can't
819 be done from an RCU callback, or any WARN_ON() where we want the
820 stack trace) *might* be movable to ->evict_inode(); however,
821 that goes only for the things that are not needed to balance something
822 done by ->alloc_inode(). IOW, if it's cleaning up the stuff that
823 might have accumulated over the life of in-core inode, ->evict_inode()
824 might be a fit.
825
826 Rules for inode destruction:
827
828 * if ->destroy_inode() is non-NULL, it gets called
829 * if ->free_inode() is non-NULL, it gets scheduled by call_rcu()
830 * combination of NULL ->destroy_inode and NULL ->free_inode is
831 treated as NULL/free_inode_nonrcu, to preserve the compatibility.
832
833 Note that the callback (be it via ->free_inode() or explicit call_rcu()
834 in ->destroy_inode()) is *NOT* ordered wrt superblock destruction;
835 as the matter of fact, the superblock and all associated structures
836 might be already gone. The filesystem driver is guaranteed to be still
837 there, but that's it. Freeing memory in the callback is fine; doing
838 more than that is possible, but requires a lot of care and is best
839 avoided.
840
841 ---
842
843 **mandatory**
844
845 DCACHE_RCUACCESS is gone; having an RCU delay on dentry freeing is the
846 default. DCACHE_NORCU opts out, and only d_alloc_pseudo() has any
847 business doing so.
848
849 ---
850
851 **mandatory**
852
853 d_alloc_pseudo() is internal-only; uses outside of alloc_file_pseudo() are
854 very suspect (and won't work in modules). Such uses are very likely to
855 be misspelled d_alloc_anon().
856
857 ---
858
859 **mandatory**
860
861 [should've been added in 2016] stale comment in finish_open() notwithstanding,
862 failure exits in ->atomic_open() instances should *NOT* fput() the file,
863 no matter what. Everything is handled by the caller.
864
865 ---
866
867 **mandatory**
868
869 clone_private_mount() returns a longterm mount now, so the proper destructor of
870 its result is kern_unmount() or kern_unmount_array().
871
872 ---
873
874 **mandatory**
875
876 zero-length bvec segments are disallowed, they must be filtered out before
877 passed on to an iterator.
878
879 ---
880
881 **mandatory**
882
883 For bvec based itererators bio_iov_iter_get_pages() now doesn't copy bvecs but
884 uses the one provided. Anyone issuing kiocb-I/O should ensure that the bvec and
885 page references stay until I/O has completed, i.e. until ->ki_complete() has
886 been called or returned with non -EIOCBQUEUED code.
887
888 ---
889
890 **mandatory**
891
892 mnt_want_write_file() can now only be paired with mnt_drop_write_file(),
893 whereas previously it could be paired with mnt_drop_write() as well.
894
895 ---
896
897 **mandatory**
898
899 iov_iter_copy_from_user_atomic() is gone; use copy_page_from_iter_atomic().
900 The difference is copy_page_from_iter_atomic() advances the iterator and
901 you don't need iov_iter_advance() after it. However, if you decide to use
902 only a part of obtained data, you should do iov_iter_revert().
903
904 ---
905
906 **mandatory**
907
908 Calling conventions for file_open_root() changed; now it takes struct path *
909 instead of passing mount and dentry separately. For callers that used to
910 pass <mnt, mnt->mnt_root> pair (i.e. the root of given mount), a new helper
911 is provided - file_open_root_mnt(). In-tree users adjusted.
912
913 ---
914
915 **mandatory**
916
917 no_llseek is gone; don't set .llseek to that - just leave it NULL instead.
918 Checks for "does that file have llseek(2), or should it fail with ESPIPE"
919 should be done by looking at FMODE_LSEEK in file->f_mode.
920
921 ---
922
923 *mandatory*
924
925 filldir_t (readdir callbacks) calling conventions have changed. Instead of
926 returning 0 or -E... it returns bool now. false means "no more" (as -E... used
927 to) and true - "keep going" (as 0 in old calling conventions). Rationale:
928 callers never looked at specific -E... values anyway. -> iterate_shared()
929 instances require no changes at all, all filldir_t ones in the tree
930 converted.
931
932 ---
933
934 **mandatory**
935
936 Calling conventions for ->tmpfile() have changed. It now takes a struct
937 file pointer instead of struct dentry pointer. d_tmpfile() is similarly
938 changed to simplify callers. The passed file is in a non-open state and on
939 success must be opened before returning (e.g. by calling
940 finish_open_simple()).
941
942 ---
943
944 **mandatory**
945
946 Calling convention for ->huge_fault has changed. It now takes a page
947 order instead of an enum page_entry_size, and it may be called without the
948 mmap_lock held. All in-tree users have been audited and do not seem to
949 depend on the mmap_lock being held, but out of tree users should verify
950 for themselves. If they do need it, they can return VM_FAULT_RETRY to
951 be called with the mmap_lock held.
952
953 ---
954
955 **mandatory**
956
957 The order of opening block devices and matching or creating superblocks has
958 changed.
959
960 The old logic opened block devices first and then tried to find a
961 suitable superblock to reuse based on the block device pointer.
962
963 The new logic tries to find a suitable superblock first based on the device
964 number, and opening the block device afterwards.
965
966 Since opening block devices cannot happen under s_umount because of lock
967 ordering requirements s_umount is now dropped while opening block devices and
968 reacquired before calling fill_super().
969
970 In the old logic concurrent mounters would find the superblock on the list of
971 superblocks for the filesystem type. Since the first opener of the block device
972 would hold s_umount they would wait until the superblock became either born or
973 was discarded due to initialization failure.
974
975 Since the new logic drops s_umount concurrent mounters could grab s_umount and
976 would spin. Instead they are now made to wait using an explicit wait-wake
977 mechanism without having to hold s_umount.
978
979 ---
980
981 **mandatory**
982
983 The holder of a block device is now the superblock.
984
985 The holder of a block device used to be the file_system_type which wasn't
986 particularly useful. It wasn't possible to go from block device to owning
987 superblock without matching on the device pointer stored in the superblock.
988 This mechanism would only work for a single device so the block layer couldn't
989 find the owning superblock of any additional devices.
990
991 In the old mechanism reusing or creating a superblock for a racing mount(2) and
992 umount(2) relied on the file_system_type as the holder. This was severely
993 underdocumented however:
994
995 (1) Any concurrent mounter that managed to grab an active reference on an
996 existing superblock was made to wait until the superblock either became
997 ready or until the superblock was removed from the list of superblocks of
998 the filesystem type. If the superblock is ready the caller would simple
999 reuse it.
1001 (2) If the mounter came after deactivate_locked_super() but before
1002 the superblock had been removed from the list of superblocks of the
1003 filesystem type the mounter would wait until the superblock was shutdown,
1004 reuse the block device and allocate a new superblock.
1006 (3) If the mounter came after deactivate_locked_super() and after
1007 the superblock had been removed from the list of superblocks of the
1008 filesystem type the mounter would reuse the block device and allocate a new
1009 superblock (the bd_holder point may still be set to the filesystem type).
1011 Because the holder of the block device was the file_system_type any concurrent
1012 mounter could open the block devices of any superblock of the same
1013 file_system_type without risking seeing EBUSY because the block device was
1014 still in use by another superblock.
1016 Making the superblock the owner of the block device changes this as the holder
1017 is now a unique superblock and thus block devices associated with it cannot be
1018 reused by concurrent mounters. So a concurrent mounter in (2) could suddenly
1019 see EBUSY when trying to open a block device whose holder was a different
1020 superblock.
1022 The new logic thus waits until the superblock and the devices are shutdown in
1023 ->kill_sb(). Removal of the superblock from the list of superblocks of the
1024 filesystem type is now moved to a later point when the devices are closed:
1026 (1) Any concurrent mounter managing to grab an active reference on an existing
1027 superblock is made to wait until the superblock is either ready or until
1028 the superblock and all devices are shutdown in ->kill_sb(). If the
1029 superblock is ready the caller will simply reuse it.
1031 (2) If the mounter comes after deactivate_locked_super() but before
1032 the superblock has been removed from the list of superblocks of the
1033 filesystem type the mounter is made to wait until the superblock and the
1034 devices are shut down in ->kill_sb() and the superblock is removed from the
1035 list of superblocks of the filesystem type. The mounter will allocate a new
1036 superblock and grab ownership of the block device (the bd_holder pointer of
1037 the block device will be set to the newly allocated superblock).
1039 (3) This case is now collapsed into (2) as the superblock is left on the list
1040 of superblocks of the filesystem type until all devices are shutdown in
1041 ->kill_sb(). In other words, if the superblock isn't on the list of
1042 superblock of the filesystem type anymore then it has given up ownership of
1043 all associated block devices (the bd_holder pointer is NULL).
1045 As this is a VFS level change it has no practical consequences for filesystems
1046 other than that all of them must use one of the provided kill_litter_super(),
1047 kill_anon_super(), or kill_block_super() helpers.
1049 ---
1051 **mandatory**
1053 Lock ordering has been changed so that s_umount ranks above open_mutex again.
1054 All places where s_umount was taken under open_mutex have been fixed up.
1056 ---
1058 **mandatory**
1060 export_operations ->encode_fh() no longer has a default implementation to
1061 encode FILEID_INO32_GEN* file handles.
1062 Filesystems that used the default implementation may use the generic helper
1063 generic_encode_ino32_fh() explicitly.
1065 ---
1067 **mandatory**
1069 If ->rename() update of .. on cross-directory move needs an exclusion with
1070 directory modifications, do *not* lock the subdirectory in question in your
1071 ->rename() - it's done by the caller now [that item should've been added in
1072 28eceeda130f "fs: Lock moved directories"].
1074 ---
1076 **mandatory**
1078 On same-directory ->rename() the (tautological) update of .. is not protected
1079 by any locks; just don't do it if the old parent is the same as the new one.
1080 We really can't lock two subdirectories in same-directory rename - not without
1081 deadlocks.
1083 ---
1085 **mandatory**
1087 lock_rename() and lock_rename_child() may fail in cross-directory case, if
1088 their arguments do not have a common ancestor. In that case ERR_PTR(-EXDEV)
1089 is returned, with no locks taken. In-tree users updated; out-of-tree ones
1090 would need to do so.
1092 ---
1094 **mandatory**
1096 The list of children anchored in parent dentry got turned into hlist now.
1097 Field names got changed (->d_children/->d_sib instead of ->d_subdirs/->d_child
1098 for anchor/entries resp.), so any affected places will be immediately caught
1099 by compiler.
1101 ---
1103 **mandatory**
1105 ->d_delete() instances are now called for dentries with ->d_lock held
1106 and refcount equal to 0. They are not permitted to drop/regain ->d_lock.
1107 None of in-tree instances did anything of that sort. Make sure yours do not...
1109 ---
1111 **mandatory**
1113 ->d_prune() instances are now called without ->d_lock held on the parent.
1114 ->d_lock on dentry itself is still held; if you need per-parent exclusions (none
1115 of the in-tree instances did), use your own spinlock.
1117 ->d_iput() and ->d_release() are called with victim dentry still in the
1118 list of parent's children. It is still unhashed, marked killed, etc., just not
1119 removed from parent's ->d_children yet.
1121 Anyone iterating through the list of children needs to be aware of the
1122 half-killed dentries that might be seen there; taking ->d_lock on those will
1123 see them negative, unhashed and with negative refcount, which means that most
1124 of the in-kernel users would've done the right thing anyway without any adjustment.
1126 ---
1128 **recommended**
1130 Block device freezing and thawing have been moved to holder operations.
1132 Before this change, get_active_super() would only be able to find the
1133 superblock of the main block device, i.e., the one stored in sb->s_bdev. Block
1134 device freezing now works for any block device owned by a given superblock, not
1135 just the main block device. The get_active_super() helper and bd_fsfreeze_sb
1136 pointer are gone.
1138 ---
1140 **mandatory**
1142 set_blocksize() takes opened struct file instead of struct block_device now
1143 and it *must* be opened exclusive.
1145 ---
1147 **mandatory**
1149 ->d_revalidate() gets two extra arguments - inode of parent directory and
1150 name our dentry is expected to have. Both are stable (dir is pinned in
1151 non-RCU case and will stay around during the call in RCU case, and name
1152 is guaranteed to stay unchanging). Your instance doesn't have to use
1153 either, but it often helps to avoid a lot of painful boilerplate.
1154 Note that while name->name is stable and NUL-terminated, it may (and
1155 often will) have name->name[name->len] equal to '/' rather than '\0' -
1156 in normal case it points into the pathname being looked up.
1157 NOTE: if you need something like full path from the root of filesystem,
1158 you are still on your own - this assists with simple cases, but it's not
1159 magic.
1161 ---
1163 **recommended**
1165 kern_path_locked() and user_path_locked() no longer return a negative
1166 dentry so this doesn't need to be checked. If the name cannot be found,
1167 ERR_PTR(-ENOENT) is returned.
1169 ---
1171 **recommended**
1173 lookup_one_qstr_excl() is changed to return errors in more cases, so
1174 these conditions don't require explicit checks:
1176 - if LOOKUP_CREATE is NOT given, then the dentry won't be negative,
1177 ERR_PTR(-ENOENT) is returned instead
1178 - if LOOKUP_EXCL IS given, then the dentry won't be positive,
1179 ERR_PTR(-EEXIST) is rreturned instread
1181 LOOKUP_EXCL now means "target must not exist". It can be combined with
1182 LOOK_CREATE or LOOKUP_RENAME_TARGET.
1184 ---
1186 **mandatory**
1187 invalidate_inodes() is gone use evict_inodes() instead.
1189 ---
1191 **mandatory**
1193 ->mkdir() now returns a dentry. If the created inode is found to
1194 already be in cache and have a dentry (often IS_ROOT()), it will need to
1195 be spliced into the given name in place of the given dentry. That dentry
1196 now needs to be returned. If the original dentry is used, NULL should
1197 be returned. Any error should be returned with ERR_PTR().
1199 In general, filesystems which use d_instantiate_new() to install the new
1200 inode can safely return NULL. Filesystems which may not have an I_NEW inode
1201 should use d_drop();d_splice_alias() and return the result of the latter.
1203 If a positive dentry cannot be returned for some reason, in-kernel
1204 clients such as cachefiles, nfsd, smb/server may not perform ideally but
1205 will fail-safe.
1207 ---
1209 ** mandatory**
1211 lookup_one(), lookup_one_unlocked(), lookup_one_positive_unlocked() now
1212 take a qstr instead of a name and len. These, not the "one_len"
1213 versions, should be used whenever accessing a filesystem from outside
1214 that filesysmtem, through a mount point - which will have a mnt_idmap.
1216 ---
1218 ** mandatory**
1220 Functions try_lookup_one_len(), lookup_one_len(),
1221 lookup_one_len_unlocked() and lookup_positive_unlocked() have been
1222 renamed to try_lookup_noperm(), lookup_noperm(),
1223 lookup_noperm_unlocked(), lookup_noperm_positive_unlocked(). They now
1224 take a qstr instead of separate name and length. QSTR() can be used
1225 when strlen() is needed for the length.
1227 These function no longer do any permission checking - they previously
1228 checked that the caller has 'X' permission on the parent. They must
1229 ONLY be used internally by a filesystem on itself when it knows that
1230 permissions are irrelevant or in a context where permission checks have
1231 already been performed such as after vfs_path_parent_lookup()
1233 ---
1235 ** mandatory**
1237 d_hash_and_lookup() is no longer exported or available outside the VFS.
1238 Use try_lookup_noperm() instead. This adds name validation and takes
1239 arguments in the opposite order but is otherwise identical.
1241 Using try_lookup_noperm() will require linux/namei.h to be included.
1243 ---
1245 **mandatory**
1247 Calling conventions for ->d_automount() have changed; we should *not* grab
1248 an extra reference to new mount - it should be returned with refcount 1.
1250 ---
1252 collect_mounts()/drop_collected_mounts()/iterate_mounts() are gone now.
1253 Replacement is collect_paths()/drop_collected_path(), with no special
1254 iterator needed. Instead of a cloned mount tree, the new interface returns
1255 an array of struct path, one for each mount collect_mounts() would've
1256 created. These struct path point to locations in the caller's namespace
1257 that would be roots of the cloned mounts.
1259 ---
1261 **mandatory**
1263 If your filesystem sets the default dentry_operations, use set_default_d_op()
1264 rather than manually setting sb->s_d_op.
1266 ---
1268 **mandatory**
1270 d_set_d_op() is no longer exported (or public, for that matter); _if_
1271 your filesystem really needed that, make use of d_splice_alias_ops()
1272 to have them set. Better yet, think hard whether you need different
1273 ->d_op for different dentries - if not, just use set_default_d_op()
1274 at mount time and be done with that. Currently procfs is the only
1275 thing that really needs ->d_op varying between dentries.
1277 ---
1279 **highly recommended**
1281 The file operations mmap() callback is deprecated in favour of
1282 mmap_prepare(). This passes a pointer to a vm_area_desc to the callback
1283 rather than a VMA, as the VMA at this stage is not yet valid.
1285 The vm_area_desc provides the minimum required information for a filesystem
1286 to initialise state upon memory mapping of a file-backed region, and output
1287 parameters for the file system to set this state.
1289 ---
1291 **mandatory**
1293 Several functions are renamed:
1295 - kern_path_locked -> start_removing_path
1296 - kern_path_create -> start_creating_path
1297 - user_path_create -> start_creating_user_path
1298 - user_path_locked_at -> start_removing_user_path_at
1299 - done_path_create -> end_creating_path
1301 ---
1303 **mandatory**
1305 Calling conventions for vfs_parse_fs_string() have changed; it does *not*
1306 take length anymore (value ? strlen(value) : 0 is used). If you want
1307 a different length, use
1309 vfs_parse_fs_qstr(fc, key, &QSTR_LEN(value, len))
1311 instead.

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

Block helper와 inode 전용 객체

1-53

Linux 2.5.0 이후 porting 지침의 첫 권고는 `sb_bread()`, `sb_getblk()`, `sb_find_get_block()`, `set_bh()`, `sb_set_blocksize()`, `sb_min_blocksize()` helper를 사용하라는 것이다. `sb_find_get_block()`은 2.4의 `get_hash_table()`을 대체한다.

새 `->alloc_inode()`와 `->destroy_inode()` method를 도입하고 `inode->u.foo_inode_i`를 제거한다. filesystem 전용 `struct foo_inode_info` 안에 `struct inode vfs_inode`를 포함시키고, `FOO_I(inode)` helper로 VFS inode에서 바깥 객체를 얻는다. `foo_alloc_inode()`는 `foo_inode_info`를 할당해 `->vfs_inode` 주소를 반환하고, `foo_destroy_inode()`는 `FOO_I(inode)`를 해제한다. 두 함수를 `super_operations`에 등록한다.

private data는 보통 `iget_locked()` 호출과 새 inode unlock 사이에 명시적으로 초기화해야 한다. 이 요구는 장차 의무가 될 것이라고 문서는 경고한다.

필수 변경으로 `foo_inode_info`는 `kmem_cache_alloc()`이나 `kmalloc()`이 아니라 항상 `alloc_inode_sb()`를 통해 할당해야 한다. 그래야 inode reclaim context가 올바르게 설정된다.

Filesystem 전용 inode 수명
`alloc_inode_sb()`로 `foo_inode_info` 할당`->vfs_inode` 주소를 VFS에 반환`FOO_I(inode)`로 private object 접근`iget_locked()`와 unlock 사이 private data 초기화`->destroy_inode()`에서 바깥 객체 해제

VFS inode를 포함한 전용 객체를 superblock inode allocator로 관리한다.

====================
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.

**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.

`->get_sb()` 전환과 초기 BKL 변경

54-109

필수 변경으로 `file_system_type`의 `->read_super()`와 `DECLARE_FSTYPE`, `DECLARE_FSTYPE_DEV`가 사라졌다. 기존 `foo_read_super()`는 성공 시 0, 실패 시 음수 오류값을 반환하는 `foo_fill_super()`로 바꾼다. 보통 `foo_get_sb()`가 `get_sb_bdev()`를 호출하게 하고, filesystem 종류에 따라 `bdev`를 `nodev`나 `single`로 바꾼다. 명시적 `file_system_type` initializer의 `->get_sb`에 이 함수를 설정한다.

`->s_vfs_rename_sem`은 이제 cross-directory rename에만 잡힌다. rename 사이의 전역 배제를 내부 용도로 의존했다면 filesystem 자체 잠금을 고쳐야 한다. 부모와 victim이 잠긴다는 기존 보장은 유지된다.

정보 항목으로 VFS가 `->lookup()`과 `->rmdir()` 또는 `->rename()`에 의한 directory 제거 사이의 배제를 제공한다. 이 배제를 위해 내부 lock을 두었다면 완화할 수 있다.

`->lookup()`, `->truncate()`, `->create()`, `->unlink()`, `->mknod()`, `->mkdir()`, `->rmdir()`, `->link()`, `->lseek()`, `->symlink()`, `->rename()`, `->readdir()`는 더 이상 BKL을 잡은 채 호출되지 않는다. 옛 동기화를 그대로 유지하려면 entry에서 `lock_kernel()`을 호출하고 return 전에 `unlock_kernel()`을 호출한다. BKL이 필요한 일부 코드만 정확히 감싸도록 범위를 줄이는 편이 더 낫다.

초기 VFS callback 전환
변경Porting 조치
`->read_super()` 제거`foo_fill_super()` + `->get_sb` wrapper
cross-directory rename전역 배제가 필요하면 내부 lock 추가
lookup 대 directory 제거VFS 배제를 활용해 불필요한 내부 lock 완화
여러 inode operation필요한 구간에만 BKL 명시

mount 진입점과 rename·directory callback의 잠금 책임이 filesystem 쪽으로 이동했다.

---

**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.

Export operation과 `iget5_locked()`

160-226

NFS 같은 export를 명시적으로 지원하기 위해 `super_block`에 `struct export_operations *s_export_op`가 추가됐다. 자세한 구조는 `include/linux/fs.h`와 `Documentation/filesystems/nfs/exporting.rst`에 있다. `decode_fh`, `encode_fh`로 filehandle을 변환하고, 표준 decode helper 및 filesystem별 `get_parent` 지원을 제공한다. 이후에는 export를 위해 `s_export_op`가 필수가 됐으며 isofs, ext2, ext3, fat가 서로 다른 예시다.

`iget4()`와 `read_inode2` callback은 `iget5_locked()`로 대체됐다. 이 함수는 superblock, inode number, `test`, `set`, opaque `data`를 받는다. inode number만으로 실제 file object를 구별할 수 없을 때 `test`를 사용한다. `set`은 새 inode를 `test`할 수 있게 필요한 필드를 초기화하는 non-blocking 함수이고, `data`는 두 callback에 그대로 전달된다.

`iget5_locked()`가 새 inode를 만들면 `I_NEW`가 설정되고 lock된 상태로 반환된다. filesystem은 초기화를 마친 뒤 `unlock_new_inode()`를 호출해야 한다. 필요하면 `i_ino`를 직접 설정하고 검사할 책임도 filesystem에 있다. inode number만 필요한 단순한 경우에는 `iget_locked()`가 test와 set을 대신 처리한다.

disk에서 inode를 읽는 데 실패하면 `iget_failed(inode)`로 새 inode를 dead 상태로 만들고 적절한 오류를 caller에 반환한다. 성공하면 `unlock_new_inode()`로 공개한다.

새 inode 조회·초기화
`iget5_locked()` 또는 `iget_locked()` 호출`I_NEW` 여부 확인필요한 private field와 disk inode 초기화실패: `iget_failed()` 후 오류 반환성공: `unlock_new_inode()`

`I_NEW` inode는 완전한 초기화 전까지 잠긴 채 유지된다.

---

**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
Documentation/filesystems/nfs/exporting.rst.

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.
isofs, ext2, ext3, fat
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);
        if (inode->i_state & I_NEW) {
                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.

`->getattr()`, `d_parent`, block-device helper

227-284

`->getattr()`가 실제 VFS 경로에서 사용되기 시작했으므로 nfs, minix 등의 구현을 참고한다. `->revalidate()`는 제거됐다. filesystem에 이 callback이 있었다면 `->getattr()`를 제공해 기존 revalidate 작업을 호출하고, symlink의 revalidate는 `->follow_link()`나 `->readlink()`에서 호출한다.

`->d_parent` 변경은 더 이상 BKL이 보호하지 않는다. 읽기가 안전한 조건은 cross-directory `rename()`이 없는 filesystem, parent가 잠겨 있음을 아는 경우, 현재 `->rename()` 안인 경우, 또는 child의 `->d_lock`을 보유한 경우 중 하나다. 그 밖의 접근은 code audit 후 lock을 추가해야 한다. 옛 tree에서도 BKL에 막연히 기대던 이런 접근은 oops나 조용한 memory corruption을 일으킬 수 있었다.

`FS_NOMOUNT`는 제거됐다. 사용하던 filesystem은 flag에 `SB_NOUSER`를 설정하며 rootfs와 bdev/socket/pipe 구현을 참고한다.

block device의 read-only 검사는 `is_read_only(kdev)` 대신 `bdev_read_only(bdev)`를 사용한다. `->permission()`도 BKL 없이 호출되므로 필요한 경우 method 안의 정확한 범위에 BKL을 잡는다.

`d_parent` 안전한 읽기 조건
조건근거
cross-directory rename 없음parent가 이동하지 않음
parent lock 보유예: `->lookup()` 인자의 parent
`->rename()` 실행 중rename 잠금 문맥
child `->d_lock` 보유dentry 관계 보호

다음 조건 중 하나가 성립하지 않으면 별도 locking이 필요하다.

---

**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.

Block 동기화, truncate, inode eviction

285-359

`->statfs()`도 BKL 없이 호출된다. 제거 안전성이 불분명한 filesystem은 각 `sb_op` 안으로 BKL을 옮긴다. `is_read_only()`는 `bdev_read_only()`로, `destroy_buffers()`는 `invalidate_bdev()`로, `fsync_dev()`는 `fsync_bdev()`로 바꾼다. 당시 LVM 파손은 `struct block_device *` 전달이 정리될 때까지 의도적으로 남겨졌다고 기록돼 있다.

`->write_begin`과 `->direct_IO` 오류 시 block truncation 책임이 `block_write_begin`, `cont_write_begin`, `nobh_write_begin`, `blockdev_direct_IO*` 같은 generic method에서 caller로 이동했다. `ext2_write_failed`와 그 caller를 예로 삼는다.

`->truncate`는 제거됐다. disk 크기를 바꾸는 filesystem은 전체 truncate sequence를 필수 `->setattr`에 구현해야 한다. 먼저 `block_truncate_page` 같은 helper로 block 끝을 0으로 만들고, size를 갱신한 뒤, 실패해서는 안 되는 on-disk truncation을 마지막에 수행한다. `setattr_prepare()`의 옛 이름은 `inode_change_ok`이며, 이제 `ATTR_SIZE` 검사도 포함하므로 `->setattr` 시작에서 무조건 호출한다.

`->clear_inode()`와 `->delete_inode()`는 `->evict_inode()`로 통합됐다. link가 남았는지와 관계없이 inode가 evict될 때 호출된다. caller는 pagecache나 inode 연관 metadata buffer를 지우지 않으므로 method가 `truncate_inode_pages_final()`을 호출해야 한다. caller는 호출 중과 이후에 async writeback이 돌지 않음을 보장한다.

`->drop_inode()`는 `inode->i_lock`을 보유한 final `iput()`에서 호출돼 drop 여부를 int로 반환한다. 기본은 `inode_generic_drop()`, 항상 drop은 `inode_just_drop()`이다. 실제 eviction은 callback 반환 뒤 caller가 수행한다. 각 `->evict_inode()`에서 `clear_inode()`를 정확히 한 번 호출하고, `mark_buffer_dirty_inode()`를 썼다면 먼저 `invalidate_inode_buffers()`를 호출한다.

`->write_inode()` 시작에서 `i_nlink == 0`만 보고 빠지는 것은 안전하지 않다. final `unlink()`와 `iput()`이 `->write_inode()` 도중 일어날 수 있어, on-disk inode를 무작정 해제하면 동시에 기록 중인 저장 공간을 없앨 수 있다.

`->evict_inode()` 정리 순서
`truncate_inode_pages_final()`필요 시 `invalidate_inode_buffers()`filesystem별 on-disk 정리`clear_inode()` 정확히 한 번caller가 실제 eviction 완료

pagecache와 inode metadata를 filesystem method가 명시적으로 정리한다.

---

**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**

block truncation on error exit from ->write_begin, and ->direct_IO
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
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
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.

Dcache callback과 RCU 수명

360-420

`.d_delete()`는 이제 reference가 없는 dentry를 cache할지 dcache에 조언할 뿐이며 refcount가 0이 될 때만 호출된다. 0 전환에서도 0회, 1회, 여러 번 호출될 수 있으므로 constant하거나 idempotent해야 한다.

`.d_compare()`와 `.d_hash()`의 호출 규약과 잠금 규칙이 크게 바뀌었다. `Documentation/filesystems/vfs.rst`와 in-tree filesystem 예제를 따라야 한다. 전역 `dcache_lock`은 fine-grained lock으로 대체됐고, 대부분은 특정 dentry의 모든 dcache 상태를 보호하는 `->d_lock`만 필요하다.

VFS namespace에 pathname으로 접근할 수 있어 rcu-walk 대상이 될 수 있는 inode는 filesystem이 RCU 지연 후 해제해야 한다. `i_dentry`와 `i_rcu`가 union storage를 공유하더라도 `inode_init_always()`가 `i_dentry`를 초기화하므로 callback에서 건드리지 않는다. 3.2부터는 예전의 명시적 정리가 필요 없다.

VFS는 dentry와 inode에 대한 atomic operation과 확장성 병목을 피하려고 `rcu-walk mode`에서 경로를 걷는다. 복잡한 filesystem callback 전에는 ref-walk로 내려갈 수 있지만 비용이 크고 RCU 이점을 잃는다. 따라서 새 RCU-aware callback을 가능한 곳에서 구현하는 것이 권장된다.

Dcache porting 핵심
대상새 규칙
`.d_delete()`refcount 0에서 반복 호출 가능, idempotent
`.d_compare()`·`.d_hash()`새 calling convention과 lock 규칙
`dcache_lock`대부분 `->d_lock`으로 대체
pathname inodeRCU 지연 해제

전역 lock 대신 객체별 lock과 RCU 수명 규칙을 적용한다.

---

**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.

RCU-aware callback과 file operation

421-487

filesystem이 `d_revalidate`를 제공하면 모든 path element에서 호출될 수 있다. 이제 `nd->flags & LOOKUP_RCU`인 rcu-walk mode에서도 호출되므로 처리할 수 없으면 `-ECHILD`를 반환한다. directory를 내려갈 때 실행 권한을 검사하는 `permission`도 `mask & MAY_NOT_BLOCK` 조건을 인식해야 한다.

`->fallocate()`는 전달된 mode를 반드시 검사한다. hole punching을 지원하지 않으면 `FALLOC_FL_PUNCH_HOLE`에 `-EOPNOTSUPP`를 반환한다. 당시에는 이 flag가 `FALLOC_FL_KEEP_SIZE`와 함께만 오므로 파일 끝을 punch해도 `i_size`를 바꾸지 않는다.

`->get_sb()`는 제거되고 `->mount()`로 바뀌었다. 보통 `get_sb_*` helper를 `mount_*`로 바꾸고 함수 type을 맞춘다. 수동 구현은 `->mnt_root`를 설정하는 대신 root pointer를 반환하고, 실패는 `ERR_PTR(...)`로 반환한다.

`->permission()`과 `generic_permission()`에서 flags 인자가 없어졌다. `IPERM_FLAG_RCU` 대신 mask에 `MAY_NOT_BLOCK`을 넣는다. `generic_permission()`의 `check_acl` 인자도 제거됐고 ACL 검사는 VFS가 담당한다. disk ACL을 읽으려면 filesystem이 non-NULL `->i_op->get_inode_acl`을 제공한다.

자체 `->llseek()`는 `SEEK_HOLE`과 `SEEK_DATA`를 처리해야 한다. 지원하지 않으면 `-EINVAL`도 가능하다. generic 규약은 `offset < i_size`일 때 `SEEK_DATA`에 같은 offset, `SEEK_HOLE`에 file end를 반환하고, `offset >= i_size`면 둘 다 `-ENXIO`다.

자체 `->fsync()`는 dirty page를 확실히 기록하도록 `filemap_write_and_wait_range()`를 호출해야 한다. 더 이상 `i_mutex`를 보유한 채 호출되지 않으므로 필요하면 callback이 직접 잡고 해제한다.

RCU 및 I/O callback 반환 규약
상황결과
RCU `d_revalidate` 처리 불가`-ECHILD`
hole punching 미지원`-EOPNOTSUPP`
`SEEK_HOLE/DATA` 미지원`-EINVAL`
offset가 `i_size` 이상`-ENXIO`
mount 실패`ERR_PTR(...)`

호출 문맥을 처리할 수 없거나 기능이 없을 때의 명시적 결과다.

---

**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
has been taken to VFS and filesystems need to provide a non-NULL
->i_op->get_inode_acl to read an ACL from disk.

---

**mandatory**

If you implement your own ->llseek() you must handle SEEK_HOLE and
SEEK_DATA.  You can handle this by returning -EINVAL, but it would be nicer to
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.

Root dentry와 nameidata 제거

488-547

오용으로 많은 bug를 만들던 `d_alloc_root()`는 `d_make_root(inode)`로 대체됐다. 성공하면 전달한 inode로 instantiate한 새 dentry를 반환한다. 실패하면 `NULL`을 반환하면서 inode reference도 소비해 drop하므로 별도 정리가 필요 없다. `NULL` inode를 넘겨도 `NULL`을 반환하고 추가 오류 처리는 없다.

`->d_revalidate()`와 `->lookup()`는 더 이상 `struct nameidata`를 받지 않고 flags만 받는다. `->create()`도 `struct nameidata *` 대신 `O_EXCL` 또는 동등 조건인지를 나타내는 boolean을 받는다. local filesystem은 객체가 없음을 보장받아 이를 무시할 수 있지만 remote·distributed filesystem은 확인할 수 있다.

`FS_REVAL_DOT`는 사라졌고 필요하면 dentry operation에 `->d_weak_revalidate()`를 추가한다. `vfs_readdir()`는 `iterate_dir()`로, `->readdir()`는 `->iterate_shared()`로 전환한다.

`vfs_follow_link`도 제거됐다. 일반 symlink는 `->follow_link`에서 `nd_set_link`를 사용하고, `/proc/<pid>` 형식의 magic link는 `nd_jump_link`를 사용한다.

제거된 interface와 대체
제거대체
`d_alloc_root()``d_make_root()`
`FS_REVAL_DOT``->d_weak_revalidate()`
`vfs_readdir()``iterate_dir()`
`->readdir()``->iterate_shared()`
`vfs_follow_link``nd_set_link` 또는 `nd_jump_link`

root dentry, directory iteration, symlink helper를 새 API로 옮긴다.

---

**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
local filesystems can ignore this argument - they are guaranteed that the
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**

->readdir() is gone now; switch to ->iterate_shared()

**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.

Parallel lookup과 directory iteration

671-727

`->i_mutex`는 `->i_rwsem`으로 바뀌었다. `inode_lock()` 계열은 이전처럼 exclusive lock을 잡지만, `->lookup()`는 parent를 shared로 잠근 상태에서 호출될 수 있다.

따라서 `->lookup()`는 `d_instantiate()`와 `d_rehash()`를 따로 호출하지 말고 `d_add()`나 `d_splice_alias()`를 사용한다. `d_rehash()`만 호출하던 경우에는 `d_add(new_dentry, NULL)`로 바꾼다. read-only filesystem data에 별도 배제가 필요하면 자체적으로 제공해야 한다. 또한 dentry를 `d_add()`나 `d_splice_alias()`에 넘긴 뒤 `->d_parent`와 `->d_name`이 고정돼 있다고 가정하면 안 된다.

같은 directory의 같은 이름 lookup은 병렬로 발생하지 않는다. 여기서 같다는 의미는 filesystem의 `->d_compare()`가 정한다. 하지만 같은 directory의 서로 다른 이름 lookup은 병렬로 실행될 수 있다.

`->iterate_shared()`는 동일한 `struct file` 안에서의 배제와 그 file의 `lseek` 간 배제를 유지하지만, 같은 directory를 여러 번 open하면 병렬 호출될 수 있다. directory를 변경하는 method와의 배제는 유지된다. iteration이 inode나 dentry별 in-core 구조를 수정하면 자체 직렬화가 필요하고, dcache pre-seeding은 `d_alloc_parallel()`로 바꾼다.

`O_CREAT` 없는 `->atomic_open()` 호출도 병렬로 발생할 수 있다.

`->setxattr()`와 `xattr_handler.set()`도 dentry와 inode를 별도로 받는다. handler는 mount의 user namespace도 받아 `i_uid`, `i_gid`를 idmap할 수 있다. attach 전 dentry일 수 있으므로 `->d_inode`를 사용하지 않는다.

Directory 병렬성
작업병렬 가능성
같은 directory, 같은 이름 lookup직렬화됨
같은 directory, 다른 이름 lookup병렬 가능
같은 `struct file`의 iterate와 lseek직렬화됨
여러 open instance의 `->iterate_shared()`병렬 가능
`->atomic_open()` without `O_CREAT`병렬 가능

이름·open instance에 따라 VFS가 제공하는 배제 범위가 다르다.

---

**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.

---

**mandatory**

->iterate_shared() is added.
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.

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.

---

**mandatory**

->atomic_open() calls without O_CREAT may happen in parallel.

---

**mandatory**

->setxattr() and xattr_handler.set() get dentry and inode passed separately.
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.
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.

Dentry 비교, statx, atomic open, file 할당

728-787

`->d_compare()`는 parent를 별도 인자로 받지 않는다. superblock이 필요하면 `dentry->d_sb`, 더 복잡한 관계면 `dentry->d_parent`를 사용한다. RCU mode에서는 여러 번 읽는 사이 값이 바뀔 수 있으므로 같은 값이 반복된다고 가정하지 않는다.

`->rename()`에는 flags 인자가 추가됐으며 filesystem이 처리하지 않는 flag에는 `EINVAL`을 반환한다. symlink의 `->readlink`는 선택 사항이므로 `readlink(2)` 결과를 특별히 꾸며야 하는 filesystem만 설정한다.

`->getattr()`는 vfsmount와 dentry를 따로 받는 대신 `struct path`를 받는다. `statx`가 요청한 field와 동기화 형식을 나타내는 `request_mask`, `query_flags`도 추가됐다. statx 전용 기능이 없으면 새 인자를 무시해도 된다.

`->atomic_open()`의 `int *opened`, `FILE_OPENED`, `FILE_CREATED`는 사라졌다. 대신 `file->f_mode`에 `FMODE_OPENED`, `FMODE_CREATED`를 설정한다. `finish_no_open()`을 호출해 caller가 직접 열게 하는 경우의 반환값은 1에서 0으로 바뀌었고, 함수 자체도 0을 반환하므로 해당 호출부는 별도 수정이 필요 없다.

`alloc_file()`은 static이 됐다. dentry 생성이 필요한 대부분의 경우 `alloc_file_pseudo(inode, vfsmount, name, flags, ops)`를 쓴다. 성공하면 새 `struct file`이 inode reference를 인수하고, 실패하면 `ERR_PTR()`를 반환하며 caller reference는 그대로이므로 caller가 inode를 drop한다. `alloc_file_clone(file, flags, ops)`는 caller reference에 영향을 주지 않고 성공 시 원본과 mount/dentry를 공유하는 새 file을 반환한다.

File allocation wrapper의 reference 규약
Helper성공실패
`alloc_file_pseudo()`새 file이 inode reference 인수`ERR_PTR()`, caller가 inode drop
`alloc_file_clone()`mount/dentry 공유 file 반환`ERR_PTR()`, caller reference 불변

성공과 실패 때 inode·caller reference 소유권이 다르다.

---

**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().

Range remap과 inode free 분리

788-840

`->clone_file_range()`와 `->dedupe_file_range`는 `->remap_file_range()`로 통합됐다. 세부 사항은 `Documentation/filesystems/vfs.rst`를 따른다.

`->lookup()`에서 inode가 `ERR_PTR(...)`인지 검사한 뒤 `d_splice_alias()`를 호출하던 코드는 검사 없이 바로 넘겨도 된다. `d_splice_alias()`가 error pointer를 올바르게 처리한다. `NULL` inode도 `d_add(dentry, NULL); return NULL;`과 같은 의미로 처리하므로 별도 분기가 필요 없다.

강력 권고 사항은 `->destroy_inode()`의 RCU 지연 부분을 새 `->free_inode()`로 옮기는 것이다. 동기 작업이나 stack trace가 필요한 `WARN_ON()`은 `->evict_inode()`로 옮길 수 있지만, `->alloc_inode()`에서 수행한 작업의 짝을 맞추는 정리는 그대로 destruction 경로에 남아야 한다. inode 생애 동안 누적된 상태 정리는 `->evict_inode()`에 적합할 수 있다.

파괴 규칙은 `->destroy_inode()`가 non-NULL이면 즉시 호출하고, `->free_inode()`가 non-NULL이면 `call_rcu()`로 예약하는 것이다. 둘 다 NULL인 조합은 호환성을 위해 `free_inode_nonrcu`처럼 처리한다.

`->free_inode()`나 `->destroy_inode()`의 명시적 `call_rcu()` callback은 superblock 파괴와 순서가 보장되지 않는다. 실행 시 superblock과 연관 구조가 이미 사라졌을 수 있고 filesystem driver만 남아 있음이 보장된다. memory free는 안전하지만 그 이상의 작업은 각별히 주의하고 가급적 피한다.

Inode destruction 역할 분리
`->evict_inode()`: 생애 중 누적 상태 동기 정리`->destroy_inode()`: 필요한 즉시 destruction 작업`call_rcu()` 예약`->free_inode()`: RCU 이후 memory 해제superblock 상태에는 의존하지 않음

동기 eviction과 RCU 지연 memory free를 서로 다른 callback에 둔다.

---

**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.

Dentry RCU 기본값과 iterator 수명

841-903

`DCACHE_RCUACCESS`는 제거됐고 dentry free를 RCU 이후로 미루는 것이 기본이다. `DCACHE_NORCU`가 이를 opt-out하며 사실상 `d_alloc_pseudo()`만 사용할 이유가 있다. `d_alloc_pseudo()`는 internal 전용이고 module 밖 사용은 동작하지 않는다. 대부분은 `d_alloc_anon()`을 잘못 쓴 경우다.

오래된 `finish_open()` comment와 달리 `->atomic_open()`의 실패 경로는 어떤 경우에도 file에 `fput()`을 호출하면 안 된다. caller가 모두 처리한다. `clone_private_mount()`는 long-term mount를 반환하므로 `kern_unmount()`나 `kern_unmount_array()`로 해제한다.

길이 0인 bvec segment는 허용되지 않으므로 iterator에 넘기기 전에 제거한다. bvec 기반 iterator에서 `bio_iov_iter_get_pages()`는 이제 bvec를 복사하지 않고 전달된 것을 직접 사용한다. `kiocb` I/O를 발행하는 코드는 `->ki_complete()`가 호출되거나 non-`-EIOCBQUEUED` 값으로 반환될 때까지 bvec와 page reference를 유지해야 한다.

`mnt_want_write_file()`은 오직 `mnt_drop_write_file()`과 짝지어야 하며 더 이상 `mnt_drop_write()`와 짝지을 수 없다.

`iov_iter_copy_from_user_atomic()`은 `copy_page_from_iter_atomic()`으로 바꾼다. 새 함수는 iterator를 전진시키므로 뒤에 `iov_iter_advance()`를 호출하지 않는다. 얻은 data 일부만 쓴다면 `iov_iter_revert()`로 남은 만큼 되돌린다.

Iterator와 reference 수명
APICaller 책임
bvec iterator길이 0 segment 제거
`bio_iov_iter_get_pages()`I/O 완료까지 bvec와 page 유지
`copy_page_from_iter_atomic()`별도 advance 금지
일부 data만 사용`iov_iter_revert()`

복사하지 않는 bvec와 자동 전진 iterator의 새 책임을 정리한다.

---

**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().

---

**mandatory**

[should've been added in 2016] stale comment in finish_open() notwithstanding,
failure exits in ->atomic_open() instances should *NOT* fput() the file,
no matter what.  Everything is handled by the caller.

---

**mandatory**

clone_private_mount() returns a longterm mount now, so the proper destructor of
its result is kern_unmount() or kern_unmount_array().

---

**mandatory**

zero-length bvec segments are disallowed, they must be filtered out before
passed on to an iterator.

---

**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.

---

**mandatory**

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.

---

**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().

Root open, directory callback, memory fault

904-952

`file_open_root()`는 mount와 dentry를 따로 받는 대신 `struct path *`를 받는다. 예전에 `<mnt, mnt->mnt_root>`를 넘기던 caller는 새 `file_open_root_mnt()` helper를 쓴다.

`no_llseek`는 제거됐다. `.llseek`에 설정하지 말고 NULL로 둔다. file이 `llseek(2)`를 지원하는지, `ESPIPE`로 실패해야 하는지는 `file->f_mode`의 `FMODE_LSEEK`로 검사한다.

`filldir_t` readdir callback의 반환형은 int에서 bool로 바뀌었다. `false`는 옛 음수 오류처럼 더 이상 진행하지 않음을, `true`는 옛 0처럼 계속 진행함을 뜻한다. caller가 구체적 오류값을 사용하지 않았기 때문이다. `->iterate_shared()` 구현은 바꿀 필요가 없다.

`->tmpfile()`는 `struct dentry *` 대신 `struct file *`를 받으며 `d_tmpfile()`도 같은 방식으로 바뀌었다. 전달된 file은 아직 open되지 않은 상태이므로 성공 반환 전에 `finish_open_simple()` 같은 함수로 열어야 한다.

`->huge_fault`는 `enum page_entry_size` 대신 page order를 받고 `mmap_lock` 없이 호출될 수 있다. out-of-tree 구현은 lock 의존 여부를 확인해야 하며 필요하면 `VM_FAULT_RETRY`를 반환해 `mmap_lock`을 보유한 상태로 다시 호출되게 한다.

Callback 반환 의미 변경
Callback새 규약
`filldir_t``false`: 중단, `true`: 계속
`->tmpfile()`non-open file을 받아 성공 전 open
`->huge_fault`page order 인자, lock 필요 시 `VM_FAULT_RETRY`

bool directory callback과 retry 가능한 huge fault를 구분한다.

---

**mandatory**

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.

---

**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.

---

*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:
callers never looked at specific -E... values anyway. -> iterate_shared()
instances require no changes at all, all filldir_t ones in the tree
converted.

---

**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()).

---

**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.

Block device open 순서와 holder 변경

953-1048

block device를 열고 superblock을 찾거나 만드는 순서가 바뀌었다. 옛 방식은 block device를 먼저 연 뒤 device pointer로 재사용할 superblock을 찾았다. 새 방식은 device number로 적합한 superblock을 먼저 찾고 그 뒤 block device를 연다.

lock ordering 때문에 `s_umount` 아래에서 block device를 열 수 없다. 따라서 open하는 동안 `s_umount`를 놓고 `fill_super()` 호출 전에 다시 잡는다. 옛 방식의 동시 mounter는 filesystem type의 superblock list에서 항목을 찾고 첫 opener가 잡은 `s_umount`를 기다려 superblock이 born 상태가 되거나 초기화 실패로 폐기되는 것을 관찰했다. 새 방식에서는 `s_umount`를 놓으므로 spin하지 않도록 명시적 wait-wake mechanism으로 기다린다.

block device holder도 `file_system_type`에서 개별 superblock으로 바뀌었다. 옛 holder로는 block device에서 소유 superblock을 직접 찾기 어려웠고, 한 device pointer만 match하므로 추가 device의 소유자를 block layer가 알 수 없었다.

옛 mount·umount 경쟁에서 기존 active superblock reference를 얻은 mounter는 준비 또는 list 제거를 기다렸다. `deactivate_locked_super()` 뒤 list 제거 전이면 shutdown을 기다린 후 device를 재사용해 새 superblock을 만들었고, list 제거 뒤라면 device를 곧바로 재사용했다. holder가 filesystem type이어서 같은 type의 다른 superblock이 device를 사용 중이어도 동시 mounter가 `EBUSY` 없이 열 수 있었다.

holder가 고유 superblock이 되면 다른 superblock에 속한 block device를 동시 mounter가 재사용할 수 없어 갑자기 `EBUSY`가 생길 수 있다. 새 로직은 `->kill_sb()`에서 superblock과 모든 device가 shutdown될 때까지 기다리고, device를 닫은 뒤에야 filesystem type의 list에서 superblock을 제거한다.

따라서 active reference를 얻은 mounter는 superblock 준비 또는 `->kill_sb()` 완료를 기다리고, ready면 재사용한다. `deactivate_locked_super()` 뒤에 온 mounter는 기존 superblock과 device shutdown 및 list 제거를 기다린 뒤 새 superblock을 할당하고 block device의 `bd_holder`를 새 superblock으로 설정한다. superblock이 list에 없다면 모든 연관 device 소유권을 포기해 `bd_holder == NULL`임을 뜻한다.

이 변경은 VFS 내부 수준이므로 filesystem의 실질적 조치는 제공된 `kill_litter_super()`, `kill_anon_super()`, `kill_block_super()` 중 하나를 반드시 사용하는 것이다.

새 block-device mount 순서
device number로 superblock 후보 검색`s_umount`를 놓고 block device open`s_umount` 재획득 후 `fill_super()`경쟁 mount는 wait-wake로 준비 또는 shutdown 대기`->kill_sb()`에서 모든 device 종료superblock list 제거와 `bd_holder` 해제

superblock을 먼저 식별하고 device ownership이 완전히 끝날 때까지 경쟁 mounter를 기다리게 한다.

---

**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.

---

**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
umount(2) relied on the file_system_type as the holder. This was severely
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.

Lock ordering, rename, dentry child list

1049-1110

lock ordering은 다시 `s_umount`가 `open_mutex`보다 높은 순위를 갖도록 바뀌었다. `open_mutex` 아래에서 `s_umount`를 잡던 모든 in-tree 위치는 수정됐다.

`export_operations->encode_fh()`는 더 이상 `FILEID_INO32_GEN*` filehandle을 encode하는 기본 구현을 제공하지 않는다. 기본 동작을 쓰던 filesystem은 `generic_encode_ino32_fh()`를 명시적으로 사용할 수 있다.

cross-directory `->rename()`에서 `..` 갱신과 directory 변경 사이의 배제가 필요해도 callback이 이동 대상 subdirectory를 잠그면 안 된다. caller가 이미 잠근다. 반대로 same-directory rename에서는 의미 없는 `..` 갱신에 어떤 lock도 없으므로 old parent와 new parent가 같으면 갱신 자체를 하지 않는다. 같은 directory rename에서 두 subdirectory를 잠그면 서로 ancestor일 수 있어 deadlock이 생길 수 있다.

`lock_rename()`과 `lock_rename_child()`는 cross-directory 인자에 공통 ancestor가 없으면 실패할 수 있다. 이때 아무 lock도 잡지 않고 `ERR_PTR(-EXDEV)`를 반환한다. out-of-tree caller도 이를 처리해야 한다.

parent dentry의 child list는 hlist로 바뀌었다. anchor field는 `->d_subdirs`에서 `->d_children`, entry field는 `->d_child`에서 `->d_sib`로 이름이 바뀌어 영향을 받는 코드는 compile error로 드러난다.

`->d_delete()`는 이제 `->d_lock`을 보유하고 refcount가 0인 dentry에 호출된다. callback은 `->d_lock`을 놓았다가 다시 잡으면 안 된다.

Rename lock 책임
상황규칙
cross-directory `..` 갱신subdirectory lock은 caller가 획득
same-directory rename`..` 갱신 생략
공통 ancestor 없음`ERR_PTR(-EXDEV)`, lock 없음
`->d_delete()``->d_lock` 유지, refcount 0

cross-directory와 same-directory의 `..` 처리 규칙이 다르다.

---

**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.

---

**mandatory**

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.

---

**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.

---

**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.

---

**mandatory**

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.

---

**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 prune, block freeze, revalidation

1111-1168

`->d_prune()`는 parent의 `->d_lock` 없이 호출된다. victim dentry 자신의 `->d_lock`은 유지된다. parent별 배제가 필요하면 자체 spinlock을 사용한다.

`->d_iput()`와 `->d_release()`가 호출될 때 victim dentry는 아직 parent의 `->d_children`에 남아 있다. unhashed이고 killed 표시가 있으며 완전히 제거되지만 않았을 뿐이다. child list iterator는 이런 half-killed dentry를 만날 수 있다. 해당 `->d_lock`을 잡으면 negative, unhashed, negative refcount 상태를 보므로 대부분의 kernel code는 수정 없이 올바르게 처리한다.

block device freeze와 thaw는 holder operation으로 이동했다. 예전 `get_active_super()`는 `sb->s_bdev`의 main device superblock만 찾을 수 있었지만 이제 주어진 superblock이 소유한 모든 block device를 freeze할 수 있다. `get_active_super()` helper와 `bd_fsfreeze_sb` pointer는 제거됐다.

`set_blocksize()`는 `struct block_device` 대신 열린 `struct file`을 받으며 그 file은 반드시 exclusive open 상태여야 한다.

`->d_revalidate()`에는 parent directory inode와 dentry가 가져야 할 name이라는 두 인자가 추가됐다. 둘은 안정적이며 구현이 사용하지 않아도 된다. `name->name`은 안정적이고 NUL-terminated지만 pathname 내부를 가리키므로 `name->name[name->len]`이 `\0` 대신 `/`일 수 있다. filesystem root부터의 전체 path가 필요하면 여전히 직접 구성해야 한다.

`kern_path_locked()`와 `user_path_locked()`는 더 이상 negative dentry를 반환하지 않는다. name이 없으면 `ERR_PTR(-ENOENT)`를 반환하므로 negative dentry 검사도 필요 없다.

Dentry teardown 관찰 상태
CallbackParent listLock
`->d_prune()`victim이 아직 관계를 가질 수 있음victim `->d_lock`만 보유
`->d_iput()`·`->d_release()``->d_children`에 half-killed 상태victim 검사 시 `->d_lock` 획득

callback 시점별 parent list와 lock 상태를 구분한다.

**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.

---

**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.

---

**mandatory**

set_blocksize() takes opened struct file instead of struct block_device now
and it *must* be opened exclusive.

---

**mandatory**

->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.

---

**recommended**

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.

Exclusive lookup과 `->mkdir()` 반환

1169-1206

`lookup_one_qstr_excl()`은 더 많은 조건을 직접 error로 반환한다. `LOOKUP_CREATE`가 없으면 negative dentry 대신 `ERR_PTR(-ENOENT)`를, `LOOKUP_EXCL`이 있으면 positive dentry 대신 `ERR_PTR(-EEXIST)`를 반환한다. `LOOKUP_EXCL`은 이제 target이 존재하면 안 된다는 의미이며 `LOOKUP_CREATE` 또는 `LOOKUP_RENAME_TARGET`과 결합할 수 있다.

`invalidate_inodes()`는 제거됐으므로 `evict_inodes()`를 사용한다.

`->mkdir()`는 이제 dentry를 반환한다. 생성한 inode가 이미 cache에 있고 dentry도 있다면, 흔히 `IS_ROOT()`인 경우 기존 dentry를 주어진 name 위치에 splice하고 그 dentry를 반환해야 한다. 원래 전달받은 dentry를 사용했다면 NULL, 오류면 `ERR_PTR()`를 반환한다.

`d_instantiate_new()`로 `I_NEW` inode를 설치하는 filesystem은 보통 NULL을 안전하게 반환할 수 있다. inode가 `I_NEW`가 아닐 수 있다면 `d_drop(); d_splice_alias()`를 사용하고 뒤 함수의 결과를 반환한다. positive dentry를 돌려주지 못해도 cachefiles, nfsd, smb/server 같은 in-kernel client는 성능이 떨어질 수 있지만 fail-safe하게 동작한다.

`->mkdir()` 결과 선택
`I_NEW` + 원래 dentry 사용`d_instantiate_new()` 후 NULL 반환이미 cache된 inode·alias 발견`d_drop()` 후 `d_splice_alias()`splice 결과 dentry 반환오류는 `ERR_PTR()`

새 inode의 cache·alias 상태에 따라 반환 dentry가 달라진다.

---

**recommended**

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.

---

**mandatory**
invalidate_inodes() is gone use evict_inodes() instead.

---

**mandatory**

->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().

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.

Qstr lookup과 permission 없는 내부 lookup

1207-1249

`lookup_one()`, `lookup_one_unlocked()`, `lookup_one_positive_unlocked()`는 name과 len을 따로 받지 않고 `qstr`을 받는다. mount point를 통해 filesystem 외부에서 접근할 때는 mount의 `mnt_idmap`을 반영하는 이 함수들을 사용하고 `one_len` 변형을 쓰지 않는다.

`try_lookup_one_len()`, `lookup_one_len()`, `lookup_one_len_unlocked()`, `lookup_positive_unlocked()`은 각각 `try_lookup_noperm()`, `lookup_noperm()`, `lookup_noperm_unlocked()`, `lookup_noperm_positive_unlocked()`로 이름이 바뀌었다. 이들도 `qstr`을 받으며 길이에 `strlen()`이 필요하면 `QSTR()`를 쓴다.

이 `noperm` 함수들은 예전에 수행하던 parent의 실행 권한 `X` 검사도 하지 않는다. 권한이 무관함을 filesystem이 아는 자기 내부 lookup이나 `vfs_path_parent_lookup()` 뒤처럼 이미 권한 검사가 끝난 문맥에서만 사용해야 한다.

`d_hash_and_lookup()`은 VFS 밖에 export되지 않는다. 대신 `try_lookup_noperm()`을 사용한다. name validation이 추가되고 인자 순서는 반대지만 나머지 동작은 같다. 사용하려면 `linux/namei.h`를 include한다.

`->d_automount()` 반환 규약도 바뀌었다. 새 mount에 추가 reference를 잡지 말고 refcount 1인 상태 그대로 반환한다.

Lookup helper 이름 변경
이전현재
`try_lookup_one_len()``try_lookup_noperm()`
`lookup_one_len()``lookup_noperm()`
`lookup_one_len_unlocked()``lookup_noperm_unlocked()`
`lookup_positive_unlocked()``lookup_noperm_positive_unlocked()`
`d_hash_and_lookup()``try_lookup_noperm()`

permission을 검사하지 않는 내부용 API임을 이름에 명시했다.

---

** 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.

---

** 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()

---

** 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.

---

**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.

Path collection, dentry operation, mmap 준비

1250-1288

`collect_mounts()`, `drop_collected_mounts()`, `iterate_mounts()`는 제거됐다. 대체 API는 `collect_paths()`와 `drop_collected_path()`이며 별도 iterator는 필요 없다. clone된 mount tree 대신, 옛 `collect_mounts()`가 만들 각 mount root에 대응하는 caller namespace 위치의 `struct path` 배열을 반환한다.

filesystem이 기본 `dentry_operations`를 설정한다면 `sb->s_d_op`를 직접 대입하지 말고 `set_default_d_op()`를 사용한다.

`d_set_d_op()`은 public/export API가 아니다. 정말 dentry마다 다른 operation이 필요하면 `d_splice_alias_ops()`로 설정한다. 그렇지 않다면 mount 때 `set_default_d_op()`를 한 번 호출하는 편이 낫다. 현재 실제로 dentry별 `->d_op` 차이가 필요한 것은 procfs뿐이라고 문서는 말한다.

file operation의 `mmap()` callback은 `mmap_prepare()`로 대체하는 것이 강력히 권장된다. 이 단계에는 VMA가 아직 유효하지 않으므로 VMA 대신 `vm_area_desc` pointer를 받는다. `vm_area_desc`는 file-backed mapping 초기화에 필요한 최소 입력과 filesystem이 상태를 설정할 출력 field를 제공한다.

Mount·dentry·mmap API
영역새 API
mount collection`collect_paths()` / `drop_collected_path()`
기본 dentry operation`set_default_d_op()`
dentry별 operation`d_splice_alias_ops()`
memory mapping`mmap_prepare(vm_area_desc *)`

복제 객체 대신 path 배열과 준비 단계 descriptor를 사용한다.

---

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.

---

**mandatory**

If your filesystem sets the default dentry_operations, use set_default_d_op()
rather than manually setting sb->s_d_op.

---

**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.

---

**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.

Path helper 이름과 filesystem string parsing

1289-1311

여러 path helper 이름이 작업의 시작·종료 의미를 드러내도록 바뀌었다. `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`로 바꾼다.

`vfs_parse_fs_string()`의 호출 규약에서는 length 인자가 제거됐다. 값 길이는 `value ? strlen(value) : 0`으로 계산된다. 다른 길이를 사용하려면 `vfs_parse_fs_qstr(fc, key, &QSTR_LEN(value, len))`을 호출한다.

Path helper rename
이전현재
`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`

호출이 path 생성·제거 작업의 어느 단계인지 이름에 명시한다.

---

**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

---

**mandatory**

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.