fs: dcache reduce branches in lookup path
authorNick Piggin <npiggin@kernel.dk>
Fri, 7 Jan 2011 06:49:55 +0000 (17:49 +1100)
committerNick Piggin <npiggin@kernel.dk>
Fri, 7 Jan 2011 06:50:28 +0000 (17:50 +1100)
Reduce some branches and memory accesses in dcache lookup by adding dentry
flags to indicate common d_ops are set, rather than having to check them.
This saves a pointer memory access (dentry->d_op) in common path lookup
situations, and saves another pointer load and branch in cases where we
have d_op but not the particular operation.

Patched with:

git grep -E '[.>]([[:space:]])*d_op([[:space:]])*=' | xargs sed -e 's/\([^\t ]*\)->d_op = \(.*\);/d_set_d_op(\1, \2);/' -e 's/\([^\t ]*\)\.d_op = \(.*\);/d_set_d_op(\&\1, \2);/' -i

Signed-off-by: Nick Piggin <npiggin@kernel.dk>
63 files changed:
arch/ia64/kernel/perfmon.c
drivers/staging/autofs/root.c
drivers/staging/smbfs/dir.c
fs/9p/vfs_inode.c
fs/adfs/dir.c
fs/adfs/super.c
fs/affs/namei.c
fs/affs/super.c
fs/afs/dir.c
fs/anon_inodes.c
fs/autofs4/inode.c
fs/autofs4/root.c
fs/btrfs/export.c
fs/btrfs/inode.c
fs/ceph/dir.c
fs/cifs/dir.c
fs/cifs/inode.c
fs/cifs/link.c
fs/cifs/readdir.c
fs/coda/dir.c
fs/configfs/dir.c
fs/dcache.c
fs/ecryptfs/inode.c
fs/ecryptfs/main.c
fs/fat/inode.c
fs/fat/namei_msdos.c
fs/fat/namei_vfat.c
fs/fuse/dir.c
fs/fuse/inode.c
fs/gfs2/export.c
fs/gfs2/ops_fstype.c
fs/gfs2/ops_inode.c
fs/hfs/dir.c
fs/hfs/super.c
fs/hfsplus/dir.c
fs/hfsplus/super.c
fs/hostfs/hostfs_kern.c
fs/hpfs/dentry.c
fs/isofs/inode.c
fs/isofs/namei.c
fs/jfs/namei.c
fs/jfs/super.c
fs/libfs.c
fs/minix/namei.c
fs/namei.c
fs/ncpfs/dir.c
fs/ncpfs/inode.c
fs/nfs/dir.c
fs/nfs/getroot.c
fs/ocfs2/export.c
fs/ocfs2/namei.c
fs/pipe.c
fs/proc/base.c
fs/proc/generic.c
fs/proc/proc_sysctl.c
fs/reiserfs/xattr.c
fs/sysfs/dir.c
fs/sysv/namei.c
fs/sysv/super.c
include/linux/dcache.h
kernel/cgroup.c
net/socket.c
net/sunrpc/rpc_pipe.c

index d39d8a53b5793265fb28a9dc68a379e3bf3ad956..5a24f40bb48e03dab94a0760d573e352624c3e0f 100644 (file)
@@ -2233,7 +2233,7 @@ pfm_alloc_file(pfm_context_t *ctx)
        }
        path.mnt = mntget(pfmfs_mnt);
 
-       path.dentry->d_op = &pfmfs_dentry_operations;
+       d_set_d_op(path.dentry, &pfmfs_dentry_operations);
        d_add(path.dentry, inode);
 
        file = alloc_file(&path, FMODE_READ, &pfm_file_ops);
index 0fdec4befd8400075ef8cb94a03fede184c0c5cb..b09adb57971f09ef72bbc08603c8a7150220f7dd 100644 (file)
@@ -237,7 +237,7 @@ static struct dentry *autofs_root_lookup(struct inode *dir, struct dentry *dentr
         *
         * We need to do this before we release the directory semaphore.
         */
-       dentry->d_op = &autofs_dentry_operations;
+       d_set_d_op(dentry, &autofs_dentry_operations);
        dentry->d_flags |= DCACHE_AUTOFS_PENDING;
        d_add(dentry, NULL);
 
index 5f79799d5d4a4f181b82eeda1e413744cce20554..78f09412740c0b1b2400bd54fd3de8c2dce8bf3b 100644 (file)
@@ -398,9 +398,9 @@ smb_new_dentry(struct dentry *dentry)
        struct smb_sb_info *server = server_from_dentry(dentry);
 
        if (server->mnt->flags & SMB_MOUNT_CASE)
-               dentry->d_op = &smbfs_dentry_operations_case;
+               d_set_d_op(dentry, &smbfs_dentry_operations_case);
        else
-               dentry->d_op = &smbfs_dentry_operations;
+               d_set_d_op(dentry, &smbfs_dentry_operations);
        dentry->d_time = jiffies;
 }
 
@@ -462,9 +462,9 @@ smb_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
        add_entry:
                        server = server_from_dentry(dentry);
                        if (server->mnt->flags & SMB_MOUNT_CASE)
-                               dentry->d_op = &smbfs_dentry_operations_case;
+                               d_set_d_op(dentry, &smbfs_dentry_operations_case);
                        else
-                               dentry->d_op = &smbfs_dentry_operations;
+                               d_set_d_op(dentry, &smbfs_dentry_operations);
 
                        d_add(dentry, inode);
                        smb_renew_times(dentry);
index f6f9081e6d2ce5650573b2205fa71e834f9fa9ef..df8bbb358d54b362e624674cd2193301cc12e7f0 100644 (file)
@@ -635,9 +635,9 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
        }
 
        if (v9ses->cache)
-               dentry->d_op = &v9fs_cached_dentry_operations;
+               d_set_d_op(dentry, &v9fs_cached_dentry_operations);
        else
-               dentry->d_op = &v9fs_dentry_operations;
+               d_set_d_op(dentry, &v9fs_dentry_operations);
 
        d_instantiate(dentry, inode);
        err = v9fs_fid_add(dentry, fid);
@@ -749,7 +749,7 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode,
                                err);
                        goto error;
                }
-               dentry->d_op = &v9fs_cached_dentry_operations;
+               d_set_d_op(dentry, &v9fs_cached_dentry_operations);
                d_instantiate(dentry, inode);
                err = v9fs_fid_add(dentry, fid);
                if (err < 0)
@@ -767,7 +767,7 @@ v9fs_vfs_create_dotl(struct inode *dir, struct dentry *dentry, int omode,
                        err = PTR_ERR(inode);
                        goto error;
                }
-               dentry->d_op = &v9fs_dentry_operations;
+               d_set_d_op(dentry, &v9fs_dentry_operations);
                d_instantiate(dentry, inode);
        }
        /* Now set the ACL based on the default value */
@@ -956,7 +956,7 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir,
                                err);
                        goto error;
                }
-               dentry->d_op = &v9fs_cached_dentry_operations;
+               d_set_d_op(dentry, &v9fs_cached_dentry_operations);
                d_instantiate(dentry, inode);
                err = v9fs_fid_add(dentry, fid);
                if (err < 0)
@@ -973,7 +973,7 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir,
                        err = PTR_ERR(inode);
                        goto error;
                }
-               dentry->d_op = &v9fs_dentry_operations;
+               d_set_d_op(dentry, &v9fs_dentry_operations);
                d_instantiate(dentry, inode);
        }
        /* Now set the ACL based on the default value */
@@ -1041,9 +1041,9 @@ static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
 
 inst_out:
        if (v9ses->cache)
-               dentry->d_op = &v9fs_cached_dentry_operations;
+               d_set_d_op(dentry, &v9fs_cached_dentry_operations);
        else
-               dentry->d_op = &v9fs_dentry_operations;
+               d_set_d_op(dentry, &v9fs_dentry_operations);
 
        d_add(dentry, inode);
        return NULL;
@@ -1709,7 +1709,7 @@ v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry *dentry,
                                        err);
                        goto error;
                }
-               dentry->d_op = &v9fs_cached_dentry_operations;
+               d_set_d_op(dentry, &v9fs_cached_dentry_operations);
                d_instantiate(dentry, inode);
                err = v9fs_fid_add(dentry, fid);
                if (err < 0)
@@ -1722,7 +1722,7 @@ v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry *dentry,
                        err = PTR_ERR(inode);
                        goto error;
                }
-               dentry->d_op = &v9fs_dentry_operations;
+               d_set_d_op(dentry, &v9fs_dentry_operations);
                d_instantiate(dentry, inode);
        }
 
@@ -1856,7 +1856,7 @@ v9fs_vfs_link_dotl(struct dentry *old_dentry, struct inode *dir,
                ihold(old_dentry->d_inode);
        }
 
-       dentry->d_op = old_dentry->d_op;
+       d_set_d_op(dentry, old_dentry->d_op);
        d_instantiate(dentry, old_dentry->d_inode);
 
        return err;
@@ -1980,7 +1980,7 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int omode,
                                err);
                        goto error;
                }
-               dentry->d_op = &v9fs_cached_dentry_operations;
+               d_set_d_op(dentry, &v9fs_cached_dentry_operations);
                d_instantiate(dentry, inode);
                err = v9fs_fid_add(dentry, fid);
                if (err < 0)
@@ -1996,7 +1996,7 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, int omode,
                        err = PTR_ERR(inode);
                        goto error;
                }
-               dentry->d_op = &v9fs_dentry_operations;
+               d_set_d_op(dentry, &v9fs_dentry_operations);
                d_instantiate(dentry, inode);
        }
        /* Now set the ACL based on the default value */
index a11e5e1027160dc4ec90e06784f22329d026d274..bf7693c384f9af5192fb8cef2da5611ac348cc90 100644 (file)
@@ -276,7 +276,7 @@ adfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
        struct object_info obj;
        int error;
 
-       dentry->d_op = &adfs_dentry_operations; 
+       d_set_d_op(dentry, &adfs_dentry_operations);
        lock_kernel();
        error = adfs_dir_lookup_byname(dir, &dentry->d_name, &obj);
        if (error == 0) {
index 47dffc513a263a0f1943ce9c510a9d80ea3e3195..a4041b52fbca294573c765540212aeba0f97c48e 100644 (file)
@@ -484,7 +484,7 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
                adfs_error(sb, "get root inode failed\n");
                goto error;
        } else
-               sb->s_root->d_op = &adfs_dentry_operations;
+               d_set_d_op(sb->s_root, &adfs_dentry_operations);
        unlock_kernel();
        return 0;
 
index 5aca08c2110082ac019d021a2e9be00fb48b2878..944a4042fb65a78719bb7f1e8a2b307b15082eaa 100644 (file)
@@ -240,7 +240,7 @@ affs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
                if (IS_ERR(inode))
                        return ERR_CAST(inode);
        }
-       dentry->d_op = AFFS_SB(sb)->s_flags & SF_INTL ? &affs_intl_dentry_operations : &affs_dentry_operations;
+       d_set_d_op(dentry, AFFS_SB(sb)->s_flags & SF_INTL ? &affs_intl_dentry_operations : &affs_dentry_operations);
        d_add(dentry, inode);
        return NULL;
 }
index 4c18fcfb0a1974d52d65678b34b77d9d72e950e9..d39081bbe7ce954c26720ecb5a8a3e59bd4cc0c7 100644 (file)
@@ -482,7 +482,7 @@ got_root:
                printk(KERN_ERR "AFFS: Get root inode failed\n");
                goto out_error;
        }
-       sb->s_root->d_op = &affs_dentry_operations;
+       d_set_d_op(sb->s_root, &affs_dentry_operations);
 
        pr_debug("AFFS: s_flags=%lX\n",sb->s_flags);
        return 0;
index 2c18cde27000abbc69dffb9b9ce991657dec3382..b8bb7e7148d036352edd12ddceb384404e28aa45 100644 (file)
@@ -581,7 +581,7 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
        }
 
 success:
-       dentry->d_op = &afs_fs_dentry_operations;
+       d_set_d_op(dentry, &afs_fs_dentry_operations);
 
        d_add(dentry, inode);
        _leave(" = 0 { vn=%u u=%u } -> { ino=%lu v=%llu }",
index 57ce55b2564cf38159638fa146c2b653c5fc66a6..aca8806fa20697551b89d11bc00d7220338ce085 100644 (file)
@@ -113,7 +113,7 @@ struct file *anon_inode_getfile(const char *name,
         */
        ihold(anon_inode_inode);
 
-       path.dentry->d_op = &anon_inodefs_dentry_operations;
+       d_set_d_op(path.dentry, &anon_inodefs_dentry_operations);
        d_instantiate(path.dentry, anon_inode_inode);
 
        error = -ENFILE;
index ac87e49fa70604e4b8238cd95fbae7a3cc1dcb07..a7bdb9dcac8471c71645753cdb4d72cc6b851a80 100644 (file)
@@ -309,7 +309,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
                goto fail_iput;
        pipe = NULL;
 
-       root->d_op = &autofs4_sb_dentry_operations;
+       d_set_d_op(root, &autofs4_sb_dentry_operations);
        root->d_fsdata = ino;
 
        /* Can this call block? */
index 10ca68a96dc7ad90d8da92060bdf006d3a663051..bfe3f2eb684d14741d002d61b9a1d8783cc2a566 100644 (file)
@@ -571,7 +571,7 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s
                 * we check for the hashed dentry and return the newly
                 * hashed dentry.
                 */
-               dentry->d_op = &autofs4_root_dentry_operations;
+               d_set_d_op(dentry, &autofs4_root_dentry_operations);
 
                /*
                 * And we need to ensure that the same dentry is used for
@@ -710,9 +710,9 @@ static int autofs4_dir_symlink(struct inode *dir,
        d_add(dentry, inode);
 
        if (dir == dir->i_sb->s_root->d_inode)
-               dentry->d_op = &autofs4_root_dentry_operations;
+               d_set_d_op(dentry, &autofs4_root_dentry_operations);
        else
-               dentry->d_op = &autofs4_dentry_operations;
+               d_set_d_op(dentry, &autofs4_dentry_operations);
 
        dentry->d_fsdata = ino;
        ino->dentry = dget(dentry);
@@ -845,9 +845,9 @@ static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, int mode)
        d_add(dentry, inode);
 
        if (dir == dir->i_sb->s_root->d_inode)
-               dentry->d_op = &autofs4_root_dentry_operations;
+               d_set_d_op(dentry, &autofs4_root_dentry_operations);
        else
-               dentry->d_op = &autofs4_dentry_operations;
+               d_set_d_op(dentry, &autofs4_dentry_operations);
 
        dentry->d_fsdata = ino;
        ino->dentry = dget(dentry);
index 659f532d26a01f6b3b1da403a3834ba116d20bdd..0ccf9a8afcdf0a9143d740c39051de3833c96701 100644 (file)
@@ -110,7 +110,7 @@ static struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid,
 
        dentry = d_obtain_alias(inode);
        if (!IS_ERR(dentry))
-               dentry->d_op = &btrfs_dentry_operations;
+               d_set_d_op(dentry, &btrfs_dentry_operations);
        return dentry;
 fail:
        srcu_read_unlock(&fs_info->subvol_srcu, index);
@@ -225,7 +225,7 @@ static struct dentry *btrfs_get_parent(struct dentry *child)
        key.offset = 0;
        dentry = d_obtain_alias(btrfs_iget(root->fs_info->sb, &key, root, NULL));
        if (!IS_ERR(dentry))
-               dentry->d_op = &btrfs_dentry_operations;
+               d_set_d_op(dentry, &btrfs_dentry_operations);
        return dentry;
 fail:
        btrfs_free_path(path);
index f9d2994a42a26dc198512277bc214753a9c563cc..63e4546b478acd144ad0c73fc886163be876f810 100644 (file)
@@ -4084,7 +4084,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
        int index;
        int ret;
 
-       dentry->d_op = &btrfs_dentry_operations;
+       d_set_d_op(dentry, &btrfs_dentry_operations);
 
        if (dentry->d_name.len > BTRFS_NAME_LEN)
                return ERR_PTR(-ENAMETOOLONG);
index 58abc3da6111c517fdcb725ce8f2b4fce4a32db3..cc01cf826769b401d65ca702d67b71238aa05355 100644 (file)
@@ -42,11 +42,11 @@ int ceph_init_dentry(struct dentry *dentry)
 
        if (dentry->d_parent == NULL ||   /* nfs fh_to_dentry */
            ceph_snap(dentry->d_parent->d_inode) == CEPH_NOSNAP)
-               dentry->d_op = &ceph_dentry_ops;
+               d_set_d_op(dentry, &ceph_dentry_ops);
        else if (ceph_snap(dentry->d_parent->d_inode) == CEPH_SNAPDIR)
-               dentry->d_op = &ceph_snapdir_dentry_ops;
+               d_set_d_op(dentry, &ceph_snapdir_dentry_ops);
        else
-               dentry->d_op = &ceph_snap_dentry_ops;
+               d_set_d_op(dentry, &ceph_snap_dentry_ops);
 
        di = kmem_cache_alloc(ceph_dentry_cachep, GFP_NOFS | __GFP_ZERO);
        if (!di)
index 88bfe686ac005401fe0d5fce2dfb95a649f0693e..e3b10ca6d4537bcdd54ea88e58e68572442e833a 100644 (file)
@@ -135,9 +135,9 @@ static void setup_cifs_dentry(struct cifsTconInfo *tcon,
                              struct inode *newinode)
 {
        if (tcon->nocase)
-               direntry->d_op = &cifs_ci_dentry_ops;
+               d_set_d_op(direntry, &cifs_ci_dentry_ops);
        else
-               direntry->d_op = &cifs_dentry_ops;
+               d_set_d_op(direntry, &cifs_dentry_ops);
        d_instantiate(direntry, newinode);
 }
 
@@ -421,9 +421,9 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
                rc = cifs_get_inode_info_unix(&newinode, full_path,
                                                inode->i_sb, xid);
                if (pTcon->nocase)
-                       direntry->d_op = &cifs_ci_dentry_ops;
+                       d_set_d_op(direntry, &cifs_ci_dentry_ops);
                else
-                       direntry->d_op = &cifs_dentry_ops;
+                       d_set_d_op(direntry, &cifs_dentry_ops);
 
                if (rc == 0)
                        d_instantiate(direntry, newinode);
@@ -604,9 +604,9 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
 
        if ((rc == 0) && (newInode != NULL)) {
                if (pTcon->nocase)
-                       direntry->d_op = &cifs_ci_dentry_ops;
+                       d_set_d_op(direntry, &cifs_ci_dentry_ops);
                else
-                       direntry->d_op = &cifs_dentry_ops;
+                       d_set_d_op(direntry, &cifs_dentry_ops);
                d_add(direntry, newInode);
                if (posix_open) {
                        filp = lookup_instantiate_filp(nd, direntry,
@@ -634,9 +634,9 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
                rc = 0;
                direntry->d_time = jiffies;
                if (pTcon->nocase)
-                       direntry->d_op = &cifs_ci_dentry_ops;
+                       d_set_d_op(direntry, &cifs_ci_dentry_ops);
                else
-                       direntry->d_op = &cifs_dentry_ops;
+                       d_set_d_op(direntry, &cifs_dentry_ops);
                d_add(direntry, NULL);
        /*      if it was once a directory (but how can we tell?) we could do
                shrink_dcache_parent(direntry); */
index 99b9a2cc14b7c93f6e60658c7fceabb1788eb961..2a239d878e8526a8e4d09224eb0ac05b3b4a9d7d 100644 (file)
@@ -1319,9 +1319,9 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
        to set uid/gid */
                        inc_nlink(inode);
                        if (pTcon->nocase)
-                               direntry->d_op = &cifs_ci_dentry_ops;
+                               d_set_d_op(direntry, &cifs_ci_dentry_ops);
                        else
-                               direntry->d_op = &cifs_dentry_ops;
+                               d_set_d_op(direntry, &cifs_dentry_ops);
 
                        cifs_unix_basic_to_fattr(&fattr, pInfo, cifs_sb);
                        cifs_fill_uniqueid(inode->i_sb, &fattr);
@@ -1363,9 +1363,9 @@ mkdir_get_info:
                                                 inode->i_sb, xid, NULL);
 
                if (pTcon->nocase)
-                       direntry->d_op = &cifs_ci_dentry_ops;
+                       d_set_d_op(direntry, &cifs_ci_dentry_ops);
                else
-                       direntry->d_op = &cifs_dentry_ops;
+                       d_set_d_op(direntry, &cifs_dentry_ops);
                d_instantiate(direntry, newinode);
                 /* setting nlink not necessary except in cases where we
                  * failed to get it from the server or was set bogus */
index 85cdbf831e7baca6c3d3fbdb1ac670e69fc595ad..fe2f6a93c49e3cf596fb14f3482f2a55e540fef7 100644 (file)
@@ -525,9 +525,9 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname)
                              rc);
                } else {
                        if (pTcon->nocase)
-                               direntry->d_op = &cifs_ci_dentry_ops;
+                               d_set_d_op(direntry, &cifs_ci_dentry_ops);
                        else
-                               direntry->d_op = &cifs_dentry_ops;
+                               d_set_d_op(direntry, &cifs_dentry_ops);
                        d_instantiate(direntry, newinode);
                }
        }
index ee463aeca0b03b2fb655d20d888ba5d9bbbf6813..ec5b68e3b928d56ee5b36157c21e67902508f51a 100644 (file)
@@ -103,9 +103,9 @@ cifs_readdir_lookup(struct dentry *parent, struct qstr *name,
        }
 
        if (cifs_sb_master_tcon(CIFS_SB(sb))->nocase)
-               dentry->d_op = &cifs_ci_dentry_ops;
+               d_set_d_op(dentry, &cifs_ci_dentry_ops);
        else
-               dentry->d_op = &cifs_dentry_ops;
+               d_set_d_op(dentry, &cifs_dentry_ops);
 
        alias = d_materialise_unique(dentry, inode);
        if (alias != NULL) {
index 9e37e8bc9b89e83351549b6b3a9a93fb7f9d5c45..aa40c811f8d22b2082a67e6929c7d33a54428e95 100644 (file)
@@ -125,7 +125,7 @@ static struct dentry *coda_lookup(struct inode *dir, struct dentry *entry, struc
                return ERR_PTR(error);
 
 exit:
-       entry->d_op = &coda_dentry_operations;
+       d_set_d_op(entry, &coda_dentry_operations);
 
        if (inode && (type & CODA_NOCACHE))
                coda_flag_inode(inode, C_VATTR | C_PURGE);
index e9acea440ffca47ccf61f048ea9708fb351d1dae..36637a8c1ed339b945057698bfab2da66467a364 100644 (file)
@@ -442,7 +442,7 @@ static int configfs_attach_attr(struct configfs_dirent * sd, struct dentry * den
                return error;
        }
 
-       dentry->d_op = &configfs_dentry_ops;
+       d_set_d_op(dentry, &configfs_dentry_ops);
        d_rehash(dentry);
 
        return 0;
@@ -489,7 +489,7 @@ static struct dentry * configfs_lookup(struct inode *dir,
                 */
                if (dentry->d_name.len > NAME_MAX)
                        return ERR_PTR(-ENAMETOOLONG);
-               dentry->d_op = &configfs_dentry_ops;
+               d_set_d_op(dentry, &configfs_dentry_ops);
                d_add(dentry, NULL);
                return NULL;
        }
@@ -683,7 +683,7 @@ static int create_default_group(struct config_group *parent_group,
        ret = -ENOMEM;
        child = d_alloc(parent, &name);
        if (child) {
-               child->d_op = &configfs_dentry_ops;
+               d_set_d_op(child, &configfs_dentry_ops);
                d_add(child, NULL);
 
                ret = configfs_attach_group(&parent_group->cg_item,
@@ -1681,7 +1681,7 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys)
        err = -ENOMEM;
        dentry = d_alloc(configfs_sb->s_root, &name);
        if (dentry) {
-               dentry->d_op = &configfs_dentry_ops;
+               d_set_d_op(dentry, &configfs_dentry_ops);
                d_add(dentry, NULL);
 
                err = configfs_attach_group(sd->s_element, &group->cg_item,
index 1d5cf511e1c7a4b379d179872ed0acd3c23eb0f7..f9693da3efbd73c36224bb14b982642425ae4a17 100644 (file)
@@ -398,7 +398,7 @@ repeat:
                return;
        }
 
-       if (dentry->d_op && dentry->d_op->d_delete) {
+       if (dentry->d_flags & DCACHE_OP_DELETE) {
                if (dentry->d_op->d_delete(dentry))
                        goto kill_it;
        }
@@ -1301,6 +1301,28 @@ struct dentry *d_alloc_name(struct dentry *parent, const char *name)
 }
 EXPORT_SYMBOL(d_alloc_name);
 
+void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op)
+{
+       BUG_ON(dentry->d_op);
+       BUG_ON(dentry->d_flags & (DCACHE_OP_HASH        |
+                               DCACHE_OP_COMPARE       |
+                               DCACHE_OP_REVALIDATE    |
+                               DCACHE_OP_DELETE ));
+       dentry->d_op = op;
+       if (!op)
+               return;
+       if (op->d_hash)
+               dentry->d_flags |= DCACHE_OP_HASH;
+       if (op->d_compare)
+               dentry->d_flags |= DCACHE_OP_COMPARE;
+       if (op->d_revalidate)
+               dentry->d_flags |= DCACHE_OP_REVALIDATE;
+       if (op->d_delete)
+               dentry->d_flags |= DCACHE_OP_DELETE;
+
+}
+EXPORT_SYMBOL(d_set_d_op);
+
 static void __d_instantiate(struct dentry *dentry, struct inode *inode)
 {
        spin_lock(&dentry->d_lock);
@@ -1731,7 +1753,7 @@ seqretry:
                 */
                if (read_seqcount_retry(&dentry->d_seq, *seq))
                        goto seqretry;
-               if (parent->d_op && parent->d_op->d_compare) {
+               if (parent->d_flags & DCACHE_OP_COMPARE) {
                        if (parent->d_op->d_compare(parent, *inode,
                                                dentry, i,
                                                tlen, tname, name))
@@ -1846,7 +1868,7 @@ struct dentry *__d_lookup(struct dentry *parent, struct qstr *name)
                 */
                tlen = dentry->d_name.len;
                tname = dentry->d_name.name;
-               if (parent->d_op && parent->d_op->d_compare) {
+               if (parent->d_flags & DCACHE_OP_COMPARE) {
                        if (parent->d_op->d_compare(parent, parent->d_inode,
                                                dentry, dentry->d_inode,
                                                tlen, tname, name))
@@ -1887,7 +1909,7 @@ struct dentry *d_hash_and_lookup(struct dentry *dir, struct qstr *name)
         * routine may choose to leave the hash value unchanged.
         */
        name->hash = full_name_hash(name->name, name->len);
-       if (dir->d_op && dir->d_op->d_hash) {
+       if (dir->d_flags & DCACHE_OP_HASH) {
                if (dir->d_op->d_hash(dir, dir->d_inode, name) < 0)
                        goto out;
        }
index 5e5c7ec1fc9825871042dd76773c6d9f280d497a..f91b35db4c6e987e3ba7bfc2196045989f874ec7 100644 (file)
@@ -441,7 +441,7 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
        struct qstr lower_name;
        int rc = 0;
 
-       ecryptfs_dentry->d_op = &ecryptfs_dops;
+       d_set_d_op(ecryptfs_dentry, &ecryptfs_dops);
        if ((ecryptfs_dentry->d_name.len == 1
             && !strcmp(ecryptfs_dentry->d_name.name, "."))
            || (ecryptfs_dentry->d_name.len == 2
index a9dbd62518e6a875abee7da0e0698ac0ed7ba4ff..351038675376bcba656b06a28825c64ab5510b35 100644 (file)
@@ -189,7 +189,7 @@ int ecryptfs_interpose(struct dentry *lower_dentry, struct dentry *dentry,
        if (special_file(lower_inode->i_mode))
                init_special_inode(inode, lower_inode->i_mode,
                                   lower_inode->i_rdev);
-       dentry->d_op = &ecryptfs_dops;
+       d_set_d_op(dentry, &ecryptfs_dops);
        fsstack_copy_attr_all(inode, lower_inode);
        /* This size will be overwritten for real files w/ headers and
         * other metadata */
@@ -594,7 +594,7 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags
                deactivate_locked_super(s);
                goto out;
        }
-       s->s_root->d_op = &ecryptfs_dops;
+       d_set_d_op(s->s_root, &ecryptfs_dops);
        s->s_root->d_sb = s;
        s->s_root->d_parent = s->s_root;
 
index 8cccfebee180a18c93888fb7ba8f71788c4ed24a..206351af7c58afc1a6a0468e264c2172a721e19d 100644 (file)
@@ -750,7 +750,7 @@ static struct dentry *fat_fh_to_dentry(struct super_block *sb,
         */
        result = d_obtain_alias(inode);
        if (!IS_ERR(result))
-               result->d_op = sb->s_root->d_op;
+               d_set_d_op(result, sb->s_root->d_op);
        return result;
 }
 
@@ -800,7 +800,7 @@ static struct dentry *fat_get_parent(struct dentry *child)
 
        parent = d_obtain_alias(inode);
        if (!IS_ERR(parent))
-               parent->d_op = sb->s_root->d_op;
+               d_set_d_op(parent, sb->s_root->d_op);
 out:
        unlock_super(sb);
 
index 3b3e072d8982674b11f3efebcb81ee0d43da95cb..35ffe43afa4bc5609794c65f8d0145b605e22f13 100644 (file)
@@ -227,10 +227,10 @@ static struct dentry *msdos_lookup(struct inode *dir, struct dentry *dentry,
        }
 out:
        unlock_super(sb);
-       dentry->d_op = &msdos_dentry_operations;
+       d_set_d_op(dentry, &msdos_dentry_operations);
        dentry = d_splice_alias(inode, dentry);
        if (dentry)
-               dentry->d_op = &msdos_dentry_operations;
+               d_set_d_op(dentry, &msdos_dentry_operations);
        return dentry;
 
 error:
@@ -673,7 +673,7 @@ static int msdos_fill_super(struct super_block *sb, void *data, int silent)
        }
 
        sb->s_flags |= MS_NOATIME;
-       sb->s_root->d_op = &msdos_dentry_operations;
+       d_set_d_op(sb->s_root, &msdos_dentry_operations);
        unlock_super(sb);
        return 0;
 }
index 4fc06278db48f734bc9060aafe11a27dcb729f44..3be5ed7d859fb0e7fd2fc0bfc807a0e5371c5317 100644 (file)
@@ -766,11 +766,11 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
 
 out:
        unlock_super(sb);
-       dentry->d_op = sb->s_root->d_op;
+       d_set_d_op(dentry, sb->s_root->d_op);
        dentry->d_time = dentry->d_parent->d_inode->i_version;
        dentry = d_splice_alias(inode, dentry);
        if (dentry) {
-               dentry->d_op = sb->s_root->d_op;
+               d_set_d_op(dentry, sb->s_root->d_op);
                dentry->d_time = dentry->d_parent->d_inode->i_version;
        }
        return dentry;
@@ -1072,9 +1072,9 @@ static int vfat_fill_super(struct super_block *sb, void *data, int silent)
        }
 
        if (MSDOS_SB(sb)->options.name_check != 's')
-               sb->s_root->d_op = &vfat_ci_dentry_ops;
+               d_set_d_op(sb->s_root, &vfat_ci_dentry_ops);
        else
-               sb->s_root->d_op = &vfat_dentry_ops;
+               d_set_d_op(sb->s_root, &vfat_dentry_ops);
 
        unlock_super(sb);
        return 0;
index c9627c95482d1f316102272e7aee88e1f2f31fe0..c9a8a426a3951237e11ec7565ef915af78f90cd1 100644 (file)
@@ -347,7 +347,7 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
        }
 
        entry = newent ? newent : entry;
-       entry->d_op = &fuse_dentry_operations;
+       d_set_d_op(entry, &fuse_dentry_operations);
        if (outarg_valid)
                fuse_change_entry_timeout(entry, &outarg);
        else
index 44e0a6c57e8729c02630fa5174a832580cafaddf..a8b31da19b93f52ad4ae5e4bd36244f961853f87 100644 (file)
@@ -626,7 +626,7 @@ static struct dentry *fuse_get_dentry(struct super_block *sb,
 
        entry = d_obtain_alias(inode);
        if (!IS_ERR(entry) && get_node_id(inode) != FUSE_ROOT_ID) {
-               entry->d_op = &fuse_dentry_operations;
+               d_set_d_op(entry, &fuse_dentry_operations);
                fuse_invalidate_entry_cache(entry);
        }
 
@@ -728,7 +728,7 @@ static struct dentry *fuse_get_parent(struct dentry *child)
 
        parent = d_obtain_alias(inode);
        if (!IS_ERR(parent) && get_node_id(inode) != FUSE_ROOT_ID) {
-               parent->d_op = &fuse_dentry_operations;
+               d_set_d_op(parent, &fuse_dentry_operations);
                fuse_invalidate_entry_cache(parent);
        }
 
index 5ab3839dfcb97719d3b9e2f96e99062eef3b3c5f..97012ecff560132c5e3ec052923809a1d106237a 100644 (file)
@@ -130,7 +130,7 @@ static struct dentry *gfs2_get_parent(struct dentry *child)
 
        dentry = d_obtain_alias(gfs2_lookupi(child->d_inode, &gfs2_qdotdot, 1));
        if (!IS_ERR(dentry))
-               dentry->d_op = &gfs2_dops;
+               d_set_d_op(dentry, &gfs2_dops);
        return dentry;
 }
 
@@ -158,7 +158,7 @@ static struct dentry *gfs2_get_dentry(struct super_block *sb,
 out_inode:
        dentry = d_obtain_alias(inode);
        if (!IS_ERR(dentry))
-               dentry->d_op = &gfs2_dops;
+               d_set_d_op(dentry, &gfs2_dops);
        return dentry;
 }
 
index 3eb1393f7b81ba80f0e56ff58a92748ca68b708e..2aeabd4218ccef570bacbd1e47b7afbb19610dd9 100644 (file)
@@ -440,7 +440,7 @@ static int gfs2_lookup_root(struct super_block *sb, struct dentry **dptr,
                iput(inode);
                return -ENOMEM;
        }
-       dentry->d_op = &gfs2_dops;
+       d_set_d_op(dentry, &gfs2_dops);
        *dptr = dentry;
        return 0;
 }
index 12cbea7502c26040fb90db5750e764bdd831079a..f28f89796f4dca6835f16bcb01de48121ce38d6b 100644 (file)
@@ -106,7 +106,7 @@ static struct dentry *gfs2_lookup(struct inode *dir, struct dentry *dentry,
 {
        struct inode *inode = NULL;
 
-       dentry->d_op = &gfs2_dops;
+       d_set_d_op(dentry, &gfs2_dops);
 
        inode = gfs2_lookupi(dir, &dentry->d_name, 0);
        if (inode && IS_ERR(inode))
index 2b3b8611b41b5010daf2392a522834075654a4ef..ea4aefe7c652c14a651d790bfeba842609cb0b64 100644 (file)
@@ -25,7 +25,7 @@ static struct dentry *hfs_lookup(struct inode *dir, struct dentry *dentry,
        struct inode *inode = NULL;
        int res;
 
-       dentry->d_op = &hfs_dentry_operations;
+       d_set_d_op(dentry, &hfs_dentry_operations);
 
        hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, &fd);
        hfs_cat_build_key(dir->i_sb, fd.search_key, dir->i_ino, &dentry->d_name);
index ef4ee5716abe0309d42b0c7507216a34b2276e75..0bef62aa4f420b43f313510e01b638b8374570ba 100644 (file)
@@ -434,7 +434,7 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
        if (!sb->s_root)
                goto bail_iput;
 
-       sb->s_root->d_op = &hfs_dentry_operations;
+       d_set_d_op(sb->s_root, &hfs_dentry_operations);
 
        /* everything's okay */
        return 0;
index 9d59c0571f5982f27e3d36d12ea6fae81f3b02c2..ccab87145f7aa4f9beeda9008142fcd31496c7ed 100644 (file)
@@ -37,7 +37,7 @@ static struct dentry *hfsplus_lookup(struct inode *dir, struct dentry *dentry,
 
        sb = dir->i_sb;
 
-       dentry->d_op = &hfsplus_dentry_operations;
+       d_set_d_op(dentry, &hfsplus_dentry_operations);
        dentry->d_fsdata = NULL;
        hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
        hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino, &dentry->d_name);
index 182e83a9079ef8f7f6ed0141a94d2f805afd124c..ddf712e4700e278ec43ad7c94be6fe51c9ef8a3b 100644 (file)
@@ -419,7 +419,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
                err = -ENOMEM;
                goto cleanup;
        }
-       sb->s_root->d_op = &hfsplus_dentry_operations;
+       d_set_d_op(sb->s_root, &hfsplus_dentry_operations);
 
        str.len = sizeof(HFSP_HIDDENDIR_NAME) - 1;
        str.name = HFSP_HIDDENDIR_NAME;
index 861113fcfc88ca3b366254a5adf1c7b1859a57fb..0bc81cf256b8320c325bf64eafd32e1aede575d6 100644 (file)
@@ -612,7 +612,7 @@ struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry,
                goto out_put;
 
        d_add(dentry, inode);
-       dentry->d_op = &hostfs_dentry_ops;
+       d_set_d_op(dentry, &hostfs_dentry_ops);
        return NULL;
 
  out_put:
index 35526df1fd328b21e536aeaf565c18c4a89004cc..32c13a94e1e904f36745e865f3f93e4ada07ab1b 100644 (file)
@@ -65,5 +65,5 @@ static const struct dentry_operations hpfs_dentry_operations = {
 
 void hpfs_set_dentry_operations(struct dentry *dentry)
 {
-       dentry->d_op = &hpfs_dentry_operations;
+       d_set_d_op(dentry, &hpfs_dentry_operations);
 }
index d8f3a652243d9e05303844e996a842dce86a3d80..844a7903c72f7dd9b0013171e1ff9492324f0c15 100644 (file)
@@ -949,7 +949,7 @@ root_found:
                table += 2;
        if (opt.check == 'r')
                table++;
-       s->s_root->d_op = &isofs_dentry_ops[table];
+       d_set_d_op(s->s_root, &isofs_dentry_ops[table]);
 
        kfree(opt.iocharset);
 
index 715f7d3180466c3204da88e3fe0ce4249952a823..679a849c3b27e0fe275bc45ca0278b7f05c5ac56 100644 (file)
@@ -172,7 +172,7 @@ struct dentry *isofs_lookup(struct inode *dir, struct dentry *dentry, struct nam
        struct inode *inode;
        struct page *page;
 
-       dentry->d_op = dir->i_sb->s_root->d_op;
+       d_set_d_op(dentry, dir->i_sb->s_root->d_op);
 
        page = alloc_page(GFP_USER);
        if (!page)
index 57f90dad8919db3a8440ce152eb27a53f0c7c5c7..a151cbdec626899168e57998173d942aa9ff72e1 100644 (file)
@@ -1466,7 +1466,7 @@ static struct dentry *jfs_lookup(struct inode *dip, struct dentry *dentry, struc
        jfs_info("jfs_lookup: name = %s", name);
 
        if (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2)
-               dentry->d_op = &jfs_ci_dentry_operations;
+               d_set_d_op(dentry, &jfs_ci_dentry_operations);
 
        if ((name[0] == '.') && (len == 1))
                inum = dip->i_ino;
@@ -1495,7 +1495,7 @@ static struct dentry *jfs_lookup(struct inode *dip, struct dentry *dentry, struc
        dentry = d_splice_alias(ip, dentry);
 
        if (dentry && (JFS_SBI(dip->i_sb)->mntflag & JFS_OS2))
-               dentry->d_op = &jfs_ci_dentry_operations;
+               d_set_d_op(dentry, &jfs_ci_dentry_operations);
 
        return dentry;
 }
index b715b0f7bdfd7ae2dec86eab4112d987914310db..3150d766e0d4da77ce60537034aee0fe0606d65d 100644 (file)
@@ -525,7 +525,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
                goto out_no_root;
 
        if (sbi->mntflag & JFS_OS2)
-               sb->s_root->d_op = &jfs_ci_dentry_operations;
+               d_set_d_op(sb->s_root, &jfs_ci_dentry_operations);
 
        /* logical blocks are represented by 40 bits in pxd_t, etc. */
        sb->s_maxbytes = ((u64) sb->s_blocksize) << 40;
index 28b36663c44e45d6599ab03825ff357476f1f0c2..889311e3d06b66c6ea99c581f96a9d2774950d12 100644 (file)
@@ -59,7 +59,7 @@ struct dentry *simple_lookup(struct inode *dir, struct dentry *dentry, struct na
 
        if (dentry->d_name.len > NAME_MAX)
                return ERR_PTR(-ENAMETOOLONG);
-       dentry->d_op = &simple_dentry_operations;
+       d_set_d_op(dentry, &simple_dentry_operations);
        d_add(dentry, NULL);
        return NULL;
 }
index c0d35a3accef98dd5ed7619214146e0f0f5d3260..1b9e07728a9fc3c95cc89b263f14fcb751697c6d 100644 (file)
@@ -23,7 +23,7 @@ static struct dentry *minix_lookup(struct inode * dir, struct dentry *dentry, st
        struct inode * inode = NULL;
        ino_t ino;
 
-       dentry->d_op = dir->i_sb->s_root->d_op;
+       d_set_d_op(dentry, dir->i_sb->s_root->d_op);
 
        if (dentry->d_name.len > minix_sb(dir->i_sb)->s_namelen)
                return ERR_PTR(-ENAMETOOLONG);
index c731b50a618469cb70de76f98f8661ea15110ca3..90bd2873e117449a9f03b4de89a21feec327ee7b 100644 (file)
@@ -587,6 +587,17 @@ do_revalidate(struct dentry *dentry, struct nameidata *nd)
        return dentry;
 }
 
+static inline int need_reval_dot(struct dentry *dentry)
+{
+       if (likely(!(dentry->d_flags & DCACHE_OP_REVALIDATE)))
+               return 0;
+
+       if (likely(!(dentry->d_sb->s_type->fs_flags & FS_REVAL_DOT)))
+               return 0;
+
+       return 1;
+}
+
 /*
  * force_reval_path - force revalidation of a dentry
  *
@@ -610,10 +621,9 @@ force_reval_path(struct path *path, struct nameidata *nd)
 
        /*
         * only check on filesystems where it's possible for the dentry to
-        * become stale. It's assumed that if this flag is set then the
-        * d_revalidate op will also be defined.
+        * become stale.
         */
-       if (!(dentry->d_sb->s_type->fs_flags & FS_REVAL_DOT))
+       if (!need_reval_dot(dentry))
                return 0;
 
        status = dentry->d_op->d_revalidate(dentry, nd);
@@ -1003,7 +1013,7 @@ static int do_lookup(struct nameidata *nd, struct qstr *name,
         * See if the low-level filesystem might want
         * to use its own hash..
         */
-       if (parent->d_op && parent->d_op->d_hash) {
+       if (unlikely(parent->d_flags & DCACHE_OP_HASH)) {
                int err = parent->d_op->d_hash(parent, nd->inode, name);
                if (err < 0)
                        return err;
@@ -1029,7 +1039,7 @@ static int do_lookup(struct nameidata *nd, struct qstr *name,
                        return -ECHILD;
 
                nd->seq = seq;
-               if (dentry->d_op && dentry->d_op->d_revalidate) {
+               if (dentry->d_flags & DCACHE_OP_REVALIDATE) {
                        /* We commonly drop rcu-walk here */
                        if (nameidata_dentry_drop_rcu(nd, dentry))
                                return -ECHILD;
@@ -1043,7 +1053,7 @@ static int do_lookup(struct nameidata *nd, struct qstr *name,
                if (!dentry)
                        goto need_lookup;
 found:
-               if (dentry->d_op && dentry->d_op->d_revalidate)
+               if (dentry->d_flags & DCACHE_OP_REVALIDATE)
                        goto need_revalidate;
 done:
                path->mnt = mnt;
@@ -1281,8 +1291,7 @@ return_reval:
                 * We bypassed the ordinary revalidation routines.
                 * We may need to check the cached dentry for staleness.
                 */
-               if (nd->path.dentry && nd->path.dentry->d_sb &&
-                   (nd->path.dentry->d_sb->s_type->fs_flags & FS_REVAL_DOT)) {
+               if (need_reval_dot(nd->path.dentry)) {
                        if (nameidata_drop_rcu_maybe(nd))
                                return -ECHILD;
                        err = -ESTALE;
@@ -1602,7 +1611,7 @@ static struct dentry *__lookup_hash(struct qstr *name,
         * See if the low-level filesystem might want
         * to use its own hash..
         */
-       if (base->d_op && base->d_op->d_hash) {
+       if (base->d_flags & DCACHE_OP_HASH) {
                err = base->d_op->d_hash(base, inode, name);
                dentry = ERR_PTR(err);
                if (err < 0)
@@ -1616,7 +1625,7 @@ static struct dentry *__lookup_hash(struct qstr *name,
         */
        dentry = d_lookup(base, name);
 
-       if (dentry && dentry->d_op && dentry->d_op->d_revalidate)
+       if (dentry && (dentry->d_flags & DCACHE_OP_REVALIDATE))
                dentry = do_revalidate(dentry, nd);
 
        if (!dentry)
@@ -2070,7 +2079,7 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
                follow_dotdot(nd);
                dir = nd->path.dentry;
        case LAST_DOT:
-               if (nd->path.mnt->mnt_sb->s_type->fs_flags & FS_REVAL_DOT) {
+               if (need_reval_dot(dir)) {
                        if (!dir->d_op->d_revalidate(dir, nd)) {
                                error = -ESTALE;
                                goto exit;
index 0ba3cdc95a44bc797fdd204dc99156d4308d34b4..4b9cbb28d7faf31121a87828e4ee4f3df8efb96b 100644 (file)
@@ -633,7 +633,7 @@ ncp_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
                entry->ino = iunique(dir->i_sb, 2);
                inode = ncp_iget(dir->i_sb, entry);
                if (inode) {
-                       newdent->d_op = &ncp_dentry_operations;
+                       d_set_d_op(newdent, &ncp_dentry_operations);
                        d_instantiate(newdent, inode);
                        if (!hashed)
                                d_rehash(newdent);
@@ -889,7 +889,7 @@ static struct dentry *ncp_lookup(struct inode *dir, struct dentry *dentry, struc
        if (inode) {
                ncp_new_dentry(dentry);
 add_entry:
-               dentry->d_op = &ncp_dentry_operations;
+               d_set_d_op(dentry, &ncp_dentry_operations);
                d_add(dentry, inode);
                error = 0;
        }
index 60047dbeb38d8254f347f103cb49fa6d547074d9..0c75a5f3cafd5d43e95c389473f8e559f5f6c189 100644 (file)
@@ -717,7 +717,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
        sb->s_root = d_alloc_root(root_inode);
         if (!sb->s_root)
                goto out_no_root;
-       sb->s_root->d_op = &ncp_root_dentry_operations;
+       d_set_d_op(sb->s_root, &ncp_root_dentry_operations);
        return 0;
 
 out_no_root:
index eb77471b8823d474ff1def428242978bf076bbfd..37e0a8bb077e7587eefdc7e3cf2ef8cf6afe9cb3 100644 (file)
@@ -438,7 +438,7 @@ void nfs_prime_dcache(struct dentry *parent, struct nfs_entry *entry)
        if (dentry == NULL)
                return;
 
-       dentry->d_op = NFS_PROTO(dir)->dentry_ops;
+       d_set_d_op(dentry, NFS_PROTO(dir)->dentry_ops);
        inode = nfs_fhget(dentry->d_sb, entry->fh, entry->fattr);
        if (IS_ERR(inode))
                goto out;
@@ -1188,7 +1188,7 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru
        if (dentry->d_name.len > NFS_SERVER(dir)->namelen)
                goto out;
 
-       dentry->d_op = NFS_PROTO(dir)->dentry_ops;
+       d_set_d_op(dentry, NFS_PROTO(dir)->dentry_ops);
 
        /*
         * If we're doing an exclusive create, optimize away the lookup
@@ -1333,7 +1333,7 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry
                res = ERR_PTR(-ENAMETOOLONG);
                goto out;
        }
-       dentry->d_op = NFS_PROTO(dir)->dentry_ops;
+       d_set_d_op(dentry, NFS_PROTO(dir)->dentry_ops);
 
        /* Let vfs_create() deal with O_EXCL. Instantiate, but don't hash
         * the dentry. */
index b3e36c3430de827ae3f054825fa9f8d1137607db..c3a5a112683380ee23411498758ef99881845275 100644 (file)
@@ -121,7 +121,7 @@ struct dentry *nfs_get_root(struct super_block *sb, struct nfs_fh *mntfh)
        security_d_instantiate(ret, inode);
 
        if (ret->d_op == NULL)
-               ret->d_op = server->nfs_client->rpc_ops->dentry_ops;
+               d_set_d_op(ret, server->nfs_client->rpc_ops->dentry_ops);
 out:
        nfs_free_fattr(fsinfo.fattr);
        return ret;
@@ -228,7 +228,7 @@ struct dentry *nfs4_get_root(struct super_block *sb, struct nfs_fh *mntfh)
        security_d_instantiate(ret, inode);
 
        if (ret->d_op == NULL)
-               ret->d_op = server->nfs_client->rpc_ops->dentry_ops;
+               d_set_d_op(ret, server->nfs_client->rpc_ops->dentry_ops);
 
 out:
        nfs_free_fattr(fattr);
index 19ad145d2af3171aaab2be2580dc89549ac37eeb..6adafa5760654645d01132203f2db65765c22ce3 100644 (file)
@@ -138,7 +138,7 @@ check_gen:
 
        result = d_obtain_alias(inode);
        if (!IS_ERR(result))
-               result->d_op = &ocfs2_dentry_ops;
+               d_set_d_op(result, &ocfs2_dentry_ops);
        else
                mlog_errno(PTR_ERR(result));
 
@@ -176,7 +176,7 @@ static struct dentry *ocfs2_get_parent(struct dentry *child)
 
        parent = d_obtain_alias(ocfs2_iget(OCFS2_SB(dir->i_sb), blkno, 0, 0));
        if (!IS_ERR(parent))
-               parent->d_op = &ocfs2_dentry_ops;
+               d_set_d_op(parent, &ocfs2_dentry_ops);
 
 bail_unlock:
        ocfs2_inode_unlock(dir, 0);
index ff5744e1e36fcb9200158eb419abc3ebdf33ec5b..d14cad6e2e412b29ea98e6678a653081deb5f308 100644 (file)
@@ -147,7 +147,7 @@ static struct dentry *ocfs2_lookup(struct inode *dir, struct dentry *dentry,
        spin_unlock(&oi->ip_lock);
 
 bail_add:
-       dentry->d_op = &ocfs2_dentry_ops;
+       d_set_d_op(dentry, &ocfs2_dentry_ops);
        ret = d_splice_alias(inode, dentry);
 
        if (inode) {
@@ -415,7 +415,7 @@ static int ocfs2_mknod(struct inode *dir,
                mlog_errno(status);
                goto leave;
        }
-       dentry->d_op = &ocfs2_dentry_ops;
+       d_set_d_op(dentry, &ocfs2_dentry_ops);
 
        status = ocfs2_add_entry(handle, dentry, inode,
                                 OCFS2_I(inode)->ip_blkno, parent_fe_bh,
@@ -743,7 +743,7 @@ static int ocfs2_link(struct dentry *old_dentry,
        }
 
        ihold(inode);
-       dentry->d_op = &ocfs2_dentry_ops;
+       d_set_d_op(dentry, &ocfs2_dentry_ops);
        d_instantiate(dentry, inode);
 
 out_commit:
@@ -1794,7 +1794,7 @@ static int ocfs2_symlink(struct inode *dir,
                mlog_errno(status);
                goto bail;
        }
-       dentry->d_op = &ocfs2_dentry_ops;
+       d_set_d_op(dentry, &ocfs2_dentry_ops);
 
        status = ocfs2_add_entry(handle, dentry, inode,
                                 le64_to_cpu(fe->i_blkno), parent_fe_bh,
@@ -2459,7 +2459,7 @@ int ocfs2_mv_orphaned_inode_to_new(struct inode *dir,
                goto out_commit;
        }
 
-       dentry->d_op = &ocfs2_dentry_ops;
+       d_set_d_op(dentry, &ocfs2_dentry_ops);
        d_instantiate(dentry, inode);
        status = 0;
 out_commit:
index ae3592dcc88c32435e74cf9be5a9f7fedaa4fa10..01a786567810cb0ffa38b3dd1a1a0ee23d1870b4 100644 (file)
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -1004,7 +1004,7 @@ struct file *create_write_pipe(int flags)
                goto err_inode;
        path.mnt = mntget(pipe_mnt);
 
-       path.dentry->d_op = &pipefs_dentry_operations;
+       d_set_d_op(path.dentry, &pipefs_dentry_operations);
        d_instantiate(path.dentry, inode);
 
        err = -ENFILE;
index d932fdb6a2453d7376d891cd237dcb08d5195873..85f0a80912aa4aaba460c5d39ccfd3831af26531 100644 (file)
@@ -1969,7 +1969,7 @@ static struct dentry *proc_fd_instantiate(struct inode *dir,
        inode->i_op = &proc_pid_link_inode_operations;
        inode->i_size = 64;
        ei->op.proc_get_link = proc_fd_link;
-       dentry->d_op = &tid_fd_dentry_operations;
+       d_set_d_op(dentry, &tid_fd_dentry_operations);
        d_add(dentry, inode);
        /* Close the race of the process dying before we return the dentry */
        if (tid_fd_revalidate(dentry, NULL))
@@ -2137,7 +2137,7 @@ static struct dentry *proc_fdinfo_instantiate(struct inode *dir,
        ei->fd = fd;
        inode->i_mode = S_IFREG | S_IRUSR;
        inode->i_fop = &proc_fdinfo_file_operations;
-       dentry->d_op = &tid_fd_dentry_operations;
+       d_set_d_op(dentry, &tid_fd_dentry_operations);
        d_add(dentry, inode);
        /* Close the race of the process dying before we return the dentry */
        if (tid_fd_revalidate(dentry, NULL))
@@ -2196,7 +2196,7 @@ static struct dentry *proc_pident_instantiate(struct inode *dir,
        if (p->fop)
                inode->i_fop = p->fop;
        ei->op = p->op;
-       dentry->d_op = &pid_dentry_operations;
+       d_set_d_op(dentry, &pid_dentry_operations);
        d_add(dentry, inode);
        /* Close the race of the process dying before we return the dentry */
        if (pid_revalidate(dentry, NULL))
@@ -2615,7 +2615,7 @@ static struct dentry *proc_base_instantiate(struct inode *dir,
        if (p->fop)
                inode->i_fop = p->fop;
        ei->op = p->op;
-       dentry->d_op = &proc_base_dentry_operations;
+       d_set_d_op(dentry, &proc_base_dentry_operations);
        d_add(dentry, inode);
        error = NULL;
 out:
@@ -2926,7 +2926,7 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
        inode->i_nlink = 2 + pid_entry_count_dirs(tgid_base_stuff,
                ARRAY_SIZE(tgid_base_stuff));
 
-       dentry->d_op = &pid_dentry_operations;
+       d_set_d_op(dentry, &pid_dentry_operations);
 
        d_add(dentry, inode);
        /* Close the race of the process dying before we return the dentry */
@@ -3169,7 +3169,7 @@ static struct dentry *proc_task_instantiate(struct inode *dir,
        inode->i_nlink = 2 + pid_entry_count_dirs(tid_base_stuff,
                ARRAY_SIZE(tid_base_stuff));
 
-       dentry->d_op = &pid_dentry_operations;
+       d_set_d_op(dentry, &pid_dentry_operations);
 
        d_add(dentry, inode);
        /* Close the race of the process dying before we return the dentry */
index 1d607be36d95b9c563d8c7d78c5033035a9d75a8..f766be29d2c7dee6578f1f212d05eaab71dd9f2b 100644 (file)
@@ -439,7 +439,7 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir,
 out_unlock:
 
        if (inode) {
-               dentry->d_op = &proc_dentry_operations;
+               d_set_d_op(dentry, &proc_dentry_operations);
                d_add(dentry, inode);
                return NULL;
        }
index 998e3a715bcc2132b2c635c534ddd935641bde9a..35efd85a4d320490af01f904838adc790920c2f7 100644 (file)
@@ -120,7 +120,7 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
                goto out;
 
        err = NULL;
-       dentry->d_op = &proc_sys_dentry_operations;
+       d_set_d_op(dentry, &proc_sys_dentry_operations);
        d_add(dentry, inode);
 
 out:
@@ -201,7 +201,7 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
                                dput(child);
                                return -ENOMEM;
                        } else {
-                               child->d_op = &proc_sys_dentry_operations;
+                               d_set_d_op(child, &proc_sys_dentry_operations);
                                d_add(child, inode);
                        }
                } else {
index 5d04a7828e7a4ee05d27446cbc8ee7fdfb433ad9..e0f0d7ea10a16f1061a4d5b0b835862e9ed0cbf4 100644 (file)
@@ -990,7 +990,7 @@ int reiserfs_lookup_privroot(struct super_block *s)
                                strlen(PRIVROOT_NAME));
        if (!IS_ERR(dentry)) {
                REISERFS_SB(s)->priv_root = dentry;
-               dentry->d_op = &xattr_lookup_poison_ops;
+               d_set_d_op(dentry, &xattr_lookup_poison_ops);
                if (dentry->d_inode)
                        dentry->d_inode->i_flags |= S_PRIVATE;
        } else
index 27e1102e303e8d403d7e81514e2283efd332ffba..3e076caa8dafd54d74f79fbaf1888c7e31e5de43 100644 (file)
@@ -701,7 +701,7 @@ static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry,
        /* instantiate and hash dentry */
        ret = d_find_alias(inode);
        if (!ret) {
-               dentry->d_op = &sysfs_dentry_ops;
+               d_set_d_op(dentry, &sysfs_dentry_ops);
                dentry->d_fsdata = sysfs_get(sd);
                d_add(dentry, inode);
        } else {
index 7507aeb4c90e586ff615eae676bd6730badaf04f..b5e68da2db32189597edc9e6f70dd6bcf57dbb40 100644 (file)
@@ -48,7 +48,7 @@ static struct dentry *sysv_lookup(struct inode * dir, struct dentry * dentry, st
        struct inode * inode = NULL;
        ino_t ino;
 
-       dentry->d_op = dir->i_sb->s_root->d_op;
+       d_set_d_op(dentry, dir->i_sb->s_root->d_op);
        if (dentry->d_name.len > SYSV_NAMELEN)
                return ERR_PTR(-ENAMETOOLONG);
        ino = sysv_inode_by_name(dentry);
index 3d9c62be0c10ebc051d64951836ba366a3586018..76712aefc4ab12e137207091e412f85f74b50fed 100644 (file)
@@ -346,7 +346,7 @@ static int complete_read_super(struct super_block *sb, int silent, int size)
        if (sbi->s_forced_ro)
                sb->s_flags |= MS_RDONLY;
        if (sbi->s_truncate)
-               sb->s_root->d_op = &sysv_dentry_operations;
+               d_set_d_op(sb->s_root, &sysv_dentry_operations);
        return 1;
 }
 
index e4414693065eae80e247e21636a3c6defa4c4b8a..f4b40a751f096d4264e5fcc8ff2c66c8485c1807 100644 (file)
@@ -183,6 +183,11 @@ struct dentry_operations {
 #define DCACHE_GENOCIDE                0x0200
 #define DCACHE_MOUNTED         0x0400  /* is a mountpoint */
 
+#define DCACHE_OP_HASH         0x1000
+#define DCACHE_OP_COMPARE      0x2000
+#define DCACHE_OP_REVALIDATE   0x4000
+#define DCACHE_OP_DELETE       0x8000
+
 
 extern spinlock_t dcache_inode_lock;
 extern seqlock_t rename_lock;
@@ -201,6 +206,7 @@ extern struct dentry * d_materialise_unique(struct dentry *, struct inode *);
 extern void __d_drop(struct dentry *dentry);
 extern void d_drop(struct dentry *dentry);
 extern void d_delete(struct dentry *);
+extern void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op);
 
 /* allocate/de-allocate */
 extern struct dentry * d_alloc(struct dentry *, const struct qstr *);
index 9f41470c3949d62c2ccd37398df77fa974ec57d4..51cddc11cd85c847ec0fee3cd9a00fae3b66b4b0 100644 (file)
@@ -2222,7 +2222,7 @@ static struct dentry *cgroup_lookup(struct inode *dir,
 
        if (dentry->d_name.len > NAME_MAX)
                return ERR_PTR(-ENAMETOOLONG);
-       dentry->d_op = &cgroup_dentry_operations;
+       d_set_d_op(dentry, &cgroup_dentry_operations);
        d_add(dentry, NULL);
        return NULL;
 }
index 817dc92e9ef809b0dc9f32f8d9f368e27946d036..991e266bc7aeb3ecba72edc69ec539e0640b6629 100644 (file)
@@ -368,7 +368,7 @@ static int sock_alloc_file(struct socket *sock, struct file **f, int flags)
        }
        path.mnt = mntget(sock_mnt);
 
-       path.dentry->d_op = &sockfs_dentry_operations;
+       d_set_d_op(path.dentry, &sockfs_dentry_operations);
        d_instantiate(path.dentry, SOCK_INODE(sock));
        SOCK_INODE(sock)->i_fop = &socket_file_ops;
 
index 2899fe27f8805229c9878d99a4c7afc6f9526d7b..09f01f41e55abf79519ded2b2d9c996f51fa5bf2 100644 (file)
@@ -591,7 +591,7 @@ static struct dentry *__rpc_lookup_create(struct dentry *parent,
                }
        }
        if (!dentry->d_inode)
-               dentry->d_op = &rpc_dentry_operations;
+               d_set_d_op(dentry, &rpc_dentry_operations);
 out_err:
        return dentry;
 }