提交 40bf48af 编写于 作者: C Christoph Hellwig

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: NChristoph Hellwig <hch@tuxera.com>
上级 6333816a
...@@ -29,7 +29,7 @@ int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset, u32 *ma ...@@ -29,7 +29,7 @@ int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset, u32 *ma
return size; return size;
dprint(DBG_BITMAP, "block_allocate: %u,%u,%u\n", size, offset, len); dprint(DBG_BITMAP, "block_allocate: %u,%u,%u\n", size, offset, len);
mutex_lock(&HFSPLUS_SB(sb).alloc_file->i_mutex); mutex_lock(&HFSPLUS_SB(sb).alloc_mutex);
mapping = HFSPLUS_SB(sb).alloc_file->i_mapping; mapping = HFSPLUS_SB(sb).alloc_file->i_mapping;
page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS, NULL); page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS, NULL);
if (IS_ERR(page)) { if (IS_ERR(page)) {
...@@ -154,7 +154,7 @@ int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset, u32 *ma ...@@ -154,7 +154,7 @@ int hfsplus_block_allocate(struct super_block *sb, u32 size, u32 offset, u32 *ma
sb->s_dirt = 1; sb->s_dirt = 1;
dprint(DBG_BITMAP, "-> %u,%u\n", start, *max); dprint(DBG_BITMAP, "-> %u,%u\n", start, *max);
out: out:
mutex_unlock(&HFSPLUS_SB(sb).alloc_file->i_mutex); mutex_unlock(&HFSPLUS_SB(sb).alloc_mutex);
return start; return start;
} }
...@@ -175,7 +175,7 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count) ...@@ -175,7 +175,7 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count)
if ((offset + count) > HFSPLUS_SB(sb).total_blocks) if ((offset + count) > HFSPLUS_SB(sb).total_blocks)
return -2; return -2;
mutex_lock(&HFSPLUS_SB(sb).alloc_file->i_mutex); mutex_lock(&HFSPLUS_SB(sb).alloc_mutex);
mapping = HFSPLUS_SB(sb).alloc_file->i_mapping; mapping = HFSPLUS_SB(sb).alloc_file->i_mapping;
pnr = offset / PAGE_CACHE_BITS; pnr = offset / PAGE_CACHE_BITS;
page = read_mapping_page(mapping, pnr, NULL); page = read_mapping_page(mapping, pnr, NULL);
...@@ -226,7 +226,7 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count) ...@@ -226,7 +226,7 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count)
kunmap(page); kunmap(page);
HFSPLUS_SB(sb).free_blocks += len; HFSPLUS_SB(sb).free_blocks += len;
sb->s_dirt = 1; sb->s_dirt = 1;
mutex_unlock(&HFSPLUS_SB(sb).alloc_file->i_mutex); mutex_unlock(&HFSPLUS_SB(sb).alloc_mutex);
return 0; return 0;
} }
...@@ -116,6 +116,9 @@ struct hfsplus_sb_info { ...@@ -116,6 +116,9 @@ struct hfsplus_sb_info {
struct inode *hidden_dir; struct inode *hidden_dir;
struct nls_table *nls; struct nls_table *nls;
/* synchronize block allocations */
struct mutex alloc_mutex;
/* Runtime variables */ /* Runtime variables */
u32 blockoffset; u32 blockoffset;
u32 sect_count; u32 sect_count;
......
...@@ -321,6 +321,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) ...@@ -321,6 +321,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
sb->s_fs_info = sbi; sb->s_fs_info = sbi;
INIT_HLIST_HEAD(&sbi->rsrc_inodes); INIT_HLIST_HEAD(&sbi->rsrc_inodes);
mutex_init(&sbi->alloc_mutex);
hfsplus_fill_defaults(sbi); hfsplus_fill_defaults(sbi);
if (!hfsplus_parse_options(data, sbi)) { if (!hfsplus_parse_options(data, sbi)) {
printk(KERN_ERR "hfs: unable to parse mount options\n"); printk(KERN_ERR "hfs: unable to parse mount options\n");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册