xfs
[Top] [All Lists]

Re: xfs: validate inode numbers in file handles correctly

To: Guoquan Yang <ygq51@xxxxxxxxxxx>
Subject: Re: xfs: validate inode numbers in file handles correctly
From: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Date: Mon, 28 Nov 2011 06:19:47 -0500
Cc: linux-xfs@xxxxxxxxxxx, hank peng <pengxihan@xxxxxxxxx>
In-reply-to: <20111123143045.GA20892@xxxxxxxxxxxxx>
References: <1276846374-23916-1-git-send-email-david@xxxxxxxxxxxxx> <loom.20111123T134243-580@xxxxxxxxxxxxxx> <20111123143045.GA20892@xxxxxxxxxxxxx>
User-agent: Mutt/1.5.21 (2010-09-15)
Guoquan and hank,

are you using 32-bit or 64-bit kernels?  I just noticed we have a
problem with exporting 64-bit inodes on 32-bit kernel because the
VFS i_ino field is just 32-bits long.  The patch below would fix
that issue.

--- xfs.orig/fs/xfs/linux-2.6/xfs_export.c      2011-11-28 12:11:08.923630697 
+0100
+++ xfs/fs/xfs/linux-2.6/xfs_export.c   2011-11-28 12:13:21.766244360 +0100
@@ -61,6 +61,8 @@ xfs_fs_encode_fh(
        struct fid              *fid = (struct fid *)fh;
        struct xfs_fid64        *fid64 = (struct xfs_fid64 *)fh;
        struct inode            *inode = dentry->d_inode;
+       struct inode            *parent;
+       struct xfs_inode        *ip = XFS_I(inode);
        int                     fileid_type;
        int                     len;
 
@@ -98,22 +100,24 @@ xfs_fs_encode_fh(
        switch (fileid_type) {
        case FILEID_INO32_GEN_PARENT:
                spin_lock(&dentry->d_lock);
-               fid->i32.parent_ino = dentry->d_parent->d_inode->i_ino;
-               fid->i32.parent_gen = dentry->d_parent->d_inode->i_generation;
+               parent = dentry->d_parent->d_inode;
+               fid->i32.parent_ino = XFS_I(parent)->i_ino;
+               fid->i32.parent_gen = parent->i_generation;
                spin_unlock(&dentry->d_lock);
                /*FALLTHRU*/
        case FILEID_INO32_GEN:
-               fid->i32.ino = inode->i_ino;
+               fid->i32.ino = ip->i_ino;
                fid->i32.gen = inode->i_generation;
                break;
        case FILEID_INO32_GEN_PARENT | XFS_FILEID_TYPE_64FLAG:
                spin_lock(&dentry->d_lock);
-               fid64->parent_ino = dentry->d_parent->d_inode->i_ino;
-               fid64->parent_gen = dentry->d_parent->d_inode->i_generation;
+               parent = dentry->d_parent->d_inode;
+               fid64->parent_ino = XFS_I(parent)->i_ino;
+               fid64->parent_gen = parent->i_generation;
                spin_unlock(&dentry->d_lock);
                /*FALLTHRU*/
        case FILEID_INO32_GEN | XFS_FILEID_TYPE_64FLAG:
-               fid64->ino = inode->i_ino;
+               fid64->ino = ip->i_ino;
                fid64->gen = inode->i_generation;
                break;
        }

<Prev in Thread] Current Thread [Next in Thread>