aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/hfsplus/extents.c20
-rw-r--r--fs/hfsplus/hfsplus_fs.h18
-rw-r--r--fs/hfsplus/inode.c9
-rw-r--r--fs/hfsplus/super.c1
4 files changed, 29 insertions, 19 deletions
diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c
index 0c9cb1820a52..06b4fc3151a3 100644
--- a/fs/hfsplus/extents.c
+++ b/fs/hfsplus/extents.c
@@ -95,24 +95,24 @@ static void __hfsplus_ext_write_extent(struct inode *inode, struct hfs_find_data
95 HFSPLUS_TYPE_RSRC : HFSPLUS_TYPE_DATA); 95 HFSPLUS_TYPE_RSRC : HFSPLUS_TYPE_DATA);
96 96
97 res = hfs_brec_find(fd); 97 res = hfs_brec_find(fd);
98 if (hip->flags & HFSPLUS_FLG_EXT_NEW) { 98 if (hip->extent_state & HFSPLUS_EXT_NEW) {
99 if (res != -ENOENT) 99 if (res != -ENOENT)
100 return; 100 return;
101 hfs_brec_insert(fd, hip->cached_extents, 101 hfs_brec_insert(fd, hip->cached_extents,
102 sizeof(hfsplus_extent_rec)); 102 sizeof(hfsplus_extent_rec));
103 hip->flags &= ~(HFSPLUS_FLG_EXT_DIRTY | HFSPLUS_FLG_EXT_NEW); 103 hip->extent_state &= ~(HFSPLUS_EXT_DIRTY | HFSPLUS_EXT_NEW);
104 } else { 104 } else {
105 if (res) 105 if (res)
106 return; 106 return;
107 hfs_bnode_write(fd->bnode, hip->cached_extents, 107 hfs_bnode_write(fd->bnode, hip->cached_extents,
108 fd->entryoffset, fd->entrylength); 108 fd->entryoffset, fd->entrylength);
109 hip->flags &= ~HFSPLUS_FLG_EXT_DIRTY; 109 hip->extent_state &= ~HFSPLUS_EXT_DIRTY;
110 } 110 }
111} 111}
112 112
113static void hfsplus_ext_write_extent_locked(struct inode *inode) 113static void hfsplus_ext_write_extent_locked(struct inode *inode)
114{ 114{
115 if (HFSPLUS_I(inode)->flags & HFSPLUS_FLG_EXT_DIRTY) { 115 if (HFSPLUS_I(inode)->extent_state & HFSPLUS_EXT_DIRTY) {
116 struct hfs_find_data fd; 116 struct hfs_find_data fd;
117 117
118 hfs_find_init(HFSPLUS_SB(inode->i_sb)->ext_tree, &fd); 118 hfs_find_init(HFSPLUS_SB(inode->i_sb)->ext_tree, &fd);
@@ -155,7 +155,7 @@ static inline int __hfsplus_ext_cache_extent(struct hfs_find_data *fd, struct in
155 155
156 WARN_ON(!mutex_is_locked(&hip->extents_lock)); 156 WARN_ON(!mutex_is_locked(&hip->extents_lock));
157 157
158 if (hip->flags & HFSPLUS_FLG_EXT_DIRTY) 158 if (hip->extent_state & HFSPLUS_EXT_DIRTY)
159 __hfsplus_ext_write_extent(inode, fd); 159 __hfsplus_ext_write_extent(inode, fd);
160 160
161 res = __hfsplus_ext_read_extent(fd, hip->cached_extents, inode->i_ino, 161 res = __hfsplus_ext_read_extent(fd, hip->cached_extents, inode->i_ino,
@@ -167,7 +167,7 @@ static inline int __hfsplus_ext_cache_extent(struct hfs_find_data *fd, struct in
167 hip->cached_blocks = hfsplus_ext_block_count(hip->cached_extents); 167 hip->cached_blocks = hfsplus_ext_block_count(hip->cached_extents);
168 } else { 168 } else {
169 hip->cached_start = hip->cached_blocks = 0; 169 hip->cached_start = hip->cached_blocks = 0;
170 hip->flags &= ~(HFSPLUS_FLG_EXT_DIRTY | HFSPLUS_FLG_EXT_NEW); 170 hip->extent_state &= ~(HFSPLUS_EXT_DIRTY | HFSPLUS_EXT_NEW);
171 } 171 }
172 return res; 172 return res;
173} 173}
@@ -429,7 +429,7 @@ int hfsplus_file_extend(struct inode *inode)
429 start, len); 429 start, len);
430 if (!res) { 430 if (!res) {
431 hfsplus_dump_extent(hip->cached_extents); 431 hfsplus_dump_extent(hip->cached_extents);
432 hip->flags |= HFSPLUS_FLG_EXT_DIRTY; 432 hip->extent_state |= HFSPLUS_EXT_DIRTY;
433 hip->cached_blocks += len; 433 hip->cached_blocks += len;
434 } else if (res == -ENOSPC) 434 } else if (res == -ENOSPC)
435 goto insert_extent; 435 goto insert_extent;
@@ -450,7 +450,7 @@ insert_extent:
450 hip->cached_extents[0].start_block = cpu_to_be32(start); 450 hip->cached_extents[0].start_block = cpu_to_be32(start);
451 hip->cached_extents[0].block_count = cpu_to_be32(len); 451 hip->cached_extents[0].block_count = cpu_to_be32(len);
452 hfsplus_dump_extent(hip->cached_extents); 452 hfsplus_dump_extent(hip->cached_extents);
453 hip->flags |= HFSPLUS_FLG_EXT_DIRTY | HFSPLUS_FLG_EXT_NEW; 453 hip->extent_state |= HFSPLUS_EXT_DIRTY | HFSPLUS_EXT_NEW;
454 hip->cached_start = hip->alloc_blocks; 454 hip->cached_start = hip->alloc_blocks;
455 hip->cached_blocks = len; 455 hip->cached_blocks = len;
456 456
@@ -513,12 +513,12 @@ void hfsplus_file_truncate(struct inode *inode)
513 alloc_cnt - start, alloc_cnt - blk_cnt); 513 alloc_cnt - start, alloc_cnt - blk_cnt);
514 hfsplus_dump_extent(hip->cached_extents); 514 hfsplus_dump_extent(hip->cached_extents);
515 if (blk_cnt > start) { 515 if (blk_cnt > start) {
516 hip->flags |= HFSPLUS_FLG_EXT_DIRTY; 516 hip->extent_state |= HFSPLUS_EXT_DIRTY;
517 break; 517 break;
518 } 518 }
519 alloc_cnt = start; 519 alloc_cnt = start;
520 hip->cached_start = hip->cached_blocks = 0; 520 hip->cached_start = hip->cached_blocks = 0;
521 hip->flags &= ~(HFSPLUS_FLG_EXT_DIRTY | HFSPLUS_FLG_EXT_NEW); 521 hip->extent_state &= ~(HFSPLUS_EXT_DIRTY | HFSPLUS_EXT_NEW);
522 hfs_brec_remove(&fd); 522 hfs_brec_remove(&fd);
523 } 523 }
524 hfs_find_exit(&fd); 524 hfs_find_exit(&fd);
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index 625549579e9e..9889d0033b8f 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -171,7 +171,7 @@ struct hfsplus_inode_info {
171 u32 cached_blocks; 171 u32 cached_blocks;
172 hfsplus_extent_rec first_extents; 172 hfsplus_extent_rec first_extents;
173 hfsplus_extent_rec cached_extents; 173 hfsplus_extent_rec cached_extents;
174 unsigned long flags; 174 unsigned int extent_state;
175 struct mutex extents_lock; 175 struct mutex extents_lock;
176 176
177 /* 177 /*
@@ -186,6 +186,11 @@ struct hfsplus_inode_info {
186 u32 linkid; 186 u32 linkid;
187 187
188 /* 188 /*
189 * Accessed using atomic bitops.
190 */
191 unsigned long flags;
192
193 /*
189 * Protected by i_mutex. 194 * Protected by i_mutex.
190 */ 195 */
191 sector_t fs_blocks; 196 sector_t fs_blocks;
@@ -196,12 +201,13 @@ struct hfsplus_inode_info {
196 struct inode vfs_inode; 201 struct inode vfs_inode;
197}; 202};
198 203
199#define HFSPLUS_FLG_RSRC 0x0001 204#define HFSPLUS_EXT_DIRTY 0x0001
200#define HFSPLUS_FLG_EXT_DIRTY 0x0002 205#define HFSPLUS_EXT_NEW 0x0002
201#define HFSPLUS_FLG_EXT_NEW 0x0004 206
207#define HFSPLUS_I_RSRC 0 /* represents a resource fork */
202 208
203#define HFSPLUS_IS_DATA(inode) (!(HFSPLUS_I(inode)->flags & HFSPLUS_FLG_RSRC)) 209#define HFSPLUS_IS_RSRC(inode) \
204#define HFSPLUS_IS_RSRC(inode) (HFSPLUS_I(inode)->flags & HFSPLUS_FLG_RSRC) 210 test_bit(HFSPLUS_I_RSRC, &HFSPLUS_I(inode)->flags)
205 211
206struct hfs_find_data { 212struct hfs_find_data {
207 /* filled by caller */ 213 /* filled by caller */
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 8cd8dc2e7fdd..0946e2cdca5e 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -190,7 +190,9 @@ static struct dentry *hfsplus_file_lookup(struct inode *dir, struct dentry *dent
190 inode->i_ino = dir->i_ino; 190 inode->i_ino = dir->i_ino;
191 INIT_LIST_HEAD(&hip->open_dir_list); 191 INIT_LIST_HEAD(&hip->open_dir_list);
192 mutex_init(&hip->extents_lock); 192 mutex_init(&hip->extents_lock);
193 hip->flags = HFSPLUS_FLG_RSRC; 193 hip->extent_state = 0;
194 hip->flags = 0;
195 set_bit(HFSPLUS_I_RSRC, &hip->flags);
194 196
195 hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd); 197 hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
196 err = hfsplus_find_cat(sb, dir->i_ino, &fd); 198 err = hfsplus_find_cat(sb, dir->i_ino, &fd);
@@ -369,6 +371,7 @@ struct inode *hfsplus_new_inode(struct super_block *sb, int mode)
369 INIT_LIST_HEAD(&hip->open_dir_list); 371 INIT_LIST_HEAD(&hip->open_dir_list);
370 mutex_init(&hip->extents_lock); 372 mutex_init(&hip->extents_lock);
371 atomic_set(&hip->opencnt, 0); 373 atomic_set(&hip->opencnt, 0);
374 hip->extent_state = 0;
372 hip->flags = 0; 375 hip->flags = 0;
373 memset(hip->first_extents, 0, sizeof(hfsplus_extent_rec)); 376 memset(hip->first_extents, 0, sizeof(hfsplus_extent_rec));
374 memset(hip->cached_extents, 0, sizeof(hfsplus_extent_rec)); 377 memset(hip->cached_extents, 0, sizeof(hfsplus_extent_rec));
@@ -498,8 +501,8 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
498 hfs_bnode_read(fd->bnode, &entry, fd->entryoffset, 501 hfs_bnode_read(fd->bnode, &entry, fd->entryoffset,
499 sizeof(struct hfsplus_cat_file)); 502 sizeof(struct hfsplus_cat_file));
500 503
501 hfsplus_inode_read_fork(inode, HFSPLUS_IS_DATA(inode) ? 504 hfsplus_inode_read_fork(inode, HFSPLUS_IS_RSRC(inode) ?
502 &file->data_fork : &file->rsrc_fork); 505 &file->rsrc_fork : &file->data_fork);
503 hfsplus_get_perms(inode, &file->permissions, 0); 506 hfsplus_get_perms(inode, &file->permissions, 0);
504 inode->i_nlink = 1; 507 inode->i_nlink = 1;
505 if (S_ISREG(inode->i_mode)) { 508 if (S_ISREG(inode->i_mode)) {
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 56e6cf80c5e0..985423728e1d 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -66,6 +66,7 @@ struct inode *hfsplus_iget(struct super_block *sb, unsigned long ino)
66 INIT_LIST_HEAD(&HFSPLUS_I(inode)->open_dir_list); 66 INIT_LIST_HEAD(&HFSPLUS_I(inode)->open_dir_list);
67 mutex_init(&HFSPLUS_I(inode)->extents_lock); 67 mutex_init(&HFSPLUS_I(inode)->extents_lock);
68 HFSPLUS_I(inode)->flags = 0; 68 HFSPLUS_I(inode)->flags = 0;
69 HFSPLUS_I(inode)->extent_state = 0;
69 HFSPLUS_I(inode)->rsrc_inode = NULL; 70 HFSPLUS_I(inode)->rsrc_inode = NULL;
70 atomic_set(&HFSPLUS_I(inode)->opencnt, 0); 71 atomic_set(&HFSPLUS_I(inode)->opencnt, 0);
71 72