Lines Matching refs:log
35 struct xlog *log,
39 struct xlog *log);
45 struct xlog *log);
48 struct xlog *log,
55 struct xlog *log,
59 struct xlog *log,
65 struct xlog *log);
68 struct xlog *log,
73 struct xlog *log,
83 struct xlog *log);
146 struct xlog *log, in xlog_grant_sub_space() argument
160 space += log->l_logsize; in xlog_grant_sub_space()
172 struct xlog *log, in xlog_grant_add_space() argument
185 tmp = log->l_logsize - space; in xlog_grant_add_space()
222 struct xlog *log, in xlog_ticket_reservation() argument
226 if (head == &log->l_write_head) { in xlog_ticket_reservation()
239 struct xlog *log, in xlog_grant_head_wake() argument
270 need_bytes = xlog_ticket_reservation(log, head, tic); in xlog_grant_head_wake()
273 xlog_grant_push_ail(log, need_bytes); in xlog_grant_head_wake()
278 trace_xfs_log_grant_wake_up(log, tic); in xlog_grant_head_wake()
288 struct xlog *log, in xlog_grant_head_wait() argument
297 if (xlog_is_shutdown(log)) in xlog_grant_head_wait()
299 xlog_grant_push_ail(log, need_bytes); in xlog_grant_head_wait()
304 XFS_STATS_INC(log->l_mp, xs_sleep_logspace); in xlog_grant_head_wait()
306 trace_xfs_log_grant_sleep(log, tic); in xlog_grant_head_wait()
308 trace_xfs_log_grant_wake(log, tic); in xlog_grant_head_wait()
311 if (xlog_is_shutdown(log)) in xlog_grant_head_wait()
313 } while (xlog_space_left(log, &head->grant) < need_bytes); in xlog_grant_head_wait()
341 struct xlog *log, in xlog_grant_head_check() argument
349 ASSERT(!xlog_in_recovery(log)); in xlog_grant_head_check()
357 *need_bytes = xlog_ticket_reservation(log, head, tic); in xlog_grant_head_check()
358 free_bytes = xlog_space_left(log, &head->grant); in xlog_grant_head_check()
361 if (!xlog_grant_head_wake(log, head, &free_bytes) || in xlog_grant_head_check()
363 error = xlog_grant_head_wait(log, head, tic, in xlog_grant_head_check()
369 error = xlog_grant_head_wait(log, head, tic, *need_bytes); in xlog_grant_head_check()
405 struct xlog *log = mp->m_log; in xfs_log_regrant() local
409 if (xlog_is_shutdown(log)) in xfs_log_regrant()
422 xlog_grant_push_ail(log, tic->t_unit_res); in xfs_log_regrant()
428 trace_xfs_log_regrant(log, tic); in xfs_log_regrant()
430 error = xlog_grant_head_check(log, &log->l_write_head, tic, in xfs_log_regrant()
435 xlog_grant_add_space(log, &log->l_write_head.grant, need_bytes); in xfs_log_regrant()
436 trace_xfs_log_regrant_exit(log, tic); in xfs_log_regrant()
437 xlog_verify_grant_tail(log); in xfs_log_regrant()
467 struct xlog *log = mp->m_log; in xfs_log_reserve() local
472 if (xlog_is_shutdown(log)) in xfs_log_reserve()
478 tic = xlog_ticket_alloc(log, unit_bytes, cnt, permanent); in xfs_log_reserve()
481 xlog_grant_push_ail(log, tic->t_cnt ? tic->t_unit_res * tic->t_cnt in xfs_log_reserve()
484 trace_xfs_log_reserve(log, tic); in xfs_log_reserve()
486 error = xlog_grant_head_check(log, &log->l_reserve_head, tic, in xfs_log_reserve()
491 xlog_grant_add_space(log, &log->l_reserve_head.grant, need_bytes); in xfs_log_reserve()
492 xlog_grant_add_space(log, &log->l_write_head.grant, need_bytes); in xfs_log_reserve()
493 trace_xfs_log_reserve_exit(log, tic); in xfs_log_reserve()
494 xlog_verify_grant_tail(log); in xfs_log_reserve()
524 struct xlog *log) in xlog_state_shutdown_callbacks() argument
529 iclog = log->l_iclog; in xlog_state_shutdown_callbacks()
536 spin_unlock(&log->l_icloglock); in xlog_state_shutdown_callbacks()
540 spin_lock(&log->l_icloglock); in xlog_state_shutdown_callbacks()
543 } while ((iclog = iclog->ic_next) != log->l_iclog); in xlog_state_shutdown_callbacks()
545 wake_up_all(&log->l_flush_wait); in xlog_state_shutdown_callbacks()
570 struct xlog *log, in xlog_state_release_iclog() argument
577 lockdep_assert_held(&log->l_icloglock); in xlog_state_release_iclog()
589 tail_lsn = xlog_assign_tail_lsn(log->l_mp); in xlog_state_release_iclog()
595 if (xlog_is_shutdown(log)) { in xlog_state_release_iclog()
602 xlog_state_shutdown_callbacks(log); in xlog_state_release_iclog()
615 xlog_verify_tail_lsn(log, iclog); in xlog_state_release_iclog()
618 spin_unlock(&log->l_icloglock); in xlog_state_release_iclog()
619 xlog_sync(log, iclog, ticket); in xlog_state_release_iclog()
620 spin_lock(&log->l_icloglock); in xlog_state_release_iclog()
641 struct xlog *log; in xfs_log_mount() local
656 log = xlog_alloc_log(mp, log_target, blk_offset, num_bblks); in xfs_log_mount()
657 if (IS_ERR(log)) { in xfs_log_mount()
658 error = PTR_ERR(log); in xfs_log_mount()
661 mp->m_log = log; in xfs_log_mount()
726 log->l_ailp = mp->m_ail; in xfs_log_mount()
739 error = xlog_recover(log); in xfs_log_mount()
745 xlog_recover_cancel(log); in xfs_log_mount()
750 error = xfs_sysfs_init(&log->l_kobj, &xfs_log_ktype, &mp->m_kobj, in xfs_log_mount()
756 clear_bit(XLOG_ACTIVE_RECOVERY, &log->l_opstate); in xfs_log_mount()
763 xlog_cil_init_post_recovery(log); in xfs_log_mount()
770 xlog_dealloc_log(log); in xfs_log_mount()
789 struct xlog *log = mp->m_log; in xfs_log_mount_finish() local
826 if (xlog_recovery_needed(log)) in xfs_log_mount_finish()
827 error = xlog_recover_finish(log); in xfs_log_mount_finish()
840 if (xlog_recovery_needed(log)) { in xfs_log_mount_finish()
852 clear_bit(XLOG_RECOVERY_NEEDED, &log->l_opstate); in xfs_log_mount_finish()
857 ASSERT(!error || xlog_is_shutdown(log)); in xfs_log_mount_finish()
900 struct xlog *log = iclog->ic_log; in xlog_wait_on_iclog() local
903 if (!xlog_is_shutdown(log) && in xlog_wait_on_iclog()
906 XFS_STATS_INC(log->l_mp, xs_log_force_sleep); in xlog_wait_on_iclog()
907 xlog_wait(&iclog->ic_force_wait, &log->l_icloglock); in xlog_wait_on_iclog()
909 spin_unlock(&log->l_icloglock); in xlog_wait_on_iclog()
912 if (xlog_is_shutdown(log)) in xlog_wait_on_iclog()
924 struct xlog *log, in xlog_write_unmount_record() argument
959 return xlog_write(log, NULL, &lv_chain, ticket, reg.i_len); in xlog_write_unmount_record()
968 struct xlog *log) in xlog_unmount_write() argument
970 struct xfs_mount *mp = log->l_mp; in xlog_unmount_write()
979 error = xlog_write_unmount_record(log, tic); in xlog_unmount_write()
988 spin_lock(&log->l_icloglock); in xlog_unmount_write()
989 iclog = log->l_iclog; in xlog_unmount_write()
994 trace_xfs_log_umount_write(log, tic); in xlog_unmount_write()
995 xfs_log_ticket_ungrant(log, tic); in xlog_unmount_write()
1001 struct xlog *log) in xfs_log_unmount_verify_iclog() argument
1003 struct xlog_in_core *iclog = log->l_iclog; in xfs_log_unmount_verify_iclog()
1008 } while ((iclog = iclog->ic_next) != log->l_iclog); in xfs_log_unmount_verify_iclog()
1022 struct xlog *log = mp->m_log; in xfs_log_unmount_write() local
1029 if (xlog_is_shutdown(log)) in xfs_log_unmount_write()
1045 xfs_log_unmount_verify_iclog(log); in xfs_log_unmount_write()
1046 xlog_unmount_write(log); in xfs_log_unmount_write()
1149 struct xlog *log = mp->m_log; in xfs_log_space_wake() local
1152 if (xlog_is_shutdown(log)) in xfs_log_space_wake()
1155 if (!list_empty_careful(&log->l_write_head.waiters)) { in xfs_log_space_wake()
1156 ASSERT(!xlog_in_recovery(log)); in xfs_log_space_wake()
1158 spin_lock(&log->l_write_head.lock); in xfs_log_space_wake()
1159 free_bytes = xlog_space_left(log, &log->l_write_head.grant); in xfs_log_space_wake()
1160 xlog_grant_head_wake(log, &log->l_write_head, &free_bytes); in xfs_log_space_wake()
1161 spin_unlock(&log->l_write_head.lock); in xfs_log_space_wake()
1164 if (!list_empty_careful(&log->l_reserve_head.waiters)) { in xfs_log_space_wake()
1165 ASSERT(!xlog_in_recovery(log)); in xfs_log_space_wake()
1167 spin_lock(&log->l_reserve_head.lock); in xfs_log_space_wake()
1168 free_bytes = xlog_space_left(log, &log->l_reserve_head.grant); in xfs_log_space_wake()
1169 xlog_grant_head_wake(log, &log->l_reserve_head, &free_bytes); in xfs_log_space_wake()
1170 spin_unlock(&log->l_reserve_head.lock); in xfs_log_space_wake()
1195 struct xlog *log = mp->m_log; in xfs_log_need_covered() local
1198 if (!xlog_cil_empty(log)) in xfs_log_need_covered()
1201 spin_lock(&log->l_icloglock); in xfs_log_need_covered()
1202 switch (log->l_covered_state) { in xfs_log_need_covered()
1209 if (xfs_ail_min_lsn(log->l_ailp)) in xfs_log_need_covered()
1211 if (!xlog_iclogs_empty(log)) in xfs_log_need_covered()
1215 if (log->l_covered_state == XLOG_STATE_COVER_NEED) in xfs_log_need_covered()
1216 log->l_covered_state = XLOG_STATE_COVER_DONE; in xfs_log_need_covered()
1218 log->l_covered_state = XLOG_STATE_COVER_DONE2; in xfs_log_need_covered()
1224 spin_unlock(&log->l_icloglock); in xfs_log_need_covered()
1289 struct xlog *log = mp->m_log; in xlog_assign_tail_lsn_locked() local
1304 tail_lsn = atomic64_read(&log->l_last_sync_lsn); in xlog_assign_tail_lsn_locked()
1305 trace_xfs_log_assign_tail_lsn(log, tail_lsn); in xlog_assign_tail_lsn_locked()
1306 atomic64_set(&log->l_tail_lsn, tail_lsn); in xlog_assign_tail_lsn_locked()
1342 struct xlog *log, in xlog_space_left() argument
1351 xlog_crack_atomic_lsn(&log->l_tail_lsn, &tail_cycle, &tail_bytes); in xlog_space_left()
1354 return log->l_logsize - (head_bytes - tail_bytes); in xlog_space_left()
1359 if (xlog_is_shutdown(log)) in xlog_space_left()
1360 return log->l_logsize; in xlog_space_left()
1371 xfs_alert(log->l_mp, "xlog_space_left: head behind tail"); in xlog_space_left()
1372 xfs_alert(log->l_mp, " tail_cycle = %d, tail_bytes = %d", in xlog_space_left()
1374 xfs_alert(log->l_mp, " GH cycle = %d, GH bytes = %d", in xlog_space_left()
1377 return log->l_logsize; in xlog_space_left()
1387 struct xlog *log = iclog->ic_log; in xlog_ioend_work() local
1400 if (XFS_TEST_ERROR(error, log->l_mp, XFS_ERRTAG_IODONE_IOERR)) { in xlog_ioend_work()
1401 xfs_alert(log->l_mp, "log I/O error %d", error); in xlog_ioend_work()
1402 xlog_force_shutdown(log, SHUTDOWN_LOG_IO_ERROR); in xlog_ioend_work()
1428 struct xlog *log) in xlog_get_iclog_buffer_size() argument
1435 log->l_iclog_bufs = mp->m_logbufs; in xlog_get_iclog_buffer_size()
1436 log->l_iclog_size = mp->m_logbsize; in xlog_get_iclog_buffer_size()
1441 log->l_iclog_heads = in xlog_get_iclog_buffer_size()
1443 log->l_iclog_hsize = log->l_iclog_heads << BBSHIFT; in xlog_get_iclog_buffer_size()
1462 struct xlog *log) in xlog_clear_incompat() argument
1464 struct xfs_mount *mp = log->l_mp; in xlog_clear_incompat()
1470 if (log->l_covered_state != XLOG_STATE_COVER_DONE2) in xlog_clear_incompat()
1473 if (!down_write_trylock(&log->l_incompat_users)) in xlog_clear_incompat()
1477 up_write(&log->l_incompat_users); in xlog_clear_incompat()
1489 struct xlog *log = container_of(to_delayed_work(work), in xfs_log_worker() local
1491 struct xfs_mount *mp = log->l_mp; in xfs_log_worker()
1506 xlog_clear_incompat(log); in xfs_log_worker()
1530 struct xlog *log; in xlog_alloc_log() local
1538 log = kmem_zalloc(sizeof(struct xlog), KM_MAYFAIL); in xlog_alloc_log()
1539 if (!log) { in xlog_alloc_log()
1544 log->l_mp = mp; in xlog_alloc_log()
1545 log->l_targ = log_target; in xlog_alloc_log()
1546 log->l_logsize = BBTOB(num_bblks); in xlog_alloc_log()
1547 log->l_logBBstart = blk_offset; in xlog_alloc_log()
1548 log->l_logBBsize = num_bblks; in xlog_alloc_log()
1549 log->l_covered_state = XLOG_STATE_COVER_IDLE; in xlog_alloc_log()
1550 set_bit(XLOG_ACTIVE_RECOVERY, &log->l_opstate); in xlog_alloc_log()
1551 INIT_DELAYED_WORK(&log->l_work, xfs_log_worker); in xlog_alloc_log()
1553 log->l_prev_block = -1; in xlog_alloc_log()
1555 xlog_assign_atomic_lsn(&log->l_tail_lsn, 1, 0); in xlog_alloc_log()
1556 xlog_assign_atomic_lsn(&log->l_last_sync_lsn, 1, 0); in xlog_alloc_log()
1557 log->l_curr_cycle = 1; /* 0 is bad since this is initial value */ in xlog_alloc_log()
1560 log->l_iclog_roundoff = mp->m_sb.sb_logsunit; in xlog_alloc_log()
1562 log->l_iclog_roundoff = BBSIZE; in xlog_alloc_log()
1564 xlog_grant_head_init(&log->l_reserve_head); in xlog_alloc_log()
1565 xlog_grant_head_init(&log->l_write_head); in xlog_alloc_log()
1584 if (log2_size && log->l_logBBstart > 0 && in xlog_alloc_log()
1592 log->l_sectBBsize = 1 << log2_size; in xlog_alloc_log()
1594 init_rwsem(&log->l_incompat_users); in xlog_alloc_log()
1596 xlog_get_iclog_buffer_size(mp, log); in xlog_alloc_log()
1598 spin_lock_init(&log->l_icloglock); in xlog_alloc_log()
1599 init_waitqueue_head(&log->l_flush_wait); in xlog_alloc_log()
1601 iclogp = &log->l_iclog; in xlog_alloc_log()
1609 ASSERT(log->l_iclog_size >= 4096); in xlog_alloc_log()
1610 for (i = 0; i < log->l_iclog_bufs; i++) { in xlog_alloc_log()
1611 size_t bvec_size = howmany(log->l_iclog_size, PAGE_SIZE) * in xlog_alloc_log()
1622 iclog->ic_data = kvzalloc(log->l_iclog_size, in xlog_alloc_log()
1630 xfs_has_logv2(log->l_mp) ? 2 : 1); in xlog_alloc_log()
1631 head->h_size = cpu_to_be32(log->l_iclog_size); in xlog_alloc_log()
1636 iclog->ic_size = log->l_iclog_size - log->l_iclog_hsize; in xlog_alloc_log()
1638 iclog->ic_log = log; in xlog_alloc_log()
1641 iclog->ic_datap = (void *)iclog->ic_data + log->l_iclog_hsize; in xlog_alloc_log()
1650 *iclogp = log->l_iclog; /* complete ring */ in xlog_alloc_log()
1651 log->l_iclog->ic_prev = prev_iclog; /* re-write 1st prev ptr */ in xlog_alloc_log()
1653 log->l_ioend_workqueue = alloc_workqueue("xfs-log/%s", in xlog_alloc_log()
1657 if (!log->l_ioend_workqueue) in xlog_alloc_log()
1660 error = xlog_cil_init(log); in xlog_alloc_log()
1663 return log; in xlog_alloc_log()
1666 destroy_workqueue(log->l_ioend_workqueue); in xlog_alloc_log()
1668 for (iclog = log->l_iclog; iclog; iclog = prev_iclog) { in xlog_alloc_log()
1672 if (prev_iclog == log->l_iclog) in xlog_alloc_log()
1676 kmem_free(log); in xlog_alloc_log()
1690 struct xlog *log, in xlog_grant_push_threshold() argument
1701 ASSERT(BTOBB(need_bytes) < log->l_logBBsize); in xlog_grant_push_threshold()
1703 free_bytes = xlog_space_left(log, &log->l_reserve_head.grant); in xlog_grant_push_threshold()
1712 free_threshold = max(free_threshold, (log->l_logBBsize >> 2)); in xlog_grant_push_threshold()
1717 xlog_crack_atomic_lsn(&log->l_tail_lsn, &threshold_cycle, in xlog_grant_push_threshold()
1720 if (threshold_block >= log->l_logBBsize) { in xlog_grant_push_threshold()
1721 threshold_block -= log->l_logBBsize; in xlog_grant_push_threshold()
1731 last_sync_lsn = atomic64_read(&log->l_last_sync_lsn); in xlog_grant_push_threshold()
1747 struct xlog *log, in xlog_grant_push_ail() argument
1752 threshold_lsn = xlog_grant_push_threshold(log, need_bytes); in xlog_grant_push_ail()
1753 if (threshold_lsn == NULLCOMMITLSN || xlog_is_shutdown(log)) in xlog_grant_push_ail()
1761 xfs_ail_push(log->l_ailp, threshold_lsn); in xlog_grant_push_ail()
1769 struct xlog *log, in xlog_pack_data() argument
1789 if (xfs_has_logv2(log->l_mp)) { in xlog_pack_data()
1800 for (i = 1; i < log->l_iclog_heads; i++) in xlog_pack_data()
1813 struct xlog *log, in xlog_cksum() argument
1826 if (xfs_has_logv2(log->l_mp)) { in xlog_cksum()
1878 struct xlog *log, in xlog_write_iclog() argument
1883 ASSERT(bno < log->l_logBBsize); in xlog_write_iclog()
1895 if (xlog_is_shutdown(log)) { in xlog_write_iclog()
1914 bio_init(&iclog->ic_bio, log->l_targ->bt_bdev, iclog->ic_bvec, in xlog_write_iclog()
1917 iclog->ic_bio.bi_iter.bi_sector = log->l_logBBstart + bno; in xlog_write_iclog()
1934 if (log->l_targ != log->l_mp->m_ddev_targp && in xlog_write_iclog()
1935 blkdev_issue_flush(log->l_mp->m_ddev_targp->bt_bdev)) { in xlog_write_iclog()
1936 xlog_force_shutdown(log, SHUTDOWN_LOG_IO_ERROR); in xlog_write_iclog()
1946 xlog_force_shutdown(log, SHUTDOWN_LOG_IO_ERROR); in xlog_write_iclog()
1956 if (bno + BTOBB(count) > log->l_logBBsize) { in xlog_write_iclog()
1959 split = bio_split(&iclog->ic_bio, log->l_logBBsize - bno, in xlog_write_iclog()
1965 iclog->ic_bio.bi_iter.bi_sector = log->l_logBBstart; in xlog_write_iclog()
1978 struct xlog *log, in xlog_split_iclog() argument
1983 unsigned int split_offset = BBTOB(log->l_logBBsize - bno); in xlog_split_iclog()
1997 struct xlog *log, in xlog_calc_iclog_size() argument
2004 count_init = log->l_iclog_hsize + iclog->ic_offset; in xlog_calc_iclog_size()
2005 count = roundup(count_init, log->l_iclog_roundoff); in xlog_calc_iclog_size()
2010 ASSERT(*roundoff < log->l_iclog_roundoff); in xlog_calc_iclog_size()
2039 struct xlog *log, in xlog_sync() argument
2051 count = xlog_calc_iclog_size(log, iclog, &roundoff); in xlog_sync()
2061 xlog_grant_add_space(log, &log->l_reserve_head.grant, roundoff); in xlog_sync()
2062 xlog_grant_add_space(log, &log->l_write_head.grant, roundoff); in xlog_sync()
2066 xlog_pack_data(log, iclog, roundoff); in xlog_sync()
2070 if (xfs_has_logv2(log->l_mp)) in xlog_sync()
2074 XFS_STATS_INC(log->l_mp, xs_log_writes); in xlog_sync()
2075 XFS_STATS_ADD(log->l_mp, xs_log_blocks, BTOBB(count)); in xlog_sync()
2080 if (bno + BTOBB(count) > log->l_logBBsize) in xlog_sync()
2081 xlog_split_iclog(log, &iclog->ic_header, bno, count); in xlog_sync()
2084 iclog->ic_header.h_crc = xlog_cksum(log, &iclog->ic_header, in xlog_sync()
2094 if (XFS_TEST_ERROR(false, log->l_mp, XFS_ERRTAG_LOG_BAD_CRC)) { in xlog_sync()
2097 xfs_warn(log->l_mp, in xlog_sync()
2102 xlog_verify_iclog(log, iclog, count); in xlog_sync()
2103 xlog_write_iclog(log, iclog, bno, count); in xlog_sync()
2111 struct xlog *log) in xlog_dealloc_log() argument
2120 iclog = log->l_iclog; in xlog_dealloc_log()
2121 for (i = 0; i < log->l_iclog_bufs; i++) { in xlog_dealloc_log()
2132 xlog_cil_destroy(log); in xlog_dealloc_log()
2134 iclog = log->l_iclog; in xlog_dealloc_log()
2135 for (i = 0; i < log->l_iclog_bufs; i++) { in xlog_dealloc_log()
2142 log->l_mp->m_log = NULL; in xlog_dealloc_log()
2143 destroy_workqueue(log->l_ioend_workqueue); in xlog_dealloc_log()
2144 kmem_free(log); in xlog_dealloc_log()
2152 struct xlog *log, in xlog_state_finish_copy() argument
2157 lockdep_assert_held(&log->l_icloglock); in xlog_state_finish_copy()
2293 struct xlog *log = iclog->ic_log; in xlog_write_get_more_iclog_space() local
2296 spin_lock(&log->l_icloglock); in xlog_write_get_more_iclog_space()
2298 xlog_state_finish_copy(log, iclog, *record_cnt, *data_cnt); in xlog_write_get_more_iclog_space()
2299 error = xlog_state_release_iclog(log, iclog, ticket); in xlog_write_get_more_iclog_space()
2300 spin_unlock(&log->l_icloglock); in xlog_write_get_more_iclog_space()
2304 error = xlog_state_get_iclog_space(log, len, &iclog, ticket, in xlog_write_get_more_iclog_space()
2493 struct xlog *log, in xlog_write() argument
2508 xfs_alert_tag(log->l_mp, XFS_PTAG_LOGRES, in xlog_write()
2510 xlog_print_tic_res(log->l_mp, ticket); in xlog_write()
2511 xlog_force_shutdown(log, SHUTDOWN_LOG_IO_ERROR); in xlog_write()
2514 error = xlog_state_get_iclog_space(log, len, &iclog, ticket, in xlog_write()
2559 spin_lock(&log->l_icloglock); in xlog_write()
2560 xlog_state_finish_copy(log, iclog, record_cnt, 0); in xlog_write()
2561 error = xlog_state_release_iclog(log, iclog, ticket); in xlog_write()
2562 spin_unlock(&log->l_icloglock); in xlog_write()
2607 struct xlog *log, in xlog_state_activate_iclogs() argument
2610 struct xlog_in_core *iclog = log->l_iclog; in xlog_state_activate_iclogs()
2621 } while ((iclog = iclog->ic_next) != log->l_iclog); in xlog_state_activate_iclogs()
2660 struct xlog *log, in xlog_state_clean_iclog() argument
2669 xlog_state_activate_iclogs(log, &iclogs_changed); in xlog_state_clean_iclog()
2673 log->l_covered_state = xlog_covered_state(log->l_covered_state, in xlog_state_clean_iclog()
2680 struct xlog *log) in xlog_get_lowest_lsn() argument
2682 struct xlog_in_core *iclog = log->l_iclog; in xlog_get_lowest_lsn()
2693 } while ((iclog = iclog->ic_next) != log->l_iclog); in xlog_get_lowest_lsn()
2722 struct xlog *log, in xlog_state_set_callback() argument
2729 ASSERT(XFS_LSN_CMP(atomic64_read(&log->l_last_sync_lsn), in xlog_state_set_callback()
2735 atomic64_set(&log->l_last_sync_lsn, header_lsn); in xlog_state_set_callback()
2736 xlog_grant_push_ail(log, 0); in xlog_state_set_callback()
2746 struct xlog *log, in xlog_state_iodone_process_iclog() argument
2767 lowest_lsn = xlog_get_lowest_lsn(log); in xlog_state_iodone_process_iclog()
2770 xlog_state_set_callback(log, iclog, header_lsn); in xlog_state_iodone_process_iclog()
2791 struct xlog *log) in xlog_state_do_iclog_callbacks() argument
2792 __releases(&log->l_icloglock) in xlog_state_do_iclog_callbacks()
2793 __acquires(&log->l_icloglock) in xlog_state_do_iclog_callbacks()
2795 struct xlog_in_core *first_iclog = log->l_iclog; in xlog_state_do_iclog_callbacks()
2802 if (xlog_state_iodone_process_iclog(log, iclog)) in xlog_state_do_iclog_callbacks()
2809 spin_unlock(&log->l_icloglock); in xlog_state_do_iclog_callbacks()
2816 spin_lock(&log->l_icloglock); in xlog_state_do_iclog_callbacks()
2817 xlog_state_clean_iclog(log, iclog); in xlog_state_do_iclog_callbacks()
2831 struct xlog *log) in xlog_state_do_callback() argument
2836 spin_lock(&log->l_icloglock); in xlog_state_do_callback()
2837 while (xlog_state_do_iclog_callbacks(log)) { in xlog_state_do_callback()
2838 if (xlog_is_shutdown(log)) in xlog_state_do_callback()
2844 xfs_warn(log->l_mp, in xlog_state_do_callback()
2850 if (log->l_iclog->ic_state == XLOG_STATE_ACTIVE) in xlog_state_do_callback()
2851 wake_up_all(&log->l_flush_wait); in xlog_state_do_callback()
2853 spin_unlock(&log->l_icloglock); in xlog_state_do_callback()
2867 struct xlog *log = iclog->ic_log; in xlog_state_done_syncing() local
2869 spin_lock(&log->l_icloglock); in xlog_state_done_syncing()
2878 if (!xlog_is_shutdown(log)) { in xlog_state_done_syncing()
2889 spin_unlock(&log->l_icloglock); in xlog_state_done_syncing()
2890 xlog_state_do_callback(log); in xlog_state_done_syncing()
2913 struct xlog *log, in xlog_state_get_iclog_space() argument
2924 spin_lock(&log->l_icloglock); in xlog_state_get_iclog_space()
2925 if (xlog_is_shutdown(log)) { in xlog_state_get_iclog_space()
2926 spin_unlock(&log->l_icloglock); in xlog_state_get_iclog_space()
2930 iclog = log->l_iclog; in xlog_state_get_iclog_space()
2932 XFS_STATS_INC(log->l_mp, xs_log_noiclogs); in xlog_state_get_iclog_space()
2935 xlog_wait(&log->l_flush_wait, &log->l_icloglock); in xlog_state_get_iclog_space()
2952 ticket->t_curr_res -= log->l_iclog_hsize; in xlog_state_get_iclog_space()
2953 head->h_cycle = cpu_to_be32(log->l_curr_cycle); in xlog_state_get_iclog_space()
2955 xlog_assign_lsn(log->l_curr_cycle, log->l_curr_block)); in xlog_state_get_iclog_space()
2956 ASSERT(log->l_curr_block >= 0); in xlog_state_get_iclog_space()
2971 xlog_state_switch_iclogs(log, iclog, iclog->ic_size); in xlog_state_get_iclog_space()
2981 error = xlog_state_release_iclog(log, iclog, ticket); in xlog_state_get_iclog_space()
2982 spin_unlock(&log->l_icloglock); in xlog_state_get_iclog_space()
2997 xlog_state_switch_iclogs(log, iclog, iclog->ic_size); in xlog_state_get_iclog_space()
3001 spin_unlock(&log->l_icloglock); in xlog_state_get_iclog_space()
3016 struct xlog *log, in xfs_log_ticket_regrant() argument
3019 trace_xfs_log_ticket_regrant(log, ticket); in xfs_log_ticket_regrant()
3024 xlog_grant_sub_space(log, &log->l_reserve_head.grant, in xfs_log_ticket_regrant()
3026 xlog_grant_sub_space(log, &log->l_write_head.grant, in xfs_log_ticket_regrant()
3030 trace_xfs_log_ticket_regrant_sub(log, ticket); in xfs_log_ticket_regrant()
3034 xlog_grant_add_space(log, &log->l_reserve_head.grant, in xfs_log_ticket_regrant()
3036 trace_xfs_log_ticket_regrant_exit(log, ticket); in xfs_log_ticket_regrant()
3060 struct xlog *log, in xfs_log_ticket_ungrant() argument
3065 trace_xfs_log_ticket_ungrant(log, ticket); in xfs_log_ticket_ungrant()
3070 trace_xfs_log_ticket_ungrant_sub(log, ticket); in xfs_log_ticket_ungrant()
3082 xlog_grant_sub_space(log, &log->l_reserve_head.grant, bytes); in xfs_log_ticket_ungrant()
3083 xlog_grant_sub_space(log, &log->l_write_head.grant, bytes); in xfs_log_ticket_ungrant()
3085 trace_xfs_log_ticket_ungrant_exit(log, ticket); in xfs_log_ticket_ungrant()
3087 xfs_log_space_wake(log->l_mp); in xfs_log_ticket_ungrant()
3097 struct xlog *log, in xlog_state_switch_iclogs() argument
3102 assert_spin_locked(&log->l_icloglock); in xlog_state_switch_iclogs()
3108 iclog->ic_header.h_prev_block = cpu_to_be32(log->l_prev_block); in xlog_state_switch_iclogs()
3109 log->l_prev_block = log->l_curr_block; in xlog_state_switch_iclogs()
3110 log->l_prev_cycle = log->l_curr_cycle; in xlog_state_switch_iclogs()
3113 log->l_curr_block += BTOBB(eventual_size)+BTOBB(log->l_iclog_hsize); in xlog_state_switch_iclogs()
3116 if (log->l_iclog_roundoff > BBSIZE) { in xlog_state_switch_iclogs()
3117 uint32_t sunit_bb = BTOBB(log->l_iclog_roundoff); in xlog_state_switch_iclogs()
3118 log->l_curr_block = roundup(log->l_curr_block, sunit_bb); in xlog_state_switch_iclogs()
3121 if (log->l_curr_block >= log->l_logBBsize) { in xlog_state_switch_iclogs()
3129 log->l_curr_block -= log->l_logBBsize; in xlog_state_switch_iclogs()
3130 ASSERT(log->l_curr_block >= 0); in xlog_state_switch_iclogs()
3132 log->l_curr_cycle++; in xlog_state_switch_iclogs()
3133 if (log->l_curr_cycle == XLOG_HEADER_MAGIC_NUM) in xlog_state_switch_iclogs()
3134 log->l_curr_cycle++; in xlog_state_switch_iclogs()
3136 ASSERT(iclog == log->l_iclog); in xlog_state_switch_iclogs()
3137 log->l_iclog = iclog->ic_next; in xlog_state_switch_iclogs()
3201 struct xlog *log = mp->m_log; in xfs_log_force() local
3207 xlog_cil_force(log); in xfs_log_force()
3209 spin_lock(&log->l_icloglock); in xfs_log_force()
3210 if (xlog_is_shutdown(log)) in xfs_log_force()
3213 iclog = log->l_iclog; in xfs_log_force()
3244 xlog_state_switch_iclogs(log, iclog, 0); in xfs_log_force()
3260 spin_unlock(&log->l_icloglock); in xfs_log_force()
3263 spin_unlock(&log->l_icloglock); in xfs_log_force()
3283 struct xlog *log, in xlog_force_lsn() argument
3292 spin_lock(&log->l_icloglock); in xlog_force_lsn()
3293 if (xlog_is_shutdown(log)) in xlog_force_lsn()
3296 iclog = log->l_iclog; in xlog_force_lsn()
3300 if (iclog == log->l_iclog) in xlog_force_lsn()
3325 &log->l_icloglock); in xlog_force_lsn()
3358 spin_unlock(&log->l_icloglock); in xlog_force_lsn()
3361 spin_unlock(&log->l_icloglock); in xlog_force_lsn()
3381 struct xlog *log = mp->m_log; in xfs_log_force_seq() local
3389 lsn = xlog_cil_force_seq(log, seq); in xfs_log_force_seq()
3393 ret = xlog_force_lsn(log, lsn, flags, log_flushed, false); in xfs_log_force_seq()
3396 ret = xlog_force_lsn(log, lsn, flags, log_flushed, true); in xfs_log_force_seq()
3428 struct xlog *log, in xlog_calc_unit_res() argument
3490 iclog_space = log->l_iclog_size - log->l_iclog_hsize; in xlog_calc_unit_res()
3502 unit_bytes += log->l_iclog_hsize * num_headers; in xlog_calc_unit_res()
3505 unit_bytes += log->l_iclog_hsize; in xlog_calc_unit_res()
3508 unit_bytes += 2 * log->l_iclog_roundoff; in xlog_calc_unit_res()
3528 struct xlog *log, in xlog_ticket_alloc() argument
3538 unit_res = xlog_calc_unit_res(log, unit_bytes, &tic->t_iclog_hdrs); in xlog_ticket_alloc()
3568 struct xlog *log) in xlog_verify_grant_tail() argument
3573 xlog_crack_grant_head(&log->l_write_head.grant, &cycle, &space); in xlog_verify_grant_tail()
3574 xlog_crack_atomic_lsn(&log->l_tail_lsn, &tail_cycle, &tail_blocks); in xlog_verify_grant_tail()
3577 !test_and_set_bit(XLOG_TAIL_WARN, &log->l_opstate)) { in xlog_verify_grant_tail()
3578 xfs_alert_tag(log->l_mp, XFS_PTAG_LOGRES, in xlog_verify_grant_tail()
3583 !test_and_set_bit(XLOG_TAIL_WARN, &log->l_opstate)) { in xlog_verify_grant_tail()
3584 xfs_alert_tag(log->l_mp, XFS_PTAG_LOGRES, in xlog_verify_grant_tail()
3593 struct xlog *log, in xlog_verify_tail_lsn() argument
3599 if (CYCLE_LSN(tail_lsn) == log->l_prev_cycle) { in xlog_verify_tail_lsn()
3601 log->l_logBBsize - (log->l_prev_block - BLOCK_LSN(tail_lsn)); in xlog_verify_tail_lsn()
3602 if (blocks < BTOBB(iclog->ic_offset)+BTOBB(log->l_iclog_hsize)) in xlog_verify_tail_lsn()
3603 xfs_emerg(log->l_mp, "%s: ran out of log space", __func__); in xlog_verify_tail_lsn()
3605 ASSERT(CYCLE_LSN(tail_lsn)+1 == log->l_prev_cycle); in xlog_verify_tail_lsn()
3607 if (BLOCK_LSN(tail_lsn) == log->l_prev_block) in xlog_verify_tail_lsn()
3608 xfs_emerg(log->l_mp, "%s: tail wrapped", __func__); in xlog_verify_tail_lsn()
3610 blocks = BLOCK_LSN(tail_lsn) - log->l_prev_block; in xlog_verify_tail_lsn()
3612 xfs_emerg(log->l_mp, "%s: ran out of log space", __func__); in xlog_verify_tail_lsn()
3633 struct xlog *log, in xlog_verify_iclog() argument
3647 spin_lock(&log->l_icloglock); in xlog_verify_iclog()
3648 icptr = log->l_iclog; in xlog_verify_iclog()
3649 for (i = 0; i < log->l_iclog_bufs; i++, icptr = icptr->ic_next) in xlog_verify_iclog()
3652 if (icptr != log->l_iclog) in xlog_verify_iclog()
3653 xfs_emerg(log->l_mp, "%s: corrupt iclog ring", __func__); in xlog_verify_iclog()
3654 spin_unlock(&log->l_icloglock); in xlog_verify_iclog()
3658 xfs_emerg(log->l_mp, "%s: invalid magic num", __func__); in xlog_verify_iclog()
3664 xfs_emerg(log->l_mp, "%s: unexpected magic num", in xlog_verify_iclog()
3694 xfs_warn(log->l_mp, in xlog_verify_iclog()
3741 struct xlog *log, in xlog_force_shutdown() argument
3746 if (!log) in xlog_force_shutdown()
3764 if (!log_error && !xlog_in_recovery(log)) in xlog_force_shutdown()
3765 xfs_log_force(log->l_mp, XFS_LOG_SYNC); in xlog_force_shutdown()
3778 spin_lock(&log->l_icloglock); in xlog_force_shutdown()
3779 if (test_and_set_bit(XLOG_IO_ERROR, &log->l_opstate)) { in xlog_force_shutdown()
3780 spin_unlock(&log->l_icloglock); in xlog_force_shutdown()
3783 spin_unlock(&log->l_icloglock); in xlog_force_shutdown()
3789 if (!test_and_set_bit(XFS_OPSTATE_SHUTDOWN, &log->l_mp->m_opstate)) { in xlog_force_shutdown()
3790 xfs_alert_tag(log->l_mp, XFS_PTAG_SHUTDOWN_LOGERROR, in xlog_force_shutdown()
3793 xfs_alert(log->l_mp, in xlog_force_shutdown()
3806 xlog_grant_head_wake_all(&log->l_reserve_head); in xlog_force_shutdown()
3807 xlog_grant_head_wake_all(&log->l_write_head); in xlog_force_shutdown()
3815 spin_lock(&log->l_cilp->xc_push_lock); in xlog_force_shutdown()
3816 wake_up_all(&log->l_cilp->xc_start_wait); in xlog_force_shutdown()
3817 wake_up_all(&log->l_cilp->xc_commit_wait); in xlog_force_shutdown()
3818 spin_unlock(&log->l_cilp->xc_push_lock); in xlog_force_shutdown()
3820 spin_lock(&log->l_icloglock); in xlog_force_shutdown()
3821 xlog_state_shutdown_callbacks(log); in xlog_force_shutdown()
3822 spin_unlock(&log->l_icloglock); in xlog_force_shutdown()
3824 wake_up_var(&log->l_opstate); in xlog_force_shutdown()
3830 struct xlog *log) in xlog_iclogs_empty() argument
3834 iclog = log->l_iclog; in xlog_iclogs_empty()
3842 } while (iclog != log->l_iclog); in xlog_iclogs_empty()
3855 struct xlog *log = mp->m_log; in xfs_log_check_lsn() local
3877 spin_lock(&log->l_icloglock); in xfs_log_check_lsn()
3882 log->l_curr_cycle, log->l_curr_block); in xfs_log_check_lsn()
3883 spin_unlock(&log->l_icloglock); in xfs_log_check_lsn()
3896 struct xlog *log) in xlog_use_incompat_feat() argument
3898 down_read(&log->l_incompat_users); in xlog_use_incompat_feat()
3904 struct xlog *log) in xlog_drop_incompat_feat() argument
3906 up_read(&log->l_incompat_users); in xlog_drop_incompat_feat()