fs: dcache rationalise dget variants
authorNick Piggin <npiggin@kernel.dk>
Fri, 7 Jan 2011 06:49:43 +0000 (17:49 +1100)
committerNick Piggin <npiggin@kernel.dk>
Fri, 7 Jan 2011 06:50:24 +0000 (17:50 +1100)
dget_locked was a shortcut to avoid the lazy lru manipulation when we already
held dcache_lock (lru manipulation was relatively cheap at that point).
However, how that the lru lock is an innermost one, we never hold it at any
caller, so the lock cost can now be avoided. We already have well working lazy
dcache LRU, so it should be fine to defer LRU manipulations to scan time.

Signed-off-by: Nick Piggin <npiggin@kernel.dk>
12 files changed:
arch/powerpc/platforms/cell/spufs/inode.c
drivers/infiniband/hw/ipath/ipath_fs.c
drivers/infiniband/hw/qib/qib_fs.c
drivers/staging/smbfs/cache.c
fs/configfs/inode.c
fs/dcache.c
fs/exportfs/expfs.c
fs/ncpfs/dir.c
fs/ocfs2/dcache.c
include/linux/dcache.h
kernel/cgroup.c
security/selinux/selinuxfs.c

index 2662b50ea8d450fa7e4c74649c50e2b231989f17..03185de7cd4a917e6749776e2252a9f14a30b956 100644 (file)
@@ -161,7 +161,7 @@ static void spufs_prune_dir(struct dentry *dir)
        list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_u.d_child) {
                spin_lock(&dentry->d_lock);
                if (!(d_unhashed(dentry)) && dentry->d_inode) {
-                       dget_locked_dlock(dentry);
+                       dget_dlock(dentry);
                        __d_drop(dentry);
                        spin_unlock(&dentry->d_lock);
                        simple_unlink(dir->d_inode, dentry);
index 925e88227deda0aaeb055cbea8b29e534532d2df..31ae1b108aea95e7ad769e49f7dd875f3a195d72 100644 (file)
@@ -279,7 +279,7 @@ static int remove_file(struct dentry *parent, char *name)
 
        spin_lock(&tmp->d_lock);
        if (!(d_unhashed(tmp) && tmp->d_inode)) {
-               dget_locked_dlock(tmp);
+               dget_dlock(tmp);
                __d_drop(tmp);
                spin_unlock(&tmp->d_lock);
                simple_unlink(parent->d_inode, tmp);
index 49af4a6538ba7797e4a4cda7112062f1fa6c27f9..df7fa251dcdc5e6e32135be4d1867398d63588e3 100644 (file)
@@ -455,7 +455,7 @@ static int remove_file(struct dentry *parent, char *name)
 
        spin_lock(&tmp->d_lock);
        if (!(d_unhashed(tmp) && tmp->d_inode)) {
-               dget_locked_dlock(tmp);
+               dget_dlock(tmp);
                __d_drop(tmp);
                spin_unlock(&tmp->d_lock);
                simple_unlink(parent->d_inode, tmp);
index 75dfd403fb90390f2900c01c31822aefbba95f95..f2a1323ca8276ebc7f35b188e8183fad5dfc2972 100644 (file)
@@ -102,7 +102,7 @@ smb_dget_fpos(struct dentry *dentry, struct dentry *parent, unsigned long fpos)
                dent = list_entry(next, struct dentry, d_u.d_child);
                if ((unsigned long)dent->d_fsdata == fpos) {
                        if (dent->d_inode)
-                               dget_locked(dent);
+                               dget(dent);
                        else
                                dent = NULL;
                        goto out_unlock;
index fb3a55fff82a7a00125061557ca71f0174d1e887..c83f4768eeaad90efa3971c9d16915703aafb014 100644 (file)
@@ -252,7 +252,7 @@ void configfs_drop_dentry(struct configfs_dirent * sd, struct dentry * parent)
        if (dentry) {
                spin_lock(&dentry->d_lock);
                if (!(d_unhashed(dentry) && dentry->d_inode)) {
-                       dget_locked_dlock(dentry);
+                       dget_dlock(dentry);
                        __d_drop(dentry);
                        spin_unlock(&dentry->d_lock);
                        simple_unlink(parent->d_inode, dentry);
index 01f016799fd4ade5bb0d25a2541a9309d650b2ce..b4d2e28eef5b1e0ee9a78e8d9b58566312300f5d 100644 (file)
@@ -429,32 +429,17 @@ int d_invalidate(struct dentry * dentry)
 EXPORT_SYMBOL(d_invalidate);
 
 /* This must be called with d_lock held */
-static inline struct dentry * __dget_locked_dlock(struct dentry *dentry)
+static inline void __dget_dlock(struct dentry *dentry)
 {
        dentry->d_count++;
-       dentry_lru_del(dentry);
-       return dentry;
 }
 
-/* This must be called with d_lock held */
-static inline struct dentry * __dget_locked(struct dentry *dentry)
+static inline void __dget(struct dentry *dentry)
 {
        spin_lock(&dentry->d_lock);
-       __dget_locked_dlock(dentry);
+       __dget_dlock(dentry);
        spin_unlock(&dentry->d_lock);
-       return dentry;
-}
-
-struct dentry * dget_locked_dlock(struct dentry *dentry)
-{
-       return __dget_locked_dlock(dentry);
-}
-
-struct dentry * dget_locked(struct dentry *dentry)
-{
-       return __dget_locked(dentry);
 }
-EXPORT_SYMBOL(dget_locked);
 
 struct dentry *dget_parent(struct dentry *dentry)
 {
@@ -512,7 +497,7 @@ again:
                            (alias->d_flags & DCACHE_DISCONNECTED)) {
                                discon_alias = alias;
                        } else if (!want_discon) {
-                               __dget_locked_dlock(alias);
+                               __dget_dlock(alias);
                                spin_unlock(&alias->d_lock);
                                return alias;
                        }
@@ -525,7 +510,7 @@ again:
                if (S_ISDIR(inode->i_mode) || !d_unhashed(alias)) {
                        if (IS_ROOT(alias) &&
                            (alias->d_flags & DCACHE_DISCONNECTED)) {
-                               __dget_locked_dlock(alias);
+                               __dget_dlock(alias);
                                spin_unlock(&alias->d_lock);
                                return alias;
                        }
@@ -561,7 +546,7 @@ restart:
        list_for_each_entry(dentry, &inode->i_dentry, d_alias) {
                spin_lock(&dentry->d_lock);
                if (!dentry->d_count) {
-                       __dget_locked_dlock(dentry);
+                       __dget_dlock(dentry);
                        __d_drop(dentry);
                        spin_unlock(&dentry->d_lock);
                        spin_unlock(&dcache_inode_lock);
@@ -1257,7 +1242,8 @@ struct dentry *d_alloc(struct dentry * parent, const struct qstr *name)
                 * don't need child lock because it is not subject
                 * to concurrency here
                 */
-               dentry->d_parent = dget_dlock(parent);
+               __dget_dlock(parent);
+               dentry->d_parent = parent;
                dentry->d_sb = parent->d_sb;
                list_add(&dentry->d_u.d_child, &parent->d_subdirs);
                spin_unlock(&parent->d_lock);
@@ -1360,7 +1346,7 @@ static struct dentry *__d_instantiate_unique(struct dentry *entry,
                        continue;
                if (memcmp(qstr->name, name, len))
                        continue;
-               dget_locked(alias);
+               __dget(alias);
                return alias;
        }
 
@@ -1613,7 +1599,7 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode,
         * reference to it, move it in place and use it.
         */
        new = list_entry(inode->i_dentry.next, struct dentry, d_alias);
-       dget_locked(new);
+       __dget(new);
        spin_unlock(&dcache_inode_lock);
        security_d_instantiate(found, inode);
        d_move(new, found);
@@ -1789,7 +1775,7 @@ int d_validate(struct dentry *dentry, struct dentry *dparent)
        list_for_each_entry(child, &dparent->d_subdirs, d_u.d_child) {
                if (dentry == child) {
                        spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
-                       __dget_locked_dlock(dentry);
+                       __dget_dlock(dentry);
                        spin_unlock(&dentry->d_lock);
                        spin_unlock(&dparent->d_lock);
                        return 1;
index 53a5c08fb63c71ed3881c132652df891fbf1a234..f06a940065f63fbdf53a1cfecc87f9a2c18f0950 100644 (file)
@@ -49,7 +49,7 @@ find_acceptable_alias(struct dentry *result,
 
        spin_lock(&dcache_inode_lock);
        list_for_each_entry(dentry, &result->d_inode->i_dentry, d_alias) {
-               dget_locked(dentry);
+               dget(dentry);
                spin_unlock(&dcache_inode_lock);
                if (toput)
                        dput(toput);
index de15c533311cd9b6674c5989d24602e1fce83065..0ba3cdc95a44bc797fdd204dc99156d4308d34b4 100644 (file)
@@ -397,7 +397,7 @@ ncp_dget_fpos(struct dentry *dentry, struct dentry *parent, unsigned long fpos)
                dent = list_entry(next, struct dentry, d_u.d_child);
                if ((unsigned long)dent->d_fsdata == fpos) {
                        if (dent->d_inode)
-                               dget_locked(dent);
+                               dget(dent);
                        else
                                dent = NULL;
                        spin_unlock(&parent->d_lock);
index b7de749bdd1253b6b0f612d5bcacf4b9d2e0b8a3..4d54c60ceee45ffe3ef74bdb7fa245de4e956c05 100644 (file)
@@ -178,7 +178,7 @@ struct dentry *ocfs2_find_local_alias(struct inode *inode,
                        mlog(0, "dentry found: %.*s\n",
                             dentry->d_name.len, dentry->d_name.name);
 
-                       dget_locked_dlock(dentry);
+                       dget_dlock(dentry);
                        spin_unlock(&dentry->d_lock);
                        break;
                }
index a2ceb94b0e3812c254ce009d1b7878f6effa31bd..ca648685f0cc9a3575fcbfe9c2353f28a4918625 100644 (file)
@@ -287,23 +287,17 @@ extern char *dentry_path(struct dentry *, char *, int);
 /* Allocation counts.. */
 
 /**
- *     dget, dget_locked       -       get a reference to a dentry
+ *     dget, dget_dlock -      get a reference to a dentry
  *     @dentry: dentry to get a reference to
  *
  *     Given a dentry or %NULL pointer increment the reference count
  *     if appropriate and return the dentry. A dentry will not be 
- *     destroyed when it has references. dget() should never be
- *     called for dentries with zero reference counter. For these cases
- *     (preferably none, functions in dcache.c are sufficient for normal
- *     needs and they take necessary precautions) you should hold d_lock
- *     and call dget_dlock() instead of dget().
+ *     destroyed when it has references.
  */
 static inline struct dentry *dget_dlock(struct dentry *dentry)
 {
-       if (dentry) {
-               BUG_ON(!dentry->d_count);
+       if (dentry)
                dentry->d_count++;
-       }
        return dentry;
 }
 
@@ -317,9 +311,6 @@ static inline struct dentry *dget(struct dentry *dentry)
        return dentry;
 }
 
-extern struct dentry * dget_locked(struct dentry *);
-extern struct dentry * dget_locked_dlock(struct dentry *);
-
 extern struct dentry *dget_parent(struct dentry *dentry);
 
 /**
index 1864cb6a6a59f7de3ce86ec52dcaa15896cb7e97..9f41470c3949d62c2ccd37398df77fa974ec57d4 100644 (file)
@@ -887,7 +887,7 @@ static void cgroup_clear_directory(struct dentry *dentry)
                        /* This should never be called on a cgroup
                         * directory with child cgroups */
                        BUG_ON(d->d_inode->i_mode & S_IFDIR);
-                       dget_locked_dlock(d);
+                       dget_dlock(d);
                        spin_unlock(&d->d_lock);
                        spin_unlock(&dentry->d_lock);
                        d_delete(d);
index 2285d693f296e404354949622688dd2fb0e57886..43deac2194912522d1d7a719f3ab1cb84408230c 100644 (file)
@@ -1154,7 +1154,7 @@ static void sel_remove_entries(struct dentry *de)
                list_del_init(node);
 
                if (d->d_inode) {
-                       dget_locked_dlock(d);
+                       dget_dlock(d);
                        spin_unlock(&de->d_lock);
                        spin_unlock(&d->d_lock);
                        d_delete(d);