Messages in this thread |  | | | Date | Fri, 10 Mar 2000 18:56:14 +0100 (CET) | | From | Jan Bobrowski <> | | Subject | idea: inode handling improvement |
| |
Hi
I have small improvement related to inode handling code. I think that by replacing long argument lists with pointer to a structure, the code will become smaller, faster, and more readable. Structure will be filled once, while arg list is filled every function call.
Inside functions it is better to explicitly cache some fields in registers, however.
What do you think about it?
Jan Bobrowski jb@wizard.ae.krakow.pl
---- example ---- typedef int (*find_inode_t)(struct inode *, struct inode_context *);
struct inode_context { struct super_block *sb; unsigned long ino; find_inode_t find_actor; struct list_head *hash; /* filled by iget4() */ void *opaque; }; static struct inode * find_inode(struct inode_context *ic) { struct super_block *sb = ic->sb; unsigned long ino = ic->ino; struct list_head *head, *tmp; struct inode * inode; tmp = head = ic->hash; for (;;) { tmp = tmp->next; inode = NULL; if (tmp == head) break; inode = list_entry(tmp, struct inode, i_hash); if (inode->i_ino != ino) continue; if (inode->i_sb != sb) continue; if (ic->find_actor && !ic->find_actor(inode, ic)) continue; break; } return inode; } struct inode *iget4(struct inode_context *ic) { struct inode * inode; ic->hash = inode_hashtable + hash(ic->sb, ic->ino); spin_lock(&inode_lock); inode = find_inode(ic); if (inode) { __iget(inode); spin_unlock(&inode_lock); wait_on_inode(inode); return inode; } spin_unlock(&inode_lock); /* * get_new_inode() will do the right thing, re-trying the search * in case it had to block at any point. */ return get_new_inode(ic); }
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
|  |