From mboxrd@z Thu Jan 1 00:00:00 1970 From: "J. R. Okajima" Subject: [RFC PATCH v4 2/2] tmpfs: refine a file handle for NFS-exporting Date: Thu, 5 Jun 2014 21:27:54 +0900 Message-ID: <1401971274-8075-3-git-send-email-hooanon05g@gmail.com> References: <20140603090400.GB29219@quack.suse.cz> <1401971274-8075-1-git-send-email-hooanon05g@gmail.com> To: linux-fsdevel@vger.kernel.org, dchinner@redhat.com, viro@zeniv.linux.org.uk, Eric Dumazet , Hugh Dickins , Christoph Hellwig , Andreas Dilger , Jan Kara Return-path: Received: from mail05-md.ns.itscom.net ([175.177.155.115]:34826 "EHLO mail05-md.ns.itscom.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751376AbaFEM16 (ORCPT ); Thu, 5 Jun 2014 08:27:58 -0400 In-Reply-To: <1401971274-8075-1-git-send-email-hooanon05g@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: The inode number in tmpfs is always 32bit. It is unnecessary to put 64bit into NFS handle, and this commit puts only 32bit. While it is also possible to replace ilookup5() by idr_find(), I don't want to confirm and maintain i_state. So let's keep ilookup5(). Cc: Eric Dumazet Cc: Hugh Dickins Cc: Christoph Hellwig Cc: Andreas Dilger Cc: Jan Kara Signed-off-by: J. R. Okajima --- mm/shmem.c | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 3ac613d..507444a 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1379,6 +1379,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode if (ino > 0) { inode->i_ino = ino; mutex_unlock(&sbinfo->idr_lock); + __insert_inode_hash(inode, inode->i_ino); } else { mutex_unlock(&sbinfo->idr_lock); iput(inode); /* shmem_free_inode() will be called */ @@ -2288,8 +2289,7 @@ static struct dentry *shmem_get_parent(struct dentry *child) static int shmem_match(struct inode *ino, void *vfh) { __u32 *fh = vfh; - __u64 inum = fh[2]; - inum = (inum << 32) | fh[1]; + __u64 inum = fh[1]; return ino->i_ino == inum && fh[0] == ino->i_generation; } @@ -2300,14 +2300,11 @@ static struct dentry *shmem_fh_to_dentry(struct super_block *sb, struct dentry *dentry = NULL; u64 inum; - if (fh_len < 3) + if (fh_len < 2) return NULL; - inum = fid->raw[2]; - inum = (inum << 32) | fid->raw[1]; - - inode = ilookup5(sb, (unsigned long)(inum + fid->raw[0]), - shmem_match, fid->raw); + inum = fid->raw[1]; + inode = ilookup5(sb, inum, shmem_match, fid->raw); if (inode) { dentry = d_find_alias(inode); iput(inode); @@ -2319,30 +2316,15 @@ static struct dentry *shmem_fh_to_dentry(struct super_block *sb, static int shmem_encode_fh(struct inode *inode, __u32 *fh, int *len, struct inode *parent) { - if (*len < 3) { - *len = 3; + if (*len < 2) { + *len = 2; return FILEID_INVALID; } - if (inode_unhashed(inode)) { - /* Unfortunately insert_inode_hash is not idempotent, - * so as we hash inodes here rather than at creation - * time, we need a lock to ensure we only try - * to do it once - */ - static DEFINE_SPINLOCK(lock); - spin_lock(&lock); - if (inode_unhashed(inode)) - __insert_inode_hash(inode, - inode->i_ino + inode->i_generation); - spin_unlock(&lock); - } - fh[0] = inode->i_generation; fh[1] = inode->i_ino; - fh[2] = ((__u64)inode->i_ino) >> 32; - *len = 3; + *len = 2; return 1; } -- 1.7.10.4