aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hfsplus
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2010-09-30 23:41:39 -0400
committerChristoph Hellwig <hch@lst.de>2010-09-30 23:41:39 -0400
commit40bf48afe92fcea61e7e164f0b2599fba8b88124 (patch)
tree233a48a5e2de1c469804f6745d8fd48e62c78abc /fs/hfsplus
parent6333816ade7e04a96ec0a34a8378c455e4f7c4dd (diff)
hfsplus: introduce alloc_mutex
Use a new per-sb alloc_mutex instead of abusing i_mutex of the alloc_file to protect block allocations. This gets rid of lockdep nesting warnings and prepares for extending the scope of alloc_mutex. Signed-off-by: Christoph Hellwig <hch@tuxera.com>
Diffstat (limited to 'fs/hfsplus')
-rw-r--r--fs/hfsplus/bitmap.c8
-rw-r--r--fs/hfsplus/hfsplus_fs.h3
-rw-r--r--fs/hfsplus/super.c1
3 files changed, 8 insertions, 4 deletions
diff --git a/fs/hfsplus/bitmap.c b/fs/hfsplus/bitmap.c
index ea30afc2a03c..8a781769a901 100644
--- a/fs/hfsplus/bitmap.c
+++ b/fs/hfsplus/bitmap.c
@@ -29,7 +29,7 @@ int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset, u32 *ma
29 return size; 29 return size;
30 30
31 dprint(DBG_BITMAP, "block_allocate: %u,%u,%u\n", size, offset, len); 31 dprint(DBG_BITMAP, "block_allocate: %u,%u,%u\n", size, offset, len);
32 mutex_lock(&HFSPLUS_SB(sb).alloc_file->i_mutex); 32 mutex_lock(&HFSPLUS_SB(sb).alloc_mutex);
33 mapping = HFSPLUS_SB(sb).alloc_file->i_mapping; 33 mapping = HFSPLUS_SB(sb).alloc_file->i_mapping;
34 page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS, NULL); 34 page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS, NULL);
35 if (IS_ERR(page)) { 35 if (IS_ERR(page)) {
@@ -154,7 +154,7 @@ done:
154 sb->s_dirt = 1; 154 sb->s_dirt = 1;
155 dprint(DBG_BITMAP, "-> %u,%u\n", start, *max); 155 dprint(DBG_BITMAP, "-> %u,%u\n", start, *max);
156out: 156out:
157 mutex_unlock(&HFSPLUS_SB(sb).alloc_file->i_mutex); 157 mutex_unlock(&HFSPLUS_SB(sb).alloc_mutex);
158 return start; 158 return start;
159} 159}
160 160
@@ -175,7 +175,7 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count)
175 if ((offset + count) > HFSPLUS_SB(sb).total_blocks) 175 if ((offset + count) > HFSPLUS_SB(sb).total_blocks)
176 return -2; 176 return -2;
177 177
178 mutex_lock(&HFSPLUS_SB(sb).alloc_file->i_mutex); 178 mutex_lock(&HFSPLUS_SB(sb).alloc_mutex);
179 mapping = HFSPLUS_SB(sb).alloc_file->i_mapping; 179 mapping = HFSPLUS_SB(sb).alloc_file->i_mapping;
180 pnr = offset / PAGE_CACHE_BITS; 180 pnr = offset / PAGE_CACHE_BITS;
181 page = read_mapping_page(mapping, pnr, NULL); 181 page = read_mapping_page(mapping, pnr, NULL);
@@ -226,7 +226,7 @@ out:
226 kunmap(page); 226 kunmap(page);
227 HFSPLUS_SB(sb).free_blocks += len; 227 HFSPLUS_SB(sb).free_blocks += len;
228 sb->s_dirt = 1; 228 sb->s_dirt = 1;
229 mutex_unlock(&HFSPLUS_SB(sb).alloc_file->i_mutex); 229 mutex_unlock(&HFSPLUS_SB(sb).alloc_mutex);
230 230
231 return 0; 231 return 0;
232} 232}
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index dc856be3c2b0..df0a6312f0f0 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -116,6 +116,9 @@ struct hfsplus_sb_info {
116 struct inode *hidden_dir; 116 struct inode *hidden_dir;
117 struct nls_table *nls; 117 struct nls_table *nls;
118 118
119 /* synchronize block allocations */
120 struct mutex alloc_mutex;
121
119 /* Runtime variables */ 122 /* Runtime variables */
120 u32 blockoffset; 123 u32 blockoffset;
121 u32 sect_count; 124 u32 sect_count;
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 3b55c050c742..3dc62aa58728 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -321,6 +321,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
321 321
322 sb->s_fs_info = sbi; 322 sb->s_fs_info = sbi;
323 INIT_HLIST_HEAD(&sbi->rsrc_inodes); 323 INIT_HLIST_HEAD(&sbi->rsrc_inodes);
324 mutex_init(&sbi->alloc_mutex);
324 hfsplus_fill_defaults(sbi); 325 hfsplus_fill_defaults(sbi);
325 if (!hfsplus_parse_options(data, sbi)) { 326 if (!hfsplus_parse_options(data, sbi)) {
326 printk(KERN_ERR "hfs: unable to parse mount options\n"); 327 printk(KERN_ERR "hfs: unable to parse mount options\n");