From: Christoph Hellwig <hch@lst.de>
To: viro@zeniv.linux.org.uk, zippel@linux-m68k.org
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH 4/6] hfsplus: introduce alloc_mutex
Date: Sun, 26 Sep 2010 23:20:19 +0200 [thread overview]
Message-ID: <20100926212019.GD6394@lst.de> (raw)
In-Reply-To: <20100926211920.GA6394@lst.de>
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>
Index: linux-2.6/fs/hfsplus/bitmap.c
===================================================================
--- linux-2.6.orig/fs/hfsplus/bitmap.c 2010-09-27 05:23:50.663327792 +0900
+++ linux-2.6/fs/hfsplus/bitmap.c 2010-09-27 05:24:10.656327794 +0900
@@ -29,7 +29,7 @@ int hfsplus_block_allocate(struct super_
return size;
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;
page = read_mapping_page(mapping, offset / PAGE_CACHE_BITS, NULL);
if (IS_ERR(page)) {
@@ -154,7 +154,7 @@ done:
sb->s_dirt = 1;
dprint(DBG_BITMAP, "-> %u,%u\n", start, *max);
out:
- mutex_unlock(&HFSPLUS_SB(sb).alloc_file->i_mutex);
+ mutex_unlock(&HFSPLUS_SB(sb).alloc_mutex);
return start;
}
@@ -175,7 +175,7 @@ int hfsplus_block_free(struct super_bloc
if ((offset + count) > HFSPLUS_SB(sb).total_blocks)
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;
pnr = offset / PAGE_CACHE_BITS;
page = read_mapping_page(mapping, pnr, NULL);
@@ -226,7 +226,7 @@ out:
kunmap(page);
HFSPLUS_SB(sb).free_blocks += len;
sb->s_dirt = 1;
- mutex_unlock(&HFSPLUS_SB(sb).alloc_file->i_mutex);
+ mutex_unlock(&HFSPLUS_SB(sb).alloc_mutex);
return 0;
}
Index: linux-2.6/fs/hfsplus/hfsplus_fs.h
===================================================================
--- linux-2.6.orig/fs/hfsplus/hfsplus_fs.h 2010-09-27 05:22:44.791327791 +0900
+++ linux-2.6/fs/hfsplus/hfsplus_fs.h 2010-09-27 05:23:22.752327920 +0900
@@ -116,6 +116,9 @@ struct hfsplus_sb_info {
struct inode *hidden_dir;
struct nls_table *nls;
+ /* synchronize block allocations */
+ struct mutex alloc_mutex;
+
/* Runtime variables */
u32 blockoffset;
u32 sect_count;
Index: linux-2.6/fs/hfsplus/super.c
===================================================================
--- linux-2.6.orig/fs/hfsplus/super.c 2010-09-27 05:23:26.520327791 +0900
+++ linux-2.6/fs/hfsplus/super.c 2010-09-27 05:23:46.730327733 +0900
@@ -321,6 +321,7 @@ static int hfsplus_fill_super(struct sup
sb->s_fs_info = sbi;
INIT_HLIST_HEAD(&sbi->rsrc_inodes);
+ mutex_init(&sbi->alloc_mutex);
hfsplus_fill_defaults(sbi);
if (!hfsplus_parse_options(data, sbi)) {
printk(KERN_ERR "hfs: unable to parse mount options\n");
next prev parent reply other threads:[~2010-09-26 21:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-26 21:19 [PATCH 1/6] hfsplus: fix BKL leak in hfsplus_ioctl Christoph Hellwig
2010-09-26 21:19 ` [PATCH 2/6] hfsplus: split hfsplus_ioctl Christoph Hellwig
2010-09-26 21:20 ` [PATCH 3/6] hfsplus: protect setflags using i_mutex Christoph Hellwig
2010-09-26 21:20 ` Christoph Hellwig [this message]
2010-09-26 21:20 ` [PATCH 5/6] hfsplus: use alloc_mutex in hfsplus_sync_fs Christoph Hellwig
2010-09-26 21:20 ` [PATCH 5/6] hfsplus: remove BKL from hfsplus_put_super Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100926212019.GD6394@lst.de \
--to=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=zippel@linux-m68k.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).