diff options
Diffstat (limited to 'Documentation/filesystems')
| -rw-r--r-- | Documentation/filesystems/Locking | 32 | ||||
| -rw-r--r-- | Documentation/filesystems/porting | 26 | ||||
| -rw-r--r-- | Documentation/filesystems/vfs.txt | 39 |
3 files changed, 68 insertions, 29 deletions
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking index 8e2da1e06e3b..e540a24e5d06 100644 --- a/Documentation/filesystems/Locking +++ b/Documentation/filesystems/Locking | |||
| @@ -9,7 +9,7 @@ be able to use diff(1). | |||
| 9 | 9 | ||
| 10 | --------------------------- dentry_operations -------------------------- | 10 | --------------------------- dentry_operations -------------------------- |
| 11 | prototypes: | 11 | prototypes: |
| 12 | int (*d_revalidate)(struct dentry *, struct nameidata *); | 12 | int (*d_revalidate)(struct dentry *, unsigned int); |
| 13 | int (*d_hash)(const struct dentry *, const struct inode *, | 13 | int (*d_hash)(const struct dentry *, const struct inode *, |
| 14 | struct qstr *); | 14 | struct qstr *); |
| 15 | int (*d_compare)(const struct dentry *, const struct inode *, | 15 | int (*d_compare)(const struct dentry *, const struct inode *, |
| @@ -37,9 +37,8 @@ d_manage: no no yes (ref-walk) maybe | |||
| 37 | 37 | ||
| 38 | --------------------------- inode_operations --------------------------- | 38 | --------------------------- inode_operations --------------------------- |
| 39 | prototypes: | 39 | prototypes: |
| 40 | int (*create) (struct inode *,struct dentry *,umode_t, struct nameidata *); | 40 | int (*create) (struct inode *,struct dentry *,umode_t, bool); |
| 41 | struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameid | 41 | struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int); |
| 42 | ata *); | ||
| 43 | int (*link) (struct dentry *,struct inode *,struct dentry *); | 42 | int (*link) (struct dentry *,struct inode *,struct dentry *); |
| 44 | int (*unlink) (struct inode *,struct dentry *); | 43 | int (*unlink) (struct inode *,struct dentry *); |
| 45 | int (*symlink) (struct inode *,struct dentry *,const char *); | 44 | int (*symlink) (struct inode *,struct dentry *,const char *); |
| @@ -62,6 +61,9 @@ ata *); | |||
| 62 | int (*removexattr) (struct dentry *, const char *); | 61 | int (*removexattr) (struct dentry *, const char *); |
| 63 | int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, u64 len); | 62 | int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, u64 len); |
| 64 | void (*update_time)(struct inode *, struct timespec *, int); | 63 | void (*update_time)(struct inode *, struct timespec *, int); |
| 64 | int (*atomic_open)(struct inode *, struct dentry *, | ||
| 65 | struct file *, unsigned open_flag, | ||
| 66 | umode_t create_mode, int *opened); | ||
| 65 | 67 | ||
| 66 | locking rules: | 68 | locking rules: |
| 67 | all may block | 69 | all may block |
| @@ -89,6 +91,7 @@ listxattr: no | |||
| 89 | removexattr: yes | 91 | removexattr: yes |
| 90 | fiemap: no | 92 | fiemap: no |
| 91 | update_time: no | 93 | update_time: no |
| 94 | atomic_open: yes | ||
| 92 | 95 | ||
| 93 | Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on | 96 | Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on |
| 94 | victim. | 97 | victim. |
| @@ -111,7 +114,6 @@ prototypes: | |||
| 111 | int (*drop_inode) (struct inode *); | 114 | int (*drop_inode) (struct inode *); |
| 112 | void (*evict_inode) (struct inode *); | 115 | void (*evict_inode) (struct inode *); |
| 113 | void (*put_super) (struct super_block *); | 116 | void (*put_super) (struct super_block *); |
| 114 | void (*write_super) (struct super_block *); | ||
| 115 | int (*sync_fs)(struct super_block *sb, int wait); | 117 | int (*sync_fs)(struct super_block *sb, int wait); |
| 116 | int (*freeze_fs) (struct super_block *); | 118 | int (*freeze_fs) (struct super_block *); |
| 117 | int (*unfreeze_fs) (struct super_block *); | 119 | int (*unfreeze_fs) (struct super_block *); |
| @@ -133,10 +135,9 @@ write_inode: | |||
| 133 | drop_inode: !!!inode->i_lock!!! | 135 | drop_inode: !!!inode->i_lock!!! |
| 134 | evict_inode: | 136 | evict_inode: |
| 135 | put_super: write | 137 | put_super: write |
| 136 | write_super: read | ||
| 137 | sync_fs: read | 138 | sync_fs: read |
| 138 | freeze_fs: read | 139 | freeze_fs: write |
| 139 | unfreeze_fs: read | 140 | unfreeze_fs: write |
| 140 | statfs: maybe(read) (see below) | 141 | statfs: maybe(read) (see below) |
| 141 | remount_fs: write | 142 | remount_fs: write |
| 142 | umount_begin: no | 143 | umount_begin: no |
| @@ -203,6 +204,8 @@ prototypes: | |||
| 203 | int (*launder_page)(struct page *); | 204 | int (*launder_page)(struct page *); |
| 204 | int (*is_partially_uptodate)(struct page *, read_descriptor_t *, unsigned long); | 205 | int (*is_partially_uptodate)(struct page *, read_descriptor_t *, unsigned long); |
| 205 | int (*error_remove_page)(struct address_space *, struct page *); | 206 | int (*error_remove_page)(struct address_space *, struct page *); |
| 207 | int (*swap_activate)(struct file *); | ||
| 208 | int (*swap_deactivate)(struct file *); | ||
| 206 | 209 | ||
| 207 | locking rules: | 210 | locking rules: |
| 208 | All except set_page_dirty and freepage may block | 211 | All except set_page_dirty and freepage may block |
| @@ -226,6 +229,8 @@ migratepage: yes (both) | |||
| 226 | launder_page: yes | 229 | launder_page: yes |
| 227 | is_partially_uptodate: yes | 230 | is_partially_uptodate: yes |
| 228 | error_remove_page: yes | 231 | error_remove_page: yes |
| 232 | swap_activate: no | ||
| 233 | swap_deactivate: no | ||
| 229 | 234 | ||
| 230 | ->write_begin(), ->write_end(), ->sync_page() and ->readpage() | 235 | ->write_begin(), ->write_end(), ->sync_page() and ->readpage() |
| 231 | may be called from the request handler (/dev/loop). | 236 | may be called from the request handler (/dev/loop). |
| @@ -327,6 +332,15 @@ cleaned, or an error value if not. Note that in order to prevent the page | |||
| 327 | getting mapped back in and redirtied, it needs to be kept locked | 332 | getting mapped back in and redirtied, it needs to be kept locked |
| 328 | across the entire operation. | 333 | across the entire operation. |
| 329 | 334 | ||
| 335 | ->swap_activate will be called with a non-zero argument on | ||
| 336 | files backing (non block device backed) swapfiles. A return value | ||
| 337 | of zero indicates success, in which case this file can be used for | ||
| 338 | backing swapspace. The swapspace operations will be proxied to the | ||
| 339 | address space operations. | ||
| 340 | |||
| 341 | ->swap_deactivate() will be called in the sys_swapoff() | ||
| 342 | path after ->swap_activate() returned success. | ||
| 343 | |||
| 330 | ----------------------- file_lock_operations ------------------------------ | 344 | ----------------------- file_lock_operations ------------------------------ |
| 331 | prototypes: | 345 | prototypes: |
| 332 | void (*fl_copy_lock)(struct file_lock *, struct file_lock *); | 346 | void (*fl_copy_lock)(struct file_lock *, struct file_lock *); |
| @@ -343,7 +357,6 @@ prototypes: | |||
| 343 | int (*lm_compare_owner)(struct file_lock *, struct file_lock *); | 357 | int (*lm_compare_owner)(struct file_lock *, struct file_lock *); |
| 344 | void (*lm_notify)(struct file_lock *); /* unblock callback */ | 358 | void (*lm_notify)(struct file_lock *); /* unblock callback */ |
| 345 | int (*lm_grant)(struct file_lock *, struct file_lock *, int); | 359 | int (*lm_grant)(struct file_lock *, struct file_lock *, int); |
| 346 | void (*lm_release_private)(struct file_lock *); | ||
| 347 | void (*lm_break)(struct file_lock *); /* break_lease callback */ | 360 | void (*lm_break)(struct file_lock *); /* break_lease callback */ |
| 348 | int (*lm_change)(struct file_lock **, int); | 361 | int (*lm_change)(struct file_lock **, int); |
| 349 | 362 | ||
| @@ -352,7 +365,6 @@ locking rules: | |||
| 352 | lm_compare_owner: yes no | 365 | lm_compare_owner: yes no |
| 353 | lm_notify: yes no | 366 | lm_notify: yes no |
| 354 | lm_grant: no no | 367 | lm_grant: no no |
| 355 | lm_release_private: maybe no | ||
| 356 | lm_break: yes no | 368 | lm_break: yes no |
| 357 | lm_change yes no | 369 | lm_change yes no |
| 358 | 370 | ||
diff --git a/Documentation/filesystems/porting b/Documentation/filesystems/porting index 8c91d1057d9a..0742feebc6e2 100644 --- a/Documentation/filesystems/porting +++ b/Documentation/filesystems/porting | |||
| @@ -94,9 +94,8 @@ protected. | |||
| 94 | --- | 94 | --- |
| 95 | [mandatory] | 95 | [mandatory] |
| 96 | 96 | ||
| 97 | BKL is also moved from around sb operations. ->write_super() Is now called | 97 | BKL is also moved from around sb operations. BKL should have been shifted into |
| 98 | without BKL held. BKL should have been shifted into individual fs sb_op | 98 | individual fs sb_op functions. If you don't need it, remove it. |
| 99 | functions. If you don't need it, remove it. | ||
| 100 | 99 | ||
| 101 | --- | 100 | --- |
| 102 | [informational] | 101 | [informational] |
| @@ -355,12 +354,10 @@ protects *all* the dcache state of a given dentry. | |||
| 355 | via rcu-walk path walk (basically, if the file can have had a path name in the | 354 | via rcu-walk path walk (basically, if the file can have had a path name in the |
| 356 | vfs namespace). | 355 | vfs namespace). |
| 357 | 356 | ||
| 358 | i_dentry and i_rcu share storage in a union, and the vfs expects | 357 | Even though i_dentry and i_rcu share storage in a union, we will |
| 359 | i_dentry to be reinitialized before it is freed, so an: | 358 | initialize the former in inode_init_always(), so just leave it alone in |
| 360 | 359 | the callback. It used to be necessary to clean it there, but not anymore | |
| 361 | INIT_LIST_HEAD(&inode->i_dentry); | 360 | (starting at 3.2). |
| 362 | |||
| 363 | must be done in the RCU callback. | ||
| 364 | 361 | ||
| 365 | -- | 362 | -- |
| 366 | [recommended] | 363 | [recommended] |
| @@ -433,3 +430,14 @@ release it yourself. | |||
| 433 | d_alloc_root() is gone, along with a lot of bugs caused by code | 430 | d_alloc_root() is gone, along with a lot of bugs caused by code |
| 434 | misusing it. Replacement: d_make_root(inode). The difference is, | 431 | misusing it. Replacement: d_make_root(inode). The difference is, |
| 435 | d_make_root() drops the reference to inode if dentry allocation fails. | 432 | d_make_root() drops the reference to inode if dentry allocation fails. |
| 433 | |||
| 434 | -- | ||
| 435 | [mandatory] | ||
| 436 | The witch is dead! Well, 2/3 of it, anyway. ->d_revalidate() and | ||
| 437 | ->lookup() do *not* take struct nameidata anymore; just the flags. | ||
| 438 | -- | ||
| 439 | [mandatory] | ||
| 440 | ->create() doesn't take struct nameidata *; unlike the previous | ||
| 441 | two, it gets "is it an O_EXCL or equivalent?" boolean argument. Note that | ||
| 442 | local filesystems can ignore tha argument - they are guaranteed that the | ||
| 443 | object doesn't exist. It's remote/distributed ones that might care... | ||
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index efd23f481704..2ee133e030c3 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt | |||
| @@ -216,7 +216,6 @@ struct super_operations { | |||
| 216 | void (*drop_inode) (struct inode *); | 216 | void (*drop_inode) (struct inode *); |
| 217 | void (*delete_inode) (struct inode *); | 217 | void (*delete_inode) (struct inode *); |
| 218 | void (*put_super) (struct super_block *); | 218 | void (*put_super) (struct super_block *); |
| 219 | void (*write_super) (struct super_block *); | ||
| 220 | int (*sync_fs)(struct super_block *sb, int wait); | 219 | int (*sync_fs)(struct super_block *sb, int wait); |
| 221 | int (*freeze_fs) (struct super_block *); | 220 | int (*freeze_fs) (struct super_block *); |
| 222 | int (*unfreeze_fs) (struct super_block *); | 221 | int (*unfreeze_fs) (struct super_block *); |
| @@ -273,9 +272,6 @@ or bottom half). | |||
| 273 | put_super: called when the VFS wishes to free the superblock | 272 | put_super: called when the VFS wishes to free the superblock |
| 274 | (i.e. unmount). This is called with the superblock lock held | 273 | (i.e. unmount). This is called with the superblock lock held |
| 275 | 274 | ||
| 276 | write_super: called when the VFS superblock needs to be written to | ||
| 277 | disc. This method is optional | ||
| 278 | |||
| 279 | sync_fs: called when VFS is writing out all dirty data associated with | 275 | sync_fs: called when VFS is writing out all dirty data associated with |
| 280 | a superblock. The second parameter indicates whether the method | 276 | a superblock. The second parameter indicates whether the method |
| 281 | should wait until the write out has been completed. Optional. | 277 | should wait until the write out has been completed. Optional. |
| @@ -341,8 +337,8 @@ This describes how the VFS can manipulate an inode in your | |||
| 341 | filesystem. As of kernel 2.6.22, the following members are defined: | 337 | filesystem. As of kernel 2.6.22, the following members are defined: |
| 342 | 338 | ||
| 343 | struct inode_operations { | 339 | struct inode_operations { |
| 344 | int (*create) (struct inode *,struct dentry *, umode_t, struct nameidata *); | 340 | int (*create) (struct inode *,struct dentry *, umode_t, bool); |
| 345 | struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *); | 341 | struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int); |
| 346 | int (*link) (struct dentry *,struct inode *,struct dentry *); | 342 | int (*link) (struct dentry *,struct inode *,struct dentry *); |
| 347 | int (*unlink) (struct inode *,struct dentry *); | 343 | int (*unlink) (struct inode *,struct dentry *); |
| 348 | int (*symlink) (struct inode *,struct dentry *,const char *); | 344 | int (*symlink) (struct inode *,struct dentry *,const char *); |
| @@ -364,6 +360,9 @@ struct inode_operations { | |||
| 364 | ssize_t (*listxattr) (struct dentry *, char *, size_t); | 360 | ssize_t (*listxattr) (struct dentry *, char *, size_t); |
| 365 | int (*removexattr) (struct dentry *, const char *); | 361 | int (*removexattr) (struct dentry *, const char *); |
| 366 | void (*update_time)(struct inode *, struct timespec *, int); | 362 | void (*update_time)(struct inode *, struct timespec *, int); |
| 363 | int (*atomic_open)(struct inode *, struct dentry *, | ||
| 364 | struct file *, unsigned open_flag, | ||
| 365 | umode_t create_mode, int *opened); | ||
| 367 | }; | 366 | }; |
| 368 | 367 | ||
| 369 | Again, all methods are called without any locks being held, unless | 368 | Again, all methods are called without any locks being held, unless |
| @@ -476,6 +475,14 @@ otherwise noted. | |||
| 476 | an inode. If this is not defined the VFS will update the inode itself | 475 | an inode. If this is not defined the VFS will update the inode itself |
| 477 | and call mark_inode_dirty_sync. | 476 | and call mark_inode_dirty_sync. |
| 478 | 477 | ||
| 478 | atomic_open: called on the last component of an open. Using this optional | ||
| 479 | method the filesystem can look up, possibly create and open the file in | ||
| 480 | one atomic operation. If it cannot perform this (e.g. the file type | ||
| 481 | turned out to be wrong) it may signal this by returning 1 instead of | ||
| 482 | usual 0 or -ve . This method is only called if the last | ||
| 483 | component is negative or needs lookup. Cached positive dentries are | ||
| 484 | still handled by f_op->open(). | ||
| 485 | |||
| 479 | The Address Space Object | 486 | The Address Space Object |
| 480 | ======================== | 487 | ======================== |
| 481 | 488 | ||
| @@ -581,6 +588,8 @@ struct address_space_operations { | |||
| 581 | int (*migratepage) (struct page *, struct page *); | 588 | int (*migratepage) (struct page *, struct page *); |
| 582 | int (*launder_page) (struct page *); | 589 | int (*launder_page) (struct page *); |
| 583 | int (*error_remove_page) (struct mapping *mapping, struct page *page); | 590 | int (*error_remove_page) (struct mapping *mapping, struct page *page); |
| 591 | int (*swap_activate)(struct file *); | ||
| 592 | int (*swap_deactivate)(struct file *); | ||
| 584 | }; | 593 | }; |
| 585 | 594 | ||
| 586 | writepage: called by the VM to write a dirty page to backing store. | 595 | writepage: called by the VM to write a dirty page to backing store. |
| @@ -749,6 +758,16 @@ struct address_space_operations { | |||
| 749 | Setting this implies you deal with pages going away under you, | 758 | Setting this implies you deal with pages going away under you, |
| 750 | unless you have them locked or reference counts increased. | 759 | unless you have them locked or reference counts increased. |
| 751 | 760 | ||
| 761 | swap_activate: Called when swapon is used on a file to allocate | ||
| 762 | space if necessary and pin the block lookup information in | ||
| 763 | memory. A return value of zero indicates success, | ||
| 764 | in which case this file can be used to back swapspace. The | ||
| 765 | swapspace operations will be proxied to this address space's | ||
| 766 | ->swap_{out,in} methods. | ||
| 767 | |||
| 768 | swap_deactivate: Called during swapoff on files where swap_activate | ||
| 769 | was successful. | ||
| 770 | |||
| 752 | 771 | ||
| 753 | The File Object | 772 | The File Object |
| 754 | =============== | 773 | =============== |
| @@ -891,7 +910,7 @@ the VFS uses a default. As of kernel 2.6.22, the following members are | |||
| 891 | defined: | 910 | defined: |
| 892 | 911 | ||
| 893 | struct dentry_operations { | 912 | struct dentry_operations { |
| 894 | int (*d_revalidate)(struct dentry *, struct nameidata *); | 913 | int (*d_revalidate)(struct dentry *, unsigned int); |
| 895 | int (*d_hash)(const struct dentry *, const struct inode *, | 914 | int (*d_hash)(const struct dentry *, const struct inode *, |
| 896 | struct qstr *); | 915 | struct qstr *); |
| 897 | int (*d_compare)(const struct dentry *, const struct inode *, | 916 | int (*d_compare)(const struct dentry *, const struct inode *, |
| @@ -910,11 +929,11 @@ struct dentry_operations { | |||
| 910 | dcache. Most filesystems leave this as NULL, because all their | 929 | dcache. Most filesystems leave this as NULL, because all their |
| 911 | dentries in the dcache are valid | 930 | dentries in the dcache are valid |
| 912 | 931 | ||
| 913 | d_revalidate may be called in rcu-walk mode (nd->flags & LOOKUP_RCU). | 932 | d_revalidate may be called in rcu-walk mode (flags & LOOKUP_RCU). |
| 914 | If in rcu-walk mode, the filesystem must revalidate the dentry without | 933 | If in rcu-walk mode, the filesystem must revalidate the dentry without |
| 915 | blocking or storing to the dentry, d_parent and d_inode should not be | 934 | blocking or storing to the dentry, d_parent and d_inode should not be |
| 916 | used without care (because they can go NULL), instead nd->inode should | 935 | used without care (because they can change and, in d_inode case, even |
| 917 | be used. | 936 | become NULL under us). |
| 918 | 937 | ||
| 919 | If a situation is encountered that rcu-walk cannot handle, return | 938 | If a situation is encountered that rcu-walk cannot handle, return |
| 920 | -ECHILD and it will be called again in ref-walk mode. | 939 | -ECHILD and it will be called again in ref-walk mode. |
