Lines Matching refs:handle
316 static int start_this_handle(journal_t *journal, handle_t *handle, in start_this_handle() argument
320 int blocks = handle->h_total_credits; in start_this_handle()
324 if (handle->h_rsv_handle) in start_this_handle()
325 rsv_blocks = handle->h_rsv_handle->h_total_credits; in start_this_handle()
361 jbd2_debug(3, "New handle %p going live.\n", handle); in start_this_handle()
382 if (!handle->h_reserved && journal->j_barrier_count) { in start_this_handle()
395 (handle->h_reserved || !journal->j_barrier_count)) { in start_this_handle()
405 if (!handle->h_reserved) { in start_this_handle()
428 handle->h_reserved = 0; in start_this_handle()
435 handle->h_transaction = transaction; in start_this_handle()
436 handle->h_requested_credits = blocks; in start_this_handle()
437 handle->h_revoke_credits_requested = handle->h_revoke_credits; in start_this_handle()
438 handle->h_start_jiffies = jiffies; in start_this_handle()
442 handle, blocks, in start_this_handle()
446 current->journal_info = handle; in start_this_handle()
454 handle->saved_alloc_context = memalloc_nofs_save(); in start_this_handle()
461 handle_t *handle = jbd2_alloc_handle(GFP_NOFS); in new_handle() local
462 if (!handle) in new_handle()
464 handle->h_total_credits = nblocks; in new_handle()
465 handle->h_ref = 1; in new_handle()
467 return handle; in new_handle()
474 handle_t *handle = journal_current_handle(); in jbd2__journal_start() local
480 if (handle) { in jbd2__journal_start()
481 J_ASSERT(handle->h_transaction->t_journal == journal); in jbd2__journal_start()
482 handle->h_ref++; in jbd2__journal_start()
483 return handle; in jbd2__journal_start()
488 handle = new_handle(nblocks); in jbd2__journal_start()
489 if (!handle) in jbd2__journal_start()
496 jbd2_free_handle(handle); in jbd2__journal_start()
501 handle->h_rsv_handle = rsv_handle; in jbd2__journal_start()
503 handle->h_revoke_credits = revoke_records; in jbd2__journal_start()
505 err = start_this_handle(journal, handle, gfp_mask); in jbd2__journal_start()
507 if (handle->h_rsv_handle) in jbd2__journal_start()
508 jbd2_free_handle(handle->h_rsv_handle); in jbd2__journal_start()
509 jbd2_free_handle(handle); in jbd2__journal_start()
512 handle->h_type = type; in jbd2__journal_start()
513 handle->h_line_no = line_no; in jbd2__journal_start()
515 handle->h_transaction->t_tid, type, in jbd2__journal_start()
518 return handle; in jbd2__journal_start()
548 static void __jbd2_journal_unreserve_handle(handle_t *handle, transaction_t *t) in __jbd2_journal_unreserve_handle() argument
550 journal_t *journal = handle->h_journal; in __jbd2_journal_unreserve_handle()
552 WARN_ON(!handle->h_reserved); in __jbd2_journal_unreserve_handle()
553 sub_reserved_credits(journal, handle->h_total_credits); in __jbd2_journal_unreserve_handle()
555 atomic_sub(handle->h_total_credits, &t->t_outstanding_credits); in __jbd2_journal_unreserve_handle()
558 void jbd2_journal_free_reserved(handle_t *handle) in jbd2_journal_free_reserved() argument
560 journal_t *journal = handle->h_journal; in jbd2_journal_free_reserved()
564 __jbd2_journal_unreserve_handle(handle, journal->j_running_transaction); in jbd2_journal_free_reserved()
566 jbd2_free_handle(handle); in jbd2_journal_free_reserved()
584 int jbd2_journal_start_reserved(handle_t *handle, unsigned int type, in jbd2_journal_start_reserved() argument
587 journal_t *journal = handle->h_journal; in jbd2_journal_start_reserved()
590 if (WARN_ON(!handle->h_reserved)) { in jbd2_journal_start_reserved()
592 jbd2_journal_stop(handle); in jbd2_journal_start_reserved()
600 jbd2_journal_free_reserved(handle); in jbd2_journal_start_reserved()
604 handle->h_journal = NULL; in jbd2_journal_start_reserved()
609 ret = start_this_handle(journal, handle, GFP_NOFS); in jbd2_journal_start_reserved()
611 handle->h_journal = journal; in jbd2_journal_start_reserved()
612 jbd2_journal_free_reserved(handle); in jbd2_journal_start_reserved()
615 handle->h_type = type; in jbd2_journal_start_reserved()
616 handle->h_line_no = line_no; in jbd2_journal_start_reserved()
618 handle->h_transaction->t_tid, type, in jbd2_journal_start_reserved()
619 line_no, handle->h_total_credits); in jbd2_journal_start_reserved()
645 int jbd2_journal_extend(handle_t *handle, int nblocks, int revoke_records) in jbd2_journal_extend() argument
647 transaction_t *transaction = handle->h_transaction; in jbd2_journal_extend()
652 if (is_handle_aborted(handle)) in jbd2_journal_extend()
663 "transaction not running\n", handle, nblocks); in jbd2_journal_extend()
668 handle->h_revoke_credits_requested + revoke_records, in jbd2_journal_extend()
671 handle->h_revoke_credits_requested, in jbd2_journal_extend()
678 "transaction too large\n", handle, nblocks); in jbd2_journal_extend()
685 handle->h_type, handle->h_line_no, in jbd2_journal_extend()
686 handle->h_total_credits, in jbd2_journal_extend()
689 handle->h_total_credits += nblocks; in jbd2_journal_extend()
690 handle->h_requested_credits += nblocks; in jbd2_journal_extend()
691 handle->h_revoke_credits += revoke_records; in jbd2_journal_extend()
692 handle->h_revoke_credits_requested += revoke_records; in jbd2_journal_extend()
695 jbd2_debug(3, "extended handle %p by %d\n", handle, nblocks); in jbd2_journal_extend()
701 static void stop_this_handle(handle_t *handle) in stop_this_handle() argument
703 transaction_t *transaction = handle->h_transaction; in stop_this_handle()
707 J_ASSERT(journal_current_handle() == handle); in stop_this_handle()
716 revokes = handle->h_revoke_credits_requested - handle->h_revoke_credits; in stop_this_handle()
722 > handle->h_total_credits); in stop_this_handle()
728 handle->h_total_credits -= revoke_descriptors; in stop_this_handle()
730 atomic_sub(handle->h_total_credits, in stop_this_handle()
732 if (handle->h_rsv_handle) in stop_this_handle()
733 __jbd2_journal_unreserve_handle(handle->h_rsv_handle, in stop_this_handle()
743 memalloc_nofs_restore(handle->saved_alloc_context); in stop_this_handle()
763 int jbd2__journal_restart(handle_t *handle, int nblocks, int revoke_records, in jbd2__journal_restart() argument
766 transaction_t *transaction = handle->h_transaction; in jbd2__journal_restart()
774 if (is_handle_aborted(handle)) in jbd2__journal_restart()
783 jbd2_debug(2, "restarting handle %p\n", handle); in jbd2__journal_restart()
784 stop_this_handle(handle); in jbd2__journal_restart()
785 handle->h_transaction = NULL; in jbd2__journal_restart()
796 handle->h_total_credits = nblocks + in jbd2__journal_restart()
799 handle->h_revoke_credits = revoke_records; in jbd2__journal_restart()
800 ret = start_this_handle(journal, handle, gfp_mask); in jbd2__journal_restart()
802 ret ? 0 : handle->h_transaction->t_tid, in jbd2__journal_restart()
803 handle->h_type, handle->h_line_no, in jbd2__journal_restart()
804 handle->h_total_credits); in jbd2__journal_restart()
810 int jbd2_journal_restart(handle_t *handle, int nblocks) in jbd2_journal_restart() argument
812 return jbd2__journal_restart(handle, nblocks, 0, GFP_NOFS); in jbd2_journal_restart()
951 do_get_write_access(handle_t *handle, struct journal_head *jh, in do_get_write_access() argument
955 transaction_t *transaction = handle->h_transaction; in do_get_write_access()
1013 if (is_handle_aborted(handle)) { in do_get_write_access()
1141 jbd2_journal_cancel_revoke(handle, jh); in do_get_write_access()
1152 static bool jbd2_write_access_granted(handle_t *handle, struct buffer_head *bh, in jbd2_write_access_granted() argument
1183 if (READ_ONCE(jh->b_transaction) != handle->h_transaction && in jbd2_write_access_granted()
1184 READ_ONCE(jh->b_next_transaction) != handle->h_transaction) in jbd2_write_access_granted()
1216 int jbd2_journal_get_write_access(handle_t *handle, struct buffer_head *bh) in jbd2_journal_get_write_access() argument
1221 if (is_handle_aborted(handle)) in jbd2_journal_get_write_access()
1224 if (jbd2_write_access_granted(handle, bh, false)) in jbd2_journal_get_write_access()
1231 rc = do_get_write_access(handle, jh, 0); in jbd2_journal_get_write_access()
1256 int jbd2_journal_get_create_access(handle_t *handle, struct buffer_head *bh) in jbd2_journal_get_create_access() argument
1258 transaction_t *transaction = handle->h_transaction; in jbd2_journal_get_create_access()
1265 if (is_handle_aborted(handle)) in jbd2_journal_get_create_access()
1323 jbd2_journal_cancel_revoke(handle, jh); in jbd2_journal_get_create_access()
1355 int jbd2_journal_get_undo_access(handle_t *handle, struct buffer_head *bh) in jbd2_journal_get_undo_access() argument
1361 if (is_handle_aborted(handle)) in jbd2_journal_get_undo_access()
1364 if (jbd2_write_access_granted(handle, bh, true)) in jbd2_journal_get_undo_access()
1375 err = do_get_write_access(handle, jh, 1); in jbd2_journal_get_undo_access()
1471 int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh) in jbd2_journal_dirty_metadata() argument
1473 transaction_t *transaction = handle->h_transaction; in jbd2_journal_dirty_metadata()
1511 handle->h_type, handle->h_line_no, in jbd2_journal_dirty_metadata()
1524 if (is_handle_aborted(handle)) { in jbd2_journal_dirty_metadata()
1542 if (WARN_ON_ONCE(jbd2_handle_buffer_credits(handle) <= 0)) { in jbd2_journal_dirty_metadata()
1547 handle->h_total_credits--; in jbd2_journal_dirty_metadata()
1643 int jbd2_journal_forget(handle_t *handle, struct buffer_head *bh) in jbd2_journal_forget() argument
1645 transaction_t *transaction = handle->h_transaction; in jbd2_journal_forget()
1652 if (is_handle_aborted(handle)) in jbd2_journal_forget()
1789 handle->h_total_credits++; in jbd2_journal_forget()
1810 int jbd2_journal_stop(handle_t *handle) in jbd2_journal_stop() argument
1812 transaction_t *transaction = handle->h_transaction; in jbd2_journal_stop()
1818 if (--handle->h_ref > 0) { in jbd2_journal_stop()
1819 jbd2_debug(4, "h_ref %d -> %d\n", handle->h_ref + 1, in jbd2_journal_stop()
1820 handle->h_ref); in jbd2_journal_stop()
1821 if (is_handle_aborted(handle)) in jbd2_journal_stop()
1830 memalloc_nofs_restore(handle->saved_alloc_context); in jbd2_journal_stop()
1836 if (is_handle_aborted(handle)) in jbd2_journal_stop()
1839 jbd2_debug(4, "Handle %p going down\n", handle); in jbd2_journal_stop()
1841 tid, handle->h_type, handle->h_line_no, in jbd2_journal_stop()
1842 jiffies - handle->h_start_jiffies, in jbd2_journal_stop()
1843 handle->h_sync, handle->h_requested_credits, in jbd2_journal_stop()
1844 (handle->h_requested_credits - in jbd2_journal_stop()
1845 handle->h_total_credits)); in jbd2_journal_stop()
1877 if (handle->h_sync && journal->j_last_sync_writer != pid && in jbd2_journal_stop()
1903 if (handle->h_sync) in jbd2_journal_stop()
1911 if (handle->h_sync || in jbd2_journal_stop()
1918 "handle %p\n", handle); in jbd2_journal_stop()
1926 if (handle->h_sync && !(current->flags & PF_MEMALLOC)) in jbd2_journal_stop()
1936 stop_this_handle(handle); in jbd2_journal_stop()
1942 if (handle->h_rsv_handle) in jbd2_journal_stop()
1943 jbd2_free_handle(handle->h_rsv_handle); in jbd2_journal_stop()
1944 jbd2_free_handle(handle); in jbd2_journal_stop()
2633 static int jbd2_journal_file_inode(handle_t *handle, struct jbd2_inode *jinode, in jbd2_journal_file_inode() argument
2636 transaction_t *transaction = handle->h_transaction; in jbd2_journal_file_inode()
2639 if (is_handle_aborted(handle)) in jbd2_journal_file_inode()
2688 int jbd2_journal_inode_ranged_write(handle_t *handle, in jbd2_journal_inode_ranged_write() argument
2691 return jbd2_journal_file_inode(handle, jinode, in jbd2_journal_inode_ranged_write()
2696 int jbd2_journal_inode_ranged_wait(handle_t *handle, struct jbd2_inode *jinode, in jbd2_journal_inode_ranged_wait() argument
2699 return jbd2_journal_file_inode(handle, jinode, JI_WAIT_DATA, in jbd2_journal_inode_ranged_wait()