aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@tuxera.com>2010-09-30 23:43:31 -0400
committerChristoph Hellwig <hch@lst.de>2010-09-30 23:43:31 -0400
commit6af502de224c3742936d54eee7e3690c09822934 (patch)
tree9988331693952348503d64764ff81dc3b5d801ab /fs
parentdd73a01a30d729e8fa6f829c4582650e258e36f9 (diff)
hfsplus: fix HFSPLUS_I calling convention
HFSPLUS_I doesn't return a pointer to the hfsplus-specific inode information like all other FOO_I macros, but dereference the pointer in a way that made it look like a direct struct derefence. This only works as long as the HFSPLUS_I macro is used directly and prevents us from keepig a local hfsplus_inode_info pointer. Fix the calling convention and introduce a local hip variable in all functions that use it constantly. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/hfsplus/btree.c9
-rw-r--r--fs/hfsplus/catalog.c14
-rw-r--r--fs/hfsplus/dir.c14
-rw-r--r--fs/hfsplus/extents.c171
-rw-r--r--fs/hfsplus/hfsplus_fs.h8
-rw-r--r--fs/hfsplus/inode.c112
-rw-r--r--fs/hfsplus/ioctl.c22
-rw-r--r--fs/hfsplus/super.c16
8 files changed, 193 insertions, 173 deletions
diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c
index 96e2128748f2..f75cf222b8b4 100644
--- a/fs/hfsplus/btree.c
+++ b/fs/hfsplus/btree.c
@@ -192,17 +192,18 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree)
192 192
193 while (!tree->free_nodes) { 193 while (!tree->free_nodes) {
194 struct inode *inode = tree->inode; 194 struct inode *inode = tree->inode;
195 struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
195 u32 count; 196 u32 count;
196 int res; 197 int res;
197 198
198 res = hfsplus_file_extend(inode); 199 res = hfsplus_file_extend(inode);
199 if (res) 200 if (res)
200 return ERR_PTR(res); 201 return ERR_PTR(res);
201 HFSPLUS_I(inode).phys_size = inode->i_size = 202 hip->phys_size = inode->i_size =
202 (loff_t)HFSPLUS_I(inode).alloc_blocks << 203 (loff_t)hip->alloc_blocks <<
203 HFSPLUS_SB(tree->sb)->alloc_blksz_shift; 204 HFSPLUS_SB(tree->sb)->alloc_blksz_shift;
204 HFSPLUS_I(inode).fs_blocks = HFSPLUS_I(inode).alloc_blocks << 205 hip->fs_blocks =
205 HFSPLUS_SB(tree->sb)->fs_shift; 206 hip->alloc_blocks << HFSPLUS_SB(tree->sb)->fs_shift;
206 inode_set_bytes(inode, inode->i_size); 207 inode_set_bytes(inode, inode->i_size);
207 count = inode->i_size >> tree->node_size_shift; 208 count = inode->i_size >> tree->node_size_shift;
208 tree->free_nodes = count - tree->node_count; 209 tree->free_nodes = count - tree->node_count;
diff --git a/fs/hfsplus/catalog.c b/fs/hfsplus/catalog.c
index 75ac1e466f1c..48979c4e8fa5 100644
--- a/fs/hfsplus/catalog.c
+++ b/fs/hfsplus/catalog.c
@@ -77,8 +77,8 @@ static void hfsplus_set_perms(struct inode *inode, struct hfsplus_perm *perms)
77 perms->rootflags |= HFSPLUS_FLG_APPEND; 77 perms->rootflags |= HFSPLUS_FLG_APPEND;
78 else 78 else
79 perms->rootflags &= ~HFSPLUS_FLG_APPEND; 79 perms->rootflags &= ~HFSPLUS_FLG_APPEND;
80 HFSPLUS_I(inode).rootflags = perms->rootflags; 80 HFSPLUS_I(inode)->rootflags = perms->rootflags;
81 HFSPLUS_I(inode).userflags = perms->userflags; 81 HFSPLUS_I(inode)->userflags = perms->userflags;
82 perms->mode = cpu_to_be16(inode->i_mode); 82 perms->mode = cpu_to_be16(inode->i_mode);
83 perms->owner = cpu_to_be32(inode->i_uid); 83 perms->owner = cpu_to_be32(inode->i_uid);
84 perms->group = cpu_to_be32(inode->i_gid); 84 perms->group = cpu_to_be32(inode->i_gid);
@@ -95,7 +95,7 @@ static int hfsplus_cat_build_record(hfsplus_cat_entry *entry, u32 cnid, struct i
95 memset(folder, 0, sizeof(*folder)); 95 memset(folder, 0, sizeof(*folder));
96 folder->type = cpu_to_be16(HFSPLUS_FOLDER); 96 folder->type = cpu_to_be16(HFSPLUS_FOLDER);
97 folder->id = cpu_to_be32(inode->i_ino); 97 folder->id = cpu_to_be32(inode->i_ino);
98 HFSPLUS_I(inode).create_date = 98 HFSPLUS_I(inode)->create_date =
99 folder->create_date = 99 folder->create_date =
100 folder->content_mod_date = 100 folder->content_mod_date =
101 folder->attribute_mod_date = 101 folder->attribute_mod_date =
@@ -113,7 +113,7 @@ static int hfsplus_cat_build_record(hfsplus_cat_entry *entry, u32 cnid, struct i
113 file->type = cpu_to_be16(HFSPLUS_FILE); 113 file->type = cpu_to_be16(HFSPLUS_FILE);
114 file->flags = cpu_to_be16(HFSPLUS_FILE_THREAD_EXISTS); 114 file->flags = cpu_to_be16(HFSPLUS_FILE_THREAD_EXISTS);
115 file->id = cpu_to_be32(cnid); 115 file->id = cpu_to_be32(cnid);
116 HFSPLUS_I(inode).create_date = 116 HFSPLUS_I(inode)->create_date =
117 file->create_date = 117 file->create_date =
118 file->content_mod_date = 118 file->content_mod_date =
119 file->attribute_mod_date = 119 file->attribute_mod_date =
@@ -133,8 +133,8 @@ static int hfsplus_cat_build_record(hfsplus_cat_entry *entry, u32 cnid, struct i
133 file->user_info.fdType = cpu_to_be32(HFSP_HARDLINK_TYPE); 133 file->user_info.fdType = cpu_to_be32(HFSP_HARDLINK_TYPE);
134 file->user_info.fdCreator = cpu_to_be32(HFSP_HFSPLUS_CREATOR); 134 file->user_info.fdCreator = cpu_to_be32(HFSP_HFSPLUS_CREATOR);
135 file->user_info.fdFlags = cpu_to_be16(0x100); 135 file->user_info.fdFlags = cpu_to_be16(0x100);
136 file->create_date = HFSPLUS_I(sbi->hidden_dir).create_date; 136 file->create_date = HFSPLUS_I(sbi->hidden_dir)->create_date;
137 file->permissions.dev = cpu_to_be32(HFSPLUS_I(inode).dev); 137 file->permissions.dev = cpu_to_be32(HFSPLUS_I(inode)->dev);
138 } 138 }
139 return sizeof(*file); 139 return sizeof(*file);
140 } 140 }
@@ -279,7 +279,7 @@ int hfsplus_delete_cat(u32 cnid, struct inode *dir, struct qstr *str)
279 hfsplus_free_fork(sb, cnid, &fork, HFSPLUS_TYPE_RSRC); 279 hfsplus_free_fork(sb, cnid, &fork, HFSPLUS_TYPE_RSRC);
280 } 280 }
281 281
282 list_for_each(pos, &HFSPLUS_I(dir).open_dir_list) { 282 list_for_each(pos, &HFSPLUS_I(dir)->open_dir_list) {
283 struct hfsplus_readdir_data *rd = 283 struct hfsplus_readdir_data *rd =
284 list_entry(pos, struct hfsplus_readdir_data, list); 284 list_entry(pos, struct hfsplus_readdir_data, list);
285 if (fd.tree->keycmp(fd.search_key, (void *)&rd->key) < 0) 285 if (fd.tree->keycmp(fd.search_key, (void *)&rd->key) < 0)
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 584777ddb0b9..5ca8308f9eb7 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -68,8 +68,8 @@ again:
68 cnid = be32_to_cpu(entry.file.id); 68 cnid = be32_to_cpu(entry.file.id);
69 if (entry.file.user_info.fdType == cpu_to_be32(HFSP_HARDLINK_TYPE) && 69 if (entry.file.user_info.fdType == cpu_to_be32(HFSP_HARDLINK_TYPE) &&
70 entry.file.user_info.fdCreator == cpu_to_be32(HFSP_HFSPLUS_CREATOR) && 70 entry.file.user_info.fdCreator == cpu_to_be32(HFSP_HFSPLUS_CREATOR) &&
71 (entry.file.create_date == HFSPLUS_I(HFSPLUS_SB(sb)->hidden_dir).create_date || 71 (entry.file.create_date == HFSPLUS_I(HFSPLUS_SB(sb)->hidden_dir)->create_date ||
72 entry.file.create_date == HFSPLUS_I(sb->s_root->d_inode).create_date) && 72 entry.file.create_date == HFSPLUS_I(sb->s_root->d_inode)->create_date) &&
73 HFSPLUS_SB(sb)->hidden_dir) { 73 HFSPLUS_SB(sb)->hidden_dir) {
74 struct qstr str; 74 struct qstr str;
75 char name[32]; 75 char name[32];
@@ -102,7 +102,7 @@ again:
102 if (IS_ERR(inode)) 102 if (IS_ERR(inode))
103 return ERR_CAST(inode); 103 return ERR_CAST(inode);
104 if (S_ISREG(inode->i_mode)) 104 if (S_ISREG(inode->i_mode))
105 HFSPLUS_I(inode).dev = linkid; 105 HFSPLUS_I(inode)->dev = linkid;
106out: 106out:
107 d_add(dentry, inode); 107 d_add(dentry, inode);
108 return NULL; 108 return NULL;
@@ -219,7 +219,7 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
219 } 219 }
220 filp->private_data = rd; 220 filp->private_data = rd;
221 rd->file = filp; 221 rd->file = filp;
222 list_add(&rd->list, &HFSPLUS_I(inode).open_dir_list); 222 list_add(&rd->list, &HFSPLUS_I(inode)->open_dir_list);
223 } 223 }
224 memcpy(&rd->key, fd.key, sizeof(struct hfsplus_cat_key)); 224 memcpy(&rd->key, fd.key, sizeof(struct hfsplus_cat_key));
225out: 225out:
@@ -287,7 +287,7 @@ static int hfsplus_link(struct dentry *src_dentry, struct inode *dst_dir,
287 if (res != -EEXIST) 287 if (res != -EEXIST)
288 return res; 288 return res;
289 } 289 }
290 HFSPLUS_I(inode).dev = id; 290 HFSPLUS_I(inode)->dev = id;
291 cnid = sbi->next_cnid++; 291 cnid = sbi->next_cnid++;
292 src_dentry->d_fsdata = (void *)(unsigned long)cnid; 292 src_dentry->d_fsdata = (void *)(unsigned long)cnid;
293 res = hfsplus_create_cat(cnid, src_dir, &src_dentry->d_name, inode); 293 res = hfsplus_create_cat(cnid, src_dir, &src_dentry->d_name, inode);
@@ -326,7 +326,7 @@ static int hfsplus_unlink(struct inode *dir, struct dentry *dentry)
326 326
327 cnid = (u32)(unsigned long)dentry->d_fsdata; 327 cnid = (u32)(unsigned long)dentry->d_fsdata;
328 if (inode->i_ino == cnid && 328 if (inode->i_ino == cnid &&
329 atomic_read(&HFSPLUS_I(inode).opencnt)) { 329 atomic_read(&HFSPLUS_I(inode)->opencnt)) {
330 str.name = name; 330 str.name = name;
331 str.len = sprintf(name, "temp%lu", inode->i_ino); 331 str.len = sprintf(name, "temp%lu", inode->i_ino);
332 res = hfsplus_rename_cat(inode->i_ino, 332 res = hfsplus_rename_cat(inode->i_ino,
@@ -347,7 +347,7 @@ static int hfsplus_unlink(struct inode *dir, struct dentry *dentry)
347 if (!inode->i_nlink) { 347 if (!inode->i_nlink) {
348 if (inode->i_ino != cnid) { 348 if (inode->i_ino != cnid) {
349 sbi->file_count--; 349 sbi->file_count--;
350 if (!atomic_read(&HFSPLUS_I(inode).opencnt)) { 350 if (!atomic_read(&HFSPLUS_I(inode)->opencnt)) {
351 res = hfsplus_delete_cat(inode->i_ino, 351 res = hfsplus_delete_cat(inode->i_ino,
352 sbi->hidden_dir, 352 sbi->hidden_dir,
353 NULL); 353 NULL);
diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c
index 181969814344..b1017eaa4fdc 100644
--- a/fs/hfsplus/extents.c
+++ b/fs/hfsplus/extents.c
@@ -85,27 +85,32 @@ static u32 hfsplus_ext_lastblock(struct hfsplus_extent *ext)
85 85
86static void __hfsplus_ext_write_extent(struct inode *inode, struct hfs_find_data *fd) 86static void __hfsplus_ext_write_extent(struct inode *inode, struct hfs_find_data *fd)
87{ 87{
88 struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
88 int res; 89 int res;
89 90
90 hfsplus_ext_build_key(fd->search_key, inode->i_ino, HFSPLUS_I(inode).cached_start, 91 hfsplus_ext_build_key(fd->search_key, inode->i_ino, hip->cached_start,
91 HFSPLUS_IS_RSRC(inode) ? HFSPLUS_TYPE_RSRC : HFSPLUS_TYPE_DATA); 92 HFSPLUS_IS_RSRC(inode) ?
93 HFSPLUS_TYPE_RSRC : HFSPLUS_TYPE_DATA);
94
92 res = hfs_brec_find(fd); 95 res = hfs_brec_find(fd);
93 if (HFSPLUS_I(inode).flags & HFSPLUS_FLG_EXT_NEW) { 96 if (hip->flags & HFSPLUS_FLG_EXT_NEW) {
94 if (res != -ENOENT) 97 if (res != -ENOENT)
95 return; 98 return;
96 hfs_brec_insert(fd, HFSPLUS_I(inode).cached_extents, sizeof(hfsplus_extent_rec)); 99 hfs_brec_insert(fd, hip->cached_extents,
97 HFSPLUS_I(inode).flags &= ~(HFSPLUS_FLG_EXT_DIRTY | HFSPLUS_FLG_EXT_NEW); 100 sizeof(hfsplus_extent_rec));
101 hip->flags &= ~(HFSPLUS_FLG_EXT_DIRTY | HFSPLUS_FLG_EXT_NEW);
98 } else { 102 } else {
99 if (res) 103 if (res)
100 return; 104 return;
101 hfs_bnode_write(fd->bnode, HFSPLUS_I(inode).cached_extents, fd->entryoffset, fd->entrylength); 105 hfs_bnode_write(fd->bnode, hip->cached_extents,
102 HFSPLUS_I(inode).flags &= ~HFSPLUS_FLG_EXT_DIRTY; 106 fd->entryoffset, fd->entrylength);
107 hip->flags &= ~HFSPLUS_FLG_EXT_DIRTY;
103 } 108 }
104} 109}
105 110
106void hfsplus_ext_write_extent(struct inode *inode) 111void hfsplus_ext_write_extent(struct inode *inode)
107{ 112{
108 if (HFSPLUS_I(inode).flags & HFSPLUS_FLG_EXT_DIRTY) { 113 if (HFSPLUS_I(inode)->flags & HFSPLUS_FLG_EXT_DIRTY) {
109 struct hfs_find_data fd; 114 struct hfs_find_data fd;
110 115
111 hfs_find_init(HFSPLUS_SB(inode->i_sb)->ext_tree, &fd); 116 hfs_find_init(HFSPLUS_SB(inode->i_sb)->ext_tree, &fd);
@@ -136,30 +141,34 @@ static inline int __hfsplus_ext_read_extent(struct hfs_find_data *fd,
136 141
137static inline int __hfsplus_ext_cache_extent(struct hfs_find_data *fd, struct inode *inode, u32 block) 142static inline int __hfsplus_ext_cache_extent(struct hfs_find_data *fd, struct inode *inode, u32 block)
138{ 143{
144 struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
139 int res; 145 int res;
140 146
141 if (HFSPLUS_I(inode).flags & HFSPLUS_FLG_EXT_DIRTY) 147 if (hip->flags & HFSPLUS_FLG_EXT_DIRTY)
142 __hfsplus_ext_write_extent(inode, fd); 148 __hfsplus_ext_write_extent(inode, fd);
143 149
144 res = __hfsplus_ext_read_extent(fd, HFSPLUS_I(inode).cached_extents, inode->i_ino, 150 res = __hfsplus_ext_read_extent(fd, hip->cached_extents, inode->i_ino,
145 block, HFSPLUS_IS_RSRC(inode) ? HFSPLUS_TYPE_RSRC : HFSPLUS_TYPE_DATA); 151 block, HFSPLUS_IS_RSRC(inode) ?
152 HFSPLUS_TYPE_RSRC :
153 HFSPLUS_TYPE_DATA);
146 if (!res) { 154 if (!res) {
147 HFSPLUS_I(inode).cached_start = be32_to_cpu(fd->key->ext.start_block); 155 hip->cached_start = be32_to_cpu(fd->key->ext.start_block);
148 HFSPLUS_I(inode).cached_blocks = hfsplus_ext_block_count(HFSPLUS_I(inode).cached_extents); 156 hip->cached_blocks = hfsplus_ext_block_count(hip->cached_extents);
149 } else { 157 } else {
150 HFSPLUS_I(inode).cached_start = HFSPLUS_I(inode).cached_blocks = 0; 158 hip->cached_start = hip->cached_blocks = 0;
151 HFSPLUS_I(inode).flags &= ~(HFSPLUS_FLG_EXT_DIRTY | HFSPLUS_FLG_EXT_NEW); 159 hip->flags &= ~(HFSPLUS_FLG_EXT_DIRTY | HFSPLUS_FLG_EXT_NEW);
152 } 160 }
153 return res; 161 return res;
154} 162}
155 163
156static int hfsplus_ext_read_extent(struct inode *inode, u32 block) 164static int hfsplus_ext_read_extent(struct inode *inode, u32 block)
157{ 165{
166 struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
158 struct hfs_find_data fd; 167 struct hfs_find_data fd;
159 int res; 168 int res;
160 169
161 if (block >= HFSPLUS_I(inode).cached_start && 170 if (block >= hip->cached_start &&
162 block < HFSPLUS_I(inode).cached_start + HFSPLUS_I(inode).cached_blocks) 171 block < hip->cached_start + hip->cached_blocks)
163 return 0; 172 return 0;
164 173
165 hfs_find_init(HFSPLUS_SB(inode->i_sb)->ext_tree, &fd); 174 hfs_find_init(HFSPLUS_SB(inode->i_sb)->ext_tree, &fd);
@@ -174,6 +183,7 @@ int hfsplus_get_block(struct inode *inode, sector_t iblock,
174{ 183{
175 struct super_block *sb = inode->i_sb; 184 struct super_block *sb = inode->i_sb;
176 struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb); 185 struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
186 struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
177 int res = -EIO; 187 int res = -EIO;
178 u32 ablock, dblock, mask; 188 u32 ablock, dblock, mask;
179 int shift; 189 int shift;
@@ -182,10 +192,10 @@ int hfsplus_get_block(struct inode *inode, sector_t iblock,
182 shift = sbi->alloc_blksz_shift - sb->s_blocksize_bits; 192 shift = sbi->alloc_blksz_shift - sb->s_blocksize_bits;
183 ablock = iblock >> sbi->fs_shift; 193 ablock = iblock >> sbi->fs_shift;
184 194
185 if (iblock >= HFSPLUS_I(inode).fs_blocks) { 195 if (iblock >= hip->fs_blocks) {
186 if (iblock > HFSPLUS_I(inode).fs_blocks || !create) 196 if (iblock > hip->fs_blocks || !create)
187 return -EIO; 197 return -EIO;
188 if (ablock >= HFSPLUS_I(inode).alloc_blocks) { 198 if (ablock >= hip->alloc_blocks) {
189 res = hfsplus_file_extend(inode); 199 res = hfsplus_file_extend(inode);
190 if (res) 200 if (res)
191 return res; 201 return res;
@@ -193,24 +203,24 @@ int hfsplus_get_block(struct inode *inode, sector_t iblock,
193 } else 203 } else
194 create = 0; 204 create = 0;
195 205
196 if (ablock < HFSPLUS_I(inode).first_blocks) { 206 if (ablock < hip->first_blocks) {
197 dblock = hfsplus_ext_find_block(HFSPLUS_I(inode).first_extents, ablock); 207 dblock = hfsplus_ext_find_block(hip->first_extents, ablock);
198 goto done; 208 goto done;
199 } 209 }
200 210
201 if (inode->i_ino == HFSPLUS_EXT_CNID) 211 if (inode->i_ino == HFSPLUS_EXT_CNID)
202 return -EIO; 212 return -EIO;
203 213
204 mutex_lock(&HFSPLUS_I(inode).extents_lock); 214 mutex_lock(&hip->extents_lock);
205 res = hfsplus_ext_read_extent(inode, ablock); 215 res = hfsplus_ext_read_extent(inode, ablock);
206 if (!res) { 216 if (!res) {
207 dblock = hfsplus_ext_find_block(HFSPLUS_I(inode).cached_extents, ablock - 217 dblock = hfsplus_ext_find_block(hip->cached_extents,
208 HFSPLUS_I(inode).cached_start); 218 ablock - hip->cached_start);
209 } else { 219 } else {
210 mutex_unlock(&HFSPLUS_I(inode).extents_lock); 220 mutex_unlock(&hip->extents_lock);
211 return -EIO; 221 return -EIO;
212 } 222 }
213 mutex_unlock(&HFSPLUS_I(inode).extents_lock); 223 mutex_unlock(&hip->extents_lock);
214 224
215done: 225done:
216 dprint(DBG_EXTENT, "get_block(%lu): %llu - %u\n", inode->i_ino, (long long)iblock, dblock); 226 dprint(DBG_EXTENT, "get_block(%lu): %llu - %u\n", inode->i_ino, (long long)iblock, dblock);
@@ -218,8 +228,8 @@ done:
218 map_bh(bh_result, sb, (dblock << sbi->fs_shift) + sbi->blockoffset + (iblock & mask)); 228 map_bh(bh_result, sb, (dblock << sbi->fs_shift) + sbi->blockoffset + (iblock & mask));
219 if (create) { 229 if (create) {
220 set_buffer_new(bh_result); 230 set_buffer_new(bh_result);
221 HFSPLUS_I(inode).phys_size += sb->s_blocksize; 231 hip->phys_size += sb->s_blocksize;
222 HFSPLUS_I(inode).fs_blocks++; 232 hip->fs_blocks++;
223 inode_add_bytes(inode, sb->s_blocksize); 233 inode_add_bytes(inode, sb->s_blocksize);
224 mark_inode_dirty(inode); 234 mark_inode_dirty(inode);
225 } 235 }
@@ -348,6 +358,7 @@ int hfsplus_file_extend(struct inode *inode)
348{ 358{
349 struct super_block *sb = inode->i_sb; 359 struct super_block *sb = inode->i_sb;
350 struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb); 360 struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
361 struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
351 u32 start, len, goal; 362 u32 start, len, goal;
352 int res; 363 int res;
353 364
@@ -360,17 +371,17 @@ int hfsplus_file_extend(struct inode *inode)
360 return -ENOSPC; 371 return -ENOSPC;
361 } 372 }
362 373
363 mutex_lock(&HFSPLUS_I(inode).extents_lock); 374 mutex_lock(&hip->extents_lock);
364 if (HFSPLUS_I(inode).alloc_blocks == HFSPLUS_I(inode).first_blocks) 375 if (hip->alloc_blocks == hip->first_blocks)
365 goal = hfsplus_ext_lastblock(HFSPLUS_I(inode).first_extents); 376 goal = hfsplus_ext_lastblock(hip->first_extents);
366 else { 377 else {
367 res = hfsplus_ext_read_extent(inode, HFSPLUS_I(inode).alloc_blocks); 378 res = hfsplus_ext_read_extent(inode, hip->alloc_blocks);
368 if (res) 379 if (res)
369 goto out; 380 goto out;
370 goal = hfsplus_ext_lastblock(HFSPLUS_I(inode).cached_extents); 381 goal = hfsplus_ext_lastblock(hip->cached_extents);
371 } 382 }
372 383
373 len = HFSPLUS_I(inode).clump_blocks; 384 len = hip->clump_blocks;
374 start = hfsplus_block_allocate(sb, sbi->total_blocks, goal, &len); 385 start = hfsplus_block_allocate(sb, sbi->total_blocks, goal, &len);
375 if (start >= sbi->total_blocks) { 386 if (start >= sbi->total_blocks) {
376 start = hfsplus_block_allocate(sb, goal, 0, &len); 387 start = hfsplus_block_allocate(sb, goal, 0, &len);
@@ -381,41 +392,41 @@ int hfsplus_file_extend(struct inode *inode)
381 } 392 }
382 393
383 dprint(DBG_EXTENT, "extend %lu: %u,%u\n", inode->i_ino, start, len); 394 dprint(DBG_EXTENT, "extend %lu: %u,%u\n", inode->i_ino, start, len);
384 if (HFSPLUS_I(inode).alloc_blocks <= HFSPLUS_I(inode).first_blocks) { 395
385 if (!HFSPLUS_I(inode).first_blocks) { 396 if (hip->alloc_blocks <= hip->first_blocks) {
397 if (!hip->first_blocks) {
386 dprint(DBG_EXTENT, "first extents\n"); 398 dprint(DBG_EXTENT, "first extents\n");
387 /* no extents yet */ 399 /* no extents yet */
388 HFSPLUS_I(inode).first_extents[0].start_block = cpu_to_be32(start); 400 hip->first_extents[0].start_block = cpu_to_be32(start);
389 HFSPLUS_I(inode).first_extents[0].block_count = cpu_to_be32(len); 401 hip->first_extents[0].block_count = cpu_to_be32(len);
390 res = 0; 402 res = 0;
391 } else { 403 } else {
392 /* try to append to extents in inode */ 404 /* try to append to extents in inode */
393 res = hfsplus_add_extent(HFSPLUS_I(inode).first_extents, 405 res = hfsplus_add_extent(hip->first_extents,
394 HFSPLUS_I(inode).alloc_blocks, 406 hip->alloc_blocks,
395 start, len); 407 start, len);
396 if (res == -ENOSPC) 408 if (res == -ENOSPC)
397 goto insert_extent; 409 goto insert_extent;
398 } 410 }
399 if (!res) { 411 if (!res) {
400 hfsplus_dump_extent(HFSPLUS_I(inode).first_extents); 412 hfsplus_dump_extent(hip->first_extents);
401 HFSPLUS_I(inode).first_blocks += len; 413 hip->first_blocks += len;
402 } 414 }
403 } else { 415 } else {
404 res = hfsplus_add_extent(HFSPLUS_I(inode).cached_extents, 416 res = hfsplus_add_extent(hip->cached_extents,
405 HFSPLUS_I(inode).alloc_blocks - 417 hip->alloc_blocks - hip->cached_start,
406 HFSPLUS_I(inode).cached_start,
407 start, len); 418 start, len);
408 if (!res) { 419 if (!res) {
409 hfsplus_dump_extent(HFSPLUS_I(inode).cached_extents); 420 hfsplus_dump_extent(hip->cached_extents);
410 HFSPLUS_I(inode).flags |= HFSPLUS_FLG_EXT_DIRTY; 421 hip->flags |= HFSPLUS_FLG_EXT_DIRTY;
411 HFSPLUS_I(inode).cached_blocks += len; 422 hip->cached_blocks += len;
412 } else if (res == -ENOSPC) 423 } else if (res == -ENOSPC)
413 goto insert_extent; 424 goto insert_extent;
414 } 425 }
415out: 426out:
416 mutex_unlock(&HFSPLUS_I(inode).extents_lock); 427 mutex_unlock(&hip->extents_lock);
417 if (!res) { 428 if (!res) {
418 HFSPLUS_I(inode).alloc_blocks += len; 429 hip->alloc_blocks += len;
419 mark_inode_dirty(inode); 430 mark_inode_dirty(inode);
420 } 431 }
421 return res; 432 return res;
@@ -424,13 +435,13 @@ insert_extent:
424 dprint(DBG_EXTENT, "insert new extent\n"); 435 dprint(DBG_EXTENT, "insert new extent\n");
425 hfsplus_ext_write_extent(inode); 436 hfsplus_ext_write_extent(inode);
426 437
427 memset(HFSPLUS_I(inode).cached_extents, 0, sizeof(hfsplus_extent_rec)); 438 memset(hip->cached_extents, 0, sizeof(hfsplus_extent_rec));
428 HFSPLUS_I(inode).cached_extents[0].start_block = cpu_to_be32(start); 439 hip->cached_extents[0].start_block = cpu_to_be32(start);
429 HFSPLUS_I(inode).cached_extents[0].block_count = cpu_to_be32(len); 440 hip->cached_extents[0].block_count = cpu_to_be32(len);
430 hfsplus_dump_extent(HFSPLUS_I(inode).cached_extents); 441 hfsplus_dump_extent(hip->cached_extents);
431 HFSPLUS_I(inode).flags |= HFSPLUS_FLG_EXT_DIRTY | HFSPLUS_FLG_EXT_NEW; 442 hip->flags |= HFSPLUS_FLG_EXT_DIRTY | HFSPLUS_FLG_EXT_NEW;
432 HFSPLUS_I(inode).cached_start = HFSPLUS_I(inode).alloc_blocks; 443 hip->cached_start = hip->alloc_blocks;
433 HFSPLUS_I(inode).cached_blocks = len; 444 hip->cached_blocks = len;
434 445
435 res = 0; 446 res = 0;
436 goto out; 447 goto out;
@@ -439,13 +450,15 @@ insert_extent:
439void hfsplus_file_truncate(struct inode *inode) 450void hfsplus_file_truncate(struct inode *inode)
440{ 451{
441 struct super_block *sb = inode->i_sb; 452 struct super_block *sb = inode->i_sb;
453 struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
442 struct hfs_find_data fd; 454 struct hfs_find_data fd;
443 u32 alloc_cnt, blk_cnt, start; 455 u32 alloc_cnt, blk_cnt, start;
444 int res; 456 int res;
445 457
446 dprint(DBG_INODE, "truncate: %lu, %Lu -> %Lu\n", inode->i_ino, 458 dprint(DBG_INODE, "truncate: %lu, %Lu -> %Lu\n",
447 (long long)HFSPLUS_I(inode).phys_size, inode->i_size); 459 inode->i_ino, (long long)hip->phys_size, inode->i_size);
448 if (inode->i_size > HFSPLUS_I(inode).phys_size) { 460
461 if (inode->i_size > hip->phys_size) {
449 struct address_space *mapping = inode->i_mapping; 462 struct address_space *mapping = inode->i_mapping;
450 struct page *page; 463 struct page *page;
451 void *fsdata; 464 void *fsdata;
@@ -462,48 +475,48 @@ void hfsplus_file_truncate(struct inode *inode)
462 return; 475 return;
463 mark_inode_dirty(inode); 476 mark_inode_dirty(inode);
464 return; 477 return;
465 } else if (inode->i_size == HFSPLUS_I(inode).phys_size) 478 } else if (inode->i_size == hip->phys_size)
466 return; 479 return;
467 480
468 blk_cnt = (inode->i_size + HFSPLUS_SB(sb)->alloc_blksz - 1) >> 481 blk_cnt = (inode->i_size + HFSPLUS_SB(sb)->alloc_blksz - 1) >>
469 HFSPLUS_SB(sb)->alloc_blksz_shift; 482 HFSPLUS_SB(sb)->alloc_blksz_shift;
470 alloc_cnt = HFSPLUS_I(inode).alloc_blocks; 483 alloc_cnt = hip->alloc_blocks;
471 if (blk_cnt == alloc_cnt) 484 if (blk_cnt == alloc_cnt)
472 goto out; 485 goto out;
473 486
474 mutex_lock(&HFSPLUS_I(inode).extents_lock); 487 mutex_lock(&hip->extents_lock);
475 hfs_find_init(HFSPLUS_SB(sb)->ext_tree, &fd); 488 hfs_find_init(HFSPLUS_SB(sb)->ext_tree, &fd);
476 while (1) { 489 while (1) {
477 if (alloc_cnt == HFSPLUS_I(inode).first_blocks) { 490 if (alloc_cnt == hip->first_blocks) {
478 hfsplus_free_extents(sb, HFSPLUS_I(inode).first_extents, 491 hfsplus_free_extents(sb, hip->first_extents,
479 alloc_cnt, alloc_cnt - blk_cnt); 492 alloc_cnt, alloc_cnt - blk_cnt);
480 hfsplus_dump_extent(HFSPLUS_I(inode).first_extents); 493 hfsplus_dump_extent(hip->first_extents);
481 HFSPLUS_I(inode).first_blocks = blk_cnt; 494 hip->first_blocks = blk_cnt;
482 break; 495 break;
483 } 496 }
484 res = __hfsplus_ext_cache_extent(&fd, inode, alloc_cnt); 497 res = __hfsplus_ext_cache_extent(&fd, inode, alloc_cnt);
485 if (res) 498 if (res)
486 break; 499 break;
487 start = HFSPLUS_I(inode).cached_start; 500 start = hip->cached_start;
488 hfsplus_free_extents(sb, HFSPLUS_I(inode).cached_extents, 501 hfsplus_free_extents(sb, hip->cached_extents,
489 alloc_cnt - start, alloc_cnt - blk_cnt); 502 alloc_cnt - start, alloc_cnt - blk_cnt);
490 hfsplus_dump_extent(HFSPLUS_I(inode).cached_extents); 503 hfsplus_dump_extent(hip->cached_extents);
491 if (blk_cnt > start) { 504 if (blk_cnt > start) {
492 HFSPLUS_I(inode).flags |= HFSPLUS_FLG_EXT_DIRTY; 505 hip->flags |= HFSPLUS_FLG_EXT_DIRTY;
493 break; 506 break;
494 } 507 }
495 alloc_cnt = start; 508 alloc_cnt = start;
496 HFSPLUS_I(inode).cached_start = HFSPLUS_I(inode).cached_blocks = 0; 509 hip->cached_start = hip->cached_blocks = 0;
497 HFSPLUS_I(inode).flags &= ~(HFSPLUS_FLG_EXT_DIRTY | HFSPLUS_FLG_EXT_NEW); 510 hip->flags &= ~(HFSPLUS_FLG_EXT_DIRTY | HFSPLUS_FLG_EXT_NEW);
498 hfs_brec_remove(&fd); 511 hfs_brec_remove(&fd);
499 } 512 }
500 hfs_find_exit(&fd); 513 hfs_find_exit(&fd);
501 mutex_unlock(&HFSPLUS_I(inode).extents_lock); 514 mutex_unlock(&hip->extents_lock);
502 515
503 HFSPLUS_I(inode).alloc_blocks = blk_cnt; 516 hip->alloc_blocks = blk_cnt;
504out: 517out:
505 HFSPLUS_I(inode).phys_size = inode->i_size; 518 hip->phys_size = inode->i_size;
506 HFSPLUS_I(inode).fs_blocks = (inode->i_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits; 519 hip->fs_blocks = (inode->i_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
507 inode_set_bytes(inode, HFSPLUS_I(inode).fs_blocks << sb->s_blocksize_bits); 520 inode_set_bytes(inode, hip->fs_blocks << sb->s_blocksize_bits);
508 mark_inode_dirty(inode); 521 mark_inode_dirty(inode);
509} 522}
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index 55f42b49f0f1..169cef964b51 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -187,8 +187,8 @@ struct hfsplus_inode_info {
187#define HFSPLUS_FLG_EXT_DIRTY 0x0002 187#define HFSPLUS_FLG_EXT_DIRTY 0x0002
188#define HFSPLUS_FLG_EXT_NEW 0x0004 188#define HFSPLUS_FLG_EXT_NEW 0x0004
189 189
190#define HFSPLUS_IS_DATA(inode) (!(HFSPLUS_I(inode).flags & HFSPLUS_FLG_RSRC)) 190#define HFSPLUS_IS_DATA(inode) (!(HFSPLUS_I(inode)->flags & HFSPLUS_FLG_RSRC))
191#define HFSPLUS_IS_RSRC(inode) (HFSPLUS_I(inode).flags & HFSPLUS_FLG_RSRC) 191#define HFSPLUS_IS_RSRC(inode) (HFSPLUS_I(inode)->flags & HFSPLUS_FLG_RSRC)
192 192
193struct hfs_find_data { 193struct hfs_find_data {
194 /* filled by caller */ 194 /* filled by caller */
@@ -379,13 +379,11 @@ static inline struct hfsplus_sb_info *HFSPLUS_SB(struct super_block *sb)
379{ 379{
380 return sb->s_fs_info; 380 return sb->s_fs_info;
381} 381}
382/* 382
383static inline struct hfsplus_inode_info *HFSPLUS_I(struct inode *inode) 383static inline struct hfsplus_inode_info *HFSPLUS_I(struct inode *inode)
384{ 384{
385 return list_entry(inode, struct hfsplus_inode_info, vfs_inode); 385 return list_entry(inode, struct hfsplus_inode_info, vfs_inode);
386} 386}
387*/
388#define HFSPLUS_I(inode) (*list_entry(inode, struct hfsplus_inode_info, vfs_inode))
389 387
390#if 1 388#if 1
391#define hfsplus_kmap(p) ({ struct page *__p = (p); kmap(__p); }) 389#define hfsplus_kmap(p) ({ struct page *__p = (p); kmap(__p); })
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 050eee6c81bd..309defb4f41f 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -36,7 +36,7 @@ static int hfsplus_write_begin(struct file *file, struct address_space *mapping,
36 *pagep = NULL; 36 *pagep = NULL;
37 ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata, 37 ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
38 hfsplus_get_block, 38 hfsplus_get_block,
39 &HFSPLUS_I(mapping->host).phys_size); 39 &HFSPLUS_I(mapping->host)->phys_size);
40 if (unlikely(ret)) { 40 if (unlikely(ret)) {
41 loff_t isize = mapping->host->i_size; 41 loff_t isize = mapping->host->i_size;
42 if (pos + len > isize) 42 if (pos + len > isize)
@@ -172,12 +172,13 @@ static struct dentry *hfsplus_file_lookup(struct inode *dir, struct dentry *dent
172 struct hfs_find_data fd; 172 struct hfs_find_data fd;
173 struct super_block *sb = dir->i_sb; 173 struct super_block *sb = dir->i_sb;
174 struct inode *inode = NULL; 174 struct inode *inode = NULL;
175 struct hfsplus_inode_info *hip;
175 int err; 176 int err;
176 177
177 if (HFSPLUS_IS_RSRC(dir) || strcmp(dentry->d_name.name, "rsrc")) 178 if (HFSPLUS_IS_RSRC(dir) || strcmp(dentry->d_name.name, "rsrc"))
178 goto out; 179 goto out;
179 180
180 inode = HFSPLUS_I(dir).rsrc_inode; 181 inode = HFSPLUS_I(dir)->rsrc_inode;
181 if (inode) 182 if (inode)
182 goto out; 183 goto out;
183 184
@@ -185,10 +186,11 @@ static struct dentry *hfsplus_file_lookup(struct inode *dir, struct dentry *dent
185 if (!inode) 186 if (!inode)
186 return ERR_PTR(-ENOMEM); 187 return ERR_PTR(-ENOMEM);
187 188
189 hip = HFSPLUS_I(inode);
188 inode->i_ino = dir->i_ino; 190 inode->i_ino = dir->i_ino;
189 INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list); 191 INIT_LIST_HEAD(&hip->open_dir_list);
190 mutex_init(&HFSPLUS_I(inode).extents_lock); 192 mutex_init(&hip->extents_lock);
191 HFSPLUS_I(inode).flags = HFSPLUS_FLG_RSRC; 193 hip->flags = HFSPLUS_FLG_RSRC;
192 194
193 hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd); 195 hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
194 err = hfsplus_find_cat(sb, dir->i_ino, &fd); 196 err = hfsplus_find_cat(sb, dir->i_ino, &fd);
@@ -199,8 +201,8 @@ static struct dentry *hfsplus_file_lookup(struct inode *dir, struct dentry *dent
199 iput(inode); 201 iput(inode);
200 return ERR_PTR(err); 202 return ERR_PTR(err);
201 } 203 }
202 HFSPLUS_I(inode).rsrc_inode = dir; 204 hip->rsrc_inode = dir;
203 HFSPLUS_I(dir).rsrc_inode = inode; 205 HFSPLUS_I(dir)->rsrc_inode = inode;
204 igrab(dir); 206 igrab(dir);
205 hlist_add_head(&inode->i_hash, &HFSPLUS_SB(sb)->rsrc_inodes); 207 hlist_add_head(&inode->i_hash, &HFSPLUS_SB(sb)->rsrc_inodes);
206 mark_inode_dirty(inode); 208 mark_inode_dirty(inode);
@@ -231,8 +233,8 @@ static void hfsplus_get_perms(struct inode *inode, struct hfsplus_perm *perms, i
231 mode = S_IFREG | ((S_IRUGO|S_IWUGO) & ~(sbi->umask)); 233 mode = S_IFREG | ((S_IRUGO|S_IWUGO) & ~(sbi->umask));
232 inode->i_mode = mode; 234 inode->i_mode = mode;
233 235
234 HFSPLUS_I(inode).rootflags = perms->rootflags; 236 HFSPLUS_I(inode)->rootflags = perms->rootflags;
235 HFSPLUS_I(inode).userflags = perms->userflags; 237 HFSPLUS_I(inode)->userflags = perms->userflags;
236 if (perms->rootflags & HFSPLUS_FLG_IMMUTABLE) 238 if (perms->rootflags & HFSPLUS_FLG_IMMUTABLE)
237 inode->i_flags |= S_IMMUTABLE; 239 inode->i_flags |= S_IMMUTABLE;
238 else 240 else
@@ -253,20 +255,20 @@ static void hfsplus_set_perms(struct inode *inode, struct hfsplus_perm *perms)
253 perms->rootflags |= HFSPLUS_FLG_APPEND; 255 perms->rootflags |= HFSPLUS_FLG_APPEND;
254 else 256 else
255 perms->rootflags &= ~HFSPLUS_FLG_APPEND; 257 perms->rootflags &= ~HFSPLUS_FLG_APPEND;
256 perms->userflags = HFSPLUS_I(inode).userflags; 258 perms->userflags = HFSPLUS_I(inode)->userflags;
257 perms->mode = cpu_to_be16(inode->i_mode); 259 perms->mode = cpu_to_be16(inode->i_mode);
258 perms->owner = cpu_to_be32(inode->i_uid); 260 perms->owner = cpu_to_be32(inode->i_uid);
259 perms->group = cpu_to_be32(inode->i_gid); 261 perms->group = cpu_to_be32(inode->i_gid);
260 perms->dev = cpu_to_be32(HFSPLUS_I(inode).dev); 262 perms->dev = cpu_to_be32(HFSPLUS_I(inode)->dev);
261} 263}
262 264
263static int hfsplus_file_open(struct inode *inode, struct file *file) 265static int hfsplus_file_open(struct inode *inode, struct file *file)
264{ 266{
265 if (HFSPLUS_IS_RSRC(inode)) 267 if (HFSPLUS_IS_RSRC(inode))
266 inode = HFSPLUS_I(inode).rsrc_inode; 268 inode = HFSPLUS_I(inode)->rsrc_inode;
267 if (!(file->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS) 269 if (!(file->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS)
268 return -EOVERFLOW; 270 return -EOVERFLOW;
269 atomic_inc(&HFSPLUS_I(inode).opencnt); 271 atomic_inc(&HFSPLUS_I(inode)->opencnt);
270 return 0; 272 return 0;
271} 273}
272 274
@@ -275,8 +277,8 @@ static int hfsplus_file_release(struct inode *inode, struct file *file)
275 struct super_block *sb = inode->i_sb; 277 struct super_block *sb = inode->i_sb;
276 278
277 if (HFSPLUS_IS_RSRC(inode)) 279 if (HFSPLUS_IS_RSRC(inode))
278 inode = HFSPLUS_I(inode).rsrc_inode; 280 inode = HFSPLUS_I(inode)->rsrc_inode;
279 if (atomic_dec_and_test(&HFSPLUS_I(inode).opencnt)) { 281 if (atomic_dec_and_test(&HFSPLUS_I(inode)->opencnt)) {
280 mutex_lock(&inode->i_mutex); 282 mutex_lock(&inode->i_mutex);
281 hfsplus_file_truncate(inode); 283 hfsplus_file_truncate(inode);
282 if (inode->i_flags & S_DEAD) { 284 if (inode->i_flags & S_DEAD) {
@@ -362,6 +364,7 @@ struct inode *hfsplus_new_inode(struct super_block *sb, int mode)
362{ 364{
363 struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb); 365 struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
364 struct inode *inode = new_inode(sb); 366 struct inode *inode = new_inode(sb);
367 struct hfsplus_inode_info *hip;
365 368
366 if (!inode) 369 if (!inode)
367 return NULL; 370 return NULL;
@@ -372,19 +375,21 @@ struct inode *hfsplus_new_inode(struct super_block *sb, int mode)
372 inode->i_gid = current_fsgid(); 375 inode->i_gid = current_fsgid();
373 inode->i_nlink = 1; 376 inode->i_nlink = 1;
374 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; 377 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
375 INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list); 378
376 mutex_init(&HFSPLUS_I(inode).extents_lock); 379 hip = HFSPLUS_I(inode);
377 atomic_set(&HFSPLUS_I(inode).opencnt, 0); 380 INIT_LIST_HEAD(&hip->open_dir_list);
378 HFSPLUS_I(inode).flags = 0; 381 mutex_init(&hip->extents_lock);
379 memset(HFSPLUS_I(inode).first_extents, 0, sizeof(hfsplus_extent_rec)); 382 atomic_set(&hip->opencnt, 0);
380 memset(HFSPLUS_I(inode).cached_extents, 0, sizeof(hfsplus_extent_rec)); 383 hip->flags = 0;
381 HFSPLUS_I(inode).alloc_blocks = 0; 384 memset(hip->first_extents, 0, sizeof(hfsplus_extent_rec));
382 HFSPLUS_I(inode).first_blocks = 0; 385 memset(hip->cached_extents, 0, sizeof(hfsplus_extent_rec));
383 HFSPLUS_I(inode).cached_start = 0; 386 hip->alloc_blocks = 0;
384 HFSPLUS_I(inode).cached_blocks = 0; 387 hip->first_blocks = 0;
385 HFSPLUS_I(inode).phys_size = 0; 388 hip->cached_start = 0;
386 HFSPLUS_I(inode).fs_blocks = 0; 389 hip->cached_blocks = 0;
387 HFSPLUS_I(inode).rsrc_inode = NULL; 390 hip->phys_size = 0;
391 hip->fs_blocks = 0;
392 hip->rsrc_inode = NULL;
388 if (S_ISDIR(inode->i_mode)) { 393 if (S_ISDIR(inode->i_mode)) {
389 inode->i_size = 2; 394 inode->i_size = 2;
390 sbi->folder_count++; 395 sbi->folder_count++;
@@ -395,12 +400,12 @@ struct inode *hfsplus_new_inode(struct super_block *sb, int mode)
395 inode->i_op = &hfsplus_file_inode_operations; 400 inode->i_op = &hfsplus_file_inode_operations;
396 inode->i_fop = &hfsplus_file_operations; 401 inode->i_fop = &hfsplus_file_operations;
397 inode->i_mapping->a_ops = &hfsplus_aops; 402 inode->i_mapping->a_ops = &hfsplus_aops;
398 HFSPLUS_I(inode).clump_blocks = sbi->data_clump_blocks; 403 hip->clump_blocks = sbi->data_clump_blocks;
399 } else if (S_ISLNK(inode->i_mode)) { 404 } else if (S_ISLNK(inode->i_mode)) {
400 sbi->file_count++; 405 sbi->file_count++;
401 inode->i_op = &page_symlink_inode_operations; 406 inode->i_op = &page_symlink_inode_operations;
402 inode->i_mapping->a_ops = &hfsplus_aops; 407 inode->i_mapping->a_ops = &hfsplus_aops;
403 HFSPLUS_I(inode).clump_blocks = 1; 408 hip->clump_blocks = 1;
404 } else 409 } else
405 sbi->file_count++; 410 sbi->file_count++;
406 insert_inode_hash(inode); 411 insert_inode_hash(inode);
@@ -436,26 +441,27 @@ void hfsplus_inode_read_fork(struct inode *inode, struct hfsplus_fork_raw *fork)
436{ 441{
437 struct super_block *sb = inode->i_sb; 442 struct super_block *sb = inode->i_sb;
438 struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb); 443 struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
444 struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
439 u32 count; 445 u32 count;
440 int i; 446 int i;
441 447
442 memcpy(&HFSPLUS_I(inode).first_extents, &fork->extents, 448 memcpy(&hip->first_extents, &fork->extents, sizeof(hfsplus_extent_rec));
443 sizeof(hfsplus_extent_rec));
444 for (count = 0, i = 0; i < 8; i++) 449 for (count = 0, i = 0; i < 8; i++)
445 count += be32_to_cpu(fork->extents[i].block_count); 450 count += be32_to_cpu(fork->extents[i].block_count);
446 HFSPLUS_I(inode).first_blocks = count; 451 hip->first_blocks = count;
447 memset(HFSPLUS_I(inode).cached_extents, 0, sizeof(hfsplus_extent_rec)); 452 memset(hip->cached_extents, 0, sizeof(hfsplus_extent_rec));
448 HFSPLUS_I(inode).cached_start = 0; 453 hip->cached_start = 0;
449 HFSPLUS_I(inode).cached_blocks = 0; 454 hip->cached_blocks = 0;
450 455
451 HFSPLUS_I(inode).alloc_blocks = be32_to_cpu(fork->total_blocks); 456 hip->alloc_blocks = be32_to_cpu(fork->total_blocks);
452 inode->i_size = HFSPLUS_I(inode).phys_size = be64_to_cpu(fork->total_size); 457 hip->phys_size = inode->i_size = be64_to_cpu(fork->total_size);
453 HFSPLUS_I(inode).fs_blocks = (inode->i_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits; 458 hip->fs_blocks =
454 inode_set_bytes(inode, HFSPLUS_I(inode).fs_blocks << sb->s_blocksize_bits); 459 (inode->i_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
455 HFSPLUS_I(inode).clump_blocks = 460 inode_set_bytes(inode, hip->fs_blocks << sb->s_blocksize_bits);
461 hip->clump_blocks =
456 be32_to_cpu(fork->clump_size) >> sbi->alloc_blksz_shift; 462 be32_to_cpu(fork->clump_size) >> sbi->alloc_blksz_shift;
457 if (!HFSPLUS_I(inode).clump_blocks) { 463 if (!hip->clump_blocks) {
458 HFSPLUS_I(inode).clump_blocks = HFSPLUS_IS_RSRC(inode) ? 464 hip->clump_blocks = HFSPLUS_IS_RSRC(inode) ?
459 sbi->rsrc_clump_blocks : 465 sbi->rsrc_clump_blocks :
460 sbi->data_clump_blocks; 466 sbi->data_clump_blocks;
461 } 467 }
@@ -463,10 +469,10 @@ void hfsplus_inode_read_fork(struct inode *inode, struct hfsplus_fork_raw *fork)
463 469
464void hfsplus_inode_write_fork(struct inode *inode, struct hfsplus_fork_raw *fork) 470void hfsplus_inode_write_fork(struct inode *inode, struct hfsplus_fork_raw *fork)
465{ 471{
466 memcpy(&fork->extents, &HFSPLUS_I(inode).first_extents, 472 memcpy(&fork->extents, &HFSPLUS_I(inode)->first_extents,
467 sizeof(hfsplus_extent_rec)); 473 sizeof(hfsplus_extent_rec));
468 fork->total_size = cpu_to_be64(inode->i_size); 474 fork->total_size = cpu_to_be64(inode->i_size);
469 fork->total_blocks = cpu_to_be32(HFSPLUS_I(inode).alloc_blocks); 475 fork->total_blocks = cpu_to_be32(HFSPLUS_I(inode)->alloc_blocks);
470} 476}
471 477
472int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd) 478int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
@@ -477,7 +483,7 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
477 483
478 type = hfs_bnode_read_u16(fd->bnode, fd->entryoffset); 484 type = hfs_bnode_read_u16(fd->bnode, fd->entryoffset);
479 485
480 HFSPLUS_I(inode).dev = 0; 486 HFSPLUS_I(inode)->dev = 0;
481 if (type == HFSPLUS_FOLDER) { 487 if (type == HFSPLUS_FOLDER) {
482 struct hfsplus_cat_folder *folder = &entry.folder; 488 struct hfsplus_cat_folder *folder = &entry.folder;
483 489
@@ -491,8 +497,8 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
491 inode->i_atime = hfsp_mt2ut(folder->access_date); 497 inode->i_atime = hfsp_mt2ut(folder->access_date);
492 inode->i_mtime = hfsp_mt2ut(folder->content_mod_date); 498 inode->i_mtime = hfsp_mt2ut(folder->content_mod_date);
493 inode->i_ctime = hfsp_mt2ut(folder->attribute_mod_date); 499 inode->i_ctime = hfsp_mt2ut(folder->attribute_mod_date);
494 HFSPLUS_I(inode).create_date = folder->create_date; 500 HFSPLUS_I(inode)->create_date = folder->create_date;
495 HFSPLUS_I(inode).fs_blocks = 0; 501 HFSPLUS_I(inode)->fs_blocks = 0;
496 inode->i_op = &hfsplus_dir_inode_operations; 502 inode->i_op = &hfsplus_dir_inode_operations;
497 inode->i_fop = &hfsplus_dir_operations; 503 inode->i_fop = &hfsplus_dir_operations;
498 } else if (type == HFSPLUS_FILE) { 504 } else if (type == HFSPLUS_FILE) {
@@ -523,7 +529,7 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
523 inode->i_atime = hfsp_mt2ut(file->access_date); 529 inode->i_atime = hfsp_mt2ut(file->access_date);
524 inode->i_mtime = hfsp_mt2ut(file->content_mod_date); 530 inode->i_mtime = hfsp_mt2ut(file->content_mod_date);
525 inode->i_ctime = hfsp_mt2ut(file->attribute_mod_date); 531 inode->i_ctime = hfsp_mt2ut(file->attribute_mod_date);
526 HFSPLUS_I(inode).create_date = file->create_date; 532 HFSPLUS_I(inode)->create_date = file->create_date;
527 } else { 533 } else {
528 printk(KERN_ERR "hfs: bad catalog entry used to create inode\n"); 534 printk(KERN_ERR "hfs: bad catalog entry used to create inode\n");
529 res = -EIO; 535 res = -EIO;
@@ -538,7 +544,7 @@ int hfsplus_cat_write_inode(struct inode *inode)
538 hfsplus_cat_entry entry; 544 hfsplus_cat_entry entry;
539 545
540 if (HFSPLUS_IS_RSRC(inode)) 546 if (HFSPLUS_IS_RSRC(inode))
541 main_inode = HFSPLUS_I(inode).rsrc_inode; 547 main_inode = HFSPLUS_I(inode)->rsrc_inode;
542 548
543 if (!main_inode->i_nlink) 549 if (!main_inode->i_nlink)
544 return 0; 550 return 0;
@@ -582,9 +588,9 @@ int hfsplus_cat_write_inode(struct inode *inode)
582 sizeof(struct hfsplus_cat_file)); 588 sizeof(struct hfsplus_cat_file));
583 hfsplus_inode_write_fork(inode, &file->data_fork); 589 hfsplus_inode_write_fork(inode, &file->data_fork);
584 if (S_ISREG(inode->i_mode)) 590 if (S_ISREG(inode->i_mode))
585 HFSPLUS_I(inode).dev = inode->i_nlink; 591 HFSPLUS_I(inode)->dev = inode->i_nlink;
586 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) 592 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
587 HFSPLUS_I(inode).dev = kdev_t_to_nr(inode->i_rdev); 593 HFSPLUS_I(inode)->dev = kdev_t_to_nr(inode->i_rdev);
588 hfsplus_set_perms(inode, &file->permissions); 594 hfsplus_set_perms(inode, &file->permissions);
589 if ((file->permissions.rootflags | file->permissions.userflags) & HFSPLUS_FLG_IMMUTABLE) 595 if ((file->permissions.rootflags | file->permissions.userflags) & HFSPLUS_FLG_IMMUTABLE)
590 file->flags |= cpu_to_be16(HFSPLUS_FILE_LOCKED); 596 file->flags |= cpu_to_be16(HFSPLUS_FILE_LOCKED);
diff --git a/fs/hfsplus/ioctl.c b/fs/hfsplus/ioctl.c
index 66dd64b88b2e..c9ac443d202a 100644
--- a/fs/hfsplus/ioctl.c
+++ b/fs/hfsplus/ioctl.c
@@ -23,13 +23,14 @@
23static int hfsplus_ioctl_getflags(struct file *file, int __user *user_flags) 23static int hfsplus_ioctl_getflags(struct file *file, int __user *user_flags)
24{ 24{
25 struct inode *inode = file->f_path.dentry->d_inode; 25 struct inode *inode = file->f_path.dentry->d_inode;
26 struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
26 unsigned int flags = 0; 27 unsigned int flags = 0;
27 28
28 if (HFSPLUS_I(inode).rootflags & HFSPLUS_FLG_IMMUTABLE) 29 if (hip->rootflags & HFSPLUS_FLG_IMMUTABLE)
29 flags |= FS_IMMUTABLE_FL; 30 flags |= FS_IMMUTABLE_FL;
30 if (HFSPLUS_I(inode).rootflags & HFSPLUS_FLG_APPEND) 31 if (hip->rootflags & HFSPLUS_FLG_APPEND)
31 flags |= FS_APPEND_FL; 32 flags |= FS_APPEND_FL;
32 if (HFSPLUS_I(inode).userflags & HFSPLUS_FLG_NODUMP) 33 if (hip->userflags & HFSPLUS_FLG_NODUMP)
33 flags |= FS_NODUMP_FL; 34 flags |= FS_NODUMP_FL;
34 35
35 return put_user(flags, user_flags); 36 return put_user(flags, user_flags);
@@ -38,6 +39,7 @@ static int hfsplus_ioctl_getflags(struct file *file, int __user *user_flags)
38static int hfsplus_ioctl_setflags(struct file *file, int __user *user_flags) 39static int hfsplus_ioctl_setflags(struct file *file, int __user *user_flags)
39{ 40{
40 struct inode *inode = file->f_path.dentry->d_inode; 41 struct inode *inode = file->f_path.dentry->d_inode;
42 struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
41 unsigned int flags; 43 unsigned int flags;
42 int err = 0; 44 int err = 0;
43 45
@@ -58,7 +60,7 @@ static int hfsplus_ioctl_setflags(struct file *file, int __user *user_flags)
58 mutex_lock(&inode->i_mutex); 60 mutex_lock(&inode->i_mutex);
59 61
60 if (flags & (FS_IMMUTABLE_FL|FS_APPEND_FL) || 62 if (flags & (FS_IMMUTABLE_FL|FS_APPEND_FL) ||
61 HFSPLUS_I(inode).rootflags & (HFSPLUS_FLG_IMMUTABLE|HFSPLUS_FLG_APPEND)) { 63 hip->rootflags & (HFSPLUS_FLG_IMMUTABLE|HFSPLUS_FLG_APPEND)) {
62 if (!capable(CAP_LINUX_IMMUTABLE)) { 64 if (!capable(CAP_LINUX_IMMUTABLE)) {
63 err = -EPERM; 65 err = -EPERM;
64 goto out_unlock_inode; 66 goto out_unlock_inode;
@@ -72,22 +74,22 @@ static int hfsplus_ioctl_setflags(struct file *file, int __user *user_flags)
72 } 74 }
73 if (flags & FS_IMMUTABLE_FL) { 75 if (flags & FS_IMMUTABLE_FL) {
74 inode->i_flags |= S_IMMUTABLE; 76 inode->i_flags |= S_IMMUTABLE;
75 HFSPLUS_I(inode).rootflags |= HFSPLUS_FLG_IMMUTABLE; 77 hip->rootflags |= HFSPLUS_FLG_IMMUTABLE;
76 } else { 78 } else {
77 inode->i_flags &= ~S_IMMUTABLE; 79 inode->i_flags &= ~S_IMMUTABLE;
78 HFSPLUS_I(inode).rootflags &= ~HFSPLUS_FLG_IMMUTABLE; 80 hip->rootflags &= ~HFSPLUS_FLG_IMMUTABLE;
79 } 81 }
80 if (flags & FS_APPEND_FL) { 82 if (flags & FS_APPEND_FL) {
81 inode->i_flags |= S_APPEND; 83 inode->i_flags |= S_APPEND;
82 HFSPLUS_I(inode).rootflags |= HFSPLUS_FLG_APPEND; 84 hip->rootflags |= HFSPLUS_FLG_APPEND;
83 } else { 85 } else {
84 inode->i_flags &= ~S_APPEND; 86 inode->i_flags &= ~S_APPEND;
85 HFSPLUS_I(inode).rootflags &= ~HFSPLUS_FLG_APPEND; 87 hip->rootflags &= ~HFSPLUS_FLG_APPEND;
86 } 88 }
87 if (flags & FS_NODUMP_FL) 89 if (flags & FS_NODUMP_FL)
88 HFSPLUS_I(inode).userflags |= HFSPLUS_FLG_NODUMP; 90 hip->userflags |= HFSPLUS_FLG_NODUMP;
89 else 91 else
90 HFSPLUS_I(inode).userflags &= ~HFSPLUS_FLG_NODUMP; 92 hip->userflags &= ~HFSPLUS_FLG_NODUMP;
91 93
92 inode->i_ctime = CURRENT_TIME_SEC; 94 inode->i_ctime = CURRENT_TIME_SEC;
93 mark_inode_dirty(inode); 95 mark_inode_dirty(inode);
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 1bf00b9ecc1a..a7bf89e85b3b 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -33,11 +33,11 @@ struct inode *hfsplus_iget(struct super_block *sb, unsigned long ino)
33 if (!(inode->i_state & I_NEW)) 33 if (!(inode->i_state & I_NEW))
34 return inode; 34 return inode;
35 35
36 INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list); 36 INIT_LIST_HEAD(&HFSPLUS_I(inode)->open_dir_list);
37 mutex_init(&HFSPLUS_I(inode).extents_lock); 37 mutex_init(&HFSPLUS_I(inode)->extents_lock);
38 HFSPLUS_I(inode).flags = 0; 38 HFSPLUS_I(inode)->flags = 0;
39 HFSPLUS_I(inode).rsrc_inode = NULL; 39 HFSPLUS_I(inode)->rsrc_inode = NULL;
40 atomic_set(&HFSPLUS_I(inode).opencnt, 0); 40 atomic_set(&HFSPLUS_I(inode)->opencnt, 0);
41 41
42 if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID) { 42 if (inode->i_ino >= HFSPLUS_FIRSTUSER_CNID) {
43 read_inode: 43 read_inode:
@@ -151,8 +151,8 @@ static void hfsplus_evict_inode(struct inode *inode)
151 truncate_inode_pages(&inode->i_data, 0); 151 truncate_inode_pages(&inode->i_data, 0);
152 end_writeback(inode); 152 end_writeback(inode);
153 if (HFSPLUS_IS_RSRC(inode)) { 153 if (HFSPLUS_IS_RSRC(inode)) {
154 HFSPLUS_I(HFSPLUS_I(inode).rsrc_inode).rsrc_inode = NULL; 154 HFSPLUS_I(HFSPLUS_I(inode)->rsrc_inode)->rsrc_inode = NULL;
155 iput(HFSPLUS_I(inode).rsrc_inode); 155 iput(HFSPLUS_I(inode)->rsrc_inode);
156 } 156 }
157} 157}
158 158
@@ -491,7 +491,7 @@ static struct inode *hfsplus_alloc_inode(struct super_block *sb)
491 491
492static void hfsplus_destroy_inode(struct inode *inode) 492static void hfsplus_destroy_inode(struct inode *inode)
493{ 493{
494 kmem_cache_free(hfsplus_inode_cachep, &HFSPLUS_I(inode)); 494 kmem_cache_free(hfsplus_inode_cachep, HFSPLUS_I(inode));
495} 495}
496 496
497#define HFSPLUS_INODE_SIZE sizeof(struct hfsplus_inode_info) 497#define HFSPLUS_INODE_SIZE sizeof(struct hfsplus_inode_info)