diff options
Diffstat (limited to 'fs/hfsplus/extents.c')
-rw-r--r-- | fs/hfsplus/extents.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c index 0022eec63cda..181969814344 100644 --- a/fs/hfsplus/extents.c +++ b/fs/hfsplus/extents.c | |||
@@ -108,7 +108,7 @@ void hfsplus_ext_write_extent(struct inode *inode) | |||
108 | if (HFSPLUS_I(inode).flags & HFSPLUS_FLG_EXT_DIRTY) { | 108 | if (HFSPLUS_I(inode).flags & HFSPLUS_FLG_EXT_DIRTY) { |
109 | struct hfs_find_data fd; | 109 | struct hfs_find_data fd; |
110 | 110 | ||
111 | hfs_find_init(HFSPLUS_SB(inode->i_sb).ext_tree, &fd); | 111 | hfs_find_init(HFSPLUS_SB(inode->i_sb)->ext_tree, &fd); |
112 | __hfsplus_ext_write_extent(inode, &fd); | 112 | __hfsplus_ext_write_extent(inode, &fd); |
113 | hfs_find_exit(&fd); | 113 | hfs_find_exit(&fd); |
114 | } | 114 | } |
@@ -162,7 +162,7 @@ static int hfsplus_ext_read_extent(struct inode *inode, u32 block) | |||
162 | block < HFSPLUS_I(inode).cached_start + HFSPLUS_I(inode).cached_blocks) | 162 | block < HFSPLUS_I(inode).cached_start + HFSPLUS_I(inode).cached_blocks) |
163 | return 0; | 163 | return 0; |
164 | 164 | ||
165 | hfs_find_init(HFSPLUS_SB(inode->i_sb).ext_tree, &fd); | 165 | hfs_find_init(HFSPLUS_SB(inode->i_sb)->ext_tree, &fd); |
166 | res = __hfsplus_ext_cache_extent(&fd, inode, block); | 166 | res = __hfsplus_ext_cache_extent(&fd, inode, block); |
167 | hfs_find_exit(&fd); | 167 | hfs_find_exit(&fd); |
168 | return res; | 168 | return res; |
@@ -172,16 +172,15 @@ static int hfsplus_ext_read_extent(struct inode *inode, u32 block) | |||
172 | int hfsplus_get_block(struct inode *inode, sector_t iblock, | 172 | int hfsplus_get_block(struct inode *inode, sector_t iblock, |
173 | struct buffer_head *bh_result, int create) | 173 | struct buffer_head *bh_result, int create) |
174 | { | 174 | { |
175 | struct super_block *sb; | 175 | struct super_block *sb = inode->i_sb; |
176 | struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb); | ||
176 | int res = -EIO; | 177 | int res = -EIO; |
177 | u32 ablock, dblock, mask; | 178 | u32 ablock, dblock, mask; |
178 | int shift; | 179 | int shift; |
179 | 180 | ||
180 | sb = inode->i_sb; | ||
181 | |||
182 | /* Convert inode block to disk allocation block */ | 181 | /* Convert inode block to disk allocation block */ |
183 | shift = HFSPLUS_SB(sb).alloc_blksz_shift - sb->s_blocksize_bits; | 182 | shift = sbi->alloc_blksz_shift - sb->s_blocksize_bits; |
184 | ablock = iblock >> HFSPLUS_SB(sb).fs_shift; | 183 | ablock = iblock >> sbi->fs_shift; |
185 | 184 | ||
186 | if (iblock >= HFSPLUS_I(inode).fs_blocks) { | 185 | if (iblock >= HFSPLUS_I(inode).fs_blocks) { |
187 | if (iblock > HFSPLUS_I(inode).fs_blocks || !create) | 186 | if (iblock > HFSPLUS_I(inode).fs_blocks || !create) |
@@ -215,8 +214,8 @@ int hfsplus_get_block(struct inode *inode, sector_t iblock, | |||
215 | 214 | ||
216 | done: | 215 | done: |
217 | dprint(DBG_EXTENT, "get_block(%lu): %llu - %u\n", inode->i_ino, (long long)iblock, dblock); | 216 | dprint(DBG_EXTENT, "get_block(%lu): %llu - %u\n", inode->i_ino, (long long)iblock, dblock); |
218 | mask = (1 << HFSPLUS_SB(sb).fs_shift) - 1; | 217 | mask = (1 << sbi->fs_shift) - 1; |
219 | map_bh(bh_result, sb, (dblock << HFSPLUS_SB(sb).fs_shift) + HFSPLUS_SB(sb).blockoffset + (iblock & mask)); | 218 | map_bh(bh_result, sb, (dblock << sbi->fs_shift) + sbi->blockoffset + (iblock & mask)); |
220 | if (create) { | 219 | if (create) { |
221 | set_buffer_new(bh_result); | 220 | set_buffer_new(bh_result); |
222 | HFSPLUS_I(inode).phys_size += sb->s_blocksize; | 221 | HFSPLUS_I(inode).phys_size += sb->s_blocksize; |
@@ -327,7 +326,7 @@ int hfsplus_free_fork(struct super_block *sb, u32 cnid, struct hfsplus_fork_raw | |||
327 | if (total_blocks == blocks) | 326 | if (total_blocks == blocks) |
328 | return 0; | 327 | return 0; |
329 | 328 | ||
330 | hfs_find_init(HFSPLUS_SB(sb).ext_tree, &fd); | 329 | hfs_find_init(HFSPLUS_SB(sb)->ext_tree, &fd); |
331 | do { | 330 | do { |
332 | res = __hfsplus_ext_read_extent(&fd, ext_entry, cnid, | 331 | res = __hfsplus_ext_read_extent(&fd, ext_entry, cnid, |
333 | total_blocks, type); | 332 | total_blocks, type); |
@@ -348,13 +347,16 @@ int hfsplus_free_fork(struct super_block *sb, u32 cnid, struct hfsplus_fork_raw | |||
348 | int hfsplus_file_extend(struct inode *inode) | 347 | int hfsplus_file_extend(struct inode *inode) |
349 | { | 348 | { |
350 | struct super_block *sb = inode->i_sb; | 349 | struct super_block *sb = inode->i_sb; |
350 | struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb); | ||
351 | u32 start, len, goal; | 351 | u32 start, len, goal; |
352 | int res; | 352 | int res; |
353 | 353 | ||
354 | if (HFSPLUS_SB(sb).alloc_file->i_size * 8 < HFSPLUS_SB(sb).total_blocks - HFSPLUS_SB(sb).free_blocks + 8) { | 354 | if (sbi->alloc_file->i_size * 8 < |
355 | sbi->total_blocks - sbi->free_blocks + 8) { | ||
355 | // extend alloc file | 356 | // extend alloc file |
356 | printk(KERN_ERR "hfs: extend alloc file! (%Lu,%u,%u)\n", HFSPLUS_SB(sb).alloc_file->i_size * 8, | 357 | printk(KERN_ERR "hfs: extend alloc file! (%Lu,%u,%u)\n", |
357 | HFSPLUS_SB(sb).total_blocks, HFSPLUS_SB(sb).free_blocks); | 358 | sbi->alloc_file->i_size * 8, |
359 | sbi->total_blocks, sbi->free_blocks); | ||
358 | return -ENOSPC; | 360 | return -ENOSPC; |
359 | } | 361 | } |
360 | 362 | ||
@@ -369,8 +371,8 @@ int hfsplus_file_extend(struct inode *inode) | |||
369 | } | 371 | } |
370 | 372 | ||
371 | len = HFSPLUS_I(inode).clump_blocks; | 373 | len = HFSPLUS_I(inode).clump_blocks; |
372 | start = hfsplus_block_allocate(sb, HFSPLUS_SB(sb).total_blocks, goal, &len); | 374 | start = hfsplus_block_allocate(sb, sbi->total_blocks, goal, &len); |
373 | if (start >= HFSPLUS_SB(sb).total_blocks) { | 375 | if (start >= sbi->total_blocks) { |
374 | start = hfsplus_block_allocate(sb, goal, 0, &len); | 376 | start = hfsplus_block_allocate(sb, goal, 0, &len); |
375 | if (start >= goal) { | 377 | if (start >= goal) { |
376 | res = -ENOSPC; | 378 | res = -ENOSPC; |
@@ -463,13 +465,14 @@ void hfsplus_file_truncate(struct inode *inode) | |||
463 | } else if (inode->i_size == HFSPLUS_I(inode).phys_size) | 465 | } else if (inode->i_size == HFSPLUS_I(inode).phys_size) |
464 | return; | 466 | return; |
465 | 467 | ||
466 | blk_cnt = (inode->i_size + HFSPLUS_SB(sb).alloc_blksz - 1) >> HFSPLUS_SB(sb).alloc_blksz_shift; | 468 | blk_cnt = (inode->i_size + HFSPLUS_SB(sb)->alloc_blksz - 1) >> |
469 | HFSPLUS_SB(sb)->alloc_blksz_shift; | ||
467 | alloc_cnt = HFSPLUS_I(inode).alloc_blocks; | 470 | alloc_cnt = HFSPLUS_I(inode).alloc_blocks; |
468 | if (blk_cnt == alloc_cnt) | 471 | if (blk_cnt == alloc_cnt) |
469 | goto out; | 472 | goto out; |
470 | 473 | ||
471 | mutex_lock(&HFSPLUS_I(inode).extents_lock); | 474 | mutex_lock(&HFSPLUS_I(inode).extents_lock); |
472 | hfs_find_init(HFSPLUS_SB(sb).ext_tree, &fd); | 475 | hfs_find_init(HFSPLUS_SB(sb)->ext_tree, &fd); |
473 | while (1) { | 476 | while (1) { |
474 | if (alloc_cnt == HFSPLUS_I(inode).first_blocks) { | 477 | if (alloc_cnt == HFSPLUS_I(inode).first_blocks) { |
475 | hfsplus_free_extents(sb, HFSPLUS_I(inode).first_extents, | 478 | hfsplus_free_extents(sb, HFSPLUS_I(inode).first_extents, |