Lines Matching refs:cil
52 xlog_cil_set_iclog_hdr_count(struct xfs_cil *cil) in xlog_cil_set_iclog_hdr_count() argument
54 struct xlog *log = cil->xc_log; in xlog_cil_set_iclog_hdr_count()
56 atomic_set(&cil->xc_iclog_hdrs, in xlog_cil_set_iclog_hdr_count()
72 struct xfs_cil *cil, in xlog_item_in_current_chkpt() argument
75 if (test_bit(XLOG_CIL_EMPTY, &cil->xc_flags)) in xlog_item_in_current_chkpt()
83 return lip->li_seq == READ_ONCE(cil->xc_current_sequence); in xlog_item_in_current_chkpt()
121 struct xfs_cil *cil, in xlog_cil_push_pcp_aggregate() argument
128 cilpcp = per_cpu_ptr(cil->xc_pcp, cpu); in xlog_cil_push_pcp_aggregate()
157 struct xfs_cil *cil, in xlog_cil_insert_pcp_aggregate() argument
165 if (!test_and_clear_bit(XLOG_CIL_PCP_SPACE, &cil->xc_flags)) in xlog_cil_insert_pcp_aggregate()
171 cilpcp = per_cpu_ptr(cil->xc_pcp, cpu); in xlog_cil_insert_pcp_aggregate()
183 struct xfs_cil *cil, in xlog_cil_ctx_switch() argument
186 xlog_cil_set_iclog_hdr_count(cil); in xlog_cil_ctx_switch()
187 set_bit(XLOG_CIL_EMPTY, &cil->xc_flags); in xlog_cil_ctx_switch()
188 set_bit(XLOG_CIL_PCP_SPACE, &cil->xc_flags); in xlog_cil_ctx_switch()
189 ctx->sequence = ++cil->xc_current_sequence; in xlog_cil_ctx_switch()
190 ctx->cil = cil; in xlog_cil_ctx_switch()
191 cil->xc_ctx = ctx; in xlog_cil_ctx_switch()
550 struct xfs_cil *cil = log->l_cilp; in xlog_cil_insert_items() local
551 struct xfs_cil_ctx *ctx = cil->xc_ctx; in xlog_cil_insert_items()
580 cilpcp = get_cpu_ptr(cil->xc_pcp); in xlog_cil_insert_items()
589 if (test_bit(XLOG_CIL_EMPTY, &cil->xc_flags) && in xlog_cil_insert_items()
590 test_and_clear_bit(XLOG_CIL_EMPTY, &cil->xc_flags)) in xlog_cil_insert_items()
612 if (atomic_read(&cil->xc_iclog_hdrs) > 0 || in xlog_cil_insert_items()
620 atomic_sub(tp->t_ticket->t_iclog_hdrs, &cil->xc_iclog_hdrs); in xlog_cil_insert_items()
628 if (!test_bit(XLOG_CIL_PCP_SPACE, &cil->xc_flags)) { in xlog_cil_insert_items()
641 xlog_cil_insert_pcp_aggregate(cil, ctx); in xlog_cil_insert_items()
705 struct xfs_mount *mp = ctx->cil->xc_log->l_mp; in xlog_discard_endio_work()
778 struct xfs_mount *mp = ctx->cil->xc_log->l_mp; in xlog_cil_committed()
779 bool abort = xlog_is_shutdown(ctx->cil->xc_log); in xlog_cil_committed()
789 spin_lock(&ctx->cil->xc_push_lock); in xlog_cil_committed()
790 wake_up_all(&ctx->cil->xc_start_wait); in xlog_cil_committed()
791 wake_up_all(&ctx->cil->xc_commit_wait); in xlog_cil_committed()
792 spin_unlock(&ctx->cil->xc_push_lock); in xlog_cil_committed()
795 xfs_trans_committed_bulk(ctx->cil->xc_log->l_ailp, &ctx->lv_chain, in xlog_cil_committed()
802 spin_lock(&ctx->cil->xc_push_lock); in xlog_cil_committed()
804 spin_unlock(&ctx->cil->xc_push_lock); in xlog_cil_committed()
838 struct xfs_cil *cil = ctx->cil; in xlog_cil_set_ctx_write_state() local
843 spin_lock(&cil->xc_push_lock); in xlog_cil_set_ctx_write_state()
852 wake_up_all(&cil->xc_start_wait); in xlog_cil_set_ctx_write_state()
853 spin_unlock(&cil->xc_push_lock); in xlog_cil_set_ctx_write_state()
860 spin_lock(&cil->xc_log->l_icloglock); in xlog_cil_set_ctx_write_state()
862 spin_unlock(&cil->xc_log->l_icloglock); in xlog_cil_set_ctx_write_state()
881 spin_lock(&cil->xc_log->l_icloglock); in xlog_cil_set_ctx_write_state()
883 spin_unlock(&cil->xc_log->l_icloglock); in xlog_cil_set_ctx_write_state()
890 spin_lock(&cil->xc_push_lock); in xlog_cil_set_ctx_write_state()
893 wake_up_all(&cil->xc_commit_wait); in xlog_cil_set_ctx_write_state()
894 spin_unlock(&cil->xc_push_lock); in xlog_cil_set_ctx_write_state()
910 struct xfs_cil *cil, in xlog_cil_order_write() argument
917 spin_lock(&cil->xc_push_lock); in xlog_cil_order_write()
918 list_for_each_entry(ctx, &cil->xc_committing, committing) { in xlog_cil_order_write()
924 if (xlog_is_shutdown(cil->xc_log)) { in xlog_cil_order_write()
925 spin_unlock(&cil->xc_push_lock); in xlog_cil_order_write()
940 xlog_wait(&cil->xc_start_wait, &cil->xc_push_lock); in xlog_cil_order_write()
946 xlog_wait(&cil->xc_commit_wait, &cil->xc_push_lock); in xlog_cil_order_write()
952 spin_unlock(&cil->xc_push_lock); in xlog_cil_order_write()
967 struct xlog *log = ctx->cil->xc_log; in xlog_cil_write_chain()
970 error = xlog_cil_order_write(ctx->cil, ctx->sequence, _START_RECORD); in xlog_cil_write_chain()
986 struct xlog *log = ctx->cil->xc_log; in xlog_cil_write_commit_record()
1008 error = xlog_cil_order_write(ctx->cil, ctx->sequence, _COMMIT_RECORD); in xlog_cil_write_commit_record()
1181 struct xfs_cil *cil = ctx->cil; in xlog_cil_push_work() local
1182 struct xlog *log = cil->xc_log; in xlog_cil_push_work()
1197 down_write(&cil->xc_ctx_lock); in xlog_cil_push_work()
1199 spin_lock(&cil->xc_push_lock); in xlog_cil_push_work()
1200 push_seq = cil->xc_push_seq; in xlog_cil_push_work()
1202 push_commit_stable = cil->xc_push_commit_stable; in xlog_cil_push_work()
1203 cil->xc_push_commit_stable = false; in xlog_cil_push_work()
1213 if (waitqueue_active(&cil->xc_push_wait)) in xlog_cil_push_work()
1214 wake_up_all(&cil->xc_push_wait); in xlog_cil_push_work()
1216 xlog_cil_push_pcp_aggregate(cil, ctx); in xlog_cil_push_work()
1223 if (test_bit(XLOG_CIL_EMPTY, &cil->xc_flags)) { in xlog_cil_push_work()
1224 cil->xc_push_seq = 0; in xlog_cil_push_work()
1225 spin_unlock(&cil->xc_push_lock); in xlog_cil_push_work()
1232 spin_unlock(&cil->xc_push_lock); in xlog_cil_push_work()
1260 list_add(&ctx->committing, &cil->xc_committing); in xlog_cil_push_work()
1261 spin_unlock(&cil->xc_push_lock); in xlog_cil_push_work()
1290 spin_lock(&cil->xc_push_lock); in xlog_cil_push_work()
1291 xlog_cil_ctx_switch(cil, new_ctx); in xlog_cil_push_work()
1292 spin_unlock(&cil->xc_push_lock); in xlog_cil_push_work()
1293 up_write(&cil->xc_ctx_lock); in xlog_cil_push_work()
1395 up_write(&cil->xc_ctx_lock); in xlog_cil_push_work()
1425 struct xlog *log) __releases(cil->xc_ctx_lock) in xlog_cil_push_background()
1427 struct xfs_cil *cil = log->l_cilp; in xlog_cil_push_background() local
1428 int space_used = atomic_read(&cil->xc_ctx->space_used); in xlog_cil_push_background()
1434 ASSERT(!test_bit(XLOG_CIL_EMPTY, &cil->xc_flags)); in xlog_cil_push_background()
1446 (cil->xc_push_seq == cil->xc_current_sequence && in xlog_cil_push_background()
1448 !waitqueue_active(&cil->xc_push_wait))) { in xlog_cil_push_background()
1449 up_read(&cil->xc_ctx_lock); in xlog_cil_push_background()
1453 spin_lock(&cil->xc_push_lock); in xlog_cil_push_background()
1454 if (cil->xc_push_seq < cil->xc_current_sequence) { in xlog_cil_push_background()
1455 cil->xc_push_seq = cil->xc_current_sequence; in xlog_cil_push_background()
1456 queue_work(cil->xc_push_wq, &cil->xc_ctx->push_work); in xlog_cil_push_background()
1465 up_read(&cil->xc_ctx_lock); in xlog_cil_push_background()
1478 trace_xfs_log_cil_wait(log, cil->xc_ctx->ticket); in xlog_cil_push_background()
1480 xlog_wait(&cil->xc_push_wait, &cil->xc_push_lock); in xlog_cil_push_background()
1484 spin_unlock(&cil->xc_push_lock); in xlog_cil_push_background()
1512 struct xfs_cil *cil = log->l_cilp; in xlog_cil_push_now() local
1514 if (!cil) in xlog_cil_push_now()
1517 ASSERT(push_seq && push_seq <= cil->xc_current_sequence); in xlog_cil_push_now()
1521 flush_workqueue(cil->xc_push_wq); in xlog_cil_push_now()
1523 spin_lock(&cil->xc_push_lock); in xlog_cil_push_now()
1532 cil->xc_push_commit_stable = async; in xlog_cil_push_now()
1538 if (test_bit(XLOG_CIL_EMPTY, &cil->xc_flags) || in xlog_cil_push_now()
1539 push_seq <= cil->xc_push_seq) { in xlog_cil_push_now()
1540 spin_unlock(&cil->xc_push_lock); in xlog_cil_push_now()
1544 cil->xc_push_seq = push_seq; in xlog_cil_push_now()
1545 queue_work(cil->xc_push_wq, &cil->xc_ctx->push_work); in xlog_cil_push_now()
1546 spin_unlock(&cil->xc_push_lock); in xlog_cil_push_now()
1553 struct xfs_cil *cil = log->l_cilp; in xlog_cil_empty() local
1556 spin_lock(&cil->xc_push_lock); in xlog_cil_empty()
1557 if (test_bit(XLOG_CIL_EMPTY, &cil->xc_flags)) in xlog_cil_empty()
1559 spin_unlock(&cil->xc_push_lock); in xlog_cil_empty()
1575 struct xfs_cil *cil, in xlog_cil_process_intents() argument
1586 if (!ilip || !xlog_item_in_current_chkpt(cil, ilip)) in xlog_cil_process_intents()
1620 struct xfs_cil *cil = log->l_cilp; in xlog_cil_commit() local
1632 down_read(&cil->xc_ctx_lock); in xlog_cil_commit()
1635 released_space = xlog_cil_process_intents(cil, tp); in xlog_cil_commit()
1661 lip->li_ops->iop_committing(lip, cil->xc_ctx->sequence); in xlog_cil_commit()
1664 *commit_seq = cil->xc_ctx->sequence; in xlog_cil_commit()
1707 struct xfs_cil *cil = log->l_cilp; in xlog_cil_force_seq() local
1711 ASSERT(sequence <= cil->xc_current_sequence); in xlog_cil_force_seq()
1714 sequence = cil->xc_current_sequence; in xlog_cil_force_seq()
1731 spin_lock(&cil->xc_push_lock); in xlog_cil_force_seq()
1732 list_for_each_entry(ctx, &cil->xc_committing, committing) { in xlog_cil_force_seq()
1748 xlog_wait(&cil->xc_commit_wait, &cil->xc_push_lock); in xlog_cil_force_seq()
1772 if (sequence == cil->xc_current_sequence && in xlog_cil_force_seq()
1773 !test_bit(XLOG_CIL_EMPTY, &cil->xc_flags)) { in xlog_cil_force_seq()
1774 spin_unlock(&cil->xc_push_lock); in xlog_cil_force_seq()
1778 spin_unlock(&cil->xc_push_lock); in xlog_cil_force_seq()
1789 spin_unlock(&cil->xc_push_lock); in xlog_cil_force_seq()
1806 struct xfs_cil *cil = log->l_cilp; in xlog_cil_pcp_dead() local
1807 struct xlog_cil_pcp *cilpcp = per_cpu_ptr(cil->xc_pcp, cpu); in xlog_cil_pcp_dead()
1810 down_write(&cil->xc_ctx_lock); in xlog_cil_pcp_dead()
1811 ctx = cil->xc_ctx; in xlog_cil_pcp_dead()
1822 up_write(&cil->xc_ctx_lock); in xlog_cil_pcp_dead()
1832 struct xfs_cil *cil; in xlog_cil_init() local
1837 cil = kmem_zalloc(sizeof(*cil), KM_MAYFAIL); in xlog_cil_init()
1838 if (!cil) in xlog_cil_init()
1844 cil->xc_push_wq = alloc_workqueue("xfs-cil/%s", in xlog_cil_init()
1847 if (!cil->xc_push_wq) in xlog_cil_init()
1850 cil->xc_log = log; in xlog_cil_init()
1851 cil->xc_pcp = alloc_percpu(struct xlog_cil_pcp); in xlog_cil_init()
1852 if (!cil->xc_pcp) in xlog_cil_init()
1856 cilpcp = per_cpu_ptr(cil->xc_pcp, cpu); in xlog_cil_init()
1861 INIT_LIST_HEAD(&cil->xc_committing); in xlog_cil_init()
1862 spin_lock_init(&cil->xc_push_lock); in xlog_cil_init()
1863 init_waitqueue_head(&cil->xc_push_wait); in xlog_cil_init()
1864 init_rwsem(&cil->xc_ctx_lock); in xlog_cil_init()
1865 init_waitqueue_head(&cil->xc_start_wait); in xlog_cil_init()
1866 init_waitqueue_head(&cil->xc_commit_wait); in xlog_cil_init()
1867 log->l_cilp = cil; in xlog_cil_init()
1870 xlog_cil_ctx_switch(cil, ctx); in xlog_cil_init()
1874 destroy_workqueue(cil->xc_push_wq); in xlog_cil_init()
1876 kmem_free(cil); in xlog_cil_init()
1884 struct xfs_cil *cil = log->l_cilp; in xlog_cil_destroy() local
1886 if (cil->xc_ctx) { in xlog_cil_destroy()
1887 if (cil->xc_ctx->ticket) in xlog_cil_destroy()
1888 xfs_log_ticket_put(cil->xc_ctx->ticket); in xlog_cil_destroy()
1889 kmem_free(cil->xc_ctx); in xlog_cil_destroy()
1892 ASSERT(test_bit(XLOG_CIL_EMPTY, &cil->xc_flags)); in xlog_cil_destroy()
1893 free_percpu(cil->xc_pcp); in xlog_cil_destroy()
1894 destroy_workqueue(cil->xc_push_wq); in xlog_cil_destroy()
1895 kmem_free(cil); in xlog_cil_destroy()