Add patch SR-ext4-resize-mark-new-group-EXT_BG_INODE_ZEROED.patch
[ext4-patch-queue/an.git] / aneesh-5-sparse-annotate-the-group-info-semaphore
blob5d91ae26ef8a993f3599547c5e0b3e5baaeba384
1 ext4: Add sparse annotations for the group info semaphore
3 From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
5 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
6 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
7 ---
8  fs/ext4/mballoc.c |   24 ++++++++++++++++++++----
9  1 files changed, 20 insertions(+), 4 deletions(-)
11 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
12 index 9211397..f4753bd 100644
13 --- a/fs/ext4/mballoc.c
14 +++ b/fs/ext4/mballoc.c
15 @@ -895,6 +895,7 @@ static int ext4_mb_init_cache(struct page *page, char *incore)
16  static noinline_for_stack int
17  ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
18                                         struct ext4_buddy *e4b)
19 +__acquires(e4b->alloc_semp)
20  {
21         int blocks_per_page;
22         int block;
23 @@ -926,6 +927,7 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
24          * till we are done with allocation
25          */
26         down_read(e4b->alloc_semp);
27 +       __acquire(e4b->alloc_semp);
29         /*
30          * the buddy cache inode stores the block bitmap
31 @@ -1020,6 +1022,7 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
32  }
34  static void ext4_mb_release_desc(struct ext4_buddy *e4b)
35 +__releases(e4b->alloc_semp)
36  {
37         if (e4b->bd_bitmap_page)
38                 page_cache_release(e4b->bd_bitmap_page);
39 @@ -1027,6 +1030,7 @@ static void ext4_mb_release_desc(struct ext4_buddy *e4b)
40                 page_cache_release(e4b->bd_buddy_page);
41         /* Done with the buddy cache */
42         up_read(e4b->alloc_semp);
43 +       __release(e4b->alloc_semp);
44  }
47 @@ -1468,8 +1472,10 @@ static int ext4_mb_try_best_found(struct ext4_allocation_context *ac,
49         BUG_ON(ex.fe_len <= 0);
50         err = ext4_mb_load_buddy(ac->ac_sb, group, e4b);
51 -       if (err)
52 +       if (err) {
53 +               __release(e4b->alloc_semp);
54                 return err;
55 +       }
57         ext4_lock_group(ac->ac_sb, group);
58         max = mb_find_extent(e4b, 0, ex.fe_start, ex.fe_len, &ex);
59 @@ -1499,8 +1505,10 @@ static int ext4_mb_find_by_goal(struct ext4_allocation_context *ac,
60                 return 0;
62         err = ext4_mb_load_buddy(ac->ac_sb, group, e4b);
63 -       if (err)
64 +       if (err) {
65 +               __release(e4b->alloc_semp);
66                 return err;
67 +       }
69         ext4_lock_group(ac->ac_sb, group);
70         max = mb_find_extent(e4b, 0, ac->ac_g_ex.fe_start,
71 @@ -1959,8 +1967,10 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
72                                 continue;
74                         err = ext4_mb_load_buddy(sb, group, &e4b);
75 -                       if (err)
76 +                       if (err) {
77 +                               __release(e4b->alloc_semp);
78                                 goto out;
79 +                       }
81                         ext4_lock_group(sb, group);
82                         if (!ext4_mb_good_group(ac, group, cr)) {
83 @@ -2271,6 +2281,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
84                 sizeof(struct ext4_group_info);
85         err = ext4_mb_load_buddy(sb, group, &e4b);
86         if (err) {
87 +               __release(e4b->alloc_semp);
88                 seq_printf(seq, "#%-5u: I/O error\n", group);
89                 return 0;
90         }
91 @@ -3816,6 +3827,7 @@ ext4_mb_discard_group_preallocations(struct super_block *sb,
93         err = ext4_mb_load_buddy(sb, group, &e4b);
94         if (err) {
95 +               __release(e4b->alloc_semp);
96                 ext4_error(sb, __func__, "Error in loading buddy "
97                                 "information for %u\n", group);
98                 put_bh(bitmap_bh);
99 @@ -3983,6 +3995,7 @@ void ext4_discard_preallocations(struct inode *inode)
101                 err = ext4_mb_load_buddy(sb, group, &e4b);
102                 if (err) {
103 +                       __release(e4b->alloc_semp);
104                         ext4_error(sb, __func__, "Error in loading buddy "
105                                         "information for %u\n", group);
106                         continue;
107 @@ -4255,6 +4268,7 @@ ext4_mb_discard_lg_preallocations(struct super_block *sb,
109                 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, NULL);
110                 if (ext4_mb_load_buddy(sb, group, &e4b)) {
111 +                       __release(e4b->alloc_semp);
112                         ext4_error(sb, __func__, "Error in loading buddy "
113                                         "information for %u\n", group);
114                         continue;
115 @@ -4715,8 +4729,10 @@ void ext4_mb_free_blocks(handle_t *handle, struct inode *inode,
116         }
118         err = ext4_mb_load_buddy(sb, block_group, &e4b);
119 -       if (err)
120 +       if (err) {
121 +               __release(e4b->alloc_semp);
122                 goto error_return;
123 +       }
124         if (metadata) {
125                 /* blocks being freed are metadata. these blocks shouldn't
126                  * be used until this transaction is committed */
127 -- 
128 1.6.0.3.514.g2f91b
131 To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
132 the body of a message to majordomo@vger.kernel.org
133 More majordomo info at  http://vger.kernel.org/majordomo-info.html