Messages in this thread | | | From | Linus Torvalds <> | Date | Tue, 14 Dec 2010 15:43:51 -0800 | Subject | Re: [PATCH] cramfs: generate unique inode number for better inode cache usage |
| |
On Tue, Dec 14, 2010 at 3:32 PM, Linus Torvalds <torvalds@linux-foundation.org> wrote: > Why do you repeat that > > inode = iget_locked(sb, cramino(cramfs_inode, offset)); > if (inode && (inode->i_state & I_NEW)) { > > so many times? > > Wouldn't it be nicer to just do it once at the top?
Oh, and I think it's probably nicer to then do the if-statements as a
switch (cram_inode->mode & S_IFMT) { case S_IFREG: ..
but what I objected to in the previous patch was doing it multiple times, and moving the nice separate helper function into the caller.
So I _think_ you should be able to just do something like this:
ino = cramino(cramfs_inode, offset); switch (cram_inode->mode & S_IFMT) { case S_IFREG: fops = generic_ro_fops; aops = &cramfs_aops; break; case S_IFDIR: ... default: ino = CRAMINO_UNIQ(offset); } inode = iget_locked(sb, ino); if (inode && (inode->i_state & I_NEW)) { inode->i_ops = iops; inode->i_fops = fops; inode->i_data.a_ops = aops; setup_inode(inode, cramfs_inode, cramfs_inode->size); }
or whatever?
Linus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |