Lines Matching refs:handle

336 static int start_this_handle(journal_t *journal, handle_t *handle,  in start_this_handle()  argument
340 int blocks = handle->h_total_credits; in start_this_handle()
344 if (handle->h_rsv_handle) in start_this_handle()
345 rsv_blocks = handle->h_rsv_handle->h_total_credits; in start_this_handle()
381 jbd_debug(3, "New handle %p going live.\n", handle); in start_this_handle()
402 if (!handle->h_reserved && journal->j_barrier_count) { in start_this_handle()
415 (handle->h_reserved || !journal->j_barrier_count)) { in start_this_handle()
425 if (!handle->h_reserved) { in start_this_handle()
448 handle->h_reserved = 0; in start_this_handle()
455 handle->h_transaction = transaction; in start_this_handle()
456 handle->h_requested_credits = blocks; in start_this_handle()
457 handle->h_revoke_credits_requested = handle->h_revoke_credits; in start_this_handle()
458 handle->h_start_jiffies = jiffies; in start_this_handle()
462 handle, blocks, in start_this_handle()
466 current->journal_info = handle; in start_this_handle()
474 handle->saved_alloc_context = memalloc_nofs_save(); in start_this_handle()
481 handle_t *handle = jbd2_alloc_handle(GFP_NOFS); in new_handle() local
482 if (!handle) in new_handle()
484 handle->h_total_credits = nblocks; in new_handle()
485 handle->h_ref = 1; in new_handle()
487 return handle; in new_handle()
494 handle_t *handle = journal_current_handle(); in jbd2__journal_start() local
500 if (handle) { in jbd2__journal_start()
501 J_ASSERT(handle->h_transaction->t_journal == journal); in jbd2__journal_start()
502 handle->h_ref++; in jbd2__journal_start()
503 return handle; in jbd2__journal_start()
508 handle = new_handle(nblocks); in jbd2__journal_start()
509 if (!handle) in jbd2__journal_start()
516 jbd2_free_handle(handle); in jbd2__journal_start()
521 handle->h_rsv_handle = rsv_handle; in jbd2__journal_start()
523 handle->h_revoke_credits = revoke_records; in jbd2__journal_start()
525 err = start_this_handle(journal, handle, gfp_mask); in jbd2__journal_start()
527 if (handle->h_rsv_handle) in jbd2__journal_start()
528 jbd2_free_handle(handle->h_rsv_handle); in jbd2__journal_start()
529 jbd2_free_handle(handle); in jbd2__journal_start()
532 handle->h_type = type; in jbd2__journal_start()
533 handle->h_line_no = line_no; in jbd2__journal_start()
535 handle->h_transaction->t_tid, type, in jbd2__journal_start()
538 return handle; in jbd2__journal_start()
568 static void __jbd2_journal_unreserve_handle(handle_t *handle, transaction_t *t) in __jbd2_journal_unreserve_handle() argument
570 journal_t *journal = handle->h_journal; in __jbd2_journal_unreserve_handle()
572 WARN_ON(!handle->h_reserved); in __jbd2_journal_unreserve_handle()
573 sub_reserved_credits(journal, handle->h_total_credits); in __jbd2_journal_unreserve_handle()
575 atomic_sub(handle->h_total_credits, &t->t_outstanding_credits); in __jbd2_journal_unreserve_handle()
578 void jbd2_journal_free_reserved(handle_t *handle) in jbd2_journal_free_reserved() argument
580 journal_t *journal = handle->h_journal; in jbd2_journal_free_reserved()
584 __jbd2_journal_unreserve_handle(handle, journal->j_running_transaction); in jbd2_journal_free_reserved()
586 jbd2_free_handle(handle); in jbd2_journal_free_reserved()
604 int jbd2_journal_start_reserved(handle_t *handle, unsigned int type, in jbd2_journal_start_reserved() argument
607 journal_t *journal = handle->h_journal; in jbd2_journal_start_reserved()
610 if (WARN_ON(!handle->h_reserved)) { in jbd2_journal_start_reserved()
612 jbd2_journal_stop(handle); in jbd2_journal_start_reserved()
620 jbd2_journal_free_reserved(handle); in jbd2_journal_start_reserved()
624 handle->h_journal = NULL; in jbd2_journal_start_reserved()
629 ret = start_this_handle(journal, handle, GFP_NOFS); in jbd2_journal_start_reserved()
631 handle->h_journal = journal; in jbd2_journal_start_reserved()
632 jbd2_journal_free_reserved(handle); in jbd2_journal_start_reserved()
635 handle->h_type = type; in jbd2_journal_start_reserved()
636 handle->h_line_no = line_no; in jbd2_journal_start_reserved()
638 handle->h_transaction->t_tid, type, in jbd2_journal_start_reserved()
639 line_no, handle->h_total_credits); in jbd2_journal_start_reserved()
665 int jbd2_journal_extend(handle_t *handle, int nblocks, int revoke_records) in jbd2_journal_extend() argument
667 transaction_t *transaction = handle->h_transaction; in jbd2_journal_extend()
672 if (is_handle_aborted(handle)) in jbd2_journal_extend()
683 "transaction not running\n", handle, nblocks); in jbd2_journal_extend()
688 handle->h_revoke_credits_requested + revoke_records, in jbd2_journal_extend()
691 handle->h_revoke_credits_requested, in jbd2_journal_extend()
699 "transaction too large\n", handle, nblocks); in jbd2_journal_extend()
706 handle->h_type, handle->h_line_no, in jbd2_journal_extend()
707 handle->h_total_credits, in jbd2_journal_extend()
710 handle->h_total_credits += nblocks; in jbd2_journal_extend()
711 handle->h_requested_credits += nblocks; in jbd2_journal_extend()
712 handle->h_revoke_credits += revoke_records; in jbd2_journal_extend()
713 handle->h_revoke_credits_requested += revoke_records; in jbd2_journal_extend()
716 jbd_debug(3, "extended handle %p by %d\n", handle, nblocks); in jbd2_journal_extend()
724 static void stop_this_handle(handle_t *handle) in stop_this_handle() argument
726 transaction_t *transaction = handle->h_transaction; in stop_this_handle()
730 J_ASSERT(journal_current_handle() == handle); in stop_this_handle()
739 revokes = handle->h_revoke_credits_requested - handle->h_revoke_credits; in stop_this_handle()
745 > handle->h_total_credits); in stop_this_handle()
751 handle->h_total_credits -= revoke_descriptors; in stop_this_handle()
753 atomic_sub(handle->h_total_credits, in stop_this_handle()
755 if (handle->h_rsv_handle) in stop_this_handle()
756 __jbd2_journal_unreserve_handle(handle->h_rsv_handle, in stop_this_handle()
766 memalloc_nofs_restore(handle->saved_alloc_context); in stop_this_handle()
786 int jbd2__journal_restart(handle_t *handle, int nblocks, int revoke_records, in jbd2__journal_restart() argument
789 transaction_t *transaction = handle->h_transaction; in jbd2__journal_restart()
797 if (is_handle_aborted(handle)) in jbd2__journal_restart()
806 jbd_debug(2, "restarting handle %p\n", handle); in jbd2__journal_restart()
807 stop_this_handle(handle); in jbd2__journal_restart()
808 handle->h_transaction = NULL; in jbd2__journal_restart()
819 handle->h_total_credits = nblocks + in jbd2__journal_restart()
822 handle->h_revoke_credits = revoke_records; in jbd2__journal_restart()
823 ret = start_this_handle(journal, handle, gfp_mask); in jbd2__journal_restart()
825 ret ? 0 : handle->h_transaction->t_tid, in jbd2__journal_restart()
826 handle->h_type, handle->h_line_no, in jbd2__journal_restart()
827 handle->h_total_credits); in jbd2__journal_restart()
833 int jbd2_journal_restart(handle_t *handle, int nblocks) in jbd2_journal_restart() argument
835 return jbd2__journal_restart(handle, nblocks, 0, GFP_NOFS); in jbd2_journal_restart()
961 do_get_write_access(handle_t *handle, struct journal_head *jh, in do_get_write_access() argument
965 transaction_t *transaction = handle->h_transaction; in do_get_write_access()
1032 if (is_handle_aborted(handle)) { in do_get_write_access()
1143 jbd2_journal_cancel_revoke(handle, jh); in do_get_write_access()
1154 static bool jbd2_write_access_granted(handle_t *handle, struct buffer_head *bh, in jbd2_write_access_granted() argument
1185 if (READ_ONCE(jh->b_transaction) != handle->h_transaction && in jbd2_write_access_granted()
1186 READ_ONCE(jh->b_next_transaction) != handle->h_transaction) in jbd2_write_access_granted()
1218 int jbd2_journal_get_write_access(handle_t *handle, struct buffer_head *bh) in jbd2_journal_get_write_access() argument
1223 if (is_handle_aborted(handle)) in jbd2_journal_get_write_access()
1226 if (jbd2_write_access_granted(handle, bh, false)) in jbd2_journal_get_write_access()
1233 rc = do_get_write_access(handle, jh, 0); in jbd2_journal_get_write_access()
1258 int jbd2_journal_get_create_access(handle_t *handle, struct buffer_head *bh) in jbd2_journal_get_create_access() argument
1260 transaction_t *transaction = handle->h_transaction; in jbd2_journal_get_create_access()
1267 if (is_handle_aborted(handle)) in jbd2_journal_get_create_access()
1325 jbd2_journal_cancel_revoke(handle, jh); in jbd2_journal_get_create_access()
1357 int jbd2_journal_get_undo_access(handle_t *handle, struct buffer_head *bh) in jbd2_journal_get_undo_access() argument
1363 if (is_handle_aborted(handle)) in jbd2_journal_get_undo_access()
1366 if (jbd2_write_access_granted(handle, bh, true)) in jbd2_journal_get_undo_access()
1377 err = do_get_write_access(handle, jh, 1); in jbd2_journal_get_undo_access()
1473 int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh) in jbd2_journal_dirty_metadata() argument
1475 transaction_t *transaction = handle->h_transaction; in jbd2_journal_dirty_metadata()
1480 if (is_handle_aborted(handle)) in jbd2_journal_dirty_metadata()
1515 handle->h_type, handle->h_line_no, in jbd2_journal_dirty_metadata()
1534 if (WARN_ON_ONCE(jbd2_handle_buffer_credits(handle) <= 0)) { in jbd2_journal_dirty_metadata()
1539 handle->h_total_credits--; in jbd2_journal_dirty_metadata()
1635 int jbd2_journal_forget(handle_t *handle, struct buffer_head *bh) in jbd2_journal_forget() argument
1637 transaction_t *transaction = handle->h_transaction; in jbd2_journal_forget()
1644 if (is_handle_aborted(handle)) in jbd2_journal_forget()
1782 handle->h_total_credits++; in jbd2_journal_forget()
1803 int jbd2_journal_stop(handle_t *handle) in jbd2_journal_stop() argument
1805 transaction_t *transaction = handle->h_transaction; in jbd2_journal_stop()
1811 if (--handle->h_ref > 0) { in jbd2_journal_stop()
1812 jbd_debug(4, "h_ref %d -> %d\n", handle->h_ref + 1, in jbd2_journal_stop()
1813 handle->h_ref); in jbd2_journal_stop()
1814 if (is_handle_aborted(handle)) in jbd2_journal_stop()
1823 memalloc_nofs_restore(handle->saved_alloc_context); in jbd2_journal_stop()
1829 if (is_handle_aborted(handle)) in jbd2_journal_stop()
1832 jbd_debug(4, "Handle %p going down\n", handle); in jbd2_journal_stop()
1834 tid, handle->h_type, handle->h_line_no, in jbd2_journal_stop()
1835 jiffies - handle->h_start_jiffies, in jbd2_journal_stop()
1836 handle->h_sync, handle->h_requested_credits, in jbd2_journal_stop()
1837 (handle->h_requested_credits - in jbd2_journal_stop()
1838 handle->h_total_credits)); in jbd2_journal_stop()
1870 if (handle->h_sync && journal->j_last_sync_writer != pid && in jbd2_journal_stop()
1896 if (handle->h_sync) in jbd2_journal_stop()
1904 if (handle->h_sync || in jbd2_journal_stop()
1911 "handle %p\n", handle); in jbd2_journal_stop()
1919 if (handle->h_sync && !(current->flags & PF_MEMALLOC)) in jbd2_journal_stop()
1929 stop_this_handle(handle); in jbd2_journal_stop()
1935 if (handle->h_rsv_handle) in jbd2_journal_stop()
1936 jbd2_free_handle(handle->h_rsv_handle); in jbd2_journal_stop()
1937 jbd2_free_handle(handle); in jbd2_journal_stop()
2647 static int jbd2_journal_file_inode(handle_t *handle, struct jbd2_inode *jinode, in jbd2_journal_file_inode() argument
2650 transaction_t *transaction = handle->h_transaction; in jbd2_journal_file_inode()
2653 if (is_handle_aborted(handle)) in jbd2_journal_file_inode()
2702 int jbd2_journal_inode_ranged_write(handle_t *handle, in jbd2_journal_inode_ranged_write() argument
2705 return jbd2_journal_file_inode(handle, jinode, in jbd2_journal_inode_ranged_write()
2710 int jbd2_journal_inode_ranged_wait(handle_t *handle, struct jbd2_inode *jinode, in jbd2_journal_inode_ranged_wait() argument
2713 return jbd2_journal_file_inode(handle, jinode, JI_WAIT_DATA, in jbd2_journal_inode_ranged_wait()