| 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_state_read_once(inode) & 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() and ->mount() are gone. Switch to using the new mount API. See |
| 452 |
Documentation/filesystems/mount_api.rst for more details. |
| 453 |
|
| 454 |
--- |
| 455 |
|
| 456 |
**mandatory** |
| 457 |
|
| 458 |
->permission() and generic_permission()have lost flags |
| 459 |
argument; instead of passing IPERM_FLAG_RCU we add MAY_NOT_BLOCK into mask. |
| 460 |
|
| 461 |
generic_permission() has also lost the check_acl argument; ACL checking |
| 462 |
has been taken to VFS and filesystems need to provide a non-NULL |
| 463 |
->i_op->get_inode_acl to read an ACL from disk. |
| 464 |
|
| 465 |
--- |
| 466 |
|
| 467 |
**mandatory** |
| 468 |
|
| 469 |
If you implement your own ->llseek() you must handle SEEK_HOLE and |
| 470 |
SEEK_DATA. You can handle this by returning -EINVAL, but it would be nicer to |
| 471 |
support it in some way. The generic handler assumes that the entire file is |
| 472 |
data and there is a virtual hole at the end of the file. So if the provided |
| 473 |
offset is less than i_size and SEEK_DATA is specified, return the same offset. |
| 474 |
If the above is true for the offset and you are given SEEK_HOLE, return the end |
| 475 |
of the file. If the offset is i_size or greater return -ENXIO in either case. |
| 476 |
|
| 477 |
**mandatory** |
| 478 |
|
| 479 |
If you have your own ->fsync() you must make sure to call |
| 480 |
filemap_write_and_wait_range() so that all dirty pages are synced out properly. |
| 481 |
You must also keep in mind that ->fsync() is not called with i_mutex held |
| 482 |
anymore, so if you require i_mutex locking you must make sure to take it and |
| 483 |
release it yourself. |
| 484 |
|
| 485 |
--- |
| 486 |
|
| 487 |
**mandatory** |
| 488 |
|
| 489 |
d_alloc_root() is gone, along with a lot of bugs caused by code |
| 490 |
misusing it. Replacement: d_make_root(inode). On success d_make_root(inode) |
| 491 |
allocates and returns a new dentry instantiated with the passed in inode. |
| 492 |
On failure NULL is returned and the passed in inode is dropped so the reference |
| 493 |
to inode is consumed in all cases and failure handling need not do any cleanup |
| 494 |
for the inode. If d_make_root(inode) is passed a NULL inode it returns NULL |
| 495 |
and also requires no further error handling. Typical usage is:: |
| 496 |
|
| 497 |
inode = foofs_new_inode(....); |
| 498 |
s->s_root = d_make_root(inode); |
| 499 |
if (!s->s_root) |
| 500 |
/* Nothing needed for the inode cleanup */ |
| 501 |
return -ENOMEM; |
| 502 |
... |
| 503 |
|
| 504 |
--- |
| 505 |
|
| 506 |
**mandatory** |
| 507 |
|
| 508 |
The witch is dead! Well, 2/3 of it, anyway. ->d_revalidate() and |
| 509 |
->lookup() do *not* take struct nameidata anymore; just the flags. |
| 510 |
|
| 511 |
--- |
| 512 |
|
| 513 |
**mandatory** |
| 514 |
|
| 515 |
->create() doesn't take ``struct nameidata *``; unlike the previous |
| 516 |
two, it gets "is it an O_EXCL or equivalent?" boolean argument. Note that |
| 517 |
local filesystems can ignore this argument - they are guaranteed that the |
| 518 |
object doesn't exist. It's remote/distributed ones that might care... |
| 519 |
|
| 520 |
--- |
| 521 |
|
| 522 |
**mandatory** |
| 523 |
|
| 524 |
FS_REVAL_DOT is gone; if you used to have it, add ->d_weak_revalidate() |
| 525 |
in your dentry operations instead. |
| 526 |
|
| 527 |
--- |
| 528 |
|
| 529 |
**mandatory** |
| 530 |
|
| 531 |
vfs_readdir() is gone; switch to iterate_dir() instead |
| 532 |
|
| 533 |
--- |
| 534 |
|
| 535 |
**mandatory** |
| 536 |
|
| 537 |
->readdir() is gone now; switch to ->iterate_shared() |
| 538 |
|
| 539 |
**mandatory** |
| 540 |
|
| 541 |
vfs_follow_link has been removed. Filesystems must use nd_set_link |
| 542 |
from ->follow_link for normal symlinks, or nd_jump_link for magic |
| 543 |
/proc/<pid> style links. |
| 544 |
|
| 545 |
--- |
| 546 |
|
| 547 |
**mandatory** |
| 548 |
|
| 549 |
iget5_locked()/ilookup5()/ilookup5_nowait() test() callback used to be |
| 550 |
called with both ->i_lock and inode_hash_lock held; the former is *not* |
| 551 |
taken anymore, so verify that your callbacks do not rely on it (none |
| 552 |
of the in-tree instances did). inode_hash_lock is still held, |
| 553 |
of course, so they are still serialized wrt removal from inode hash, |
| 554 |
as well as wrt set() callback of iget5_locked(). |
| 555 |
|
| 556 |
--- |
| 557 |
|
| 558 |
**mandatory** |
| 559 |
|
| 560 |
d_materialise_unique() is gone; d_splice_alias() does everything you |
| 561 |
need now. Remember that they have opposite orders of arguments ;-/ |
| 562 |
|
| 563 |
--- |
| 564 |
|
| 565 |
**mandatory** |
| 566 |
|
| 567 |
f_dentry is gone; use f_path.dentry, or, better yet, see if you can avoid |
| 568 |
it entirely. |
| 569 |
|
| 570 |
--- |
| 571 |
|
| 572 |
**mandatory** |
| 573 |
|
| 574 |
never call ->read() and ->write() directly; use __vfs_{read,write} or |
| 575 |
wrappers; instead of checking for ->write or ->read being NULL, look for |
| 576 |
FMODE_CAN_{WRITE,READ} in file->f_mode. |
| 577 |
|
| 578 |
--- |
| 579 |
|
| 580 |
**mandatory** |
| 581 |
|
| 582 |
do _not_ use new_sync_{read,write} for ->read/->write; leave it NULL |
| 583 |
instead. |
| 584 |
|
| 585 |
--- |
| 586 |
|
| 587 |
**mandatory** |
| 588 |
->aio_read/->aio_write are gone. Use ->read_iter/->write_iter. |
| 589 |
|
| 590 |
--- |
| 591 |
|
| 592 |
**recommended** |
| 593 |
|
| 594 |
for embedded ("fast") symlinks just set inode->i_link to wherever the |
| 595 |
symlink body is and use simple_follow_link() as ->follow_link(). |
| 596 |
|
| 597 |
--- |
| 598 |
|
| 599 |
**mandatory** |
| 600 |
|
| 601 |
calling conventions for ->follow_link() have changed. Instead of returning |
| 602 |
cookie and using nd_set_link() to store the body to traverse, we return |
| 603 |
the body to traverse and store the cookie using explicit void ** argument. |
| 604 |
nameidata isn't passed at all - nd_jump_link() doesn't need it and |
| 605 |
nd_[gs]et_link() is gone. |
| 606 |
|
| 607 |
--- |
| 608 |
|
| 609 |
**mandatory** |
| 610 |
|
| 611 |
calling conventions for ->put_link() have changed. It gets inode instead of |
| 612 |
dentry, it does not get nameidata at all and it gets called only when cookie |
| 613 |
is non-NULL. Note that link body isn't available anymore, so if you need it, |
| 614 |
store it as cookie. |
| 615 |
|
| 616 |
--- |
| 617 |
|
| 618 |
**mandatory** |
| 619 |
|
| 620 |
any symlink that might use page_follow_link_light/page_put_link() must |
| 621 |
have inode_nohighmem(inode) called before anything might start playing with |
| 622 |
its pagecache. No highmem pages should end up in the pagecache of such |
| 623 |
symlinks. That includes any preseeding that might be done during symlink |
| 624 |
creation. page_symlink() will honour the mapping gfp flags, so once |
| 625 |
you've done inode_nohighmem() it's safe to use, but if you allocate and |
| 626 |
insert the page manually, make sure to use the right gfp flags. |
| 627 |
|
| 628 |
--- |
| 629 |
|
| 630 |
**mandatory** |
| 631 |
|
| 632 |
->follow_link() is replaced with ->get_link(); same API, except that |
| 633 |
|
| 634 |
* ->get_link() gets inode as a separate argument |
| 635 |
* ->get_link() may be called in RCU mode - in that case NULL |
| 636 |
dentry is passed |
| 637 |
|
| 638 |
--- |
| 639 |
|
| 640 |
**mandatory** |
| 641 |
|
| 642 |
->get_link() gets struct delayed_call ``*done`` now, and should do |
| 643 |
set_delayed_call() where it used to set ``*cookie``. |
| 644 |
|
| 645 |
->put_link() is gone - just give the destructor to set_delayed_call() |
| 646 |
in ->get_link(). |
| 647 |
|
| 648 |
--- |
| 649 |
|
| 650 |
**mandatory** |
| 651 |
|
| 652 |
->getxattr() and xattr_handler.get() get dentry and inode passed separately. |
| 653 |
dentry might be yet to be attached to inode, so do _not_ use its ->d_inode |
| 654 |
in the instances. Rationale: !@#!@# security_d_instantiate() needs to be |
| 655 |
called before we attach dentry to inode. |
| 656 |
|
| 657 |
--- |
| 658 |
|
| 659 |
**mandatory** |
| 660 |
|
| 661 |
symlinks are no longer the only inodes that do *not* have i_bdev/i_cdev/ |
| 662 |
i_pipe/i_link union zeroed out at inode eviction. As the result, you can't |
| 663 |
assume that non-NULL value in ->i_nlink at ->destroy_inode() implies that |
| 664 |
it's a symlink. Checking ->i_mode is really needed now. In-tree we had |
| 665 |
to fix shmem_destroy_callback() that used to take that kind of shortcut; |
| 666 |
watch out, since that shortcut is no longer valid. |
| 667 |
|
| 668 |
--- |
| 669 |
|
| 670 |
**mandatory** |
| 671 |
|
| 672 |
->i_mutex is replaced with ->i_rwsem now. inode_lock() et.al. work as |
| 673 |
they used to - they just take it exclusive. However, ->lookup() may be |
| 674 |
called with parent locked shared. Its instances must not |
| 675 |
|
| 676 |
* use d_instantiate) and d_rehash() separately - use d_add() or |
| 677 |
d_splice_alias() instead. |
| 678 |
* use d_rehash() alone - call d_add(new_dentry, NULL) instead. |
| 679 |
* in the unlikely case when (read-only) access to filesystem |
| 680 |
data structures needs exclusion for some reason, arrange it |
| 681 |
yourself. None of the in-tree filesystems needed that. |
| 682 |
* rely on ->d_parent and ->d_name not changing after dentry has |
| 683 |
been fed to d_add() or d_splice_alias(). Again, none of the |
| 684 |
in-tree instances relied upon that. |
| 685 |
|
| 686 |
We are guaranteed that lookups of the same name in the same directory |
| 687 |
will not happen in parallel ("same" in the sense of your ->d_compare()). |
| 688 |
Lookups on different names in the same directory can and do happen in |
| 689 |
parallel now. |
| 690 |
|
| 691 |
--- |
| 692 |
|
| 693 |
**mandatory** |
| 694 |
|
| 695 |
->iterate_shared() is added. |
| 696 |
Exclusion on struct file level is still provided (as well as that |
| 697 |
between it and lseek on the same struct file), but if your directory |
| 698 |
has been opened several times, you can get these called in parallel. |
| 699 |
Exclusion between that method and all directory-modifying ones is |
| 700 |
still provided, of course. |
| 701 |
|
| 702 |
If you have any per-inode or per-dentry in-core data structures modified |
| 703 |
by ->iterate_shared(), you might need something to serialize the access |
| 704 |
to them. If you do dcache pre-seeding, you'll need to switch to |
| 705 |
d_alloc_parallel() for that; look for in-tree examples. |
| 706 |
|
| 707 |
--- |
| 708 |
|
| 709 |
**mandatory** |
| 710 |
|
| 711 |
->atomic_open() calls without O_CREAT may happen in parallel. |
| 712 |
|
| 713 |
--- |
| 714 |
|
| 715 |
**mandatory** |
| 716 |
|
| 717 |
->setxattr() and xattr_handler.set() get dentry and inode passed separately. |
| 718 |
The xattr_handler.set() gets passed the user namespace of the mount the inode |
| 719 |
is seen from so filesystems can idmap the i_uid and i_gid accordingly. |
| 720 |
dentry might be yet to be attached to inode, so do _not_ use its ->d_inode |
| 721 |
in the instances. Rationale: !@#!@# security_d_instantiate() needs to be |
| 722 |
called before we attach dentry to inode and !@#!@##!@$!$#!@#$!@$!@$ smack |
| 723 |
->d_instantiate() uses not just ->getxattr() but ->setxattr() as well. |
| 724 |
|
| 725 |
--- |
| 726 |
|
| 727 |
**mandatory** |
| 728 |
|
| 729 |
->d_compare() doesn't get parent as a separate argument anymore. If you |
| 730 |
used it for finding the struct super_block involved, dentry->d_sb will |
| 731 |
work just as well; if it's something more complicated, use dentry->d_parent. |
| 732 |
Just be careful not to assume that fetching it more than once will yield |
| 733 |
the same value - in RCU mode it could change under you. |
| 734 |
|
| 735 |
--- |
| 736 |
|
| 737 |
**mandatory** |
| 738 |
|
| 739 |
->rename() has an added flags argument. Any flags not handled by the |
| 740 |
filesystem should result in EINVAL being returned. |
| 741 |
|
| 742 |
--- |
| 743 |
|
| 744 |
|
| 745 |
**recommended** |
| 746 |
|
| 747 |
->readlink is optional for symlinks. Don't set, unless filesystem needs |
| 748 |
to fake something for readlink(2). |
| 749 |
|
| 750 |
--- |
| 751 |
|
| 752 |
**mandatory** |
| 753 |
|
| 754 |
->getattr() is now passed a struct path rather than a vfsmount and |
| 755 |
dentry separately, and it now has request_mask and query_flags arguments |
| 756 |
to specify the fields and sync type requested by statx. Filesystems not |
| 757 |
supporting any statx-specific features may ignore the new arguments. |
| 758 |
|
| 759 |
--- |
| 760 |
|
| 761 |
**mandatory** |
| 762 |
|
| 763 |
->atomic_open() calling conventions have changed. Gone is ``int *opened``, |
| 764 |
along with FILE_OPENED/FILE_CREATED. In place of those we have |
| 765 |
FMODE_OPENED/FMODE_CREATED, set in file->f_mode. Additionally, return |
| 766 |
value for 'called finish_no_open(), open it yourself' case has become |
| 767 |
0, not 1. Since finish_no_open() itself is returning 0 now, that part |
| 768 |
does not need any changes in ->atomic_open() instances. |
| 769 |
|
| 770 |
--- |
| 771 |
|
| 772 |
**mandatory** |
| 773 |
|
| 774 |
alloc_file() has become static now; two wrappers are to be used instead. |
| 775 |
alloc_file_pseudo(inode, vfsmount, name, flags, ops) is for the cases |
| 776 |
when dentry needs to be created; that's the majority of old alloc_file() |
| 777 |
users. Calling conventions: on success a reference to new struct file |
| 778 |
is returned and callers reference to inode is subsumed by that. On |
| 779 |
failure, ERR_PTR() is returned and no caller's references are affected, |
| 780 |
so the caller needs to drop the inode reference it held. |
| 781 |
alloc_file_clone(file, flags, ops) does not affect any caller's references. |
| 782 |
On success you get a new struct file sharing the mount/dentry with the |
| 783 |
original, on failure - ERR_PTR(). |
| 784 |
|
| 785 |
--- |
| 786 |
|
| 787 |
**mandatory** |
| 788 |
|
| 789 |
->clone_file_range() and ->dedupe_file_range have been replaced with |
| 790 |
->remap_file_range(). See Documentation/filesystems/vfs.rst for more |
| 791 |
information. |
| 792 |
|
| 793 |
--- |
| 794 |
|
| 795 |
**recommended** |
| 796 |
|
| 797 |
->lookup() instances doing an equivalent of:: |
| 798 |
|
| 799 |
if (IS_ERR(inode)) |
| 800 |
return ERR_CAST(inode); |
| 801 |
return d_splice_alias(inode, dentry); |
| 802 |
|
| 803 |
don't need to bother with the check - d_splice_alias() will do the |
| 804 |
right thing when given ERR_PTR(...) as inode. Moreover, passing NULL |
| 805 |
inode to d_splice_alias() will also do the right thing (equivalent of |
| 806 |
d_add(dentry, NULL); return NULL;), so that kind of special cases |
| 807 |
also doesn't need a separate treatment. |
| 808 |
|
| 809 |
--- |
| 810 |
|
| 811 |
**strongly recommended** |
| 812 |
|
| 813 |
take the RCU-delayed parts of ->destroy_inode() into a new method - |
| 814 |
->free_inode(). If ->destroy_inode() becomes empty - all the better, |
| 815 |
just get rid of it. Synchronous work (e.g. the stuff that can't |
| 816 |
be done from an RCU callback, or any WARN_ON() where we want the |
| 817 |
stack trace) *might* be movable to ->evict_inode(); however, |
| 818 |
that goes only for the things that are not needed to balance something |
| 819 |
done by ->alloc_inode(). IOW, if it's cleaning up the stuff that |
| 820 |
might have accumulated over the life of in-core inode, ->evict_inode() |
| 821 |
might be a fit. |
| 822 |
|
| 823 |
Rules for inode destruction: |
| 824 |
|
| 825 |
* if ->destroy_inode() is non-NULL, it gets called |
| 826 |
* if ->free_inode() is non-NULL, it gets scheduled by call_rcu() |
| 827 |
* combination of NULL ->destroy_inode and NULL ->free_inode is |
| 828 |
treated as NULL/free_inode_nonrcu, to preserve the compatibility. |
| 829 |
|
| 830 |
Note that the callback (be it via ->free_inode() or explicit call_rcu() |
| 831 |
in ->destroy_inode()) is *NOT* ordered wrt superblock destruction; |
| 832 |
as the matter of fact, the superblock and all associated structures |
| 833 |
might be already gone. The filesystem driver is guaranteed to be still |
| 834 |
there, but that's it. Freeing memory in the callback is fine; doing |
| 835 |
more than that is possible, but requires a lot of care and is best |
| 836 |
avoided. |
| 837 |
|
| 838 |
--- |
| 839 |
|
| 840 |
**mandatory** |
| 841 |
|
| 842 |
DCACHE_RCUACCESS is gone; having an RCU delay on dentry freeing is the |
| 843 |
default. DCACHE_NORCU opts out, and only d_alloc_pseudo() has any |
| 844 |
business doing so. |
| 845 |
|
| 846 |
--- |
| 847 |
|
| 848 |
**mandatory** |
| 849 |
|
| 850 |
d_alloc_pseudo() is internal-only; uses outside of alloc_file_pseudo() are |
| 851 |
very suspect (and won't work in modules). Such uses are very likely to |
| 852 |
be misspelled d_alloc_anon(). |
| 853 |
|
| 854 |
--- |
| 855 |
|
| 856 |
**mandatory** |
| 857 |
|
| 858 |
[should've been added in 2016] stale comment in finish_open() notwithstanding, |
| 859 |
failure exits in ->atomic_open() instances should *NOT* fput() the file, |
| 860 |
no matter what. Everything is handled by the caller. |
| 861 |
|
| 862 |
--- |
| 863 |
|
| 864 |
**mandatory** |
| 865 |
|
| 866 |
clone_private_mount() returns a longterm mount now, so the proper destructor of |
| 867 |
its result is kern_unmount() or kern_unmount_array(). |
| 868 |
|
| 869 |
--- |
| 870 |
|
| 871 |
**mandatory** |
| 872 |
|
| 873 |
zero-length bvec segments are disallowed, they must be filtered out before |
| 874 |
passed on to an iterator. |
| 875 |
|
| 876 |
--- |
| 877 |
|
| 878 |
**mandatory** |
| 879 |
|
| 880 |
For bvec based itererators bio_iov_iter_get_pages() now doesn't copy bvecs but |
| 881 |
uses the one provided. Anyone issuing kiocb-I/O should ensure that the bvec and |
| 882 |
page references stay until I/O has completed, i.e. until ->ki_complete() has |
| 883 |
been called or returned with non -EIOCBQUEUED code. |
| 884 |
|
| 885 |
--- |
| 886 |
|
| 887 |
**mandatory** |
| 888 |
|
| 889 |
mnt_want_write_file() can now only be paired with mnt_drop_write_file(), |
| 890 |
whereas previously it could be paired with mnt_drop_write() as well. |
| 891 |
|
| 892 |
--- |
| 893 |
|
| 894 |
**mandatory** |
| 895 |
|
| 896 |
iov_iter_copy_from_user_atomic() is gone; use copy_page_from_iter_atomic(). |
| 897 |
The difference is copy_page_from_iter_atomic() advances the iterator and |
| 898 |
you don't need iov_iter_advance() after it. However, if you decide to use |
| 899 |
only a part of obtained data, you should do iov_iter_revert(). |
| 900 |
|
| 901 |
--- |
| 902 |
|
| 903 |
**mandatory** |
| 904 |
|
| 905 |
Calling conventions for file_open_root() changed; now it takes struct path * |
| 906 |
instead of passing mount and dentry separately. For callers that used to |
| 907 |
pass <mnt, mnt->mnt_root> pair (i.e. the root of given mount), a new helper |
| 908 |
is provided - file_open_root_mnt(). In-tree users adjusted. |
| 909 |
|
| 910 |
--- |
| 911 |
|
| 912 |
**mandatory** |
| 913 |
|
| 914 |
no_llseek is gone; don't set .llseek to that - just leave it NULL instead. |
| 915 |
Checks for "does that file have llseek(2), or should it fail with ESPIPE" |
| 916 |
should be done by looking at FMODE_LSEEK in file->f_mode. |
| 917 |
|
| 918 |
--- |
| 919 |
|
| 920 |
*mandatory* |
| 921 |
|
| 922 |
filldir_t (readdir callbacks) calling conventions have changed. Instead of |
| 923 |
returning 0 or -E... it returns bool now. false means "no more" (as -E... used |
| 924 |
to) and true - "keep going" (as 0 in old calling conventions). Rationale: |
| 925 |
callers never looked at specific -E... values anyway. -> iterate_shared() |
| 926 |
instances require no changes at all, all filldir_t ones in the tree |
| 927 |
converted. |
| 928 |
|
| 929 |
--- |
| 930 |
|
| 931 |
**mandatory** |
| 932 |
|
| 933 |
Calling conventions for ->tmpfile() have changed. It now takes a struct |
| 934 |
file pointer instead of struct dentry pointer. d_tmpfile() is similarly |
| 935 |
changed to simplify callers. The passed file is in a non-open state and on |
| 936 |
success must be opened before returning (e.g. by calling |
| 937 |
finish_open_simple()). |
| 938 |
|
| 939 |
--- |
| 940 |
|
| 941 |
**mandatory** |
| 942 |
|
| 943 |
Calling convention for ->huge_fault has changed. It now takes a page |
| 944 |
order instead of an enum page_entry_size, and it may be called without the |
| 945 |
mmap_lock held. All in-tree users have been audited and do not seem to |
| 946 |
depend on the mmap_lock being held, but out of tree users should verify |
| 947 |
for themselves. If they do need it, they can return VM_FAULT_RETRY to |
| 948 |
be called with the mmap_lock held. |
| 949 |
|
| 950 |
--- |
| 951 |
|
| 952 |
**mandatory** |
| 953 |
|
| 954 |
The order of opening block devices and matching or creating superblocks has |
| 955 |
changed. |
| 956 |
|
| 957 |
The old logic opened block devices first and then tried to find a |
| 958 |
suitable superblock to reuse based on the block device pointer. |
| 959 |
|
| 960 |
The new logic tries to find a suitable superblock first based on the device |
| 961 |
number, and opening the block device afterwards. |
| 962 |
|
| 963 |
Since opening block devices cannot happen under s_umount because of lock |
| 964 |
ordering requirements s_umount is now dropped while opening block devices and |
| 965 |
reacquired before calling fill_super(). |
| 966 |
|
| 967 |
In the old logic concurrent mounters would find the superblock on the list of |
| 968 |
superblocks for the filesystem type. Since the first opener of the block device |
| 969 |
would hold s_umount they would wait until the superblock became either born or |
| 970 |
was discarded due to initialization failure. |
| 971 |
|
| 972 |
Since the new logic drops s_umount concurrent mounters could grab s_umount and |
| 973 |
would spin. Instead they are now made to wait using an explicit wait-wake |
| 974 |
mechanism without having to hold s_umount. |
| 975 |
|
| 976 |
--- |
| 977 |
|
| 978 |
**mandatory** |
| 979 |
|
| 980 |
The holder of a block device is now the superblock. |
| 981 |
|
| 982 |
The holder of a block device used to be the file_system_type which wasn't |
| 983 |
particularly useful. It wasn't possible to go from block device to owning |
| 984 |
superblock without matching on the device pointer stored in the superblock. |
| 985 |
This mechanism would only work for a single device so the block layer couldn't |
| 986 |
find the owning superblock of any additional devices. |
| 987 |
|
| 988 |
In the old mechanism reusing or creating a superblock for a racing mount(2) and |
| 989 |
umount(2) relied on the file_system_type as the holder. This was severely |
| 990 |
underdocumented however: |
| 991 |
|
| 992 |
(1) Any concurrent mounter that managed to grab an active reference on an |
| 993 |
existing superblock was made to wait until the superblock either became |
| 994 |
ready or until the superblock was removed from the list of superblocks of |
| 995 |
the filesystem type. If the superblock is ready the caller would simple |
| 996 |
reuse it. |
| 997 |
|
| 998 |
(2) If the mounter came after deactivate_locked_super() but before |
| 999 |
the superblock had been removed from the list of superblocks of the |
| 1000 |
filesystem type the mounter would wait until the superblock was shutdown, |
| 1001 |
reuse the block device and allocate a new superblock. |
| 1002 |
|
| 1003 |
(3) If the mounter came after deactivate_locked_super() and after |
| 1004 |
the superblock had been removed from the list of superblocks of the |
| 1005 |
filesystem type the mounter would reuse the block device and allocate a new |
| 1006 |
superblock (the bd_holder point may still be set to the filesystem type). |
| 1007 |
|
| 1008 |
Because the holder of the block device was the file_system_type any concurrent |
| 1009 |
mounter could open the block devices of any superblock of the same |
| 1010 |
file_system_type without risking seeing EBUSY because the block device was |
| 1011 |
still in use by another superblock. |
| 1012 |
|
| 1013 |
Making the superblock the owner of the block device changes this as the holder |
| 1014 |
is now a unique superblock and thus block devices associated with it cannot be |
| 1015 |
reused by concurrent mounters. So a concurrent mounter in (2) could suddenly |
| 1016 |
see EBUSY when trying to open a block device whose holder was a different |
| 1017 |
superblock. |
| 1018 |
|
| 1019 |
The new logic thus waits until the superblock and the devices are shutdown in |
| 1020 |
->kill_sb(). Removal of the superblock from the list of superblocks of the |
| 1021 |
filesystem type is now moved to a later point when the devices are closed: |
| 1022 |
|
| 1023 |
(1) Any concurrent mounter managing to grab an active reference on an existing |
| 1024 |
superblock is made to wait until the superblock is either ready or until |
| 1025 |
the superblock and all devices are shutdown in ->kill_sb(). If the |
| 1026 |
superblock is ready the caller will simply reuse it. |
| 1027 |
|
| 1028 |
(2) If the mounter comes after deactivate_locked_super() but before |
| 1029 |
the superblock has been removed from the list of superblocks of the |
| 1030 |
filesystem type the mounter is made to wait until the superblock and the |
| 1031 |
devices are shut down in ->kill_sb() and the superblock is removed from the |
| 1032 |
list of superblocks of the filesystem type. The mounter will allocate a new |
| 1033 |
superblock and grab ownership of the block device (the bd_holder pointer of |
| 1034 |
the block device will be set to the newly allocated superblock). |
| 1035 |
|
| 1036 |
(3) This case is now collapsed into (2) as the superblock is left on the list |
| 1037 |
of superblocks of the filesystem type until all devices are shutdown in |
| 1038 |
->kill_sb(). In other words, if the superblock isn't on the list of |
| 1039 |
superblock of the filesystem type anymore then it has given up ownership of |
| 1040 |
all associated block devices (the bd_holder pointer is NULL). |
| 1041 |
|
| 1042 |
As this is a VFS level change it has no practical consequences for filesystems |
| 1043 |
other than that all of them must use one of the provided kill_litter_super(), |
| 1044 |
kill_anon_super(), or kill_block_super() helpers. |
| 1045 |
|
| 1046 |
--- |
| 1047 |
|
| 1048 |
**mandatory** |
| 1049 |
|
| 1050 |
Lock ordering has been changed so that s_umount ranks above open_mutex again. |
| 1051 |
All places where s_umount was taken under open_mutex have been fixed up. |
| 1052 |
|
| 1053 |
--- |
| 1054 |
|
| 1055 |
**mandatory** |
| 1056 |
|
| 1057 |
export_operations ->encode_fh() no longer has a default implementation to |
| 1058 |
encode FILEID_INO32_GEN* file handles. |
| 1059 |
Filesystems that used the default implementation may use the generic helper |
| 1060 |
generic_encode_ino32_fh() explicitly. |
| 1061 |
|
| 1062 |
--- |
| 1063 |
|
| 1064 |
**mandatory** |
| 1065 |
|
| 1066 |
If ->rename() update of .. on cross-directory move needs an exclusion with |
| 1067 |
directory modifications, do *not* lock the subdirectory in question in your |
| 1068 |
->rename() - it's done by the caller now [that item should've been added in |
| 1069 |
28eceeda130f "fs: Lock moved directories"]. |
| 1070 |
|
| 1071 |
--- |
| 1072 |
|
| 1073 |
**mandatory** |
| 1074 |
|
| 1075 |
On same-directory ->rename() the (tautological) update of .. is not protected |
| 1076 |
by any locks; just don't do it if the old parent is the same as the new one. |
| 1077 |
We really can't lock two subdirectories in same-directory rename - not without |
| 1078 |
deadlocks. |
| 1079 |
|
| 1080 |
--- |
| 1081 |
|
| 1082 |
**mandatory** |
| 1083 |
|
| 1084 |
lock_rename() and lock_rename_child() may fail in cross-directory case, if |
| 1085 |
their arguments do not have a common ancestor. In that case ERR_PTR(-EXDEV) |
| 1086 |
is returned, with no locks taken. In-tree users updated; out-of-tree ones |
| 1087 |
would need to do so. |
| 1088 |
|
| 1089 |
--- |
| 1090 |
|
| 1091 |
**mandatory** |
| 1092 |
|
| 1093 |
The list of children anchored in parent dentry got turned into hlist now. |
| 1094 |
Field names got changed (->d_children/->d_sib instead of ->d_subdirs/->d_child |
| 1095 |
for anchor/entries resp.), so any affected places will be immediately caught |
| 1096 |
by compiler. |
| 1097 |
|
| 1098 |
--- |
| 1099 |
|
| 1100 |
**mandatory** |
| 1101 |
|
| 1102 |
->d_delete() instances are now called for dentries with ->d_lock held |
| 1103 |
and refcount equal to 0. They are not permitted to drop/regain ->d_lock. |
| 1104 |
None of in-tree instances did anything of that sort. Make sure yours do not... |
| 1105 |
|
| 1106 |
--- |
| 1107 |
|
| 1108 |
**mandatory** |
| 1109 |
|
| 1110 |
->d_prune() instances are now called without ->d_lock held on the parent. |
| 1111 |
->d_lock on dentry itself is still held; if you need per-parent exclusions (none |
| 1112 |
of the in-tree instances did), use your own spinlock. |
| 1113 |
|
| 1114 |
->d_iput() and ->d_release() are called with victim dentry still in the |
| 1115 |
list of parent's children. It is still unhashed, marked killed, etc., just not |
| 1116 |
removed from parent's ->d_children yet. |
| 1117 |
|
| 1118 |
Anyone iterating through the list of children needs to be aware of the |
| 1119 |
half-killed dentries that might be seen there; taking ->d_lock on those will |
| 1120 |
see them negative, unhashed and with negative refcount, which means that most |
| 1121 |
of the in-kernel users would've done the right thing anyway without any adjustment. |
| 1122 |
|
| 1123 |
--- |
| 1124 |
|
| 1125 |
**recommended** |
| 1126 |
|
| 1127 |
Block device freezing and thawing have been moved to holder operations. |
| 1128 |
|
| 1129 |
Before this change, get_active_super() would only be able to find the |
| 1130 |
superblock of the main block device, i.e., the one stored in sb->s_bdev. Block |
| 1131 |
device freezing now works for any block device owned by a given superblock, not |
| 1132 |
just the main block device. The get_active_super() helper and bd_fsfreeze_sb |
| 1133 |
pointer are gone. |
| 1134 |
|
| 1135 |
--- |
| 1136 |
|
| 1137 |
**mandatory** |
| 1138 |
|
| 1139 |
set_blocksize() takes opened struct file instead of struct block_device now |
| 1140 |
and it *must* be opened exclusive. |
| 1141 |
|
| 1142 |
--- |
| 1143 |
|
| 1144 |
**mandatory** |
| 1145 |
|
| 1146 |
->d_revalidate() gets two extra arguments - inode of parent directory and |
| 1147 |
name our dentry is expected to have. Both are stable (dir is pinned in |
| 1148 |
non-RCU case and will stay around during the call in RCU case, and name |
| 1149 |
is guaranteed to stay unchanging). Your instance doesn't have to use |
| 1150 |
either, but it often helps to avoid a lot of painful boilerplate. |
| 1151 |
Note that while name->name is stable and NUL-terminated, it may (and |
| 1152 |
often will) have name->name[name->len] equal to '/' rather than '\0' - |
| 1153 |
in normal case it points into the pathname being looked up. |
| 1154 |
NOTE: if you need something like full path from the root of filesystem, |
| 1155 |
you are still on your own - this assists with simple cases, but it's not |
| 1156 |
magic. |
| 1157 |
|
| 1158 |
--- |
| 1159 |
|
| 1160 |
**recommended** |
| 1161 |
|
| 1162 |
kern_path_locked() and user_path_locked() no longer return a negative |
| 1163 |
dentry so this doesn't need to be checked. If the name cannot be found, |
| 1164 |
ERR_PTR(-ENOENT) is returned. |
| 1165 |
|
| 1166 |
--- |
| 1167 |
|
| 1168 |
**recommended** |
| 1169 |
|
| 1170 |
lookup_one_qstr_excl() is changed to return errors in more cases, so |
| 1171 |
these conditions don't require explicit checks: |
| 1172 |
|
| 1173 |
- if LOOKUP_CREATE is NOT given, then the dentry won't be negative, |
| 1174 |
ERR_PTR(-ENOENT) is returned instead |
| 1175 |
- if LOOKUP_EXCL IS given, then the dentry won't be positive, |
| 1176 |
ERR_PTR(-EEXIST) is rreturned instread |
| 1177 |
|
| 1178 |
LOOKUP_EXCL now means "target must not exist". It can be combined with |
| 1179 |
LOOK_CREATE or LOOKUP_RENAME_TARGET. |
| 1180 |
|
| 1181 |
--- |
| 1182 |
|
| 1183 |
**mandatory** |
| 1184 |
invalidate_inodes() is gone use evict_inodes() instead. |
| 1185 |
|
| 1186 |
--- |
| 1187 |
|
| 1188 |
**mandatory** |
| 1189 |
|
| 1190 |
->mkdir() now returns a dentry. If the created inode is found to |
| 1191 |
already be in cache and have a dentry (often IS_ROOT()), it will need to |
| 1192 |
be spliced into the given name in place of the given dentry. That dentry |
| 1193 |
now needs to be returned. If the original dentry is used, NULL should |
| 1194 |
be returned. Any error should be returned with ERR_PTR(). |
| 1195 |
|
| 1196 |
In general, filesystems which use d_instantiate_new() to install the new |
| 1197 |
inode can safely return NULL. Filesystems which may not have an I_NEW inode |
| 1198 |
should use d_drop();d_splice_alias() and return the result of the latter. |
| 1199 |
|
| 1200 |
If a positive dentry cannot be returned for some reason, in-kernel |
| 1201 |
clients such as cachefiles, nfsd, smb/server may not perform ideally but |
| 1202 |
will fail-safe. |
| 1203 |
|
| 1204 |
--- |
| 1205 |
|
| 1206 |
** mandatory** |
| 1207 |
|
| 1208 |
lookup_one(), lookup_one_unlocked(), lookup_one_positive_unlocked() now |
| 1209 |
take a qstr instead of a name and len. These, not the "one_len" |
| 1210 |
versions, should be used whenever accessing a filesystem from outside |
| 1211 |
that filesysmtem, through a mount point - which will have a mnt_idmap. |
| 1212 |
|
| 1213 |
--- |
| 1214 |
|
| 1215 |
** mandatory** |
| 1216 |
|
| 1217 |
Functions try_lookup_one_len(), lookup_one_len(), |
| 1218 |
lookup_one_len_unlocked() and lookup_positive_unlocked() have been |
| 1219 |
renamed to try_lookup_noperm(), lookup_noperm(), |
| 1220 |
lookup_noperm_unlocked(), lookup_noperm_positive_unlocked(). They now |
| 1221 |
take a qstr instead of separate name and length. QSTR() can be used |
| 1222 |
when strlen() is needed for the length. |
| 1223 |
|
| 1224 |
These function no longer do any permission checking - they previously |
| 1225 |
checked that the caller has 'X' permission on the parent. They must |
| 1226 |
ONLY be used internally by a filesystem on itself when it knows that |
| 1227 |
permissions are irrelevant or in a context where permission checks have |
| 1228 |
already been performed such as after vfs_path_parent_lookup() |
| 1229 |
|
| 1230 |
--- |
| 1231 |
|
| 1232 |
** mandatory** |
| 1233 |
|
| 1234 |
d_hash_and_lookup() is no longer exported or available outside the VFS. |
| 1235 |
Use try_lookup_noperm() instead. This adds name validation and takes |
| 1236 |
arguments in the opposite order but is otherwise identical. |
| 1237 |
|
| 1238 |
Using try_lookup_noperm() will require linux/namei.h to be included. |
| 1239 |
|
| 1240 |
--- |
| 1241 |
|
| 1242 |
**mandatory** |
| 1243 |
|
| 1244 |
Calling conventions for ->d_automount() have changed; we should *not* grab |
| 1245 |
an extra reference to new mount - it should be returned with refcount 1. |
| 1246 |
|
| 1247 |
--- |
| 1248 |
|
| 1249 |
collect_mounts()/drop_collected_mounts()/iterate_mounts() are gone now. |
| 1250 |
Replacement is collect_paths()/drop_collected_path(), with no special |
| 1251 |
iterator needed. Instead of a cloned mount tree, the new interface returns |
| 1252 |
an array of struct path, one for each mount collect_mounts() would've |
| 1253 |
created. These struct path point to locations in the caller's namespace |
| 1254 |
that would be roots of the cloned mounts. |
| 1255 |
|
| 1256 |
--- |
| 1257 |
|
| 1258 |
**mandatory** |
| 1259 |
|
| 1260 |
If your filesystem sets the default dentry_operations, use set_default_d_op() |
| 1261 |
rather than manually setting sb->s_d_op. |
| 1262 |
|
| 1263 |
--- |
| 1264 |
|
| 1265 |
**mandatory** |
| 1266 |
|
| 1267 |
d_set_d_op() is no longer exported (or public, for that matter); _if_ |
| 1268 |
your filesystem really needed that, make use of d_splice_alias_ops() |
| 1269 |
to have them set. Better yet, think hard whether you need different |
| 1270 |
->d_op for different dentries - if not, just use set_default_d_op() |
| 1271 |
at mount time and be done with that. Currently procfs is the only |
| 1272 |
thing that really needs ->d_op varying between dentries. |
| 1273 |
|
| 1274 |
--- |
| 1275 |
|
| 1276 |
**highly recommended** |
| 1277 |
|
| 1278 |
The file operations mmap() callback is deprecated in favour of |
| 1279 |
mmap_prepare(). This passes a pointer to a vm_area_desc to the callback |
| 1280 |
rather than a VMA, as the VMA at this stage is not yet valid. |
| 1281 |
|
| 1282 |
The vm_area_desc provides the minimum required information for a filesystem |
| 1283 |
to initialise state upon memory mapping of a file-backed region, and output |
| 1284 |
parameters for the file system to set this state. |
| 1285 |
|
| 1286 |
In nearly all cases, this is all that is required for a filesystem. However, if |
| 1287 |
a filesystem needs to perform an operation such a pre-population of page tables, |
| 1288 |
then that action can be specified in the vm_area_desc->action field, which can |
| 1289 |
be configured using the mmap_action_*() helpers. |
| 1290 |
|
| 1291 |
--- |
| 1292 |
|
| 1293 |
**mandatory** |
| 1294 |
|
| 1295 |
Several functions are renamed: |
| 1296 |
|
| 1297 |
- kern_path_locked -> start_removing_path |
| 1298 |
- kern_path_create -> start_creating_path |
| 1299 |
- user_path_create -> start_creating_user_path |
| 1300 |
- user_path_locked_at -> start_removing_user_path_at |
| 1301 |
- done_path_create -> end_creating_path |
| 1302 |
|
| 1303 |
--- |
| 1304 |
|
| 1305 |
**mandatory** |
| 1306 |
|
| 1307 |
Calling conventions for vfs_parse_fs_string() have changed; it does *not* |
| 1308 |
take length anymore (value ? strlen(value) : 0 is used). If you want |
| 1309 |
a different length, use |
| 1310 |
|
| 1311 |
vfs_parse_fs_qstr(fc, key, &QSTR_LEN(value, len)) |
| 1312 |
|
| 1313 |
instead. |
| 1314 |
|
| 1315 |
--- |
| 1316 |
|
| 1317 |
**mandatory** |
| 1318 |
|
| 1319 |
vfs_mkdir() now returns a dentry - the one returned by ->mkdir(). If |
| 1320 |
that dentry is different from the dentry passed in, including if it is |
| 1321 |
an IS_ERR() dentry pointer, the original dentry is dput(). |
| 1322 |
|
| 1323 |
When vfs_mkdir() returns an error, and so both dputs() the original |
| 1324 |
dentry and doesn't provide a replacement, it also unlocks the parent. |
| 1325 |
Consequently the return value from vfs_mkdir() can be passed to |
| 1326 |
end_creating() and the parent will be unlocked precisely when necessary. |
| 1327 |
|
| 1328 |
--- |
| 1329 |
|
| 1330 |
**mandatory** |
| 1331 |
|
| 1332 |
kill_litter_super() is gone; convert to DCACHE_PERSISTENT use (as all |
| 1333 |
in-tree filesystems have done). |
| 1334 |
|
| 1335 |
--- |
| 1336 |
|
| 1337 |
**mandatory** |
| 1338 |
|
| 1339 |
The ->setlease() file_operation must now be explicitly set in order to provide |
| 1340 |
support for leases. When set to NULL, the kernel will now return -EINVAL to |
| 1341 |
attempts to set a lease. Filesystems that wish to use the kernel-internal lease |
| 1342 |
implementation should set it to generic_setlease(). |
| 1343 |
|
| 1344 |
--- |
| 1345 |
|
| 1346 |
**mandatory** |
| 1347 |
|
| 1348 |
fs/namei.c primitives that consume filesystem references (do_renameat2(), |
| 1349 |
do_linkat(), do_symlinkat(), do_mkdirat(), do_mknodat(), do_unlinkat() |
| 1350 |
and do_rmdir()) are gone; they are replaced with non-consuming analogues |
| 1351 |
(filename_renameat2(), etc.) |
| 1352 |
Callers are adjusted - responsibility for dropping the filenames belongs |
| 1353 |
to them now. |
| 1354 |
|
| 1355 |
--- |
| 1356 |
|
| 1357 |
**mandatory** |
| 1358 |
|
| 1359 |
readlink_copy() now requires link length as the 4th argument. Said length needs |
| 1360 |
to match what strlen() would return if it was ran on the string. |
| 1361 |
|
| 1362 |
However, if the string is freely accessible for the duration of inode's |
| 1363 |
lifetime, consider using inode_set_cached_link() instead. |