aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/filesystems
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-07-03 12:10:19 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-03 12:10:19 -0400
commit790eac5640abf7a57fa3a644386df330e18c11b0 (patch)
tree08de20bde44f59e51b91ff473a71047c2957e8c9 /Documentation/filesystems
parent0b0585c3e192967cb2ef0ac0816eb8a8c8d99840 (diff)
parent48bde8d3620f5f3c6ae9ff599eb404055ae51664 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull second set of VFS changes from Al Viro: "Assorted f_pos race fixes, making do_splice_direct() safe to call with i_mutex on parent, O_TMPFILE support, Jeff's locks.c series, ->d_hash/->d_compare calling conventions changes from Linus, misc stuff all over the place." * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (63 commits) Document ->tmpfile() ext4: ->tmpfile() support vfs: export lseek_execute() to modules lseek_execute() doesn't need an inode passed to it block_dev: switch to fixed_size_llseek() cpqphp_sysfs: switch to fixed_size_llseek() tile-srom: switch to fixed_size_llseek() proc_powerpc: switch to fixed_size_llseek() ubi/cdev: switch to fixed_size_llseek() pci/proc: switch to fixed_size_llseek() isapnp: switch to fixed_size_llseek() lpfc: switch to fixed_size_llseek() locks: give the blocked_hash its own spinlock locks: add a new "lm_owner_key" lock operation locks: turn the blocked_list into a hashtable locks: convert fl_link to a hlist_node locks: avoid taking global lock if possible when waking up blocked waiters locks: protect most of the file_lock handling with i_lock locks: encapsulate the fl_link list handling locks: make "added" in __posix_lock_file a bool ...
Diffstat (limited to 'Documentation/filesystems')
-rw-r--r--Documentation/filesystems/Locking35
-rw-r--r--Documentation/filesystems/vfs.txt24
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).
11prototypes: 11prototypes:
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
70locking rules: 69locking rules:
71 all may block 70 all may block
@@ -93,6 +92,7 @@ removexattr: yes
93fiemap: no 92fiemap: no
94update_time: no 93update_time: no
95atomic_open: yes 94atomic_open: yes
95tmpfile: no
96 96
97 Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on 97 Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on
98victim. 98victim.
@@ -344,25 +344,38 @@ prototypes:
344 344
345 345
346locking rules: 346locking rules:
347 file_lock_lock may block 347 inode->i_lock may block
348fl_copy_lock: yes no 348fl_copy_lock: yes no
349fl_release_private: maybe no 349fl_release_private: maybe no
350 350
351----------------------- lock_manager_operations --------------------------- 351----------------------- lock_manager_operations ---------------------------
352prototypes: 352prototypes:
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
359locking rules: 360locking rules:
360 file_lock_lock may block 361
361lm_compare_owner: yes no 362 inode->i_lock blocked_lock_lock may block
362lm_notify: yes no 363lm_compare_owner: yes[1] maybe no
363lm_grant: no no 364lm_owner_key yes[1] yes no
364lm_break: yes no 365lm_notify: yes yes no
365lm_change yes no 366lm_grant: no no no
367lm_break: yes no no
368lm_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
372associated with either file_lock argument! This is the case with deadlock
373detection, since the code has to chase down the owners of locks that may
374be entirely unrelated to the one on which the lock is being acquired.
375For deadlock detection however, the blocked_lock_lock is also held. The
376fact that these locks are held ensures that the file_locks do not
377disappear out from under you while doing the comparison or generating an
378owner key.
366 379
367--------------------------- buffer_head ----------------------------------- 380--------------------------- buffer_head -----------------------------------
368prototypes: 381prototypes:
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
475The Address Space Object 480The Address Space Object
476======================== 481========================
477 482
@@ -901,10 +906,8 @@ defined:
901struct dentry_operations { 906struct 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.