xfs
[Top] [All Lists]

Re: xfs: validate inode numbers in file handles correctly

To: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Subject: Re: xfs: validate inode numbers in file handles correctly
From: hank peng <pengxihan@xxxxxxxxx>
Date: Sat, 3 Dec 2011 16:27:39 +0800
Cc: Guoquan Yang <ygq51@xxxxxxxxxxx>, linux-xfs@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=SIUxV9tuA6VigTphIxZNM7ZQBn+AqbDycZ9HNasPoOo=; b=CGeiSdD/bWcAaI+ozsigUMYtDDZKvnn8s6k+BOf1h5HzqjXkX4hR+TOGkJkFbue9Cs aQyi1K0BUtKnd7UDaDgmQnQIQF/A6rFlIbuzIuNzmeXYyvVRgPMiTANaIVc4SF2h+e2Z b267qmFbLmOdEzC9nzUo1AmzwDk8KYuhdYQZE=
In-reply-to: <20111128111947.GA26454@xxxxxxxxxxxxx>
References: <1276846374-23916-1-git-send-email-david@xxxxxxxxxxxxx> <loom.20111123T134243-580@xxxxxxxxxxxxxx> <20111123143045.GA20892@xxxxxxxxxxxxx> <20111128111947.GA26454@xxxxxxxxxxxxx>
2011/11/28 Christoph Hellwig <hch@xxxxxxxxxxxxx>:
> 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.
>
yes, we use inode64 on 32-bit kernel.


> --- 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;
>        }

I haven't tested this patch, but I have a question now: although I use
inode64 option when mounting, my filesystem did not exceed 2T limit,
so, 32-bit inode would be no problem, right?

-- 
The simplest is not all best but the best is surely the simplest!
<Prev in Thread] Current Thread [Next in Thread>