checkpoint.c (f5a7a6b0d9b6af7d46124ed3f6b3995225cb62d0) | checkpoint.c (8e85fb3f305b24b79c6d9cb7a56d22b062335ad3) |
---|---|
1/* 2 * linux/fs/jbd2/checkpoint.c 3 * 4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1999 5 * 6 * Copyright 1999 Red Hat Software --- All Rights Reserved 7 * 8 * This file is part of the Linux kernel and is made available under --- 218 unchanged lines hidden (view full) --- 227 * 228 * Return 1 if something happened which requires us to abort the current 229 * scan of the checkpoint list. 230 * 231 * Called with j_list_lock held and drops it if 1 is returned 232 * Called under jbd_lock_bh_state(jh2bh(jh)), and drops it 233 */ 234static int __process_buffer(journal_t *journal, struct journal_head *jh, | 1/* 2 * linux/fs/jbd2/checkpoint.c 3 * 4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1999 5 * 6 * Copyright 1999 Red Hat Software --- All Rights Reserved 7 * 8 * This file is part of the Linux kernel and is made available under --- 218 unchanged lines hidden (view full) --- 227 * 228 * Return 1 if something happened which requires us to abort the current 229 * scan of the checkpoint list. 230 * 231 * Called with j_list_lock held and drops it if 1 is returned 232 * Called under jbd_lock_bh_state(jh2bh(jh)), and drops it 233 */ 234static int __process_buffer(journal_t *journal, struct journal_head *jh, |
235 struct buffer_head **bhs, int *batch_count) | 235 struct buffer_head **bhs, int *batch_count, 236 transaction_t *transaction) |
236{ 237 struct buffer_head *bh = jh2bh(jh); 238 int ret = 0; 239 240 if (buffer_locked(bh)) { 241 atomic_inc(&bh->b_count); 242 spin_unlock(&journal->j_list_lock); 243 jbd_unlock_bh_state(bh); 244 wait_on_buffer(bh); 245 /* the journal_head may have gone by now */ 246 BUFFER_TRACE(bh, "brelse"); 247 __brelse(bh); 248 ret = 1; 249 } else if (jh->b_transaction != NULL) { 250 transaction_t *t = jh->b_transaction; 251 tid_t tid = t->t_tid; 252 | 237{ 238 struct buffer_head *bh = jh2bh(jh); 239 int ret = 0; 240 241 if (buffer_locked(bh)) { 242 atomic_inc(&bh->b_count); 243 spin_unlock(&journal->j_list_lock); 244 jbd_unlock_bh_state(bh); 245 wait_on_buffer(bh); 246 /* the journal_head may have gone by now */ 247 BUFFER_TRACE(bh, "brelse"); 248 __brelse(bh); 249 ret = 1; 250 } else if (jh->b_transaction != NULL) { 251 transaction_t *t = jh->b_transaction; 252 tid_t tid = t->t_tid; 253 |
254 transaction->t_chp_stats.cs_forced_to_close++; |
|
253 spin_unlock(&journal->j_list_lock); 254 jbd_unlock_bh_state(bh); 255 jbd2_log_start_commit(journal, tid); 256 jbd2_log_wait_commit(journal, tid); 257 ret = 1; 258 } else if (!buffer_dirty(bh)) { 259 J_ASSERT_JH(jh, !buffer_jbddirty(bh)); 260 BUFFER_TRACE(bh, "remove from checkpoint"); --- 13 unchanged lines hidden (view full) --- 274 */ 275 BUFFER_TRACE(bh, "queue"); 276 get_bh(bh); 277 J_ASSERT_BH(bh, !buffer_jwrite(bh)); 278 set_buffer_jwrite(bh); 279 bhs[*batch_count] = bh; 280 __buffer_relink_io(jh); 281 jbd_unlock_bh_state(bh); | 255 spin_unlock(&journal->j_list_lock); 256 jbd_unlock_bh_state(bh); 257 jbd2_log_start_commit(journal, tid); 258 jbd2_log_wait_commit(journal, tid); 259 ret = 1; 260 } else if (!buffer_dirty(bh)) { 261 J_ASSERT_JH(jh, !buffer_jbddirty(bh)); 262 BUFFER_TRACE(bh, "remove from checkpoint"); --- 13 unchanged lines hidden (view full) --- 276 */ 277 BUFFER_TRACE(bh, "queue"); 278 get_bh(bh); 279 J_ASSERT_BH(bh, !buffer_jwrite(bh)); 280 set_buffer_jwrite(bh); 281 bhs[*batch_count] = bh; 282 __buffer_relink_io(jh); 283 jbd_unlock_bh_state(bh); |
284 transaction->t_chp_stats.cs_written++; |
|
282 (*batch_count)++; 283 if (*batch_count == NR_BATCH) { 284 spin_unlock(&journal->j_list_lock); 285 __flush_batch(journal, bhs, batch_count); 286 ret = 1; 287 } 288 } 289 return ret; --- 27 unchanged lines hidden (view full) --- 317 /* 318 * OK, we need to start writing disk blocks. Take one transaction 319 * and write it. 320 */ 321 spin_lock(&journal->j_list_lock); 322 if (!journal->j_checkpoint_transactions) 323 goto out; 324 transaction = journal->j_checkpoint_transactions; | 285 (*batch_count)++; 286 if (*batch_count == NR_BATCH) { 287 spin_unlock(&journal->j_list_lock); 288 __flush_batch(journal, bhs, batch_count); 289 ret = 1; 290 } 291 } 292 return ret; --- 27 unchanged lines hidden (view full) --- 320 /* 321 * OK, we need to start writing disk blocks. Take one transaction 322 * and write it. 323 */ 324 spin_lock(&journal->j_list_lock); 325 if (!journal->j_checkpoint_transactions) 326 goto out; 327 transaction = journal->j_checkpoint_transactions; |
328 if (transaction->t_chp_stats.cs_chp_time == 0) 329 transaction->t_chp_stats.cs_chp_time = jiffies; |
|
325 this_tid = transaction->t_tid; 326restart: 327 /* 328 * If someone cleaned up this transaction while we slept, we're 329 * done (maybe it's a new transaction, but it fell at the same 330 * address). 331 */ 332 if (journal->j_checkpoint_transactions == transaction && --- 8 unchanged lines hidden (view full) --- 341 342 jh = transaction->t_checkpoint_list; 343 bh = jh2bh(jh); 344 if (!jbd_trylock_bh_state(bh)) { 345 jbd_sync_bh(journal, bh); 346 retry = 1; 347 break; 348 } | 330 this_tid = transaction->t_tid; 331restart: 332 /* 333 * If someone cleaned up this transaction while we slept, we're 334 * done (maybe it's a new transaction, but it fell at the same 335 * address). 336 */ 337 if (journal->j_checkpoint_transactions == transaction && --- 8 unchanged lines hidden (view full) --- 346 347 jh = transaction->t_checkpoint_list; 348 bh = jh2bh(jh); 349 if (!jbd_trylock_bh_state(bh)) { 350 jbd_sync_bh(journal, bh); 351 retry = 1; 352 break; 353 } |
349 retry = __process_buffer(journal, jh, bhs,&batch_count); | 354 retry = __process_buffer(journal, jh, bhs, &batch_count, 355 transaction); |
350 if (!retry && lock_need_resched(&journal->j_list_lock)){ 351 spin_unlock(&journal->j_list_lock); 352 retry = 1; 353 break; 354 } 355 } 356 357 if (batch_count) { --- 340 unchanged lines hidden --- | 356 if (!retry && lock_need_resched(&journal->j_list_lock)){ 357 spin_unlock(&journal->j_list_lock); 358 retry = 1; 359 break; 360 } 361 } 362 363 if (batch_count) { --- 340 unchanged lines hidden --- |