]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] iget_locked [6/6]
authorJan Harkes <jaharkes@cs.cmu.edu>
Mon, 20 May 2002 02:25:21 +0000 (19:25 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Mon, 20 May 2002 02:25:21 +0000 (19:25 -0700)
As of the last patch the inode_hashtable doesn't really need to be
indexed by i_ino anymore, the only reason we still have to keep the
hashvalue and i_ino identical is because of insert_inode_hash.

If at some point a FS specific getattr method is implemented it will be
possible to completely remove any use of i_ino by the VFS.

fs/coda/cnode.c
fs/inode.c
fs/nfs/inode.c
include/linux/fs.h
kernel/ksyms.c

index 090a16fb6abf31b1f232473e2ce0bec70d76ce70..60ee649aacc5bfbbc3b479515a16f478fa794ed2 100644 (file)
@@ -74,16 +74,17 @@ struct inode * coda_iget(struct super_block * sb, ViceFid * fid,
        struct inode *inode;
        struct coda_inode_info *cii;
        struct coda_sb_info *sbi = coda_sbp(sb);
-       ino_t ino = coda_f2i(fid);
+       unsigned long hash = coda_f2i(fid);
 
-       inode = iget5_locked(sb, ino, coda_test_inode, coda_set_inode, fid);
+       inode = iget5_locked(sb, hash, coda_test_inode, coda_set_inode, fid);
 
        if (!inode)
                return ERR_PTR(-ENOMEM);
 
        if (inode->i_state & I_NEW) {
                cii = ITOC(inode);
-               inode->i_ino = ino;
+               /* we still need to set i_ino for things like stat(2) */
+               inode->i_ino = hash;
                list_add(&cii->c_cilist, &sbi->sbi_cihead);
                unlock_new_inode(inode);
        }
@@ -124,6 +125,7 @@ void coda_replace_fid(struct inode *inode, struct ViceFid *oldfid,
                      struct ViceFid *newfid)
 {
        struct coda_inode_info *cii;
+       unsigned long hash = coda_f2i(newfid);
        
        cii = ITOC(inode);
 
@@ -134,23 +136,22 @@ void coda_replace_fid(struct inode *inode, struct ViceFid *oldfid,
        /* XXX we probably need to hold some lock here! */
        remove_inode_hash(inode);
        cii->c_fid = *newfid;
-       inode->i_ino = coda_f2i(newfid);
-       insert_inode_hash(inode);
+       inode->i_ino = hash;
+       __insert_inode_hash(inode, hash);
 }
 
 /* convert a fid to an inode. */
 struct inode *coda_fid_to_inode(ViceFid *fid, struct super_block *sb) 
 {
-       ino_t nr;
        struct inode *inode;
+       unsigned long hash = coda_f2i(fid);
 
        if ( !sb ) {
                printk("coda_fid_to_inode: no sb!\n");
                return NULL;
        }
 
-       nr = coda_f2i(fid);
-       inode = iget5_locked(sb, nr, coda_test_inode, coda_fail_inode, fid);
+       inode = iget5_locked(sb, hash, coda_test_inode, coda_fail_inode, fid);
        if ( !inode )
                return NULL;
 
index 9d6db0e68210c48b4db1c9a4a1a2699db3ed8808..8389f550e30cafeae58d2f057667cddcde15d8af 100644 (file)
@@ -635,9 +635,9 @@ static struct inode * get_new_inode_fast(struct super_block *sb, struct list_hea
        return inode;
 }
 
-static inline unsigned long hash(struct super_block *sb, unsigned long i_ino)
+static inline unsigned long hash(struct super_block *sb, unsigned long hashval)
 {
-       unsigned long tmp = i_ino + ((unsigned long) sb / L1_CACHE_BYTES);
+       unsigned long tmp = hashval + ((unsigned long) sb / L1_CACHE_BYTES);
        tmp = tmp + (tmp >> I_HASHBITS);
        return tmp & I_HASHMASK;
 }
@@ -703,9 +703,9 @@ struct inode *igrab(struct inode *inode)
  * the filesystem gets back a new locked and hashed inode and gets
  * to fill it in before unlocking it via unlock_new_inode().
  */
-struct inode *iget5_locked(struct super_block *sb, unsigned long ino, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *data)
+struct inode *iget5_locked(struct super_block *sb, unsigned long hashval, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *data)
 {
-       struct list_head * head = inode_hashtable + hash(sb,ino);
+       struct list_head * head = inode_hashtable + hash(sb, hashval);
        struct inode * inode;
 
        spin_lock(&inode_lock);
@@ -759,18 +759,20 @@ EXPORT_SYMBOL(iget_locked);
 EXPORT_SYMBOL(unlock_new_inode);
 
 /**
- *     insert_inode_hash - hash an inode
+ *     __insert_inode_hash - hash an inode
  *     @inode: unhashed inode
+ *     @hashval: unsigned long value used to locate this object in the
+ *             inode_hashtable.
  *
  *     Add an inode to the inode hash for this superblock. If the inode
  *     has no superblock it is added to a separate anonymous chain.
  */
  
-void insert_inode_hash(struct inode *inode)
+void __insert_inode_hash(struct inode *inode, unsigned long hashval)
 {
        struct list_head *head = &anon_hash_chain;
        if (inode->i_sb)
-               head = inode_hashtable + hash(inode->i_sb, inode->i_ino);
+               head = inode_hashtable + hash(inode->i_sb, hashval);
        spin_lock(&inode_lock);
        list_add(&inode->i_hash, head);
        spin_unlock(&inode_lock);
index 0011043d51cb9f9221ceff03e3c96693b44d706c..ea03c0e8a85002808224d1bf9b1beeea8c61b00f 100644 (file)
@@ -641,7 +641,7 @@ __nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
                fattr:  fattr
        };
        struct inode *inode = NULL;
-       unsigned long ino;
+       unsigned long hash;
 
        if ((fattr->valid & NFS_ATTR_FATTR) == 0)
                goto out_no_inode;
@@ -651,9 +651,9 @@ __nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
                goto out_no_inode;
        }
 
-       ino = nfs_fattr_to_ino_t(fattr);
+       hash = nfs_fattr_to_ino_t(fattr);
 
-       if (!(inode = iget5_locked(sb, ino, nfs_find_actor, nfs_init_locked, &desc)))
+       if (!(inode = iget5_locked(sb, hash, nfs_find_actor, nfs_init_locked, &desc)))
                goto out_no_inode;
 
        if (inode->i_state & I_NEW) {
@@ -661,7 +661,9 @@ __nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
                loff_t          new_isize;
                time_t          new_atime;
 
-               inode->i_ino = ino;
+               /* We set i_ino for the few things that still rely on it,
+                * such as stat(2) */
+               inode->i_ino = hash;
 
                /* We can't support UPDATE_ATIME(), since the server will reset it */
                inode->i_flags |= S_NOATIME;
index 4ec6c2fe76c693058ba980f9931dda3dc7148f5b..f3e56d1f70f2ab5c843ec57364da600fe5e09740 100644 (file)
@@ -1221,8 +1221,13 @@ extern void __iget(struct inode * inode);
 extern void clear_inode(struct inode *);
 extern struct inode *new_inode(struct super_block *);
 extern void remove_suid(struct dentry *);
-extern void insert_inode_hash(struct inode *);
+
+extern void __insert_inode_hash(struct inode *, unsigned long hashval);
 extern void remove_inode_hash(struct inode *);
+static inline void insert_inode_hash(struct inode *inode) {
+       __insert_inode_hash(inode, inode->i_ino);
+}
+
 extern struct file * get_empty_filp(void);
 extern void file_move(struct file *f, struct list_head *list);
 extern void ll_rw_block(int, int, struct buffer_head * bh[]);
index a3a721cbd42647a455d66eac8f71a5fb075cd5b6..51bf57dfda336b9f9650b737135f5f572fd7d52f 100644 (file)
@@ -537,7 +537,7 @@ EXPORT_SYMBOL(clear_inode);
 EXPORT_SYMBOL(init_special_inode);
 EXPORT_SYMBOL(__get_hash_table);
 EXPORT_SYMBOL(new_inode);
-EXPORT_SYMBOL(insert_inode_hash);
+EXPORT_SYMBOL(__insert_inode_hash);
 EXPORT_SYMBOL(remove_inode_hash);
 EXPORT_SYMBOL(buffer_insert_list);
 EXPORT_SYMBOL(make_bad_inode);