Lines Matching refs:handle

331 static int start_this_handle(journal_t *journal, handle_t *handle,  in start_this_handle()  argument
335 int blocks = handle->h_total_credits; in start_this_handle()
339 if (handle->h_rsv_handle) in start_this_handle()
340 rsv_blocks = handle->h_rsv_handle->h_total_credits; in start_this_handle()
376 jbd2_debug(3, "New handle %p going live.\n", handle); in start_this_handle()
397 if (!handle->h_reserved && journal->j_barrier_count) { in start_this_handle()
410 (handle->h_reserved || !journal->j_barrier_count)) { in start_this_handle()
420 if (!handle->h_reserved) { in start_this_handle()
443 handle->h_reserved = 0; in start_this_handle()
450 handle->h_transaction = transaction; in start_this_handle()
451 handle->h_requested_credits = blocks; in start_this_handle()
452 handle->h_revoke_credits_requested = handle->h_revoke_credits; in start_this_handle()
453 handle->h_start_jiffies = jiffies; in start_this_handle()
457 handle, blocks, in start_this_handle()
461 current->journal_info = handle; in start_this_handle()
469 handle->saved_alloc_context = memalloc_nofs_save(); in start_this_handle()
476 handle_t *handle = jbd2_alloc_handle(GFP_NOFS); in new_handle() local
477 if (!handle) in new_handle()
479 handle->h_total_credits = nblocks; in new_handle()
480 handle->h_ref = 1; in new_handle()
482 return handle; in new_handle()
489 handle_t *handle = journal_current_handle(); in jbd2__journal_start() local
495 if (handle) { in jbd2__journal_start()
496 J_ASSERT(handle->h_transaction->t_journal == journal); in jbd2__journal_start()
497 handle->h_ref++; in jbd2__journal_start()
498 return handle; in jbd2__journal_start()
503 handle = new_handle(nblocks); in jbd2__journal_start()
504 if (!handle) in jbd2__journal_start()
511 jbd2_free_handle(handle); in jbd2__journal_start()
516 handle->h_rsv_handle = rsv_handle; in jbd2__journal_start()
518 handle->h_revoke_credits = revoke_records; in jbd2__journal_start()
520 err = start_this_handle(journal, handle, gfp_mask); in jbd2__journal_start()
522 if (handle->h_rsv_handle) in jbd2__journal_start()
523 jbd2_free_handle(handle->h_rsv_handle); in jbd2__journal_start()
524 jbd2_free_handle(handle); in jbd2__journal_start()
527 handle->h_type = type; in jbd2__journal_start()
528 handle->h_line_no = line_no; in jbd2__journal_start()
530 handle->h_transaction->t_tid, type, in jbd2__journal_start()
533 return handle; in jbd2__journal_start()
563 static void __jbd2_journal_unreserve_handle(handle_t *handle, transaction_t *t) in __jbd2_journal_unreserve_handle() argument
565 journal_t *journal = handle->h_journal; in __jbd2_journal_unreserve_handle()
567 WARN_ON(!handle->h_reserved); in __jbd2_journal_unreserve_handle()
568 sub_reserved_credits(journal, handle->h_total_credits); in __jbd2_journal_unreserve_handle()
570 atomic_sub(handle->h_total_credits, &t->t_outstanding_credits); in __jbd2_journal_unreserve_handle()
573 void jbd2_journal_free_reserved(handle_t *handle) in jbd2_journal_free_reserved() argument
575 journal_t *journal = handle->h_journal; in jbd2_journal_free_reserved()
579 __jbd2_journal_unreserve_handle(handle, journal->j_running_transaction); in jbd2_journal_free_reserved()
581 jbd2_free_handle(handle); in jbd2_journal_free_reserved()
599 int jbd2_journal_start_reserved(handle_t *handle, unsigned int type, in jbd2_journal_start_reserved() argument
602 journal_t *journal = handle->h_journal; in jbd2_journal_start_reserved()
605 if (WARN_ON(!handle->h_reserved)) { in jbd2_journal_start_reserved()
607 jbd2_journal_stop(handle); in jbd2_journal_start_reserved()
615 jbd2_journal_free_reserved(handle); in jbd2_journal_start_reserved()
619 handle->h_journal = NULL; in jbd2_journal_start_reserved()
624 ret = start_this_handle(journal, handle, GFP_NOFS); in jbd2_journal_start_reserved()
626 handle->h_journal = journal; in jbd2_journal_start_reserved()
627 jbd2_journal_free_reserved(handle); in jbd2_journal_start_reserved()
630 handle->h_type = type; in jbd2_journal_start_reserved()
631 handle->h_line_no = line_no; in jbd2_journal_start_reserved()
633 handle->h_transaction->t_tid, type, in jbd2_journal_start_reserved()
634 line_no, handle->h_total_credits); in jbd2_journal_start_reserved()
660 int jbd2_journal_extend(handle_t *handle, int nblocks, int revoke_records) in jbd2_journal_extend() argument
662 transaction_t *transaction = handle->h_transaction; in jbd2_journal_extend()
667 if (is_handle_aborted(handle)) in jbd2_journal_extend()
678 "transaction not running\n", handle, nblocks); in jbd2_journal_extend()
683 handle->h_revoke_credits_requested + revoke_records, in jbd2_journal_extend()
686 handle->h_revoke_credits_requested, in jbd2_journal_extend()
693 "transaction too large\n", handle, nblocks); in jbd2_journal_extend()
700 handle->h_type, handle->h_line_no, in jbd2_journal_extend()
701 handle->h_total_credits, in jbd2_journal_extend()
704 handle->h_total_credits += nblocks; in jbd2_journal_extend()
705 handle->h_requested_credits += nblocks; in jbd2_journal_extend()
706 handle->h_revoke_credits += revoke_records; in jbd2_journal_extend()
707 handle->h_revoke_credits_requested += revoke_records; in jbd2_journal_extend()
710 jbd2_debug(3, "extended handle %p by %d\n", handle, nblocks); in jbd2_journal_extend()
716 static void stop_this_handle(handle_t *handle) in stop_this_handle() argument
718 transaction_t *transaction = handle->h_transaction; in stop_this_handle()
722 J_ASSERT(journal_current_handle() == handle); in stop_this_handle()
731 revokes = handle->h_revoke_credits_requested - handle->h_revoke_credits; in stop_this_handle()
737 > handle->h_total_credits); in stop_this_handle()
743 handle->h_total_credits -= revoke_descriptors; in stop_this_handle()
745 atomic_sub(handle->h_total_credits, in stop_this_handle()
747 if (handle->h_rsv_handle) in stop_this_handle()
748 __jbd2_journal_unreserve_handle(handle->h_rsv_handle, in stop_this_handle()
758 memalloc_nofs_restore(handle->saved_alloc_context); in stop_this_handle()
778 int jbd2__journal_restart(handle_t *handle, int nblocks, int revoke_records, in jbd2__journal_restart() argument
781 transaction_t *transaction = handle->h_transaction; in jbd2__journal_restart()
789 if (is_handle_aborted(handle)) in jbd2__journal_restart()
798 jbd2_debug(2, "restarting handle %p\n", handle); in jbd2__journal_restart()
799 stop_this_handle(handle); in jbd2__journal_restart()
800 handle->h_transaction = NULL; in jbd2__journal_restart()
811 handle->h_total_credits = nblocks + in jbd2__journal_restart()
814 handle->h_revoke_credits = revoke_records; in jbd2__journal_restart()
815 ret = start_this_handle(journal, handle, gfp_mask); in jbd2__journal_restart()
817 ret ? 0 : handle->h_transaction->t_tid, in jbd2__journal_restart()
818 handle->h_type, handle->h_line_no, in jbd2__journal_restart()
819 handle->h_total_credits); in jbd2__journal_restart()
825 int jbd2_journal_restart(handle_t *handle, int nblocks) in jbd2_journal_restart() argument
827 return jbd2__journal_restart(handle, nblocks, 0, GFP_NOFS); in jbd2_journal_restart()
966 do_get_write_access(handle_t *handle, struct journal_head *jh, in do_get_write_access() argument
970 transaction_t *transaction = handle->h_transaction; in do_get_write_access()
1028 if (is_handle_aborted(handle)) { in do_get_write_access()
1156 jbd2_journal_cancel_revoke(handle, jh); in do_get_write_access()
1167 static bool jbd2_write_access_granted(handle_t *handle, struct buffer_head *bh, in jbd2_write_access_granted() argument
1198 if (READ_ONCE(jh->b_transaction) != handle->h_transaction && in jbd2_write_access_granted()
1199 READ_ONCE(jh->b_next_transaction) != handle->h_transaction) in jbd2_write_access_granted()
1231 int jbd2_journal_get_write_access(handle_t *handle, struct buffer_head *bh) in jbd2_journal_get_write_access() argument
1236 if (is_handle_aborted(handle)) in jbd2_journal_get_write_access()
1239 if (jbd2_write_access_granted(handle, bh, false)) in jbd2_journal_get_write_access()
1246 rc = do_get_write_access(handle, jh, 0); in jbd2_journal_get_write_access()
1271 int jbd2_journal_get_create_access(handle_t *handle, struct buffer_head *bh) in jbd2_journal_get_create_access() argument
1273 transaction_t *transaction = handle->h_transaction; in jbd2_journal_get_create_access()
1280 if (is_handle_aborted(handle)) in jbd2_journal_get_create_access()
1338 jbd2_journal_cancel_revoke(handle, jh); in jbd2_journal_get_create_access()
1370 int jbd2_journal_get_undo_access(handle_t *handle, struct buffer_head *bh) in jbd2_journal_get_undo_access() argument
1376 if (is_handle_aborted(handle)) in jbd2_journal_get_undo_access()
1379 if (jbd2_write_access_granted(handle, bh, true)) in jbd2_journal_get_undo_access()
1390 err = do_get_write_access(handle, jh, 1); in jbd2_journal_get_undo_access()
1486 int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh) in jbd2_journal_dirty_metadata() argument
1488 transaction_t *transaction = handle->h_transaction; in jbd2_journal_dirty_metadata()
1526 handle->h_type, handle->h_line_no, in jbd2_journal_dirty_metadata()
1539 if (is_handle_aborted(handle)) { in jbd2_journal_dirty_metadata()
1557 if (WARN_ON_ONCE(jbd2_handle_buffer_credits(handle) <= 0)) { in jbd2_journal_dirty_metadata()
1562 handle->h_total_credits--; in jbd2_journal_dirty_metadata()
1658 int jbd2_journal_forget(handle_t *handle, struct buffer_head *bh) in jbd2_journal_forget() argument
1660 transaction_t *transaction = handle->h_transaction; in jbd2_journal_forget()
1667 if (is_handle_aborted(handle)) in jbd2_journal_forget()
1804 handle->h_total_credits++; in jbd2_journal_forget()
1825 int jbd2_journal_stop(handle_t *handle) in jbd2_journal_stop() argument
1827 transaction_t *transaction = handle->h_transaction; in jbd2_journal_stop()
1833 if (--handle->h_ref > 0) { in jbd2_journal_stop()
1834 jbd2_debug(4, "h_ref %d -> %d\n", handle->h_ref + 1, in jbd2_journal_stop()
1835 handle->h_ref); in jbd2_journal_stop()
1836 if (is_handle_aborted(handle)) in jbd2_journal_stop()
1845 memalloc_nofs_restore(handle->saved_alloc_context); in jbd2_journal_stop()
1851 if (is_handle_aborted(handle)) in jbd2_journal_stop()
1854 jbd2_debug(4, "Handle %p going down\n", handle); in jbd2_journal_stop()
1856 tid, handle->h_type, handle->h_line_no, in jbd2_journal_stop()
1857 jiffies - handle->h_start_jiffies, in jbd2_journal_stop()
1858 handle->h_sync, handle->h_requested_credits, in jbd2_journal_stop()
1859 (handle->h_requested_credits - in jbd2_journal_stop()
1860 handle->h_total_credits)); in jbd2_journal_stop()
1892 if (handle->h_sync && journal->j_last_sync_writer != pid && in jbd2_journal_stop()
1918 if (handle->h_sync) in jbd2_journal_stop()
1926 if (handle->h_sync || in jbd2_journal_stop()
1933 "handle %p\n", handle); in jbd2_journal_stop()
1941 if (handle->h_sync && !(current->flags & PF_MEMALLOC)) in jbd2_journal_stop()
1951 stop_this_handle(handle); in jbd2_journal_stop()
1957 if (handle->h_rsv_handle) in jbd2_journal_stop()
1958 jbd2_free_handle(handle->h_rsv_handle); in jbd2_journal_stop()
1959 jbd2_free_handle(handle); in jbd2_journal_stop()
2648 static int jbd2_journal_file_inode(handle_t *handle, struct jbd2_inode *jinode, in jbd2_journal_file_inode() argument
2651 transaction_t *transaction = handle->h_transaction; in jbd2_journal_file_inode()
2654 if (is_handle_aborted(handle)) in jbd2_journal_file_inode()
2703 int jbd2_journal_inode_ranged_write(handle_t *handle, in jbd2_journal_inode_ranged_write() argument
2706 return jbd2_journal_file_inode(handle, jinode, in jbd2_journal_inode_ranged_write()
2711 int jbd2_journal_inode_ranged_wait(handle_t *handle, struct jbd2_inode *jinode, in jbd2_journal_inode_ranged_wait() argument
2714 return jbd2_journal_file_inode(handle, jinode, JI_WAIT_DATA, in jbd2_journal_inode_ranged_wait()