• Home
  • Raw
  • Download

Lines Matching refs:journal

80 static void jbd2_get_transaction(journal_t *journal,  in jbd2_get_transaction()  argument
83 transaction->t_journal = journal; in jbd2_get_transaction()
86 transaction->t_tid = journal->j_transaction_sequence++; in jbd2_get_transaction()
87 transaction->t_expires = jiffies + journal->j_commit_interval; in jbd2_get_transaction()
91 atomic_read(&journal->j_reserved_credits)); in jbd2_get_transaction()
97 journal->j_commit_timer.expires = round_jiffies_up(transaction->t_expires); in jbd2_get_transaction()
98 add_timer(&journal->j_commit_timer); in jbd2_get_transaction()
100 J_ASSERT(journal->j_running_transaction == NULL); in jbd2_get_transaction()
101 journal->j_running_transaction = transaction; in jbd2_get_transaction()
145 static void wait_transaction_locked(journal_t *journal) in wait_transaction_locked() argument
146 __releases(journal->j_state_lock) in wait_transaction_locked()
150 tid_t tid = journal->j_running_transaction->t_tid; in wait_transaction_locked()
152 prepare_to_wait_exclusive(&journal->j_wait_transaction_locked, &wait, in wait_transaction_locked()
154 need_to_start = !tid_geq(journal->j_commit_request, tid); in wait_transaction_locked()
155 read_unlock(&journal->j_state_lock); in wait_transaction_locked()
157 jbd2_log_start_commit(journal, tid); in wait_transaction_locked()
158 jbd2_might_wait_for_commit(journal); in wait_transaction_locked()
160 finish_wait(&journal->j_wait_transaction_locked, &wait); in wait_transaction_locked()
168 static void wait_transaction_switching(journal_t *journal) in wait_transaction_switching() argument
169 __releases(journal->j_state_lock) in wait_transaction_switching()
173 if (WARN_ON(!journal->j_running_transaction || in wait_transaction_switching()
174 journal->j_running_transaction->t_state != T_SWITCH)) { in wait_transaction_switching()
175 read_unlock(&journal->j_state_lock); in wait_transaction_switching()
178 prepare_to_wait_exclusive(&journal->j_wait_transaction_locked, &wait, in wait_transaction_switching()
180 read_unlock(&journal->j_state_lock); in wait_transaction_switching()
188 finish_wait(&journal->j_wait_transaction_locked, &wait); in wait_transaction_switching()
191 static void sub_reserved_credits(journal_t *journal, int blocks) in sub_reserved_credits() argument
193 atomic_sub(blocks, &journal->j_reserved_credits); in sub_reserved_credits()
194 wake_up(&journal->j_wait_reserved); in sub_reserved_credits()
203 static int add_transaction_credits(journal_t *journal, int blocks, in add_transaction_credits() argument
206 transaction_t *t = journal->j_running_transaction; in add_transaction_credits()
216 wait_transaction_locked(journal); in add_transaction_credits()
226 if (needed > journal->j_max_transaction_buffers) { in add_transaction_credits()
238 if (atomic_read(&journal->j_reserved_credits) + total > in add_transaction_credits()
239 journal->j_max_transaction_buffers) { in add_transaction_credits()
240 read_unlock(&journal->j_state_lock); in add_transaction_credits()
241 jbd2_might_wait_for_commit(journal); in add_transaction_credits()
242 wait_event(journal->j_wait_reserved, in add_transaction_credits()
243 atomic_read(&journal->j_reserved_credits) + total <= in add_transaction_credits()
244 journal->j_max_transaction_buffers); in add_transaction_credits()
248 wait_transaction_locked(journal); in add_transaction_credits()
263 if (jbd2_log_space_left(journal) < jbd2_space_needed(journal)) { in add_transaction_credits()
265 read_unlock(&journal->j_state_lock); in add_transaction_credits()
266 jbd2_might_wait_for_commit(journal); in add_transaction_credits()
267 write_lock(&journal->j_state_lock); in add_transaction_credits()
268 if (jbd2_log_space_left(journal) < jbd2_space_needed(journal)) in add_transaction_credits()
269 __jbd2_log_wait_for_space(journal); in add_transaction_credits()
270 write_unlock(&journal->j_state_lock); in add_transaction_credits()
278 needed = atomic_add_return(rsv_blocks, &journal->j_reserved_credits); in add_transaction_credits()
280 if (needed > journal->j_max_transaction_buffers / 2) { in add_transaction_credits()
281 sub_reserved_credits(journal, rsv_blocks); in add_transaction_credits()
283 read_unlock(&journal->j_state_lock); in add_transaction_credits()
284 jbd2_might_wait_for_commit(journal); in add_transaction_credits()
285 wait_event(journal->j_wait_reserved, in add_transaction_credits()
286 atomic_read(&journal->j_reserved_credits) + rsv_blocks in add_transaction_credits()
287 <= journal->j_max_transaction_buffers / 2); in add_transaction_credits()
300 static int start_this_handle(journal_t *journal, handle_t *handle, in start_this_handle() argument
316 if ((rsv_blocks > journal->j_max_transaction_buffers / 2) || in start_this_handle()
317 (rsv_blocks + blocks > journal->j_max_transaction_buffers)) { in start_this_handle()
321 journal->j_max_transaction_buffers); in start_this_handle()
327 if (!journal->j_running_transaction) { in start_this_handle()
347 read_lock(&journal->j_state_lock); in start_this_handle()
348 BUG_ON(journal->j_flags & JBD2_UNMOUNT); in start_this_handle()
349 if (is_journal_aborted(journal) || in start_this_handle()
350 (journal->j_errno != 0 && !(journal->j_flags & JBD2_ACK_ERR))) { in start_this_handle()
351 read_unlock(&journal->j_state_lock); in start_this_handle()
361 if (!handle->h_reserved && journal->j_barrier_count) { in start_this_handle()
362 read_unlock(&journal->j_state_lock); in start_this_handle()
363 wait_event(journal->j_wait_transaction_locked, in start_this_handle()
364 journal->j_barrier_count == 0); in start_this_handle()
368 if (!journal->j_running_transaction) { in start_this_handle()
369 read_unlock(&journal->j_state_lock); in start_this_handle()
372 write_lock(&journal->j_state_lock); in start_this_handle()
373 if (!journal->j_running_transaction && in start_this_handle()
374 (handle->h_reserved || !journal->j_barrier_count)) { in start_this_handle()
375 jbd2_get_transaction(journal, new_transaction); in start_this_handle()
378 write_unlock(&journal->j_state_lock); in start_this_handle()
382 transaction = journal->j_running_transaction; in start_this_handle()
386 if (add_transaction_credits(journal, blocks, rsv_blocks)) in start_this_handle()
397 wait_transaction_switching(journal); in start_this_handle()
400 sub_reserved_credits(journal, blocks); in start_this_handle()
416 jbd2_log_space_left(journal)); in start_this_handle()
417 read_unlock(&journal->j_state_lock); in start_this_handle()
420 rwsem_acquire_read(&journal->j_trans_commit_map, 0, 0, _THIS_IP_); in start_this_handle()
442 handle_t *jbd2__journal_start(journal_t *journal, int nblocks, int rsv_blocks, in jbd2__journal_start() argument
449 if (!journal) in jbd2__journal_start()
453 J_ASSERT(handle->h_transaction->t_journal == journal); in jbd2__journal_start()
470 rsv_handle->h_journal = journal; in jbd2__journal_start()
474 err = start_this_handle(journal, handle, gfp_mask); in jbd2__journal_start()
483 trace_jbd2_handle_start(journal->j_fs_dev->bd_dev, in jbd2__journal_start()
511 handle_t *jbd2_journal_start(journal_t *journal, int nblocks) in jbd2_journal_start() argument
513 return jbd2__journal_start(journal, nblocks, 0, GFP_NOFS, 0, 0); in jbd2_journal_start()
519 journal_t *journal = handle->h_journal; in jbd2_journal_free_reserved() local
522 sub_reserved_credits(journal, handle->h_buffer_credits); in jbd2_journal_free_reserved()
544 journal_t *journal = handle->h_journal; in jbd2_journal_start_reserved() local
566 ret = start_this_handle(journal, handle, GFP_NOFS); in jbd2_journal_start_reserved()
568 handle->h_journal = journal; in jbd2_journal_start_reserved()
574 trace_jbd2_handle_start(journal->j_fs_dev->bd_dev, in jbd2_journal_start_reserved()
604 journal_t *journal; in jbd2_journal_extend() local
610 journal = transaction->t_journal; in jbd2_journal_extend()
614 read_lock(&journal->j_state_lock); in jbd2_journal_extend()
627 if (wanted > journal->j_max_transaction_buffers) { in jbd2_journal_extend()
635 jbd2_log_space_left(journal)) { in jbd2_journal_extend()
642 trace_jbd2_handle_extend(journal->j_fs_dev->bd_dev, in jbd2_journal_extend()
656 read_unlock(&journal->j_state_lock); in jbd2_journal_extend()
680 journal_t *journal; in jbd2__journal_restart() local
688 journal = transaction->t_journal; in jbd2__journal_restart()
697 read_lock(&journal->j_state_lock); in jbd2__journal_restart()
702 sub_reserved_credits(journal, in jbd2__journal_restart()
706 wake_up(&journal->j_wait_updates); in jbd2__journal_restart()
713 need_to_start = !tid_geq(journal->j_commit_request, tid); in jbd2__journal_restart()
714 read_unlock(&journal->j_state_lock); in jbd2__journal_restart()
716 jbd2_log_start_commit(journal, tid); in jbd2__journal_restart()
718 rwsem_release(&journal->j_trans_commit_map, 1, _THIS_IP_); in jbd2__journal_restart()
726 ret = start_this_handle(journal, handle, gfp_mask); in jbd2__journal_restart()
748 void jbd2_journal_lock_updates(journal_t *journal) in jbd2_journal_lock_updates() argument
752 jbd2_might_wait_for_commit(journal); in jbd2_journal_lock_updates()
754 write_lock(&journal->j_state_lock); in jbd2_journal_lock_updates()
755 ++journal->j_barrier_count; in jbd2_journal_lock_updates()
758 if (atomic_read(&journal->j_reserved_credits)) { in jbd2_journal_lock_updates()
759 write_unlock(&journal->j_state_lock); in jbd2_journal_lock_updates()
760 wait_event(journal->j_wait_reserved, in jbd2_journal_lock_updates()
761 atomic_read(&journal->j_reserved_credits) == 0); in jbd2_journal_lock_updates()
762 write_lock(&journal->j_state_lock); in jbd2_journal_lock_updates()
767 transaction_t *transaction = journal->j_running_transaction; in jbd2_journal_lock_updates()
773 prepare_to_wait(&journal->j_wait_updates, &wait, in jbd2_journal_lock_updates()
777 finish_wait(&journal->j_wait_updates, &wait); in jbd2_journal_lock_updates()
781 write_unlock(&journal->j_state_lock); in jbd2_journal_lock_updates()
783 finish_wait(&journal->j_wait_updates, &wait); in jbd2_journal_lock_updates()
784 write_lock(&journal->j_state_lock); in jbd2_journal_lock_updates()
786 write_unlock(&journal->j_state_lock); in jbd2_journal_lock_updates()
794 mutex_lock(&journal->j_barrier); in jbd2_journal_lock_updates()
805 void jbd2_journal_unlock_updates (journal_t *journal) in jbd2_journal_unlock_updates() argument
807 J_ASSERT(journal->j_barrier_count != 0); in jbd2_journal_unlock_updates()
809 mutex_unlock(&journal->j_barrier); in jbd2_journal_unlock_updates()
810 write_lock(&journal->j_state_lock); in jbd2_journal_unlock_updates()
811 --journal->j_barrier_count; in jbd2_journal_unlock_updates()
812 write_unlock(&journal->j_state_lock); in jbd2_journal_unlock_updates()
813 wake_up_all(&journal->j_wait_transaction_locked); in jbd2_journal_unlock_updates()
865 journal_t *journal; in do_get_write_access() local
870 journal = transaction->t_journal; in do_get_write_access()
912 journal->j_committing_transaction); in do_get_write_access()
966 spin_lock(&journal->j_list_lock); in do_get_write_access()
968 spin_unlock(&journal->j_list_lock); in do_get_write_access()
983 J_ASSERT_JH(jh, jh->b_transaction == journal->j_committing_transaction); in do_get_write_access()
1160 journal_t *journal; in jbd2_journal_get_create_access() local
1168 journal = transaction->t_journal; in jbd2_journal_get_create_access()
1182 (jh->b_transaction == journal->j_committing_transaction && in jbd2_journal_get_create_access()
1202 spin_lock(&journal->j_list_lock); in jbd2_journal_get_create_access()
1204 spin_unlock(&journal->j_list_lock); in jbd2_journal_get_create_access()
1205 } else if (jh->b_transaction == journal->j_committing_transaction) { in jbd2_journal_get_create_access()
1210 spin_lock(&journal->j_list_lock); in jbd2_journal_get_create_access()
1212 spin_unlock(&journal->j_list_lock); in jbd2_journal_get_create_access()
1375 journal_t *journal; in jbd2_journal_dirty_metadata() local
1422 journal = transaction->t_journal; in jbd2_journal_dirty_metadata()
1461 journal->j_running_transaction)) { in jbd2_journal_dirty_metadata()
1465 journal->j_devname, in jbd2_journal_dirty_metadata()
1469 journal->j_running_transaction, in jbd2_journal_dirty_metadata()
1470 journal->j_running_transaction ? in jbd2_journal_dirty_metadata()
1471 journal->j_running_transaction->t_tid : 0); in jbd2_journal_dirty_metadata()
1488 journal->j_committing_transaction)) || in jbd2_journal_dirty_metadata()
1495 journal->j_devname, in jbd2_journal_dirty_metadata()
1517 spin_lock(&journal->j_list_lock); in jbd2_journal_dirty_metadata()
1519 spin_unlock(&journal->j_list_lock); in jbd2_journal_dirty_metadata()
1547 journal_t *journal; in jbd2_journal_forget() local
1555 journal = transaction->t_journal; in jbd2_journal_forget()
1612 spin_lock(&journal->j_list_lock); in jbd2_journal_forget()
1619 spin_unlock(&journal->j_list_lock); in jbd2_journal_forget()
1623 spin_unlock(&journal->j_list_lock); in jbd2_journal_forget()
1626 journal->j_committing_transaction)); in jbd2_journal_forget()
1640 spin_lock(&journal->j_list_lock); in jbd2_journal_forget()
1642 spin_unlock(&journal->j_list_lock); in jbd2_journal_forget()
1659 spin_lock(&journal->j_list_lock); in jbd2_journal_forget()
1662 spin_unlock(&journal->j_list_lock); in jbd2_journal_forget()
1672 spin_unlock(&journal->j_list_lock); in jbd2_journal_forget()
1684 spin_unlock(&journal->j_list_lock); in jbd2_journal_forget()
1721 journal_t *journal; in jbd2_journal_stop() local
1742 journal = transaction->t_journal; in jbd2_journal_stop()
1758 trace_jbd2_handle_stats(journal->j_fs_dev->bd_dev, in jbd2_journal_stop()
1796 if (handle->h_sync && journal->j_last_sync_writer != pid && in jbd2_journal_stop()
1797 journal->j_max_batch_time) { in jbd2_journal_stop()
1800 journal->j_last_sync_writer = pid; in jbd2_journal_stop()
1802 read_lock(&journal->j_state_lock); in jbd2_journal_stop()
1803 commit_time = journal->j_average_commit_time; in jbd2_journal_stop()
1804 read_unlock(&journal->j_state_lock); in jbd2_journal_stop()
1810 1000*journal->j_min_batch_time); in jbd2_journal_stop()
1812 1000*journal->j_max_batch_time); in jbd2_journal_stop()
1836 journal->j_max_transaction_buffers) || in jbd2_journal_stop()
1845 jbd2_log_start_commit(journal, transaction->t_tid); in jbd2_journal_stop()
1863 wake_up(&journal->j_wait_updates); in jbd2_journal_stop()
1864 if (journal->j_barrier_count) in jbd2_journal_stop()
1865 wake_up(&journal->j_wait_transaction_locked); in jbd2_journal_stop()
1868 rwsem_release(&journal->j_trans_commit_map, 1, _THIS_IP_); in jbd2_journal_stop()
1871 err = jbd2_log_wait_commit(journal, tid); in jbd2_journal_stop()
2007 void jbd2_journal_unfile_buffer(journal_t *journal, struct journal_head *jh) in jbd2_journal_unfile_buffer() argument
2014 spin_lock(&journal->j_list_lock); in jbd2_journal_unfile_buffer()
2016 spin_unlock(&journal->j_list_lock); in jbd2_journal_unfile_buffer()
2027 __journal_try_to_free_buffer(journal_t *journal, struct buffer_head *bh) in __journal_try_to_free_buffer() argument
2039 spin_lock(&journal->j_list_lock); in __journal_try_to_free_buffer()
2045 spin_unlock(&journal->j_list_lock); in __journal_try_to_free_buffer()
2088 int jbd2_journal_try_to_free_buffers(journal_t *journal, in jbd2_journal_try_to_free_buffers() argument
2113 __journal_try_to_free_buffer(journal, bh); in jbd2_journal_try_to_free_buffers()
2136 jbd2_journal_abort(journal, -EIO); in jbd2_journal_try_to_free_buffers()
2223 static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh, in journal_unmap_buffer() argument
2242 write_lock(&journal->j_state_lock); in journal_unmap_buffer()
2244 spin_lock(&journal->j_list_lock); in journal_unmap_buffer()
2294 if (journal->j_running_transaction) { in journal_unmap_buffer()
2300 journal->j_running_transaction); in journal_unmap_buffer()
2307 if (journal->j_committing_transaction) { in journal_unmap_buffer()
2310 journal->j_committing_transaction); in journal_unmap_buffer()
2320 } else if (transaction == journal->j_committing_transaction) { in journal_unmap_buffer()
2329 spin_unlock(&journal->j_list_lock); in journal_unmap_buffer()
2331 write_unlock(&journal->j_state_lock); in journal_unmap_buffer()
2342 if (journal->j_running_transaction && buffer_jbddirty(bh)) in journal_unmap_buffer()
2343 jh->b_next_transaction = journal->j_running_transaction; in journal_unmap_buffer()
2346 spin_unlock(&journal->j_list_lock); in journal_unmap_buffer()
2348 write_unlock(&journal->j_state_lock); in journal_unmap_buffer()
2357 J_ASSERT_JH(jh, transaction == journal->j_running_transaction); in journal_unmap_buffer()
2374 spin_unlock(&journal->j_list_lock); in journal_unmap_buffer()
2376 write_unlock(&journal->j_state_lock); in journal_unmap_buffer()
2401 int jbd2_journal_invalidatepage(journal_t *journal, in jbd2_journal_invalidatepage() argument
2435 ret = journal_unmap_buffer(journal, bh, partial_page); in jbd2_journal_invalidatepage()
2598 void jbd2_journal_refile_buffer(journal_t *journal, struct journal_head *jh) in jbd2_journal_refile_buffer() argument
2605 spin_lock(&journal->j_list_lock); in jbd2_journal_refile_buffer()
2608 spin_unlock(&journal->j_list_lock); in jbd2_journal_refile_buffer()
2619 journal_t *journal; in jbd2_journal_file_inode() local
2623 journal = transaction->t_journal; in jbd2_journal_file_inode()
2628 spin_lock(&journal->j_list_lock); in jbd2_journal_file_inode()
2656 journal->j_committing_transaction); in jbd2_journal_file_inode()
2665 spin_unlock(&journal->j_list_lock); in jbd2_journal_file_inode()
2705 int jbd2_journal_begin_ordered_truncate(journal_t *journal, in jbd2_journal_begin_ordered_truncate() argument
2718 read_lock(&journal->j_state_lock); in jbd2_journal_begin_ordered_truncate()
2719 commit_trans = journal->j_committing_transaction; in jbd2_journal_begin_ordered_truncate()
2720 read_unlock(&journal->j_state_lock); in jbd2_journal_begin_ordered_truncate()
2721 spin_lock(&journal->j_list_lock); in jbd2_journal_begin_ordered_truncate()
2723 spin_unlock(&journal->j_list_lock); in jbd2_journal_begin_ordered_truncate()
2728 jbd2_journal_abort(journal, ret); in jbd2_journal_begin_ordered_truncate()