diff options
Diffstat (limited to 'Documentation/filesystems')
-rw-r--r-- | Documentation/filesystems/Locking | 35 | ||||
-rw-r--r-- | Documentation/filesystems/vfs.txt | 24 |
2 files changed, 37 insertions, 22 deletions
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking index 9858f337529c..fe7afe225381 100644 --- a/Documentation/filesystems/Locking +++ b/Documentation/filesystems/Locking | |||
@@ -11,10 +11,8 @@ be able to use diff(1). | |||
11 | prototypes: | 11 | prototypes: |
12 | int (*d_revalidate)(struct dentry *, unsigned int); | 12 | int (*d_revalidate)(struct dentry *, unsigned int); |
13 | int (*d_weak_revalidate)(struct dentry *, unsigned int); | 13 | int (*d_weak_revalidate)(struct dentry *, unsigned int); |
14 | int (*d_hash)(const struct dentry *, const struct inode *, | 14 | int (*d_hash)(const struct dentry *, struct qstr *); |
15 | struct qstr *); | 15 | int (*d_compare)(const struct dentry *, const struct dentry *, |
16 | int (*d_compare)(const struct dentry *, const struct inode *, | ||
17 | const struct dentry *, const struct inode *, | ||
18 | unsigned int, const char *, const struct qstr *); | 16 | unsigned int, const char *, const struct qstr *); |
19 | int (*d_delete)(struct dentry *); | 17 | int (*d_delete)(struct dentry *); |
20 | void (*d_release)(struct dentry *); | 18 | void (*d_release)(struct dentry *); |
@@ -66,6 +64,7 @@ prototypes: | |||
66 | int (*atomic_open)(struct inode *, struct dentry *, | 64 | int (*atomic_open)(struct inode *, struct dentry *, |
67 | struct file *, unsigned open_flag, | 65 | struct file *, unsigned open_flag, |
68 | umode_t create_mode, int *opened); | 66 | umode_t create_mode, int *opened); |
67 | int (*tmpfile) (struct inode *, struct dentry *, umode_t); | ||
69 | 68 | ||
70 | locking rules: | 69 | locking rules: |
71 | all may block | 70 | all may block |
@@ -93,6 +92,7 @@ removexattr: yes | |||
93 | fiemap: no | 92 | fiemap: no |
94 | update_time: no | 93 | update_time: no |
95 | atomic_open: yes | 94 | atomic_open: yes |
95 | tmpfile: no | ||
96 | 96 | ||
97 | Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on | 97 | Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on |
98 | victim. | 98 | victim. |
@@ -344,25 +344,38 @@ prototypes: | |||
344 | 344 | ||
345 | 345 | ||
346 | locking rules: | 346 | locking rules: |
347 | file_lock_lock may block | 347 | inode->i_lock may block |
348 | fl_copy_lock: yes no | 348 | fl_copy_lock: yes no |
349 | fl_release_private: maybe no | 349 | fl_release_private: maybe no |
350 | 350 | ||
351 | ----------------------- lock_manager_operations --------------------------- | 351 | ----------------------- lock_manager_operations --------------------------- |
352 | prototypes: | 352 | prototypes: |
353 | int (*lm_compare_owner)(struct file_lock *, struct file_lock *); | 353 | int (*lm_compare_owner)(struct file_lock *, struct file_lock *); |
354 | unsigned long (*lm_owner_key)(struct file_lock *); | ||
354 | void (*lm_notify)(struct file_lock *); /* unblock callback */ | 355 | void (*lm_notify)(struct file_lock *); /* unblock callback */ |
355 | int (*lm_grant)(struct file_lock *, struct file_lock *, int); | 356 | int (*lm_grant)(struct file_lock *, struct file_lock *, int); |
356 | void (*lm_break)(struct file_lock *); /* break_lease callback */ | 357 | void (*lm_break)(struct file_lock *); /* break_lease callback */ |
357 | int (*lm_change)(struct file_lock **, int); | 358 | int (*lm_change)(struct file_lock **, int); |
358 | 359 | ||
359 | locking rules: | 360 | locking rules: |
360 | file_lock_lock may block | 361 | |
361 | lm_compare_owner: yes no | 362 | inode->i_lock blocked_lock_lock may block |
362 | lm_notify: yes no | 363 | lm_compare_owner: yes[1] maybe no |
363 | lm_grant: no no | 364 | lm_owner_key yes[1] yes no |
364 | lm_break: yes no | 365 | lm_notify: yes yes no |
365 | lm_change yes no | 366 | lm_grant: no no no |
367 | lm_break: yes no no | ||
368 | lm_change yes no no | ||
369 | |||
370 | [1]: ->lm_compare_owner and ->lm_owner_key are generally called with | ||
371 | *an* inode->i_lock held. It may not be the i_lock of the inode | ||
372 | associated with either file_lock argument! This is the case with deadlock | ||
373 | detection, since the code has to chase down the owners of locks that may | ||
374 | be entirely unrelated to the one on which the lock is being acquired. | ||
375 | For deadlock detection however, the blocked_lock_lock is also held. The | ||
376 | fact that these locks are held ensures that the file_locks do not | ||
377 | disappear out from under you while doing the comparison or generating an | ||
378 | owner key. | ||
366 | 379 | ||
367 | --------------------------- buffer_head ----------------------------------- | 380 | --------------------------- buffer_head ----------------------------------- |
368 | prototypes: | 381 | prototypes: |
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index e6bd1ffd821e..1f0ba30ae47e 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt | |||
@@ -360,6 +360,8 @@ struct inode_operations { | |||
360 | int (*removexattr) (struct dentry *, const char *); | 360 | int (*removexattr) (struct dentry *, const char *); |
361 | void (*update_time)(struct inode *, struct timespec *, int); | 361 | void (*update_time)(struct inode *, struct timespec *, int); |
362 | int (*atomic_open)(struct inode *, struct dentry *, | 362 | int (*atomic_open)(struct inode *, struct dentry *, |
363 | int (*tmpfile) (struct inode *, struct dentry *, umode_t); | ||
364 | } ____cacheline_aligned; | ||
363 | struct file *, unsigned open_flag, | 365 | struct file *, unsigned open_flag, |
364 | umode_t create_mode, int *opened); | 366 | umode_t create_mode, int *opened); |
365 | }; | 367 | }; |
@@ -472,6 +474,9 @@ otherwise noted. | |||
472 | component is negative or needs lookup. Cached positive dentries are | 474 | component is negative or needs lookup. Cached positive dentries are |
473 | still handled by f_op->open(). | 475 | still handled by f_op->open(). |
474 | 476 | ||
477 | tmpfile: called in the end of O_TMPFILE open(). Optional, equivalent to | ||
478 | atomically creating, opening and unlinking a file in given directory. | ||
479 | |||
475 | The Address Space Object | 480 | The Address Space Object |
476 | ======================== | 481 | ======================== |
477 | 482 | ||
@@ -901,10 +906,8 @@ defined: | |||
901 | struct dentry_operations { | 906 | struct dentry_operations { |
902 | int (*d_revalidate)(struct dentry *, unsigned int); | 907 | int (*d_revalidate)(struct dentry *, unsigned int); |
903 | int (*d_weak_revalidate)(struct dentry *, unsigned int); | 908 | int (*d_weak_revalidate)(struct dentry *, unsigned int); |
904 | int (*d_hash)(const struct dentry *, const struct inode *, | 909 | int (*d_hash)(const struct dentry *, struct qstr *); |
905 | struct qstr *); | 910 | int (*d_compare)(const struct dentry *, const struct dentry *, |
906 | int (*d_compare)(const struct dentry *, const struct inode *, | ||
907 | const struct dentry *, const struct inode *, | ||
908 | unsigned int, const char *, const struct qstr *); | 911 | unsigned int, const char *, const struct qstr *); |
909 | int (*d_delete)(const struct dentry *); | 912 | int (*d_delete)(const struct dentry *); |
910 | void (*d_release)(struct dentry *); | 913 | void (*d_release)(struct dentry *); |
@@ -949,25 +952,24 @@ struct dentry_operations { | |||
949 | 952 | ||
950 | d_hash: called when the VFS adds a dentry to the hash table. The first | 953 | d_hash: called when the VFS adds a dentry to the hash table. The first |
951 | dentry passed to d_hash is the parent directory that the name is | 954 | dentry passed to d_hash is the parent directory that the name is |
952 | to be hashed into. The inode is the dentry's inode. | 955 | to be hashed into. |
953 | 956 | ||
954 | Same locking and synchronisation rules as d_compare regarding | 957 | Same locking and synchronisation rules as d_compare regarding |
955 | what is safe to dereference etc. | 958 | what is safe to dereference etc. |
956 | 959 | ||
957 | d_compare: called to compare a dentry name with a given name. The first | 960 | d_compare: called to compare a dentry name with a given name. The first |
958 | dentry is the parent of the dentry to be compared, the second is | 961 | dentry is the parent of the dentry to be compared, the second is |
959 | the parent's inode, then the dentry and inode (may be NULL) of the | 962 | the child dentry. len and name string are properties of the dentry |
960 | child dentry. len and name string are properties of the dentry to be | 963 | to be compared. qstr is the name to compare it with. |
961 | compared. qstr is the name to compare it with. | ||
962 | 964 | ||
963 | Must be constant and idempotent, and should not take locks if | 965 | Must be constant and idempotent, and should not take locks if |
964 | possible, and should not or store into the dentry or inodes. | 966 | possible, and should not or store into the dentry. |
965 | Should not dereference pointers outside the dentry or inodes without | 967 | Should not dereference pointers outside the dentry without |
966 | lots of care (eg. d_parent, d_inode, d_name should not be used). | 968 | lots of care (eg. d_parent, d_inode, d_name should not be used). |
967 | 969 | ||
968 | However, our vfsmount is pinned, and RCU held, so the dentries and | 970 | However, our vfsmount is pinned, and RCU held, so the dentries and |
969 | inodes won't disappear, neither will our sb or filesystem module. | 971 | inodes won't disappear, neither will our sb or filesystem module. |
970 | ->i_sb and ->d_sb may be used. | 972 | ->d_sb may be used. |
971 | 973 | ||
972 | It is a tricky calling convention because it needs to be called under | 974 | It is a tricky calling convention because it needs to be called under |
973 | "rcu-walk", ie. without any locks or references on things. | 975 | "rcu-walk", ie. without any locks or references on things. |