diff mbox

[RFC,-v2,5/9] ext4: sparse annotate the group info semaphore

Message ID 1225733769-23734-5-git-send-email-aneesh.kumar@linux.vnet.ibm.com
State Superseded, archived
Headers show

Commit Message

Aneesh Kumar K.V Nov. 3, 2008, 5:36 p.m. UTC
sparse annotate the group info allocation semaphore

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 fs/ext4/mballoc.c |   28 +++++++++++++++++++++++-----
 1 files changed, 23 insertions(+), 5 deletions(-)

Comments

Theodore Ts'o Nov. 4, 2008, 5:43 p.m. UTC | #1
I changed the description of this patch to be more grammatically
correct:

ext4: Add sparse annotations for the group info semaphore

Hmm...  Why not merge this with patch #3, "ext4: Use
EXT4_GROUP_INFO_NEED_INIT_BIT during resize" where alloc_semp is newly
defined?

      	  	 	     	     	   	- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Aneesh Kumar K.V Nov. 5, 2008, 2:59 p.m. UTC | #2
On Tue, Nov 04, 2008 at 12:43:57PM -0500, Theodore Tso wrote:
> I changed the description of this patch to be more grammatically
> correct:
> 
> ext4: Add sparse annotations for the group info semaphore
> 
> Hmm...  Why not merge this with patch #3, "ext4: Use
> EXT4_GROUP_INFO_NEED_INIT_BIT during resize" where alloc_semp is newly
> defined?
> 

Mostly because I found the error path annotation ugly. It is easier to
fold the patch later than split. I wanted to make sure it is the right
way to annotate.

-aneesh
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 390dc81..34a365e 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -895,6 +895,7 @@  static int ext4_mb_init_cache(struct page *page, char *incore)
 static noinline_for_stack int
 ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
 					struct ext4_buddy *e4b)
+__acquires(e4b->alloc_semp)
 {
 	int blocks_per_page;
 	int block;
@@ -926,6 +927,7 @@  ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
 	 * till we are done with allocation
 	 */
 	down_read(e4b->alloc_semp);
+	__acquire(e4b->alloc_semp);
 
 	/*
 	 * the buddy cache inode stores the block bitmap
@@ -1020,6 +1022,7 @@  ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
 }
 
 static void ext4_mb_release_desc(struct ext4_buddy *e4b)
+__releases(e4b->alloc_semp)
 {
 	if (e4b->bd_bitmap_page)
 		page_cache_release(e4b->bd_bitmap_page);
@@ -1027,6 +1030,7 @@  static void ext4_mb_release_desc(struct ext4_buddy *e4b)
 		page_cache_release(e4b->bd_buddy_page);
 	/* Done with the buddy cache */
 	up_read(e4b->alloc_semp);
+	__release(e4b->alloc_semp);
 }
 
 
@@ -1468,8 +1472,10 @@  static int ext4_mb_try_best_found(struct ext4_allocation_context *ac,
 
 	BUG_ON(ex.fe_len <= 0);
 	err = ext4_mb_load_buddy(ac->ac_sb, group, e4b);
-	if (err)
+	if (err) {
+		__release(e4b->alloc_semp);
 		return err;
+	}
 
 	ext4_lock_group(ac->ac_sb, group);
 	max = mb_find_extent(e4b, 0, ex.fe_start, ex.fe_len, &ex);
@@ -1499,8 +1505,10 @@  static int ext4_mb_find_by_goal(struct ext4_allocation_context *ac,
 		return 0;
 
 	err = ext4_mb_load_buddy(ac->ac_sb, group, e4b);
-	if (err)
+	if (err) {
+		__release(e4b->alloc_semp);
 		return err;
+	}
 
 	ext4_lock_group(ac->ac_sb, group);
 	max = mb_find_extent(e4b, 0, ac->ac_g_ex.fe_start,
@@ -1963,8 +1971,10 @@  ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
 				continue;
 
 			err = ext4_mb_load_buddy(sb, group, &e4b);
-			if (err)
+			if (err) {
+				__release(e4b->alloc_semp);
 				goto out;
+			}
 
 			ext4_lock_group(sb, group);
 			if (!ext4_mb_good_group(ac, group, cr)) {
@@ -2275,6 +2285,7 @@  static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
 		sizeof(struct ext4_group_info);
 	err = ext4_mb_load_buddy(sb, group, &e4b);
 	if (err) {
+		__release(e4b->alloc_semp);
 		seq_printf(seq, "#%-5lu: I/O error\n", group);
 		return 0;
 	}
@@ -3820,6 +3831,7 @@  ext4_mb_discard_group_preallocations(struct super_block *sb,
 
 	err = ext4_mb_load_buddy(sb, group, &e4b);
 	if (err) {
+		__release(e4b->alloc_semp);
 		ext4_error(sb, __func__, "Error in loading buddy "
 				"information for %lu\n", group);
 		put_bh(bitmap_bh);
@@ -3987,6 +3999,7 @@  void ext4_discard_preallocations(struct inode *inode)
 
 		err = ext4_mb_load_buddy(sb, group, &e4b);
 		if (err) {
+			__release(e4b->alloc_semp);
 			ext4_error(sb, __func__, "Error in loading buddy "
 					"information for %lu\n", group);
 			continue;
@@ -4260,6 +4273,7 @@  ext4_mb_discard_lg_preallocations(struct super_block *sb,
 
 		ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, NULL);
 		if (ext4_mb_load_buddy(sb, group, &e4b)) {
+			__release(e4b->alloc_semp);
 			ext4_error(sb, __func__, "Error in loading buddy "
 					"information for %lu\n", group);
 			continue;
@@ -4720,8 +4734,10 @@  void ext4_mb_free_blocks(handle_t *handle, struct inode *inode,
 	}
 
 	err = ext4_mb_load_buddy(sb, block_group, &e4b);
-	if (err)
+	if (err) {
+		__release(e4b->alloc_semp);
 		goto error_return;
+	}
 	if (metadata) {
 		/* blocks being freed are metadata. these blocks shouldn't
 		 * be used until this transaction is committed */
@@ -4805,8 +4821,10 @@  ext4_mb_search_free_extents(struct inode *inode,
 	end = EXT4_BLOCKS_PER_GROUP(sb) - 1;
 
 	err = ext4_mb_load_buddy(sb, group_no, &e4b);
-	if (err)
+	if (err) {
+		__release(e4b->alloc_semp);
 		return err;
+	}
 
 	/* We consider about the boot block if bs = 1k */
 	if (sb->s_blocksize == 1024)