Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: 'struct file' has no member named 'f_dentry' #2959

Closed
FransUrbo opened this issue Dec 12, 2014 · 9 comments
Closed

error: 'struct file' has no member named 'f_dentry' #2959

FransUrbo opened this issue Dec 12, 2014 · 9 comments
Labels
Type: Building Indicates an issue related to building binaries
Milestone

Comments

@FransUrbo
Copy link
Contributor

This on latest (head) linux source (git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git).

/usr/src/zfs/module/zfs/../../module/zfs/zpl_file.c: In function 'zpl_ioctl_getflags':
/usr/src/zfs/module/zfs/../../module/zfs/zpl_file.c:625:25: error: 'struct file' has no member named 'f_dentry'
/usr/src/zfs/module/zfs/../../module/zfs/zpl_file.c: In function 'zpl_ioctl_setflags':
/usr/src/zfs/module/zfs/../../module/zfs/zpl_file.c:661:25: error: 'struct file' has no member named 'f_dentry'

Temporary solution as in torvalds/linux@78d28e6:

diff --git a/module/zfs/zpl_file.c b/module/zfs/zpl_file.c
index cabe9bf..a55f8a7 100644
--- a/module/zfs/zpl_file.c
+++ b/module/zfs/zpl_file.c
@@ -622,7 +622,7 @@ zpl_fallocate(struct file *filp, int mode, loff_t offset, loff_t len)
 static int
 zpl_ioctl_getflags(struct file *filp, void __user *arg)
 {
-       struct inode *ip = filp->f_dentry->d_inode;
+       struct inode *ip = filp->f_path.dentry;
        unsigned int ioctl_flags = 0;
        uint64_t zfs_flags = ITOZ(ip)->z_pflags;
        int error;
@@ -658,7 +658,7 @@ zpl_ioctl_getflags(struct file *filp, void __user *arg)
 static int
 zpl_ioctl_setflags(struct file *filp, void __user *arg)
 {
-       struct inode    *ip = filp->f_dentry->d_inode;
+       struct inode    *ip = filp->f_path.dentry;
        uint64_t        zfs_flags = ITOZ(ip)->z_pflags;
        unsigned int    ioctl_flags;
        cred_t          *cr = CRED();

Notes from @ryao on IRC:

[12:27:27] <ryao> FransUrbo: I think that is what we will want to do unless we want another autotools check. f_inode is not in 2.6.32.
[12:28:28] <ryao> FransUrbo: Another option is to bring the macro into include/linux/file_compat.h in the SPL.
@ryao
Copy link
Contributor

ryao commented Dec 12, 2014

module/zfs/zvol.c also needs to be patched for kernels built with CONFIG_COMPAT=y.

@FransUrbo
Copy link
Contributor Author

Doesn't seem to be like that for me:

# pwd
/usr/src/zfs
# grep ^LINUX config.log
LINUX='/usr/src/Kernels/linux-linus'
LINUX_OBJ='/usr/src/Kernels/linux-linus'
LINUX_SYMBOLS='Module.symvers'
LINUX_VERSION='3.18.0+git92a578b'
# grep ^CONFIG_COMPAT /usr/src/Kernels/linux-linus/.config
CONFIG_COMPAT_OLD_SIGACTION=y
CONFIG_COMPAT_VDSO=y
CONFIG_COMPAT_BINFMT_ELF=y
CONFIG_COMPAT=y
CONFIG_COMPAT_FOR_U64_ALIGNMENT=y
CONFIG_COMPAT_NETLINK_MESSAGES=y
# grep ^CONFIG_COMPAT /usr/src/Kernels/linux-linus/include/config/auto.conf
CONFIG_COMPAT_NETLINK_MESSAGES=y
CONFIG_COMPAT=y
CONFIG_COMPAT_BINFMT_ELF=y
CONFIG_COMPAT_OLD_SIGACTION=y
CONFIG_COMPAT_VDSO=y
CONFIG_COMPAT_FOR_U64_ALIGNMENT=y
# grep CONFIG_COMPAT /usr/src/Kernels/linux-linus/include/generated/autoconf.h
#define CONFIG_COMPAT_NETLINK_MESSAGES 1
#define CONFIG_COMPAT 1
#define CONFIG_COMPAT_BINFMT_ELF 1
#define CONFIG_COMPAT_OLD_SIGACTION 1
#define CONFIG_COMPAT_VDSO 1
#define CONFIG_COMPAT_FOR_U64_ALIGNMENT 1

@FransUrbo
Copy link
Contributor Author

The reason why it isn't triggered in zvol.c is that the code snippet

#ifdef CONFIG_COMPAT
static long
zvol_compat_ioctl_by_inode(struct file *file,
    unsigned int cmd, unsigned long arg)
{
        if (file == NULL)
                return (SET_ERROR(-EINVAL));

        return (zvol_compat_ioctl(file->f_dentry->d_inode->i_bdev,
            file->f_mode, cmd, arg));
}
#else
#define zvol_compat_ioctl_by_inode      NULL
#endif

(which should have triggered the problem), is inside the else of a previous #ifdef HAVE_BDEV_BLOCK_DEVICE_OPERATIONS. This seems wrong, so:

diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c
index d3262f0..92c73aa 100644
--- a/module/zfs/zvol.c
+++ b/module/zfs/zvol.c
@@ -1214,6 +1214,18 @@ zvol_ioctl_by_inode(struct inode *inode, struct file *file,
        return (zvol_ioctl(inode->i_bdev, file->f_mode, cmd, arg));
 }

+static struct block_device_operations zvol_ops = {
+       .open                   = zvol_open_by_inode,
+       .release                = zvol_release_by_inode,
+       .ioctl                  = zvol_ioctl_by_inode,
+       .compat_ioctl           = zvol_compat_ioctl_by_inode,
+       .media_changed          = zvol_media_changed,
+       .revalidate_disk        = zvol_revalidate_disk,
+       .getgeo                 = zvol_getgeo,
+       .owner                  = THIS_MODULE,
+};
+#endif /* HAVE_BDEV_BLOCK_DEVICE_OPERATIONS */
+
 #ifdef CONFIG_COMPAT
 static long
 zvol_compat_ioctl_by_inode(struct file *file,
@@ -1222,25 +1234,13 @@ zvol_compat_ioctl_by_inode(struct file *file,
        if (file == NULL)
                return (SET_ERROR(-EINVAL));

-       return (zvol_compat_ioctl(file->f_dentry->d_inode->i_bdev,
+       return (zvol_compat_ioctl(file->f_path.dentry->i_bdev,
            file->f_mode, cmd, arg));
 }
 #else
 #define        zvol_compat_ioctl_by_inode      NULL
 #endif

-static struct block_device_operations zvol_ops = {
-       .open                   = zvol_open_by_inode,
-       .release                = zvol_release_by_inode,
-       .ioctl                  = zvol_ioctl_by_inode,
-       .compat_ioctl           = zvol_compat_ioctl_by_inode,
-       .media_changed          = zvol_media_changed,
-       .revalidate_disk        = zvol_revalidate_disk,
-       .getgeo                 = zvol_getgeo,
-       .owner                  = THIS_MODULE,
-};
-#endif /* HAVE_BDEV_BLOCK_DEVICE_OPERATIONS */
-
 /*
  * Allocate memory for a new zvol_state_t and setup the required
  * request queue and generic disk structures for the block device.

However, this instead leads to:

/usr/src/zfs/module/zfs/../../module/zfs/zvol.c: In function 'zvol_compat_ioctl_by_inode':
/usr/src/zfs/module/zfs/../../module/zfs/zvol.c:1237:47: error: 'struct dentry' has no member named 'i_bdev'
/usr/src/zfs/module/zfs/../../module/zfs/zvol.c: At top level:
/usr/src/zfs/module/zfs/../../module/zfs/zvol.c:1231:1: warning: 'zvol_compat_ioctl_by_inode' defined but not used [-Wunused-function]

Comments by @ryao on irc:

[13:05:05] <ryao> I think we should just leave it be given that it is protected by #ifdev HAVE_BDEV_BLOCK_DEVICE_OPERATIONS
[13:05:05] <ryao> FransUrbo: Maybe with a comment stating such.
[13:07:07] <ryao> Another option is to just insert the macro into the SPL.
[13:07:07] <ryao> #ifndef f_dentry #define f_dentry ... #endif
[13:08:08] <ryao> That seems more appealing now that we know that the zvol code where this is used won't need access to the macro unless it is an older system where it already has access.

@behlendorf
Copy link
Contributor

It appears that torvalds/linux@496ad9a introduced the file_inode() helper for this very case. We're going to want to update the code the use the helper. When it's available we'll use the kernels version of it, when it's not we should fallback to our legacy version.

@behlendorf behlendorf added Type: Building Indicates an issue related to building binaries Difficulty - Medium labels Dec 19, 2014
@behlendorf behlendorf added this to the 0.6.4 milestone Dec 19, 2014
@behlendorf
Copy link
Contributor

It would be great if someone proposed a patch for this while uses file_inode().

@behlendorf
Copy link
Contributor

Closing, fixed by 534759f

@danielkza
Copy link

Kernel 3.19 is now out and up in Fedora and this has hit me. I have to stay in 3.18 in the mean time. Would it be possible introduce a manual patch in the Fedora repository to get it to work, or do I have to wait until 0.6.4 is out?

@danielkza
Copy link

Working perfectly now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Building Indicates an issue related to building binaries
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants
@behlendorf @FransUrbo @danielkza @ryao and others