aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2013-01-18 14:11:40 -0800
committerBrian Behlendorf <[email protected]>2013-01-18 15:04:23 -0800
commitee93035378ff1f0769bb4216dc35057a2f14f9b9 (patch)
treef5e044f0670eefb9af4d23c91c5707926d5c0128
parentbabf3f9b6d9294b0a88457941d60af5d9d7b744d (diff)
Use sb->s_d_op default dentry operations
As of Linux 2.6.37 the right way to register custom dentry operations is to use the super block's ->s_d_op field. For older kernels they should be registered as part of the lookup operation. Signed-off-by: Brian Behlendorf <[email protected]> Closes #1223
-rw-r--r--config/kernel-dentry-operations.m419
-rw-r--r--config/kernel.m41
-rw-r--r--module/zfs/zfs_vfsops.c3
-rw-r--r--module/zfs/zpl_inode.c17
4 files changed, 29 insertions, 11 deletions
diff --git a/config/kernel-dentry-operations.m4 b/config/kernel-dentry-operations.m4
index 5685b7d6f..dfbea7dfd 100644
--- a/config/kernel-dentry-operations.m4
+++ b/config/kernel-dentry-operations.m4
@@ -62,3 +62,22 @@ AC_DEFUN([ZFS_AC_KERNEL_D_SET_D_OP],
AC_MSG_RESULT(no)
])
])
+
+dnl #
+dnl # 2.6.38 API chage
+dnl # Added sb->s_d_op default dentry_operations member
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_S_D_OP],
+ [AC_MSG_CHECKING([whether super_block has s_d_op])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/fs.h>
+ ],[
+ struct super_block sb __attribute__ ((unused));
+ sb.s_d_op = NULL;
+ ], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_S_D_OP, 1, [struct super_block has s_d_op])
+ ], [
+ AC_MSG_RESULT(no)
+ ])
+])
diff --git a/config/kernel.m4 b/config/kernel.m4
index 58a808011..fd6ab1f9a 100644
--- a/config/kernel.m4
+++ b/config/kernel.m4
@@ -71,6 +71,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
ZFS_AC_KERNEL_CALLBACK_SECURITY_INODE_INIT_SECURITY
ZFS_AC_KERNEL_MOUNT_NODEV
ZFS_AC_KERNEL_SHRINK
+ ZFS_AC_KERNEL_S_D_OP
ZFS_AC_KERNEL_BDI
ZFS_AC_KERNEL_BDI_SETUP_AND_REGISTER
ZFS_AC_KERNEL_SET_NLINK
diff --git a/module/zfs/zfs_vfsops.c b/module/zfs/zfs_vfsops.c
index f44524238..620e39bc2 100644
--- a/module/zfs/zfs_vfsops.c
+++ b/module/zfs/zfs_vfsops.c
@@ -1188,6 +1188,9 @@ zfs_domount(struct super_block *sb, void *data, int silent)
sb->s_op = &zpl_super_operations;
sb->s_xattr = zpl_xattr_handlers;
sb->s_export_op = &zpl_export_operations;
+#ifdef HAVE_S_D_OP
+ sb->s_d_op = &zpl_dentry_operations;
+#endif /* HAVE_S_D_OP */
/* Set features for file system. */
zfs_set_fuid_feature(zsb);
diff --git a/module/zfs/zpl_inode.c b/module/zfs/zpl_inode.c
index 15ee0f610..0f6f3a41e 100644
--- a/module/zfs/zpl_inode.c
+++ b/module/zfs/zpl_inode.c
@@ -48,6 +48,9 @@ zpl_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
spin_lock(&dentry->d_lock);
dentry->d_time = jiffies;
+#ifndef HAVE_S_D_OP
+ d_set_d_op(dentry, &zpl_dentry_operations);
+#endif /* HAVE_S_D_OP */
spin_unlock(&dentry->d_lock);
if (error) {
@@ -99,7 +102,6 @@ zpl_create(struct inode *dir, struct dentry *dentry, zpl_umode_t mode,
error = zpl_xattr_security_init(ip, dir, &dentry->d_name);
VERIFY3S(error, ==, 0);
d_instantiate(dentry, ip);
- d_set_d_op(dentry, &zpl_dentry_operations);
}
kmem_free(vap, sizeof(vattr_t));
@@ -131,10 +133,8 @@ zpl_mknod(struct inode *dir, struct dentry *dentry, zpl_umode_t mode,
vap->va_rdev = rdev;
error = -zfs_create(dir, dname(dentry), vap, 0, mode, &ip, cr, 0, NULL);
- if (error == 0) {
+ if (error == 0)
d_instantiate(dentry, ip);
- d_set_d_op(dentry, &zpl_dentry_operations);
- }
kmem_free(vap, sizeof(vattr_t));
crfree(cr);
@@ -170,10 +170,8 @@ zpl_mkdir(struct inode *dir, struct dentry *dentry, zpl_umode_t mode)
zpl_vap_init(vap, dir, mode | S_IFDIR, cr);
error = -zfs_mkdir(dir, dname(dentry), vap, &ip, cr, 0, NULL);
- if (error == 0) {
+ if (error == 0)
d_instantiate(dentry, ip);
- d_set_d_op(dentry, &zpl_dentry_operations);
- }
kmem_free(vap, sizeof(vattr_t));
crfree(cr);
@@ -278,10 +276,8 @@ zpl_symlink(struct inode *dir, struct dentry *dentry, const char *name)
zpl_vap_init(vap, dir, S_IFLNK | S_IRWXUGO, cr);
error = -zfs_symlink(dir, dname(dentry), vap, (char *)name, &ip, cr, 0);
- if (error == 0) {
+ if (error == 0)
d_instantiate(dentry, ip);
- d_set_d_op(dentry, &zpl_dentry_operations);
- }
kmem_free(vap, sizeof(vattr_t));
crfree(cr);
@@ -352,7 +348,6 @@ zpl_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
}
d_instantiate(dentry, ip);
- d_set_d_op(dentry, &zpl_dentry_operations);
out:
crfree(cr);
ASSERT3S(error, <=, 0);