]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
fs: change d_delete semantics
authorNick Piggin <npiggin@kernel.dk>
Fri, 7 Jan 2011 06:49:23 +0000 (17:49 +1100)
committerNick Piggin <npiggin@kernel.dk>
Fri, 7 Jan 2011 06:50:18 +0000 (17:50 +1100)
Change d_delete from a dentry deletion notification to a dentry caching
advise, more like ->drop_inode. Require it to be constant and idempotent,
and not take d_lock. This is how all existing filesystems use the callback
anyway.

This makes fine grained dentry locking of dput and dentry lru scanning
much simpler.

Signed-off-by: Nick Piggin <npiggin@kernel.dk>
22 files changed:
Documentation/filesystems/porting
Documentation/filesystems/vfs.txt
arch/ia64/kernel/perfmon.c
drivers/staging/smbfs/dir.c
fs/9p/vfs_dentry.c
fs/afs/dir.c
fs/btrfs/inode.c
fs/coda/dir.c
fs/configfs/dir.c
fs/dcache.c
fs/gfs2/dentry.c
fs/hostfs/hostfs_kern.c
fs/libfs.c
fs/ncpfs/dir.c
fs/nfs/dir.c
fs/proc/base.c
fs/proc/generic.c
fs/proc/proc_sysctl.c
fs/sysfs/dir.c
include/linux/dcache.h
kernel/cgroup.c
net/sunrpc/rpc_pipe.c

index b12c89538680aaf5f2cf3f5f872321f73a3d57ab..9e71c9ad3108682104db03ee82135e90d6d90038 100644 (file)
@@ -318,3 +318,11 @@ if it's zero is not *and* *never* *had* *been* enough.  Final unlink() and iput(
 may happen while the inode is in the middle of ->write_inode(); e.g. if you blindly
 free the on-disk inode, you may end up doing that while ->write_inode() is writing
 to it.
+
+---
+[mandatory]
+
+       .d_delete() now only advises the dcache as to whether or not to cache
+unreferenced dentries, and is now only called when the dentry refcount goes to
+0. Even on 0 refcount transition, it must be able to tolerate being called 0,
+1, or more times (eg. constant, idempotent).
index 20899e095e7e6879580b53aa9aa0282fb4b5ce63..95c0a93f056c76454cc86ffafda25dd83d8ca99f 100644 (file)
@@ -847,9 +847,9 @@ defined:
 
 struct dentry_operations {
        int (*d_revalidate)(struct dentry *, struct nameidata *);
-       int (*d_hash) (struct dentry *, struct qstr *);
-       int (*d_compare) (struct dentry *, struct qstr *, struct qstr *);
-       int (*d_delete)(struct dentry *);
+       int (*d_hash)(struct dentry *, struct qstr *);
+       int (*d_compare)(struct dentry *, struct qstr *, struct qstr *);
+       int (*d_delete)(const struct dentry *);
        void (*d_release)(struct dentry *);
        void (*d_iput)(struct dentry *, struct inode *);
        char *(*d_dname)(struct dentry *, char *, int);
@@ -864,9 +864,11 @@ struct dentry_operations {
 
   d_compare: called when a dentry should be compared with another
 
-  d_delete: called when the last reference to a dentry is
-       deleted. This means no-one is using the dentry, however it is
-       still valid and in the dcache
+  d_delete: called when the last reference to a dentry is dropped and the
+       dcache is deciding whether or not to cache it. Return 1 to delete
+       immediately, or 0 to cache the dentry. Default is NULL which means to
+       always cache a reachable dentry. d_delete must be constant and
+       idempotent.
 
   d_release: called when a dentry is really deallocated
 
@@ -910,14 +912,11 @@ manipulate dentries:
        the usage count)
 
   dput: close a handle for a dentry (decrements the usage count). If
-       the usage count drops to 0, the "d_delete" method is called
-       and the dentry is placed on the unused list if the dentry is
-       still in its parents hash list. Putting the dentry on the
-       unused list just means that if the system needs some RAM, it
-       goes through the unused list of dentries and deallocates them.
-       If the dentry has already been unhashed and the usage count
-       drops to 0, in this case the dentry is deallocated after the
-       "d_delete" method is called
+       the usage count drops to 0, and the dentry is still in its
+       parent's hash, the "d_delete" method is called to check whether
+       it should be cached. If it should not be cached, or if the dentry
+       is not hashed, it is deleted. Otherwise cached dentries are put
+       into an LRU list to be reclaimed on memory shortage.
 
   d_drop: this unhashes a dentry from its parents hash list. A
        subsequent call to dput() will deallocate the dentry if its
index 39e534f5a3b05fc36c46d1e58b0c581c6c307bc5..d39d8a53b5793265fb28a9dc68a379e3bf3ad956 100644 (file)
@@ -2185,7 +2185,7 @@ static const struct file_operations pfm_file_ops = {
 };
 
 static int
-pfmfs_delete_dentry(struct dentry *dentry)
+pfmfs_delete_dentry(const struct dentry *dentry)
 {
        return 1;
 }
index f088ea2f6ac9f27991d605b4093666d1a3d0843c..2270d4822c2f98c3a6721334d71cb896630be453 100644 (file)
@@ -276,7 +276,7 @@ smb_dir_open(struct inode *dir, struct file *file)
 static int smb_lookup_validate(struct dentry *, struct nameidata *);
 static int smb_hash_dentry(struct dentry *, struct qstr *);
 static int smb_compare_dentry(struct dentry *, struct qstr *, struct qstr *);
-static int smb_delete_dentry(struct dentry *);
+static int smb_delete_dentry(const struct dentry *);
 
 static const struct dentry_operations smbfs_dentry_operations =
 {
@@ -367,7 +367,7 @@ out:
  * We use this to unhash dentries with bad inodes.
  */
 static int
-smb_delete_dentry(struct dentry * dentry)
+smb_delete_dentry(const struct dentry *dentry)
 {
        if (dentry->d_inode) {
                if (is_bad_inode(dentry->d_inode)) {
index cbf4e50f3933aa3cb8b714a518a530203a3e5385..466d2a4fc5cb8b91ee4eca23832e6e5b2d4bf1a2 100644 (file)
@@ -51,7 +51,7 @@
  *
  */
 
-static int v9fs_dentry_delete(struct dentry *dentry)
+static int v9fs_dentry_delete(const struct dentry *dentry)
 {
        P9_DPRINTK(P9_DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_name.name,
                                                                        dentry);
@@ -68,7 +68,7 @@ static int v9fs_dentry_delete(struct dentry *dentry)
  *
  */
 
-static int v9fs_cached_dentry_delete(struct dentry *dentry)
+static int v9fs_cached_dentry_delete(const struct dentry *dentry)
 {
        struct inode *inode = dentry->d_inode;
        P9_DPRINTK(P9_DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_name.name,
index 5439e1bc9a86a5702094eaea35eb4c6ebd8e67fe..2c18cde27000abbc69dffb9b9ce991657dec3382 100644 (file)
@@ -23,7 +23,7 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
 static int afs_dir_open(struct inode *inode, struct file *file);
 static int afs_readdir(struct file *file, void *dirent, filldir_t filldir);
 static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd);
-static int afs_d_delete(struct dentry *dentry);
+static int afs_d_delete(const struct dentry *dentry);
 static void afs_d_release(struct dentry *dentry);
 static int afs_lookup_filldir(void *_cookie, const char *name, int nlen,
                                  loff_t fpos, u64 ino, unsigned dtype);
@@ -730,7 +730,7 @@ out_bad:
  * - called from dput() when d_count is going to 0.
  * - return 1 to request dentry be unhashed, 0 otherwise
  */
-static int afs_d_delete(struct dentry *dentry)
+static int afs_d_delete(const struct dentry *dentry)
 {
        _enter("%s", dentry->d_name.name);
 
index 72f31ecb5c90085a2d6adfdc9b690ee038bf508f..7ce9f89327890a385c792108c2ad6ac905311091 100644 (file)
@@ -4127,7 +4127,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
        return inode;
 }
 
-static int btrfs_dentry_delete(struct dentry *dentry)
+static int btrfs_dentry_delete(const struct dentry *dentry)
 {
        struct btrfs_root *root;
 
index 5d8b35539601b819389057b9114dd49a75828597..4cce3b07d9d75d09878f46009265574ff93699f4 100644 (file)
@@ -47,7 +47,7 @@ static int coda_readdir(struct file *file, void *buf, filldir_t filldir);
 
 /* dentry ops */
 static int coda_dentry_revalidate(struct dentry *de, struct nameidata *nd);
-static int coda_dentry_delete(struct dentry *);
+static int coda_dentry_delete(const struct dentry *);
 
 /* support routines */
 static int coda_venus_readdir(struct file *coda_file, void *buf,
@@ -577,7 +577,7 @@ out:
  * This is the callback from dput() when d_count is going to 0.
  * We use this to unhash dentries with bad inodes.
  */
-static int coda_dentry_delete(struct dentry * dentry)
+static int coda_dentry_delete(const struct dentry * dentry)
 {
        int flags;
 
index 57870696941569e78f8942a71ee946711acf5f4a..20024a9ef5a7ade59f4ff6bc513f8683a9d93f44 100644 (file)
@@ -67,7 +67,7 @@ static void configfs_d_iput(struct dentry * dentry,
  * We _must_ delete our dentries on last dput, as the chain-to-parent
  * behavior is required to clear the parents of default_groups.
  */
-static int configfs_d_delete(struct dentry *dentry)
+static int configfs_d_delete(const struct dentry *dentry)
 {
        return 1;
 }
index b2cb2662ca0033e6fa0c80032c8272e1697f1006..6ee6bc40cb63191fd615fc5049f80cf8da1b5ee2 100644 (file)
@@ -453,8 +453,6 @@ static void prune_one_dentry(struct dentry * dentry)
                if (!atomic_dec_and_lock(&dentry->d_count, &dentry->d_lock))
                        return;
 
-               if (dentry->d_op && dentry->d_op->d_delete)
-                       dentry->d_op->d_delete(dentry);
                dentry_lru_del(dentry);
                __d_drop(dentry);
                dentry = d_kill(dentry);
index 6798755b3858685b611da5e439393bcffb332563..e80fea2f65ffd8456a92ce5a97b784aa00474d7a 100644 (file)
@@ -106,7 +106,7 @@ static int gfs2_dhash(struct dentry *dentry, struct qstr *str)
        return 0;
 }
 
-static int gfs2_dentry_delete(struct dentry *dentry)
+static int gfs2_dentry_delete(const struct dentry *dentry)
 {
        struct gfs2_inode *ginode;
 
index 2c0f148a49e65e9cb01016249a76dfd7985aeb25..cfe8bc7de51145829e989f56fd6e086a277da324 100644 (file)
@@ -32,7 +32,7 @@ static inline struct hostfs_inode_info *HOSTFS_I(struct inode *inode)
 
 #define FILE_HOSTFS_I(file) HOSTFS_I((file)->f_path.dentry->d_inode)
 
-static int hostfs_d_delete(struct dentry *dentry)
+static int hostfs_d_delete(const struct dentry *dentry)
 {
        return 1;
 }
index a3accdf528add9161bd6dccfb84f7c08ccb28437..b9d25d83e228551cb4c4391438f8fe380ff13108 100644 (file)
@@ -37,7 +37,7 @@ int simple_statfs(struct dentry *dentry, struct kstatfs *buf)
  * Retaining negative dentries for an in-memory filesystem just wastes
  * memory and lookup time: arrange for them to be deleted immediately.
  */
-static int simple_delete_dentry(struct dentry *dentry)
+static int simple_delete_dentry(const struct dentry *dentry)
 {
        return 1;
 }
index f22b12e7d337c37abc957ee2b4c2b204f52206b1..d6e6453881ceab20ab143664292e548aafa0e1ce 100644 (file)
@@ -76,7 +76,7 @@ const struct inode_operations ncp_dir_inode_operations =
 static int ncp_lookup_validate(struct dentry *, struct nameidata *);
 static int ncp_hash_dentry(struct dentry *, struct qstr *);
 static int ncp_compare_dentry (struct dentry *, struct qstr *, struct qstr *);
-static int ncp_delete_dentry(struct dentry *);
+static int ncp_delete_dentry(const struct dentry *);
 
 static const struct dentry_operations ncp_dentry_operations =
 {
@@ -162,7 +162,7 @@ ncp_compare_dentry(struct dentry *dentry, struct qstr *a, struct qstr *b)
  * Closing files can be safely postponed until iput() - it's done there anyway.
  */
 static int
-ncp_delete_dentry(struct dentry * dentry)
+ncp_delete_dentry(const struct dentry * dentry)
 {
        struct inode *inode = dentry->d_inode;
 
index 996dd8989a9135203cab110f57e7c1f8df49e200..9184c7c80f7895d8d15cd8af0c64e6beebe57093 100644 (file)
@@ -1117,7 +1117,7 @@ out_error:
 /*
  * This is called from dput() when d_count is going to 0.
  */
-static int nfs_dentry_delete(struct dentry *dentry)
+static int nfs_dentry_delete(const struct dentry *dentry)
 {
        dfprintk(VFS, "NFS: dentry_delete(%s/%s, %x)\n",
                dentry->d_parent->d_name.name, dentry->d_name.name,
index 182845147fe45bde8f5607a799f23cc1e2818117..d932fdb6a2453d7376d891cd237dcb08d5195873 100644 (file)
@@ -1744,7 +1744,7 @@ static int pid_revalidate(struct dentry *dentry, struct nameidata *nd)
        return 0;
 }
 
-static int pid_delete_dentry(struct dentry * dentry)
+static int pid_delete_dentry(const struct dentry * dentry)
 {
        /* Is the task we represent dead?
         * If so, then don't put the dentry on the lru list,
index dd29f033766101acfcee512850db17c8e086c7ed..1d607be36d95b9c563d8c7d78c5033035a9d75a8 100644 (file)
@@ -400,7 +400,7 @@ static const struct inode_operations proc_link_inode_operations = {
  * smarter: we could keep a "volatile" flag in the 
  * inode to indicate which ones to keep.
  */
-static int proc_delete_dentry(struct dentry * dentry)
+static int proc_delete_dentry(const struct dentry * dentry)
 {
        return 1;
 }
index b652cb00906b02927c7f4afa048d6bd83615936d..a256d770ea189016bdaeec8793c061b331d6a8e1 100644 (file)
@@ -392,7 +392,7 @@ static int proc_sys_revalidate(struct dentry *dentry, struct nameidata *nd)
        return !PROC_I(dentry->d_inode)->sysctl->unregistering;
 }
 
-static int proc_sys_delete(struct dentry *dentry)
+static int proc_sys_delete(const struct dentry *dentry)
 {
        return !!PROC_I(dentry->d_inode)->sysctl->unregistering;
 }
index 7e54bac8c4b00a6c9fbe86828f0f2c4aca8222c8..27e1102e303e8d403d7e81514e2283efd332ffba 100644 (file)
@@ -231,7 +231,7 @@ void release_sysfs_dirent(struct sysfs_dirent * sd)
                goto repeat;
 }
 
-static int sysfs_dentry_delete(struct dentry *dentry)
+static int sysfs_dentry_delete(const struct dentry *dentry)
 {
        struct sysfs_dirent *sd = dentry->d_fsdata;
        return !!(sd->s_flags & SYSFS_FLAG_REMOVED);
index fff975576b5ba4cc4dc3456bcb5e866e51b34c8c..cbfc9567e4e940c5debe54eed888ca65b988697d 100644 (file)
@@ -133,9 +133,9 @@ enum dentry_d_lock_class
 
 struct dentry_operations {
        int (*d_revalidate)(struct dentry *, struct nameidata *);
-       int (*d_hash) (struct dentry *, struct qstr *);
-       int (*d_compare) (struct dentry *, struct qstr *, struct qstr *);
-       int (*d_delete)(struct dentry *);
+       int (*d_hash)(struct dentry *, struct qstr *);
+       int (*d_compare)(struct dentry *, struct qstr *, struct qstr *);
+       int (*d_delete)(const struct dentry *);
        void (*d_release)(struct dentry *);
        void (*d_iput)(struct dentry *, struct inode *);
        char *(*d_dname)(struct dentry *, char *, int);
index 163c890f436d7f9bfccf565c08464d4814b641e7..746055b214d7a84077bb5a166dd477d357ae9a84 100644 (file)
@@ -2198,7 +2198,7 @@ static inline struct cftype *__file_cft(struct file *file)
        return __d_cft(file->f_dentry);
 }
 
-static int cgroup_delete_dentry(struct dentry *dentry)
+static int cgroup_delete_dentry(const struct dentry *dentry)
 {
        return 1;
 }
index 10a17a37ec4e90c683588de990670288136cc793..a0dc1a86fcea68126ebca5a4a30141036a3f85ce 100644 (file)
@@ -430,7 +430,7 @@ void rpc_put_mount(void)
 }
 EXPORT_SYMBOL_GPL(rpc_put_mount);
 
-static int rpc_delete_dentry(struct dentry *dentry)
+static int rpc_delete_dentry(const struct dentry *dentry)
 {
        return 1;
 }