diff options
author | Theodore Ts'o <tytso@mit.edu> | 2014-09-01 21:26:09 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2014-09-01 21:26:09 -0400 |
commit | 88fe1acb5bedfcba5f42fcdf165493ee587ba643 (patch) | |
tree | eb6afdde3b1c1dbb964855a1673355f3728f5698 /fs/jbd2 | |
parent | be1158cc615fd723552f0d9912087423c7cadda5 (diff) |
jbd2: fold __wait_cp_io into jbd2_log_do_checkpoint()
__wait_cp_io() is only called by jbd2_log_do_checkpoint(). Fold it in
to make it a bit easier to understand.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/jbd2')
-rw-r--r-- | fs/jbd2/checkpoint.c | 87 |
1 files changed, 31 insertions, 56 deletions
diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c index f1507e5b7c9a..18c7a8d3da13 100644 --- a/fs/jbd2/checkpoint.c +++ b/fs/jbd2/checkpoint.c | |||
@@ -183,58 +183,6 @@ void __jbd2_log_wait_for_space(journal_t *journal) | |||
183 | } | 183 | } |
184 | } | 184 | } |
185 | 185 | ||
186 | /* | ||
187 | * Clean up transaction's list of buffers submitted for io. | ||
188 | * We wait for any pending IO to complete and remove any clean | ||
189 | * buffers. Note that we take the buffers in the opposite ordering | ||
190 | * from the one in which they were submitted for IO. | ||
191 | * | ||
192 | * Return 0 on success, and return <0 if some buffers have failed | ||
193 | * to be written out. | ||
194 | * | ||
195 | * Called with j_list_lock held. | ||
196 | */ | ||
197 | static int __wait_cp_io(journal_t *journal, transaction_t *transaction) | ||
198 | { | ||
199 | struct journal_head *jh; | ||
200 | struct buffer_head *bh; | ||
201 | tid_t this_tid; | ||
202 | int released = 0; | ||
203 | int ret = 0; | ||
204 | |||
205 | this_tid = transaction->t_tid; | ||
206 | restart: | ||
207 | /* Did somebody clean up the transaction in the meanwhile? */ | ||
208 | if (journal->j_checkpoint_transactions != transaction || | ||
209 | transaction->t_tid != this_tid) | ||
210 | return ret; | ||
211 | while (!released && transaction->t_checkpoint_io_list) { | ||
212 | jh = transaction->t_checkpoint_io_list; | ||
213 | bh = jh2bh(jh); | ||
214 | get_bh(bh); | ||
215 | if (buffer_locked(bh)) { | ||
216 | spin_unlock(&journal->j_list_lock); | ||
217 | wait_on_buffer(bh); | ||
218 | /* the journal_head may have gone by now */ | ||
219 | BUFFER_TRACE(bh, "brelse"); | ||
220 | __brelse(bh); | ||
221 | spin_lock(&journal->j_list_lock); | ||
222 | goto restart; | ||
223 | } | ||
224 | if (unlikely(buffer_write_io_error(bh))) | ||
225 | ret = -EIO; | ||
226 | |||
227 | /* | ||
228 | * Now in whatever state the buffer currently is, we know that | ||
229 | * it has been written out and so we can drop it from the list | ||
230 | */ | ||
231 | released = __jbd2_journal_remove_checkpoint(jh); | ||
232 | __brelse(bh); | ||
233 | } | ||
234 | |||
235 | return ret; | ||
236 | } | ||
237 | |||
238 | static void | 186 | static void |
239 | __flush_batch(journal_t *journal, int *batch_count) | 187 | __flush_batch(journal_t *journal, int *batch_count) |
240 | { | 188 | { |
@@ -268,7 +216,7 @@ int jbd2_log_do_checkpoint(journal_t *journal) | |||
268 | struct buffer_head *bh; | 216 | struct buffer_head *bh; |
269 | transaction_t *transaction; | 217 | transaction_t *transaction; |
270 | tid_t this_tid; | 218 | tid_t this_tid; |
271 | int err, result, batch_count = 0; | 219 | int result, batch_count = 0, done = 0; |
272 | 220 | ||
273 | jbd_debug(1, "Start checkpoint\n"); | 221 | jbd_debug(1, "Start checkpoint\n"); |
274 | 222 | ||
@@ -384,9 +332,36 @@ restart: | |||
384 | * Now we issued all of the transaction's buffers, let's deal | 332 | * Now we issued all of the transaction's buffers, let's deal |
385 | * with the buffers that are out for I/O. | 333 | * with the buffers that are out for I/O. |
386 | */ | 334 | */ |
387 | err = __wait_cp_io(journal, transaction); | 335 | restart2: |
388 | if (!result) | 336 | /* Did somebody clean up the transaction in the meanwhile? */ |
389 | result = err; | 337 | if (journal->j_checkpoint_transactions != transaction || |
338 | transaction->t_tid != this_tid) | ||
339 | goto out; | ||
340 | |||
341 | while (!done && transaction->t_checkpoint_io_list) { | ||
342 | jh = transaction->t_checkpoint_io_list; | ||
343 | bh = jh2bh(jh); | ||
344 | get_bh(bh); | ||
345 | if (buffer_locked(bh)) { | ||
346 | spin_unlock(&journal->j_list_lock); | ||
347 | wait_on_buffer(bh); | ||
348 | /* the journal_head may have gone by now */ | ||
349 | BUFFER_TRACE(bh, "brelse"); | ||
350 | __brelse(bh); | ||
351 | spin_lock(&journal->j_list_lock); | ||
352 | goto restart2; | ||
353 | } | ||
354 | if (unlikely(buffer_write_io_error(bh)) && !result) | ||
355 | result = -EIO; | ||
356 | |||
357 | /* | ||
358 | * Now in whatever state the buffer currently is, we | ||
359 | * know that it has been written out and so we can | ||
360 | * drop it from the list | ||
361 | */ | ||
362 | done = __jbd2_journal_remove_checkpoint(jh); | ||
363 | __brelse(bh); | ||
364 | } | ||
390 | out: | 365 | out: |
391 | spin_unlock(&journal->j_list_lock); | 366 | spin_unlock(&journal->j_list_lock); |
392 | if (result < 0) | 367 | if (result < 0) |