From: Christoph Hellwig <hch@lst.de>
To: viro@zeniv.linux.org.uk, zippel@linux-m68k.org
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH 3/14] hfsplus: clean up hfsplus_iget
Date: Fri, 1 Oct 2010 09:25:47 +0200 [thread overview]
Message-ID: <20101001072547.GC27055@lst.de> (raw)
In-Reply-To: <20101001072500.GA26972@lst.de>
Add a new hfsplus_system_read_inode for reading the special system inodes
and streamline the fastpath iget code.
Signed-off-by: Christoph Hellwig <hch@tuxera.com>
Index: linux-2.6/fs/hfsplus/super.c
===================================================================
--- linux-2.6.orig/fs/hfsplus/super.c 2010-09-30 12:02:01.032782662 +0200
+++ linux-2.6/fs/hfsplus/super.c 2010-09-30 12:05:37.576782660 +0200
@@ -20,12 +20,42 @@ static void hfsplus_destroy_inode(struct
#include "hfsplus_fs.h"
+static int hfsplus_system_read_inode(struct inode *inode)
+{
+ struct hfsplus_vh *vhdr = HFSPLUS_SB(inode->i_sb)->s_vhdr;
+
+ switch (inode->i_ino) {
+ case HFSPLUS_EXT_CNID:
+ hfsplus_inode_read_fork(inode, &vhdr->ext_file);
+ inode->i_mapping->a_ops = &hfsplus_btree_aops;
+ break;
+ case HFSPLUS_CAT_CNID:
+ hfsplus_inode_read_fork(inode, &vhdr->cat_file);
+ inode->i_mapping->a_ops = &hfsplus_btree_aops;
+ break;
+ case HFSPLUS_ALLOC_CNID:
+ hfsplus_inode_read_fork(inode, &vhdr->alloc_file);
+ inode->i_mapping->a_ops = &hfsplus_aops;
+ break;
+ case HFSPLUS_START_CNID:
+ hfsplus_inode_read_fork(inode, &vhdr->start_file);
+ break;
+ case HFSPLUS_ATTR_CNID:
+ hfsplus_inode_read_fork(inode, &vhdr->attr_file);
+ inode->i_mapping->a_ops = &hfsplus_btree_aops;
+ break;
+ default:
+ return -EIO;
+ }
+
+ return 0;
+}
+
struct inode *hfsplus_iget(struct super_block *sb, unsigned long ino)
{
struct hfs_find_data fd;
- struct hfsplus_vh *vhdr;
struct inode *inode;
- long err = -EIO;
+ int err;
inode = iget_locked(sb, ino);
if (!inode)
@@ -39,51 +69,24 @@ struct inode *hfsplus_iget(struct super_
HFSPLUS_I(inode)->rsrc_inode = NULL;
atomic_set(&HFSPLUS_I(inode)->opencnt, 0);
- if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID) {
- read_inode:
+ if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID ||
+ inode->i_ino == HFSPLUS_ROOT_CNID) {
hfs_find_init(HFSPLUS_SB(inode->i_sb)->cat_tree, &fd);
err = hfsplus_find_cat(inode->i_sb, inode->i_ino, &fd);
if (!err)
err = hfsplus_cat_read_inode(inode, &fd);
hfs_find_exit(&fd);
- if (err)
- goto bad_inode;
- goto done;
+ } else {
+ err = hfsplus_system_read_inode(inode);
}
- vhdr = HFSPLUS_SB(inode->i_sb)->s_vhdr;
- switch(inode->i_ino) {
- case HFSPLUS_ROOT_CNID:
- goto read_inode;
- case HFSPLUS_EXT_CNID:
- hfsplus_inode_read_fork(inode, &vhdr->ext_file);
- inode->i_mapping->a_ops = &hfsplus_btree_aops;
- break;
- case HFSPLUS_CAT_CNID:
- hfsplus_inode_read_fork(inode, &vhdr->cat_file);
- inode->i_mapping->a_ops = &hfsplus_btree_aops;
- break;
- case HFSPLUS_ALLOC_CNID:
- hfsplus_inode_read_fork(inode, &vhdr->alloc_file);
- inode->i_mapping->a_ops = &hfsplus_aops;
- break;
- case HFSPLUS_START_CNID:
- hfsplus_inode_read_fork(inode, &vhdr->start_file);
- break;
- case HFSPLUS_ATTR_CNID:
- hfsplus_inode_read_fork(inode, &vhdr->attr_file);
- inode->i_mapping->a_ops = &hfsplus_btree_aops;
- break;
- default:
- goto bad_inode;
+
+ if (err) {
+ iget_failed(inode);
+ return ERR_PTR(err);
}
-done:
unlock_new_inode(inode);
return inode;
-
-bad_inode:
- iget_failed(inode);
- return ERR_PTR(err);
}
static int hfsplus_write_inode(struct inode *inode,
next prev parent reply other threads:[~2010-10-01 7:25 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-01 7:25 [PATCH 0/14] more hfsplus updates Christoph Hellwig
2010-10-01 7:25 ` [PATCH 1/14] hfsplus: fix HFSPLUS_SB calling convention Christoph Hellwig
2010-10-01 7:25 ` [PATCH 2/14] hfsplus: fix HFSPLUS_I " Christoph Hellwig
2010-10-01 7:25 ` Christoph Hellwig [this message]
2010-10-01 7:26 ` [PATCH 4/14] hfsplus: clean up hfsplus_write_inode Christoph Hellwig
2010-10-01 7:26 ` [PATCH 5/14] hfsplus: merge mknod/mkdir/creat Christoph Hellwig
2010-10-01 7:26 ` [PATCH 6/14] hfsplus: fix error handling in hfsplus_symlink Christoph Hellwig
2010-10-01 7:26 ` [PATCH 7/14] hfsplus: do not cache and write next_alloc Christoph Hellwig
2010-10-01 7:26 ` [PATCH 8/14] hfsplus: remove the rsrc_inodes list Christoph Hellwig
2010-10-01 7:26 ` [PATCH 9/14] hfsplus: add per-superblock lock for volume header updates Christoph Hellwig
2010-10-01 7:27 ` [PATCH 10/14] hfsplus: use atomic bitops for the superblock flags Christoph Hellwig
2010-10-01 7:27 ` [PATCH 11/14] hfsplus: protect readdir against removals from open_dir_list Christoph Hellwig
2010-10-01 7:27 ` [PATCH 12/14] hfsplus: add missing extent locking in hfsplus_write_inode Christoph Hellwig
2010-10-01 7:27 ` [PATCH 13/14] hfsplus: convert tree_lock to mutex Christoph Hellwig
2010-10-01 7:28 ` [PATCH 14/14] hfsplus: fix rename over directories Christoph Hellwig
2010-10-01 14:06 ` [PATCH 0/14] more hfsplus updates Christoph Hellwig
2010-10-01 14:16 ` Christoph Hellwig
2010-10-02 4:09 ` Stephen Rothwell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101001072547.GC27055@lst.de \
--to=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=zippel@linux-m68k.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).