aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hfsplus
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@tuxera.com>2010-09-30 23:43:43 -0400
committerChristoph Hellwig <hch@lst.de>2010-09-30 23:43:43 -0400
commitb5080f77ed2de3c8ac67a63044f8a781c75207d9 (patch)
tree48897d88cf2ce0025be0ddb2b53d296c874cd379 /fs/hfsplus
parentfc4fff82104fa096eada73943fe5249500acd5fa (diff)
hfsplus: clean up hfsplus_write_inode
Add a new hfsplus_system_write_inode for writing the special system inodes and streamline the fastpath write_inode code. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
Diffstat (limited to 'fs/hfsplus')
-rw-r--r--fs/hfsplus/super.c80
1 files changed, 37 insertions, 43 deletions
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index bd09ea23435b..e485a38b994d 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -89,63 +89,57 @@ struct inode *hfsplus_iget(struct super_block *sb, unsigned long ino)
89 return inode; 89 return inode;
90} 90}
91 91
92static int hfsplus_write_inode(struct inode *inode, 92static int hfsplus_system_write_inode(struct inode *inode)
93 struct writeback_control *wbc)
94{ 93{
95 struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb); 94 struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
96 struct hfsplus_vh *vhdr; 95 struct hfsplus_vh *vhdr = sbi->s_vhdr;
97 int ret = 0; 96 struct hfsplus_fork_raw *fork;
97 struct hfs_btree *tree = NULL;
98 98
99 dprint(DBG_INODE, "hfsplus_write_inode: %lu\n", inode->i_ino);
100 hfsplus_ext_write_extent(inode);
101 if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID) {
102 return hfsplus_cat_write_inode(inode);
103 }
104 vhdr = sbi->s_vhdr;
105 switch (inode->i_ino) { 99 switch (inode->i_ino) {
106 case HFSPLUS_ROOT_CNID:
107 ret = hfsplus_cat_write_inode(inode);
108 break;
109 case HFSPLUS_EXT_CNID: 100 case HFSPLUS_EXT_CNID:
110 if (vhdr->ext_file.total_size != cpu_to_be64(inode->i_size)) { 101 fork = &vhdr->ext_file;
111 sbi->flags |= HFSPLUS_SB_WRITEBACKUP; 102 tree = sbi->ext_tree;
112 inode->i_sb->s_dirt = 1;
113 }
114 hfsplus_inode_write_fork(inode, &vhdr->ext_file);
115 hfs_btree_write(sbi->ext_tree);
116 break; 103 break;
117 case HFSPLUS_CAT_CNID: 104 case HFSPLUS_CAT_CNID:
118 if (vhdr->cat_file.total_size != cpu_to_be64(inode->i_size)) { 105 fork = &vhdr->cat_file;
119 sbi->flags |= HFSPLUS_SB_WRITEBACKUP; 106 tree = sbi->cat_tree;
120 inode->i_sb->s_dirt = 1;
121 }
122 hfsplus_inode_write_fork(inode, &vhdr->cat_file);
123 hfs_btree_write(sbi->cat_tree);
124 break; 107 break;
125 case HFSPLUS_ALLOC_CNID: 108 case HFSPLUS_ALLOC_CNID:
126 if (vhdr->alloc_file.total_size != cpu_to_be64(inode->i_size)) { 109 fork = &vhdr->alloc_file;
127 sbi->flags |= HFSPLUS_SB_WRITEBACKUP;
128 inode->i_sb->s_dirt = 1;
129 }
130 hfsplus_inode_write_fork(inode, &vhdr->alloc_file);
131 break; 110 break;
132 case HFSPLUS_START_CNID: 111 case HFSPLUS_START_CNID:
133 if (vhdr->start_file.total_size != cpu_to_be64(inode->i_size)) { 112 fork = &vhdr->start_file;
134 sbi->flags |= HFSPLUS_SB_WRITEBACKUP;
135 inode->i_sb->s_dirt = 1;
136 }
137 hfsplus_inode_write_fork(inode, &vhdr->start_file);
138 break; 113 break;
139 case HFSPLUS_ATTR_CNID: 114 case HFSPLUS_ATTR_CNID:
140 if (vhdr->attr_file.total_size != cpu_to_be64(inode->i_size)) { 115 fork = &vhdr->attr_file;
141 sbi->flags |= HFSPLUS_SB_WRITEBACKUP; 116 tree = sbi->attr_tree;
142 inode->i_sb->s_dirt = 1; 117 default:
143 } 118 return -EIO;
144 hfsplus_inode_write_fork(inode, &vhdr->attr_file); 119 }
145 hfs_btree_write(sbi->attr_tree); 120
146 break; 121 if (fork->total_size != cpu_to_be64(inode->i_size)) {
122 sbi->flags |= HFSPLUS_SB_WRITEBACKUP;
123 inode->i_sb->s_dirt = 1;
147 } 124 }
148 return ret; 125 hfsplus_inode_write_fork(inode, fork);
126 if (tree)
127 hfs_btree_write(tree);
128 return 0;
129}
130
131static int hfsplus_write_inode(struct inode *inode,
132 struct writeback_control *wbc)
133{
134 dprint(DBG_INODE, "hfsplus_write_inode: %lu\n", inode->i_ino);
135
136 hfsplus_ext_write_extent(inode);
137
138 if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID ||
139 inode->i_ino == HFSPLUS_ROOT_CNID)
140 return hfsplus_cat_write_inode(inode);
141 else
142 return hfsplus_system_write_inode(inode);
149} 143}
150 144
151static void hfsplus_evict_inode(struct inode *inode) 145static void hfsplus_evict_inode(struct inode *inode)