Commit ddacfaf76dd620af9b73343a975749778321b51c
1 parent
f92a0b6ff4
Exists in
master
and in
7 other branches
[GFS2] Move logging code into log.c (mostly)
This moves the logging code from meta_io.c into log.c and glops.c. As a result the routines can now be static and all the logging code is together in log.c, leaving meta_io.c with just metadata i/o code in it. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Showing 4 changed files with 165 additions and 169 deletions Side-by-side Diff
fs/gfs2/glops.c
... | ... | @@ -26,7 +26,58 @@ |
26 | 26 | #include "recovery.h" |
27 | 27 | #include "rgrp.h" |
28 | 28 | #include "util.h" |
29 | +#include "trans.h" | |
29 | 30 | |
31 | +/** | |
32 | + * ail_empty_gl - remove all buffers for a given lock from the AIL | |
33 | + * @gl: the glock | |
34 | + * | |
35 | + * None of the buffers should be dirty, locked, or pinned. | |
36 | + */ | |
37 | + | |
38 | +static void gfs2_ail_empty_gl(struct gfs2_glock *gl) | |
39 | +{ | |
40 | + struct gfs2_sbd *sdp = gl->gl_sbd; | |
41 | + unsigned int blocks; | |
42 | + struct list_head *head = &gl->gl_ail_list; | |
43 | + struct gfs2_bufdata *bd; | |
44 | + struct buffer_head *bh; | |
45 | + u64 blkno; | |
46 | + int error; | |
47 | + | |
48 | + blocks = atomic_read(&gl->gl_ail_count); | |
49 | + if (!blocks) | |
50 | + return; | |
51 | + | |
52 | + error = gfs2_trans_begin(sdp, 0, blocks); | |
53 | + if (gfs2_assert_withdraw(sdp, !error)) | |
54 | + return; | |
55 | + | |
56 | + gfs2_log_lock(sdp); | |
57 | + while (!list_empty(head)) { | |
58 | + bd = list_entry(head->next, struct gfs2_bufdata, | |
59 | + bd_ail_gl_list); | |
60 | + bh = bd->bd_bh; | |
61 | + blkno = bh->b_blocknr; | |
62 | + gfs2_assert_withdraw(sdp, !buffer_busy(bh)); | |
63 | + | |
64 | + bd->bd_ail = NULL; | |
65 | + list_del(&bd->bd_ail_st_list); | |
66 | + list_del(&bd->bd_ail_gl_list); | |
67 | + atomic_dec(&gl->gl_ail_count); | |
68 | + brelse(bh); | |
69 | + gfs2_log_unlock(sdp); | |
70 | + | |
71 | + gfs2_trans_add_revoke(sdp, blkno); | |
72 | + | |
73 | + gfs2_log_lock(sdp); | |
74 | + } | |
75 | + gfs2_assert_withdraw(sdp, !atomic_read(&gl->gl_ail_count)); | |
76 | + gfs2_log_unlock(sdp); | |
77 | + | |
78 | + gfs2_trans_end(sdp); | |
79 | + gfs2_log_flush(sdp, NULL); | |
80 | +} | |
30 | 81 | |
31 | 82 | /** |
32 | 83 | * gfs2_pte_inval - Sync and invalidate all PTEs associated with a glock |
fs/gfs2/log.c
... | ... | @@ -58,6 +58,90 @@ |
58 | 58 | return blks; |
59 | 59 | } |
60 | 60 | |
61 | +/** | |
62 | + * gfs2_ail1_start_one - Start I/O on a part of the AIL | |
63 | + * @sdp: the filesystem | |
64 | + * @tr: the part of the AIL | |
65 | + * | |
66 | + */ | |
67 | + | |
68 | +static void gfs2_ail1_start_one(struct gfs2_sbd *sdp, struct gfs2_ail *ai) | |
69 | +{ | |
70 | + struct gfs2_bufdata *bd, *s; | |
71 | + struct buffer_head *bh; | |
72 | + int retry; | |
73 | + | |
74 | + BUG_ON(!spin_is_locked(&sdp->sd_log_lock)); | |
75 | + | |
76 | + do { | |
77 | + retry = 0; | |
78 | + | |
79 | + list_for_each_entry_safe_reverse(bd, s, &ai->ai_ail1_list, | |
80 | + bd_ail_st_list) { | |
81 | + bh = bd->bd_bh; | |
82 | + | |
83 | + gfs2_assert(sdp, bd->bd_ail == ai); | |
84 | + | |
85 | + if (!buffer_busy(bh)) { | |
86 | + if (!buffer_uptodate(bh)) { | |
87 | + gfs2_log_unlock(sdp); | |
88 | + gfs2_io_error_bh(sdp, bh); | |
89 | + gfs2_log_lock(sdp); | |
90 | + } | |
91 | + list_move(&bd->bd_ail_st_list, &ai->ai_ail2_list); | |
92 | + continue; | |
93 | + } | |
94 | + | |
95 | + if (!buffer_dirty(bh)) | |
96 | + continue; | |
97 | + | |
98 | + list_move(&bd->bd_ail_st_list, &ai->ai_ail1_list); | |
99 | + | |
100 | + gfs2_log_unlock(sdp); | |
101 | + wait_on_buffer(bh); | |
102 | + ll_rw_block(WRITE, 1, &bh); | |
103 | + gfs2_log_lock(sdp); | |
104 | + | |
105 | + retry = 1; | |
106 | + break; | |
107 | + } | |
108 | + } while (retry); | |
109 | +} | |
110 | + | |
111 | +/** | |
112 | + * gfs2_ail1_empty_one - Check whether or not a trans in the AIL has been synced | |
113 | + * @sdp: the filesystem | |
114 | + * @ai: the AIL entry | |
115 | + * | |
116 | + */ | |
117 | + | |
118 | +static int gfs2_ail1_empty_one(struct gfs2_sbd *sdp, struct gfs2_ail *ai, int flags) | |
119 | +{ | |
120 | + struct gfs2_bufdata *bd, *s; | |
121 | + struct buffer_head *bh; | |
122 | + | |
123 | + list_for_each_entry_safe_reverse(bd, s, &ai->ai_ail1_list, | |
124 | + bd_ail_st_list) { | |
125 | + bh = bd->bd_bh; | |
126 | + | |
127 | + gfs2_assert(sdp, bd->bd_ail == ai); | |
128 | + | |
129 | + if (buffer_busy(bh)) { | |
130 | + if (flags & DIO_ALL) | |
131 | + continue; | |
132 | + else | |
133 | + break; | |
134 | + } | |
135 | + | |
136 | + if (!buffer_uptodate(bh)) | |
137 | + gfs2_io_error_bh(sdp, bh); | |
138 | + | |
139 | + list_move(&bd->bd_ail_st_list, &ai->ai_ail2_list); | |
140 | + } | |
141 | + | |
142 | + return list_empty(&ai->ai_ail1_list); | |
143 | +} | |
144 | + | |
61 | 145 | void gfs2_ail1_start(struct gfs2_sbd *sdp, int flags) |
62 | 146 | { |
63 | 147 | struct list_head *head = &sdp->sd_ail1_list; |
... | ... | @@ -119,6 +203,31 @@ |
119 | 203 | gfs2_log_unlock(sdp); |
120 | 204 | |
121 | 205 | return ret; |
206 | +} | |
207 | + | |
208 | + | |
209 | +/** | |
210 | + * gfs2_ail2_empty_one - Check whether or not a trans in the AIL has been synced | |
211 | + * @sdp: the filesystem | |
212 | + * @ai: the AIL entry | |
213 | + * | |
214 | + */ | |
215 | + | |
216 | +static void gfs2_ail2_empty_one(struct gfs2_sbd *sdp, struct gfs2_ail *ai) | |
217 | +{ | |
218 | + struct list_head *head = &ai->ai_ail2_list; | |
219 | + struct gfs2_bufdata *bd; | |
220 | + | |
221 | + while (!list_empty(head)) { | |
222 | + bd = list_entry(head->prev, struct gfs2_bufdata, | |
223 | + bd_ail_st_list); | |
224 | + gfs2_assert(sdp, bd->bd_ail == ai); | |
225 | + bd->bd_ail = NULL; | |
226 | + list_del(&bd->bd_ail_st_list); | |
227 | + list_del(&bd->bd_ail_gl_list); | |
228 | + atomic_dec(&bd->bd_gl->gl_ail_count); | |
229 | + brelse(bd->bd_bh); | |
230 | + } | |
122 | 231 | } |
123 | 232 | |
124 | 233 | static void ail2_empty(struct gfs2_sbd *sdp, unsigned int new_tail) |
fs/gfs2/meta_io.c
... | ... | @@ -34,11 +34,6 @@ |
34 | 34 | #include "util.h" |
35 | 35 | #include "ops_address.h" |
36 | 36 | |
37 | -#define buffer_busy(bh) \ | |
38 | -((bh)->b_state & ((1ul << BH_Dirty) | (1ul << BH_Lock) | (1ul << BH_Pinned))) | |
39 | -#define buffer_in_io(bh) \ | |
40 | -((bh)->b_state & ((1ul << BH_Dirty) | (1ul << BH_Lock))) | |
41 | - | |
42 | 37 | static int aspace_get_block(struct inode *inode, sector_t lblock, |
43 | 38 | struct buffer_head *bh_result, int create) |
44 | 39 | { |
... | ... | @@ -89,165 +84,6 @@ |
89 | 84 | { |
90 | 85 | remove_inode_hash(aspace); |
91 | 86 | iput(aspace); |
92 | -} | |
93 | - | |
94 | -/** | |
95 | - * gfs2_ail1_start_one - Start I/O on a part of the AIL | |
96 | - * @sdp: the filesystem | |
97 | - * @tr: the part of the AIL | |
98 | - * | |
99 | - */ | |
100 | - | |
101 | -void gfs2_ail1_start_one(struct gfs2_sbd *sdp, struct gfs2_ail *ai) | |
102 | -{ | |
103 | - struct gfs2_bufdata *bd, *s; | |
104 | - struct buffer_head *bh; | |
105 | - int retry; | |
106 | - | |
107 | - BUG_ON(!spin_is_locked(&sdp->sd_log_lock)); | |
108 | - | |
109 | - do { | |
110 | - retry = 0; | |
111 | - | |
112 | - list_for_each_entry_safe_reverse(bd, s, &ai->ai_ail1_list, | |
113 | - bd_ail_st_list) { | |
114 | - bh = bd->bd_bh; | |
115 | - | |
116 | - gfs2_assert(sdp, bd->bd_ail == ai); | |
117 | - | |
118 | - if (!buffer_busy(bh)) { | |
119 | - if (!buffer_uptodate(bh)) { | |
120 | - gfs2_log_unlock(sdp); | |
121 | - gfs2_io_error_bh(sdp, bh); | |
122 | - gfs2_log_lock(sdp); | |
123 | - } | |
124 | - list_move(&bd->bd_ail_st_list, &ai->ai_ail2_list); | |
125 | - continue; | |
126 | - } | |
127 | - | |
128 | - if (!buffer_dirty(bh)) | |
129 | - continue; | |
130 | - | |
131 | - list_move(&bd->bd_ail_st_list, &ai->ai_ail1_list); | |
132 | - | |
133 | - gfs2_log_unlock(sdp); | |
134 | - wait_on_buffer(bh); | |
135 | - ll_rw_block(WRITE, 1, &bh); | |
136 | - gfs2_log_lock(sdp); | |
137 | - | |
138 | - retry = 1; | |
139 | - break; | |
140 | - } | |
141 | - } while (retry); | |
142 | -} | |
143 | - | |
144 | -/** | |
145 | - * gfs2_ail1_empty_one - Check whether or not a trans in the AIL has been synced | |
146 | - * @sdp: the filesystem | |
147 | - * @ai: the AIL entry | |
148 | - * | |
149 | - */ | |
150 | - | |
151 | -int gfs2_ail1_empty_one(struct gfs2_sbd *sdp, struct gfs2_ail *ai, int flags) | |
152 | -{ | |
153 | - struct gfs2_bufdata *bd, *s; | |
154 | - struct buffer_head *bh; | |
155 | - | |
156 | - list_for_each_entry_safe_reverse(bd, s, &ai->ai_ail1_list, | |
157 | - bd_ail_st_list) { | |
158 | - bh = bd->bd_bh; | |
159 | - | |
160 | - gfs2_assert(sdp, bd->bd_ail == ai); | |
161 | - | |
162 | - if (buffer_busy(bh)) { | |
163 | - if (flags & DIO_ALL) | |
164 | - continue; | |
165 | - else | |
166 | - break; | |
167 | - } | |
168 | - | |
169 | - if (!buffer_uptodate(bh)) | |
170 | - gfs2_io_error_bh(sdp, bh); | |
171 | - | |
172 | - list_move(&bd->bd_ail_st_list, &ai->ai_ail2_list); | |
173 | - } | |
174 | - | |
175 | - return list_empty(&ai->ai_ail1_list); | |
176 | -} | |
177 | - | |
178 | -/** | |
179 | - * gfs2_ail2_empty_one - Check whether or not a trans in the AIL has been synced | |
180 | - * @sdp: the filesystem | |
181 | - * @ai: the AIL entry | |
182 | - * | |
183 | - */ | |
184 | - | |
185 | -void gfs2_ail2_empty_one(struct gfs2_sbd *sdp, struct gfs2_ail *ai) | |
186 | -{ | |
187 | - struct list_head *head = &ai->ai_ail2_list; | |
188 | - struct gfs2_bufdata *bd; | |
189 | - | |
190 | - while (!list_empty(head)) { | |
191 | - bd = list_entry(head->prev, struct gfs2_bufdata, | |
192 | - bd_ail_st_list); | |
193 | - gfs2_assert(sdp, bd->bd_ail == ai); | |
194 | - bd->bd_ail = NULL; | |
195 | - list_del(&bd->bd_ail_st_list); | |
196 | - list_del(&bd->bd_ail_gl_list); | |
197 | - atomic_dec(&bd->bd_gl->gl_ail_count); | |
198 | - brelse(bd->bd_bh); | |
199 | - } | |
200 | -} | |
201 | - | |
202 | -/** | |
203 | - * ail_empty_gl - remove all buffers for a given lock from the AIL | |
204 | - * @gl: the glock | |
205 | - * | |
206 | - * None of the buffers should be dirty, locked, or pinned. | |
207 | - */ | |
208 | - | |
209 | -void gfs2_ail_empty_gl(struct gfs2_glock *gl) | |
210 | -{ | |
211 | - struct gfs2_sbd *sdp = gl->gl_sbd; | |
212 | - unsigned int blocks; | |
213 | - struct list_head *head = &gl->gl_ail_list; | |
214 | - struct gfs2_bufdata *bd; | |
215 | - struct buffer_head *bh; | |
216 | - u64 blkno; | |
217 | - int error; | |
218 | - | |
219 | - blocks = atomic_read(&gl->gl_ail_count); | |
220 | - if (!blocks) | |
221 | - return; | |
222 | - | |
223 | - error = gfs2_trans_begin(sdp, 0, blocks); | |
224 | - if (gfs2_assert_withdraw(sdp, !error)) | |
225 | - return; | |
226 | - | |
227 | - gfs2_log_lock(sdp); | |
228 | - while (!list_empty(head)) { | |
229 | - bd = list_entry(head->next, struct gfs2_bufdata, | |
230 | - bd_ail_gl_list); | |
231 | - bh = bd->bd_bh; | |
232 | - blkno = bh->b_blocknr; | |
233 | - gfs2_assert_withdraw(sdp, !buffer_busy(bh)); | |
234 | - | |
235 | - bd->bd_ail = NULL; | |
236 | - list_del(&bd->bd_ail_st_list); | |
237 | - list_del(&bd->bd_ail_gl_list); | |
238 | - atomic_dec(&gl->gl_ail_count); | |
239 | - brelse(bh); | |
240 | - gfs2_log_unlock(sdp); | |
241 | - | |
242 | - gfs2_trans_add_revoke(sdp, blkno); | |
243 | - | |
244 | - gfs2_log_lock(sdp); | |
245 | - } | |
246 | - gfs2_assert_withdraw(sdp, !atomic_read(&gl->gl_ail_count)); | |
247 | - gfs2_log_unlock(sdp); | |
248 | - | |
249 | - gfs2_trans_end(sdp); | |
250 | - gfs2_log_flush(sdp, NULL); | |
251 | 87 | } |
252 | 88 | |
253 | 89 | /** |
fs/gfs2/meta_io.h
... | ... | @@ -40,11 +40,6 @@ |
40 | 40 | struct inode *gfs2_aspace_get(struct gfs2_sbd *sdp); |
41 | 41 | void gfs2_aspace_put(struct inode *aspace); |
42 | 42 | |
43 | -void gfs2_ail1_start_one(struct gfs2_sbd *sdp, struct gfs2_ail *ai); | |
44 | -int gfs2_ail1_empty_one(struct gfs2_sbd *sdp, struct gfs2_ail *ai, int flags); | |
45 | -void gfs2_ail2_empty_one(struct gfs2_sbd *sdp, struct gfs2_ail *ai); | |
46 | -void gfs2_ail_empty_gl(struct gfs2_glock *gl); | |
47 | - | |
48 | 43 | void gfs2_meta_inval(struct gfs2_glock *gl); |
49 | 44 | void gfs2_meta_sync(struct gfs2_glock *gl); |
50 | 45 | |
... | ... | @@ -73,6 +68,11 @@ |
73 | 68 | |
74 | 69 | struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen); |
75 | 70 | void gfs2_meta_syncfs(struct gfs2_sbd *sdp); |
71 | + | |
72 | +#define buffer_busy(bh) \ | |
73 | +((bh)->b_state & ((1ul << BH_Dirty) | (1ul << BH_Lock) | (1ul << BH_Pinned))) | |
74 | +#define buffer_in_io(bh) \ | |
75 | +((bh)->b_state & ((1ul << BH_Dirty) | (1ul << BH_Lock))) | |
76 | 76 | |
77 | 77 | #endif /* __DIO_DOT_H__ */ |