diff options
Diffstat (limited to 'fs/hfsplus/bitmap.c')
| -rw-r--r-- | fs/hfsplus/bitmap.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/fs/hfsplus/bitmap.c b/fs/hfsplus/bitmap.c index ea30afc2a03c..ad57f5991eb1 100644 --- a/fs/hfsplus/bitmap.c +++ b/fs/hfsplus/bitmap.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | 17 | ||
| 18 | int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset, u32 *max) | 18 | int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset, u32 *max) |
| 19 | { | 19 | { |
| 20 | struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb); | ||
| 20 | struct page *page; | 21 | struct page *page; |
| 21 | struct address_space *mapping; | 22 | struct address_space *mapping; |
| 22 | __be32 *pptr, *curr, *end; | 23 | __be32 *pptr, *curr, *end; |
| @@ -29,8 +30,8 @@ int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset, u32 *ma | |||
| 29 | return size; | 30 | return size; |
| 30 | 31 | ||
| 31 | dprint(DBG_BITMAP, "block_allocate: %u,%u,%u\n", size, offset, len); | 32 | dprint(DBG_BITMAP, "block_allocate: %u,%u,%u\n", size, offset, len); |
| 32 | mutex_lock(&HFSPLUS_SB(sb).alloc_file->i_mutex); | 33 | mutex_lock(&sbi->alloc_mutex); |
| 33 | mapping = HFSPLUS_SB(sb).alloc_file->i_mapping; | 34 | mapping = sbi->alloc_file->i_mapping; |
| 34 | page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS, NULL); | 35 | page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS, NULL); |
| 35 | if (IS_ERR(page)) { | 36 | if (IS_ERR(page)) { |
| 36 | start = size; | 37 | start = size; |
| @@ -150,16 +151,17 @@ done: | |||
| 150 | set_page_dirty(page); | 151 | set_page_dirty(page); |
| 151 | kunmap(page); | 152 | kunmap(page); |
| 152 | *max = offset + (curr - pptr) * 32 + i - start; | 153 | *max = offset + (curr - pptr) * 32 + i - start; |
| 153 | HFSPLUS_SB(sb).free_blocks -= *max; | 154 | sbi->free_blocks -= *max; |
| 154 | sb->s_dirt = 1; | 155 | sb->s_dirt = 1; |
| 155 | dprint(DBG_BITMAP, "-> %u,%u\n", start, *max); | 156 | dprint(DBG_BITMAP, "-> %u,%u\n", start, *max); |
| 156 | out: | 157 | out: |
| 157 | mutex_unlock(&HFSPLUS_SB(sb).alloc_file->i_mutex); | 158 | mutex_unlock(&sbi->alloc_mutex); |
| 158 | return start; | 159 | return start; |
| 159 | } | 160 | } |
| 160 | 161 | ||
| 161 | int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count) | 162 | int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count) |
| 162 | { | 163 | { |
| 164 | struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb); | ||
| 163 | struct page *page; | 165 | struct page *page; |
| 164 | struct address_space *mapping; | 166 | struct address_space *mapping; |
| 165 | __be32 *pptr, *curr, *end; | 167 | __be32 *pptr, *curr, *end; |
| @@ -172,11 +174,11 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count) | |||
| 172 | 174 | ||
| 173 | dprint(DBG_BITMAP, "block_free: %u,%u\n", offset, count); | 175 | dprint(DBG_BITMAP, "block_free: %u,%u\n", offset, count); |
| 174 | /* are all of the bits in range? */ | 176 | /* are all of the bits in range? */ |
| 175 | if ((offset + count) > HFSPLUS_SB(sb).total_blocks) | 177 | if ((offset + count) > sbi->total_blocks) |
| 176 | return -2; | 178 | return -2; |
| 177 | 179 | ||
| 178 | mutex_lock(&HFSPLUS_SB(sb).alloc_file->i_mutex); | 180 | mutex_lock(&sbi->alloc_mutex); |
| 179 | mapping = HFSPLUS_SB(sb).alloc_file->i_mapping; | 181 | mapping = sbi->alloc_file->i_mapping; |
| 180 | pnr = offset / PAGE_CACHE_BITS; | 182 | pnr = offset / PAGE_CACHE_BITS; |
| 181 | page = read_mapping_page(mapping, pnr, NULL); | 183 | page = read_mapping_page(mapping, pnr, NULL); |
| 182 | pptr = kmap(page); | 184 | pptr = kmap(page); |
| @@ -224,9 +226,9 @@ done: | |||
| 224 | out: | 226 | out: |
| 225 | set_page_dirty(page); | 227 | set_page_dirty(page); |
| 226 | kunmap(page); | 228 | kunmap(page); |
| 227 | HFSPLUS_SB(sb).free_blocks += len; | 229 | sbi->free_blocks += len; |
| 228 | sb->s_dirt = 1; | 230 | sb->s_dirt = 1; |
| 229 | mutex_unlock(&HFSPLUS_SB(sb).alloc_file->i_mutex); | 231 | mutex_unlock(&sbi->alloc_mutex); |
| 230 | 232 | ||
| 231 | return 0; | 233 | return 0; |
| 232 | } | 234 | } |
