From mboxrd@z Thu Jan 1 00:00:00 1970 From: "J. R. Okajima" Subject: [PATCH v2 2/2] tmpfs: refine a file handle for NFS-exporting Date: Fri, 30 May 2014 00:46:17 +0900 Message-ID: <1401378377-30757-2-git-send-email-hooanon05g@gmail.com> References: <20140522151431.GA25517@lst.de> <1401378377-30757-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 mail03-md.ns.itscom.net ([175.177.155.113]:55096 "EHLO mail03-md.ns.itscom.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932605AbaE2PqV (ORCPT ); Thu, 29 May 2014 11:46:21 -0400 In-Reply-To: <1401378377-30757-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 | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 440db70..96bdd2b 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1373,7 +1373,9 @@ 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); - if (unlikely(ino < 0)) { + if (ino > 0) + __insert_inode_hash(inode, inode->i_ino); + else { iput(inode); /* shmem_free_inode() will be called */ inode = NULL; } @@ -2281,8 +2283,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; } @@ -2293,14 +2294,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); @@ -2312,30 +2310,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