aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authorNick Piggin <npiggin@kernel.dk>2011-01-07 01:49:27 -0500
committerNick Piggin <npiggin@kernel.dk>2011-01-07 01:50:19 -0500
commit621e155a3591962420eacdd39f6f0aa29ceb221e (patch)
tree387a9fb396f1bf24514b712c294182e36ba51076 /Documentation
parentfb2d5b86aff355a27ebfc132d3c99f4a940cc3fe (diff)
fs: change d_compare for rcu-walk
Change d_compare so it may be called from lock-free RCU lookups. This does put significant restrictions on what may be done from the callback, however there don't seem to have been any problems with in-tree fses. If some strange use case pops up that _really_ cannot cope with the rcu-walk rules, we can just add new rcu-unaware callbacks, which would cause name lookup to drop out of rcu-walk mode. For in-tree filesystems, this is just a mechanical change. Signed-off-by: Nick Piggin <npiggin@kernel.dk>
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/filesystems/Locking4
-rw-r--r--Documentation/filesystems/porting7
-rw-r--r--Documentation/filesystems/vfs.txt26
3 files changed, 33 insertions, 4 deletions
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
index 33fa3e5d38f..9a76f8d8bf9 100644
--- a/Documentation/filesystems/Locking
+++ b/Documentation/filesystems/Locking
@@ -11,7 +11,9 @@ be able to use diff(1).
11prototypes: 11prototypes:
12 int (*d_revalidate)(struct dentry *, int); 12 int (*d_revalidate)(struct dentry *, int);
13 int (*d_hash) (struct dentry *, struct qstr *); 13 int (*d_hash) (struct dentry *, struct qstr *);
14 int (*d_compare) (struct dentry *, struct qstr *, struct qstr *); 14 int (*d_compare)(const struct dentry *, const struct inode *,
15 const struct dentry *, const struct inode *,
16 unsigned int, const char *, const struct qstr *);
15 int (*d_delete)(struct dentry *); 17 int (*d_delete)(struct dentry *);
16 void (*d_release)(struct dentry *); 18 void (*d_release)(struct dentry *);
17 void (*d_iput)(struct dentry *, struct inode *); 19 void (*d_iput)(struct dentry *, struct inode *);
diff --git a/Documentation/filesystems/porting b/Documentation/filesystems/porting
index 9e71c9ad310..d44511e2082 100644
--- a/Documentation/filesystems/porting
+++ b/Documentation/filesystems/porting
@@ -326,3 +326,10 @@ to it.
326unreferenced dentries, and is now only called when the dentry refcount goes to 326unreferenced dentries, and is now only called when the dentry refcount goes to
3270. Even on 0 refcount transition, it must be able to tolerate being called 0, 3270. Even on 0 refcount transition, it must be able to tolerate being called 0,
3281, or more times (eg. constant, idempotent). 3281, or more times (eg. constant, idempotent).
329
330---
331[mandatory]
332
333 .d_compare() calling convention and locking rules are significantly
334changed. Read updated documentation in Documentation/filesystems/vfs.txt (and
335look at examples of other filesystems) for guidance.
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index 95c0a93f056..250681b8c7c 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -848,7 +848,9 @@ defined:
848struct dentry_operations { 848struct dentry_operations {
849 int (*d_revalidate)(struct dentry *, struct nameidata *); 849 int (*d_revalidate)(struct dentry *, struct nameidata *);
850 int (*d_hash)(struct dentry *, struct qstr *); 850 int (*d_hash)(struct dentry *, struct qstr *);
851 int (*d_compare)(struct dentry *, struct qstr *, struct qstr *); 851 int (*d_compare)(const struct dentry *, const struct inode *,
852 const struct dentry *, const struct inode *,
853 unsigned int, const char *, const struct qstr *);
852 int (*d_delete)(const struct dentry *); 854 int (*d_delete)(const struct dentry *);
853 void (*d_release)(struct dentry *); 855 void (*d_release)(struct dentry *);
854 void (*d_iput)(struct dentry *, struct inode *); 856 void (*d_iput)(struct dentry *, struct inode *);
@@ -860,9 +862,27 @@ struct dentry_operations {
860 dcache. Most filesystems leave this as NULL, because all their 862 dcache. Most filesystems leave this as NULL, because all their
861 dentries in the dcache are valid 863 dentries in the dcache are valid
862 864
863 d_hash: called when the VFS adds a dentry to the hash table 865 d_hash: called when the VFS adds a dentry to the hash table. The first
866 dentry passed to d_hash is the parent directory that the name is
867 to be hashed into.
864 868
865 d_compare: called when a dentry should be compared with another 869 d_compare: called to compare a dentry name with a given name. The first
870 dentry is the parent of the dentry to be compared, the second is
871 the parent's inode, then the dentry and inode (may be NULL) of the
872 child dentry. len and name string are properties of the dentry to be
873 compared. qstr is the name to compare it with.
874
875 Must be constant and idempotent, and should not take locks if
876 possible, and should not or store into the dentry or inodes.
877 Should not dereference pointers outside the dentry or inodes without
878 lots of care (eg. d_parent, d_inode, d_name should not be used).
879
880 However, our vfsmount is pinned, and RCU held, so the dentries and
881 inodes won't disappear, neither will our sb or filesystem module.
882 ->i_sb and ->d_sb may be used.
883
884 It is a tricky calling convention because it needs to be called under
885 "rcu-walk", ie. without any locks or references on things.
866 886
867 d_delete: called when the last reference to a dentry is dropped and the 887 d_delete: called when the last reference to a dentry is dropped and the
868 dcache is deciding whether or not to cache it. Return 1 to delete 888 dcache is deciding whether or not to cache it. Return 1 to delete