195
196
197
198
199
200
201static int __wait_cp_io(journal_t *journal, transaction_t *transaction)
202{
203 struct journal_head *jh;
204 struct buffer_head *bh;
205 tid_t this_tid;
206 int released = 0;
207 int ret = 0;
208
209 this_tid = transaction->t_tid;
210restart:
211
212 if (journal->j_checkpoint_transactions != transaction ||
213 transaction->t_tid != this_tid)
214 return ret;
215 while (!released && transaction->t_checkpoint_io_list) {
216 jh = transaction->t_checkpoint_io_list;
217 bh = jh2bh(jh);
218 if (!jbd_trylock_bh_state(bh)) {
219 jbd_sync_bh(journal, bh);
220 spin_lock(&journal->j_list_lock);
221 goto restart;
222 }
223 if (buffer_locked(bh)) {
224 atomic_inc(&bh->b_count);
225 spin_unlock(&journal->j_list_lock);
226 jbd_unlock_bh_state(bh);
227 wait_on_buffer(bh);
228
229 BUFFER_TRACE(bh, "brelse");
230 __brelse(bh);
231 spin_lock(&journal->j_list_lock);
232 goto restart;
233 }
234 if (unlikely(buffer_write_io_error(bh)))
235 ret = -EIO;