Lines Matching full: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);
93 * However, this padding does not get written into the log, and hence we have to
94 * track the space used by the log vectors separately to prevent log space hangs
95 * due to inaccurate accounting (i.e. a leak) of the used log space through the
99 * log. This prepends the data region we return to the caller to copy their data
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
252 * limiting the target to the log head (l_last_sync_lsn) at the in xlog_grant_head_wake()
253 * time. This may not reflect where the log head is now as the in xlog_grant_head_wake()
257 * log that has moved rather than the tail. As the tail didn't in xlog_grant_head_wake()
260 * pushed to the target defined by the old log head location, we in xlog_grant_head_wake()
266 * target reflects both the current log tail and log head in xlog_grant_head_wake()
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()
323 * Atomically get the log space required for a log ticket.
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()
381 * Do not write to the log on norecovery mounts, if the data or log in xfs_log_writable()
383 * mounts allow internal writes for log recovery and unmount purposes, in xfs_log_writable()
405 struct xlog *log = mp->m_log; in xfs_log_regrant() local
409 if (xlog_is_shutdown(log)) in xfs_log_regrant()
417 * the log. Just add one to the existing tid so that we can see chains in xfs_log_regrant()
418 * of rolling transactions in the log easily. 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()
452 * Reserve log space and return a ticket corresponding to the reservation.
454 * Each reservation is going to reserve extra space for a log record header.
455 * When writes happen to the on-disk log, we don't subtract the length of the
456 * log record header from any reservation. By wasting space in each
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()
509 * Run all the pending iclog callbacks and wake log force waiters and iclog
511 * don't care what order we process callbacks here because the log is shut down
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()
553 * log tail is updated correctly. NEED_FUA indicates that the iclog will be
555 * within the iclog. We need to ensure that the log tail does not move beyond
570 struct xlog *log, in xlog_state_release_iclog() argument
577 lockdep_assert_held(&log->l_icloglock); in xlog_state_release_iclog()
581 * Grabbing the current log tail needs to be atomic w.r.t. the writing in xlog_state_release_iclog()
582 * of the tail LSN into the iclog so we guarantee that the log tail does 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()
625 * Mount a log filesystem
628 * log_target - buftarg of on-disk log device
630 * num_bblocks - Number of BBSIZE blocks in on-disk log
641 struct xlog *log; in xfs_log_mount() local
657 log = xlog_alloc_log(mp, log_target, blk_offset, num_bblks); in xfs_log_mount()
658 if (IS_ERR(log)) { in xfs_log_mount()
659 error = PTR_ERR(log); in xfs_log_mount()
662 mp->m_log = log; in xfs_log_mount()
665 * Now that we have set up the log and it's internal geometry in xfs_log_mount()
666 * parameters, we can validate the given log space and drop a critical in xfs_log_mount()
667 * message via syslog if the log size is too small. A log that is too in xfs_log_mount()
668 * small can lead to unexpected situations in transaction log space in xfs_log_mount()
670 * the other log geometry constraints, so we don't have to check those in xfs_log_mount()
676 * way to grow the log (short of black magic surgery with xfs_db). in xfs_log_mount()
680 * filesystem with a log that is too small. in xfs_log_mount()
685 "Log size %d blocks too small, minimum size is %d blocks", in xfs_log_mount()
689 * Log check errors are always fatal on v5; or whenever bad in xfs_log_mount()
693 xfs_crit(mp, "AAIEEE! Log failed size checks. Abort!"); in xfs_log_mount()
698 xfs_crit(mp, "Log size out of supported range."); in xfs_log_mount()
700 "Continuing onwards, but if log hangs are experienced then please report this message in the bug re… in xfs_log_mount()
704 * Initialize the AIL now we have a log. in xfs_log_mount()
711 log->l_ailp = mp->m_ail; in xfs_log_mount()
714 * skip log recovery on a norecovery mount. pretend it all in xfs_log_mount()
718 error = xlog_recover(log); in xfs_log_mount()
720 xfs_warn(mp, "log mount/recovery failed: error %d", in xfs_log_mount()
722 xlog_recover_cancel(log); in xfs_log_mount()
727 error = xfs_sysfs_init(&log->l_kobj, &xfs_log_ktype, &mp->m_kobj, in xfs_log_mount()
728 "log"); in xfs_log_mount()
733 clear_bit(XLOG_ACTIVE_RECOVERY, &log->l_opstate); in xfs_log_mount()
736 * Now the log has been fully initialised and we know were our in xfs_log_mount()
740 xlog_cil_init_post_recovery(log); in xfs_log_mount()
747 xlog_dealloc_log(log); in xfs_log_mount()
758 * If we finish recovery successfully, start the background log work. If we are
766 struct xlog *log = mp->m_log; in xfs_log_mount_finish() local
775 * During the second phase of log recovery, we need iget and in xfs_log_mount_finish()
778 * of inodes before we're done replaying log items on those in xfs_log_mount_finish()
787 * in log recovery failure. We have to evict the unreferenced in xfs_log_mount_finish()
796 if (xlog_recovery_needed(log)) in xfs_log_mount_finish()
797 error = xlog_recover_finish(log); in xfs_log_mount_finish()
802 * Drain the buffer LRU after log recovery. This is required for v4 in xfs_log_mount_finish()
810 if (xlog_recovery_needed(log)) { in xfs_log_mount_finish()
822 clear_bit(XLOG_RECOVERY_NEEDED, &log->l_opstate); in xfs_log_mount_finish()
824 /* Make sure the log is dead if we're returning failure. */ in xfs_log_mount_finish()
825 ASSERT(!error || xlog_is_shutdown(log)); in xfs_log_mount_finish()
832 * the log.
858 * Cycle all the iclogbuf locks to make sure all log IO completion
862 xlog_wait_iclog_completion(struct xlog *log) in xlog_wait_iclog_completion() argument
865 struct xlog_in_core *iclog = log->l_iclog; in xlog_wait_iclog_completion()
867 for (i = 0; i < log->l_iclog_bufs; i++) { in xlog_wait_iclog_completion()
876 * log force state machine. Waiting on ic_force_wait ensures iclog completions
885 struct xlog *log = iclog->ic_log; in xlog_wait_on_iclog() local
888 if (!xlog_is_shutdown(log) && in xlog_wait_on_iclog()
891 XFS_STATS_INC(log->l_mp, xs_log_force_sleep); in xlog_wait_on_iclog()
892 xlog_wait(&iclog->ic_force_wait, &log->l_icloglock); in xlog_wait_on_iclog()
894 spin_unlock(&log->l_icloglock); in xlog_wait_on_iclog()
897 if (xlog_is_shutdown(log)) in xlog_wait_on_iclog()
909 struct xlog *log, in xlog_write_unmount_record() argument
944 return xlog_write(log, NULL, &lv_chain, ticket, reg.i_len); in xlog_write_unmount_record()
949 * log.
953 struct xlog *log) in xlog_unmount_write() argument
955 struct xfs_mount *mp = log->l_mp; in xlog_unmount_write()
964 error = xlog_write_unmount_record(log, tic); in xlog_unmount_write()
967 * transitioning log state to shutdown. Just continue... in xlog_unmount_write()
973 spin_lock(&log->l_icloglock); in xlog_unmount_write()
974 iclog = log->l_iclog; in xlog_unmount_write()
979 trace_xfs_log_umount_write(log, tic); in xlog_unmount_write()
980 xfs_log_ticket_ungrant(log, tic); in xlog_unmount_write()
986 struct xlog *log) in xfs_log_unmount_verify_iclog() argument
988 struct xlog_in_core *iclog = log->l_iclog; in xfs_log_unmount_verify_iclog()
993 } while ((iclog = iclog->ic_next) != log->l_iclog); in xfs_log_unmount_verify_iclog()
1007 struct xlog *log = mp->m_log; in xfs_log_unmount_write() local
1014 if (xlog_is_shutdown(log)) in xfs_log_unmount_write()
1019 * record to force log recovery at next mount, after which the summary in xfs_log_unmount_write()
1030 xfs_log_unmount_verify_iclog(log); in xfs_log_unmount_write()
1031 xlog_unmount_write(log); in xfs_log_unmount_write()
1035 * Empty the log for unmount/freeze.
1037 * To do this, we first need to shut down the background log work so it is not
1038 * trying to cover the log as we clean up. We then need to unpin all objects in
1039 * the log so we can then flush them out. Once they have completed their IO and
1040 * run the callbacks removing themselves from the AIL, we can cover the log.
1047 * Clear log incompat features since we're quiescing the log. Report in xfs_log_quiesce()
1048 * failures, though it's not fatal to have a higher log feature in xfs_log_quiesce()
1049 * protection level than the log contents actually require. in xfs_log_quiesce()
1057 "Failed to clear log incompat features on quiesce"); in xfs_log_quiesce()
1087 * Shut down and release the AIL and Log.
1090 * from the AIL so that the log is empty before we write the unmount record to
1091 * the log. Once this is done, we can tear down the AIL and the log.
1100 * If shutdown has come from iclog IO context, the log in xfs_log_unmount()
1136 * Wake up processes waiting for log space after we have moved the log tail.
1142 struct xlog *log = mp->m_log; in xfs_log_space_wake() local
1145 if (xlog_is_shutdown(log)) in xfs_log_space_wake()
1148 if (!list_empty_careful(&log->l_write_head.waiters)) { in xfs_log_space_wake()
1149 ASSERT(!xlog_in_recovery(log)); in xfs_log_space_wake()
1151 spin_lock(&log->l_write_head.lock); in xfs_log_space_wake()
1152 free_bytes = xlog_space_left(log, &log->l_write_head.grant); in xfs_log_space_wake()
1153 xlog_grant_head_wake(log, &log->l_write_head, &free_bytes); in xfs_log_space_wake()
1154 spin_unlock(&log->l_write_head.lock); in xfs_log_space_wake()
1157 if (!list_empty_careful(&log->l_reserve_head.waiters)) { in xfs_log_space_wake()
1158 ASSERT(!xlog_in_recovery(log)); in xfs_log_space_wake()
1160 spin_lock(&log->l_reserve_head.lock); in xfs_log_space_wake()
1161 free_bytes = xlog_space_left(log, &log->l_reserve_head.grant); in xfs_log_space_wake()
1162 xlog_grant_head_wake(log, &log->l_reserve_head, &free_bytes); in xfs_log_space_wake()
1163 spin_unlock(&log->l_reserve_head.lock); in xfs_log_space_wake()
1169 * covered. To begin the transition to the idle state firstly the log needs to
1171 * we start attempting to cover the log.
1174 * informed that dummy transactions are required to move the log into the idle
1178 * cover the log as we may be in a situation where there isn't log space
1180 * tail of the log is pinned by an item that is modified in the CIL. Hence
1182 * can't start trying to idle the log until both the CIL and AIL are empty.
1188 struct xlog *log = mp->m_log; in xfs_log_need_covered() local
1191 if (!xlog_cil_empty(log)) in xfs_log_need_covered()
1194 spin_lock(&log->l_icloglock); in xfs_log_need_covered()
1195 switch (log->l_covered_state) { in xfs_log_need_covered()
1202 if (xfs_ail_min_lsn(log->l_ailp)) in xfs_log_need_covered()
1204 if (!xlog_iclogs_empty(log)) in xfs_log_need_covered()
1208 if (log->l_covered_state == XLOG_STATE_COVER_NEED) in xfs_log_need_covered()
1209 log->l_covered_state = XLOG_STATE_COVER_DONE; in xfs_log_need_covered()
1211 log->l_covered_state = XLOG_STATE_COVER_DONE2; in xfs_log_need_covered()
1217 spin_unlock(&log->l_icloglock); in xfs_log_need_covered()
1222 * Explicitly cover the log. This is similar to background log covering but
1224 * the log is idle and suitable for covering. The CIL, iclog buffers and AIL
1243 * state machine if the log requires covering. Therefore, we must call in xfs_log_cover()
1247 * Fall into the covering sequence if the log needs covering or the in xfs_log_cover()
1257 * To cover the log, commit the superblock twice (at most) in in xfs_log_cover()
1262 * covering the log. Push the AIL one more time to leave it empty, as in xfs_log_cover()
1276 * We may be holding the log iclog lock upon entering this routine.
1282 struct xlog *log = mp->m_log; in xlog_assign_tail_lsn_locked() local
1289 * To make sure we always have a valid LSN for the log tail we keep in xlog_assign_tail_lsn_locked()
1290 * track of the last LSN which was committed in log->l_last_sync_lsn, in xlog_assign_tail_lsn_locked()
1297 tail_lsn = atomic64_read(&log->l_last_sync_lsn); in xlog_assign_tail_lsn_locked()
1298 trace_xfs_log_assign_tail_lsn(log, tail_lsn); in xlog_assign_tail_lsn_locked()
1299 atomic64_set(&log->l_tail_lsn, tail_lsn); in xlog_assign_tail_lsn_locked()
1317 * Return the space in the log between the tail and the head. The head
1321 * in the log. This works for all places where this function is called
1327 * but then treat it as if the log is empty.
1329 * If the log is shut down, the head and tail may be invalid or out of whack, so
1335 struct xlog *log, in xlog_space_left() argument
1344 xlog_crack_atomic_lsn(&log->l_tail_lsn, &tail_cycle, &tail_bytes); in xlog_space_left()
1347 return log->l_logsize - (head_bytes - tail_bytes); in xlog_space_left()
1352 if (xlog_is_shutdown(log)) in xlog_space_left()
1353 return log->l_logsize; in xlog_space_left()
1362 * return the size of the log as the amount of space left. in xlog_space_left()
1364 xfs_alert(log->l_mp, "xlog_space_left: head behind tail"); in xlog_space_left()
1365 xfs_alert(log->l_mp, " tail_cycle = %d, tail_bytes = %d", in xlog_space_left()
1367 xfs_alert(log->l_mp, " GH cycle = %d, GH bytes = %d", in xlog_space_left()
1370 return log->l_logsize; in xlog_space_left()
1380 struct xlog *log = iclog->ic_log; in xlog_ioend_work() local
1393 if (XFS_TEST_ERROR(error, log->l_mp, XFS_ERRTAG_IODONE_IOERR)) { in xlog_ioend_work()
1394 xfs_alert(log->l_mp, "log I/O error %d", error); in xlog_ioend_work()
1395 xlog_force_shutdown(log, SHUTDOWN_LOG_IO_ERROR); in xlog_ioend_work()
1411 * Return size of each in-core log record buffer.
1421 struct xlog *log) in xlog_get_iclog_buffer_size() argument
1428 log->l_iclog_bufs = mp->m_logbufs; in xlog_get_iclog_buffer_size()
1429 log->l_iclog_size = mp->m_logbsize; in xlog_get_iclog_buffer_size()
1434 log->l_iclog_heads = in xlog_get_iclog_buffer_size()
1436 log->l_iclog_hsize = log->l_iclog_heads << BBSHIFT; in xlog_get_iclog_buffer_size()
1448 * Clear the log incompat flags if we have the opportunity.
1450 * This only happens if we're about to log the second dummy transaction as part
1451 * of covering the log and we can get the log incompat feature usage lock.
1455 struct xlog *log) in xlog_clear_incompat() argument
1457 struct xfs_mount *mp = log->l_mp; in xlog_clear_incompat()
1463 if (log->l_covered_state != XLOG_STATE_COVER_DONE2) in xlog_clear_incompat()
1466 if (!down_write_trylock(&log->l_incompat_users)) in xlog_clear_incompat()
1470 up_write(&log->l_incompat_users); in xlog_clear_incompat()
1475 * disk. If there is nothing dirty, then we might need to cover the log to
1482 struct xlog *log = container_of(to_delayed_work(work), in xfs_log_worker() local
1484 struct xfs_mount *mp = log->l_mp; in xfs_log_worker()
1489 * Dump a transaction into the log that contains no real change. in xfs_log_worker()
1490 * This is needed to stamp the current tail LSN into the log in xfs_log_worker()
1495 * will prevent log covering from making progress. Hence we in xfs_log_worker()
1496 * synchronously log the superblock instead to ensure the in xfs_log_worker()
1499 xlog_clear_incompat(log); in xfs_log_worker()
1512 * This routine initializes some of the log structure for a given mount point.
1523 struct xlog *log; in xlog_alloc_log() local
1531 log = kmem_zalloc(sizeof(struct xlog), KM_MAYFAIL); in xlog_alloc_log()
1532 if (!log) { in xlog_alloc_log()
1533 xfs_warn(mp, "Log allocation failed: No memory!"); in xlog_alloc_log()
1537 log->l_mp = mp; in xlog_alloc_log()
1538 log->l_targ = log_target; in xlog_alloc_log()
1539 log->l_logsize = BBTOB(num_bblks); in xlog_alloc_log()
1540 log->l_logBBstart = blk_offset; in xlog_alloc_log()
1541 log->l_logBBsize = num_bblks; in xlog_alloc_log()
1542 log->l_covered_state = XLOG_STATE_COVER_IDLE; in xlog_alloc_log()
1543 set_bit(XLOG_ACTIVE_RECOVERY, &log->l_opstate); in xlog_alloc_log()
1544 INIT_DELAYED_WORK(&log->l_work, xfs_log_worker); in xlog_alloc_log()
1546 log->l_prev_block = -1; in xlog_alloc_log()
1547 /* log->l_tail_lsn = 0x100000000LL; cycle = 1; current block = 0 */ in xlog_alloc_log()
1548 xlog_assign_atomic_lsn(&log->l_tail_lsn, 1, 0); in xlog_alloc_log()
1549 xlog_assign_atomic_lsn(&log->l_last_sync_lsn, 1, 0); in xlog_alloc_log()
1550 log->l_curr_cycle = 1; /* 0 is bad since this is initial value */ in xlog_alloc_log()
1553 log->l_iclog_roundoff = mp->m_sb.sb_logsunit; in xlog_alloc_log()
1555 log->l_iclog_roundoff = BBSIZE; in xlog_alloc_log()
1557 xlog_grant_head_init(&log->l_reserve_head); in xlog_alloc_log()
1558 xlog_grant_head_init(&log->l_write_head); in xlog_alloc_log()
1564 xfs_warn(mp, "Log sector size too small (0x%x < 0x%x)", in xlog_alloc_log()
1571 xfs_warn(mp, "Log sector size too large (0x%x > 0x%x)", in xlog_alloc_log()
1576 /* for larger sector sizes, must have v2 or external log */ in xlog_alloc_log()
1577 if (log2_size && log->l_logBBstart > 0 && in xlog_alloc_log()
1580 "log sector size (0x%x) invalid for configuration.", in xlog_alloc_log()
1585 log->l_sectBBsize = 1 << log2_size; in xlog_alloc_log()
1587 init_rwsem(&log->l_incompat_users); in xlog_alloc_log()
1589 xlog_get_iclog_buffer_size(mp, log); in xlog_alloc_log()
1591 spin_lock_init(&log->l_icloglock); in xlog_alloc_log()
1592 init_waitqueue_head(&log->l_flush_wait); in xlog_alloc_log()
1594 iclogp = &log->l_iclog; in xlog_alloc_log()
1602 ASSERT(log->l_iclog_size >= 4096); in xlog_alloc_log()
1603 for (i = 0; i < log->l_iclog_bufs; i++) { in xlog_alloc_log()
1604 size_t bvec_size = howmany(log->l_iclog_size, PAGE_SIZE) * in xlog_alloc_log()
1615 iclog->ic_data = kvzalloc(log->l_iclog_size, in xlog_alloc_log()
1623 xfs_has_logv2(log->l_mp) ? 2 : 1); in xlog_alloc_log()
1624 head->h_size = cpu_to_be32(log->l_iclog_size); in xlog_alloc_log()
1629 iclog->ic_size = log->l_iclog_size - log->l_iclog_hsize; in xlog_alloc_log()
1631 iclog->ic_log = log; in xlog_alloc_log()
1634 iclog->ic_datap = (void *)iclog->ic_data + log->l_iclog_hsize; in xlog_alloc_log()
1643 *iclogp = log->l_iclog; /* complete ring */ in xlog_alloc_log()
1644 log->l_iclog->ic_prev = prev_iclog; /* re-write 1st prev ptr */ in xlog_alloc_log()
1646 log->l_ioend_workqueue = alloc_workqueue("xfs-log/%s", in xlog_alloc_log()
1650 if (!log->l_ioend_workqueue) in xlog_alloc_log()
1653 error = xlog_cil_init(log); in xlog_alloc_log()
1656 return log; in xlog_alloc_log()
1659 destroy_workqueue(log->l_ioend_workqueue); in xlog_alloc_log()
1661 for (iclog = log->l_iclog; iclog; iclog = prev_iclog) { in xlog_alloc_log()
1665 if (prev_iclog == log->l_iclog) in xlog_alloc_log()
1669 kmem_free(log); in xlog_alloc_log()
1675 * Compute the LSN that we'd need to push the log tail towards in order to have
1676 * (a) enough on-disk log space to log the number of bytes specified, (b) at
1677 * least 25% of the log space free, and (c) at least 256 blocks free. If the
1678 * log free space already meets all three thresholds, this function returns
1683 struct xlog *log, in xlog_grant_push_threshold() argument
1694 ASSERT(BTOBB(need_bytes) < log->l_logBBsize); in xlog_grant_push_threshold()
1696 free_bytes = xlog_space_left(log, &log->l_reserve_head.grant); in xlog_grant_push_threshold()
1701 * log to the maximum of what the caller needs, one quarter of the in xlog_grant_push_threshold()
1702 * log, and 256 blocks. in xlog_grant_push_threshold()
1705 free_threshold = max(free_threshold, (log->l_logBBsize >> 2)); in xlog_grant_push_threshold()
1710 xlog_crack_atomic_lsn(&log->l_tail_lsn, &threshold_cycle, in xlog_grant_push_threshold()
1713 if (threshold_block >= log->l_logBBsize) { in xlog_grant_push_threshold()
1714 threshold_block -= log->l_logBBsize; in xlog_grant_push_threshold()
1721 * log record known to be on disk. Use a snapshot of the last sync lsn in xlog_grant_push_threshold()
1724 last_sync_lsn = atomic64_read(&log->l_last_sync_lsn); in xlog_grant_push_threshold()
1732 * Push the tail of the log if we need to do so to maintain the free log space
1734 * policy which pushes on an lsn which is further along in the log once we
1740 struct xlog *log, in xlog_grant_push_ail() argument
1745 threshold_lsn = xlog_grant_push_threshold(log, need_bytes); in xlog_grant_push_ail()
1746 if (threshold_lsn == NULLCOMMITLSN || xlog_is_shutdown(log)) in xlog_grant_push_ail()
1754 xfs_ail_push(log->l_ailp, threshold_lsn); in xlog_grant_push_ail()
1762 struct xlog *log, in xlog_pack_data() argument
1782 if (xfs_has_logv2(log->l_mp)) { in xlog_pack_data()
1793 for (i = 1; i < log->l_iclog_heads; i++) in xlog_pack_data()
1799 * Calculate the checksum for a log buffer.
1806 struct xlog *log, in xlog_cksum() argument
1819 if (xfs_has_logv2(log->l_mp)) { in xlog_cksum()
1871 struct xlog *log, in xlog_write_iclog() argument
1876 ASSERT(bno < log->l_logBBsize); in xlog_write_iclog()
1885 * across the log IO to archieve that. in xlog_write_iclog()
1888 if (xlog_is_shutdown(log)) { in xlog_write_iclog()
1891 * the log state machine to propagate I/O errors instead of in xlog_write_iclog()
1904 * writeback throttle from throttling log writes behind background in xlog_write_iclog()
1907 bio_init(&iclog->ic_bio, log->l_targ->bt_bdev, iclog->ic_bvec, in xlog_write_iclog()
1910 iclog->ic_bio.bi_iter.bi_sector = log->l_logBBstart + bno; in xlog_write_iclog()
1917 * For external log devices, we also need to flush the data in xlog_write_iclog()
1920 * but it *must* complete before we issue the external log IO. in xlog_write_iclog()
1923 * writeback from the log succeeded. Repeating the flush is in xlog_write_iclog()
1924 * not possible, hence we must shut down with log IO error to in xlog_write_iclog()
1927 if (log->l_targ != log->l_mp->m_ddev_targp && in xlog_write_iclog()
1928 blkdev_issue_flush(log->l_mp->m_ddev_targp->bt_bdev)) { in xlog_write_iclog()
1929 xlog_force_shutdown(log, SHUTDOWN_LOG_IO_ERROR); in xlog_write_iclog()
1939 xlog_force_shutdown(log, SHUTDOWN_LOG_IO_ERROR); in xlog_write_iclog()
1946 * If this log buffer would straddle the end of the log we will have in xlog_write_iclog()
1949 if (bno + BTOBB(count) > log->l_logBBsize) { in xlog_write_iclog()
1952 split = bio_split(&iclog->ic_bio, log->l_logBBsize - bno, in xlog_write_iclog()
1958 iclog->ic_bio.bi_iter.bi_sector = log->l_logBBstart; in xlog_write_iclog()
1966 * written to the start of the log. Watch out for the header magic
1971 struct xlog *log, in xlog_split_iclog() argument
1976 unsigned int split_offset = BBTOB(log->l_logBBsize - bno); in xlog_split_iclog()
1990 struct xlog *log, in xlog_calc_iclog_size() argument
1997 count_init = log->l_iclog_hsize + iclog->ic_offset; in xlog_calc_iclog_size()
1998 count = roundup(count_init, log->l_iclog_roundoff); in xlog_calc_iclog_size()
2003 ASSERT(*roundoff < log->l_iclog_roundoff); in xlog_calc_iclog_size()
2008 * Flush out the in-core log (iclog) to the on-disk log in an asynchronous
2010 * ptr in the log to point to the next available iclog. This allows further
2012 * Before an in-core log can be written out, the data section must be scanned
2024 * log will require grabbing the lock though.
2026 * The entire log manager uses a logical block numbering scheme. Only
2027 * xlog_write_iclog knows about the fact that the log may not start with
2032 struct xlog *log, in xlog_sync() argument
2044 count = xlog_calc_iclog_size(log, iclog, &roundoff); in xlog_sync()
2054 xlog_grant_add_space(log, &log->l_reserve_head.grant, roundoff); in xlog_sync()
2055 xlog_grant_add_space(log, &log->l_write_head.grant, roundoff); in xlog_sync()
2059 xlog_pack_data(log, iclog, roundoff); in xlog_sync()
2063 if (xfs_has_logv2(log->l_mp)) in xlog_sync()
2067 XFS_STATS_INC(log->l_mp, xs_log_writes); in xlog_sync()
2068 XFS_STATS_ADD(log->l_mp, xs_log_blocks, BTOBB(count)); in xlog_sync()
2073 if (bno + BTOBB(count) > log->l_logBBsize) in xlog_sync()
2074 xlog_split_iclog(log, &iclog->ic_header, bno, count); in xlog_sync()
2077 iclog->ic_header.h_crc = xlog_cksum(log, &iclog->ic_header, in xlog_sync()
2080 * Intentionally corrupt the log record CRC based on the error injection in xlog_sync()
2081 * frequency, if defined. This facilitates testing log recovery in the in xlog_sync()
2082 * event of torn writes. Hence, set the IOABORT state to abort the log in xlog_sync()
2087 if (XFS_TEST_ERROR(false, log->l_mp, XFS_ERRTAG_LOG_BAD_CRC)) { in xlog_sync()
2090 xfs_warn(log->l_mp, in xlog_sync()
2091 "Intentionally corrupted log record at LSN 0x%llx. Shutdown imminent.", in xlog_sync()
2095 xlog_verify_iclog(log, iclog, count); in xlog_sync()
2096 xlog_write_iclog(log, iclog, bno, count); in xlog_sync()
2100 * Deallocate a log structure
2104 struct xlog *log) in xlog_dealloc_log() argument
2111 * iclog EIO error will try to shut down the log, which accesses the in xlog_dealloc_log()
2114 xlog_cil_destroy(log); in xlog_dealloc_log()
2116 iclog = log->l_iclog; in xlog_dealloc_log()
2117 for (i = 0; i < log->l_iclog_bufs; i++) { in xlog_dealloc_log()
2124 log->l_mp->m_log = NULL; in xlog_dealloc_log()
2125 destroy_workqueue(log->l_ioend_workqueue); in xlog_dealloc_log()
2126 kmem_free(log); in xlog_dealloc_log()
2134 struct xlog *log, in xlog_state_finish_copy() argument
2139 lockdep_assert_held(&log->l_icloglock); in xlog_state_finish_copy()
2173 xfs_warn(mp, " log res = %d", tp->t_log_res); in xlog_print_trans()
2174 xfs_warn(mp, " log count = %d", tp->t_log_count); in xlog_print_trans()
2179 /* dump each log item */ in xlog_print_trans()
2185 xfs_warn(mp, "log item: "); in xlog_print_trans()
2195 /* dump each iovec for the log item */ in xlog_print_trans()
2233 * Write log vectors into a single iclog which is guaranteed by the caller
2234 * to have enough space to write the entire log vector into.
2252 * Ordered log vectors have no regions to write so this in xlog_write_full()
2275 struct xlog *log = iclog->ic_log; in xlog_write_get_more_iclog_space() local
2278 spin_lock(&log->l_icloglock); in xlog_write_get_more_iclog_space()
2280 xlog_state_finish_copy(log, iclog, *record_cnt, *data_cnt); in xlog_write_get_more_iclog_space()
2281 error = xlog_state_release_iclog(log, iclog, ticket); in xlog_write_get_more_iclog_space()
2282 spin_unlock(&log->l_icloglock); in xlog_write_get_more_iclog_space()
2286 error = xlog_state_get_iclog_space(log, len, &iclog, ticket, in xlog_write_get_more_iclog_space()
2297 * Write log vectors into a single iclog which is smaller than the current chain
2299 * and then stop. We return the log vector that is to be written that cannot
2325 * length otherwise log recovery will just skip over it and in xlog_write_partial()
2372 * space for log transaction opheaders left in the current in xlog_write_partial()
2426 * No more iovecs remain in this logvec so return the next log vec to in xlog_write_partial()
2434 * Write some region out to in-core log
2448 * 2. Write log operation header (header per region)
2455 * 5. Release iclog for potential flush to on-disk log.
2465 * on all log operation writes which don't contain the end of the
2466 * region. The XLOG_END_TRANS bit is used for the in-core log
2475 struct xlog *log, in xlog_write() argument
2490 xfs_alert_tag(log->l_mp, XFS_PTAG_LOGRES, in xlog_write()
2492 xlog_print_tic_res(log->l_mp, ticket); in xlog_write()
2493 xlog_force_shutdown(log, SHUTDOWN_LOG_IO_ERROR); in xlog_write()
2496 error = xlog_state_get_iclog_space(log, len, &iclog, ticket, in xlog_write()
2513 * If the entire log vec does not fit in the iclog, punt it to in xlog_write()
2541 spin_lock(&log->l_icloglock); in xlog_write()
2542 xlog_state_finish_copy(log, iclog, record_cnt, 0); in xlog_write()
2543 error = xlog_state_release_iclog(log, iclog, ticket); in xlog_write()
2544 spin_unlock(&log->l_icloglock); in xlog_write()
2589 struct xlog *log, in xlog_state_activate_iclogs() argument
2592 struct xlog_in_core *iclog = log->l_iclog; in xlog_state_activate_iclogs()
2603 } while ((iclog = iclog->ic_next) != log->l_iclog); in xlog_state_activate_iclogs()
2642 struct xlog *log, in xlog_state_clean_iclog() argument
2651 xlog_state_activate_iclogs(log, &iclogs_changed); in xlog_state_clean_iclog()
2655 log->l_covered_state = xlog_covered_state(log->l_covered_state, in xlog_state_clean_iclog()
2662 struct xlog *log) in xlog_get_lowest_lsn() argument
2664 struct xlog_in_core *iclog = log->l_iclog; in xlog_get_lowest_lsn()
2675 } while ((iclog = iclog->ic_next) != log->l_iclog); in xlog_get_lowest_lsn()
2683 * tail of the log half way through a transaction as this may be the only
2684 * transaction in the log and moving the tail to point to the middle of it
2695 * amount of log space bound up in this committing transaction then the
2697 * freeing space in the log. Hence once we've updated the last_sync_lsn we
2699 * no longer bound by the old log head location and can move forwards and make
2704 struct xlog *log, in xlog_state_set_callback() argument
2711 ASSERT(XFS_LSN_CMP(atomic64_read(&log->l_last_sync_lsn), in xlog_state_set_callback()
2717 atomic64_set(&log->l_last_sync_lsn, header_lsn); in xlog_state_set_callback()
2718 xlog_grant_push_ail(log, 0); in xlog_state_set_callback()
2728 struct xlog *log, in xlog_state_iodone_process_iclog() argument
2749 lowest_lsn = xlog_get_lowest_lsn(log); in xlog_state_iodone_process_iclog()
2752 xlog_state_set_callback(log, iclog, header_lsn); in xlog_state_iodone_process_iclog()
2773 struct xlog *log) in xlog_state_do_iclog_callbacks() argument
2774 __releases(&log->l_icloglock) in xlog_state_do_iclog_callbacks()
2775 __acquires(&log->l_icloglock) in xlog_state_do_iclog_callbacks()
2777 struct xlog_in_core *first_iclog = log->l_iclog; in xlog_state_do_iclog_callbacks()
2784 if (xlog_state_iodone_process_iclog(log, iclog)) in xlog_state_do_iclog_callbacks()
2791 spin_unlock(&log->l_icloglock); in xlog_state_do_iclog_callbacks()
2798 spin_lock(&log->l_icloglock); in xlog_state_do_iclog_callbacks()
2799 xlog_state_clean_iclog(log, iclog); in xlog_state_do_iclog_callbacks()
2813 struct xlog *log) in xlog_state_do_callback() argument
2818 spin_lock(&log->l_icloglock); in xlog_state_do_callback()
2819 while (xlog_state_do_iclog_callbacks(log)) { in xlog_state_do_callback()
2820 if (xlog_is_shutdown(log)) in xlog_state_do_callback()
2826 xfs_warn(log->l_mp, in xlog_state_do_callback()
2832 if (log->l_iclog->ic_state == XLOG_STATE_ACTIVE) in xlog_state_do_callback()
2833 wake_up_all(&log->l_flush_wait); in xlog_state_do_callback()
2835 spin_unlock(&log->l_icloglock); in xlog_state_do_callback()
2843 * global state machine log lock.
2849 struct xlog *log = iclog->ic_log; in xlog_state_done_syncing() local
2851 spin_lock(&log->l_icloglock); in xlog_state_done_syncing()
2857 * split log writes, on the second, we shut down the file system and in xlog_state_done_syncing()
2860 if (!xlog_is_shutdown(log)) { in xlog_state_done_syncing()
2871 spin_unlock(&log->l_icloglock); in xlog_state_done_syncing()
2872 xlog_state_do_callback(log); in xlog_state_done_syncing()
2876 * If the head of the in-core log ring is not (ACTIVE or DIRTY), then we must
2886 * log's data space.
2887 * * in-core log pointer to which xlog_write() should write.
2888 * * boolean indicating this is a continued write to an in-core log.
2889 * If this is the last write, then the in-core log's offset field
2895 struct xlog *log, in xlog_state_get_iclog_space() argument
2906 spin_lock(&log->l_icloglock); in xlog_state_get_iclog_space()
2907 if (xlog_is_shutdown(log)) { in xlog_state_get_iclog_space()
2908 spin_unlock(&log->l_icloglock); in xlog_state_get_iclog_space()
2912 iclog = log->l_iclog; in xlog_state_get_iclog_space()
2914 XFS_STATS_INC(log->l_mp, xs_log_noiclogs); in xlog_state_get_iclog_space()
2916 /* Wait for log writes to have flushed */ in xlog_state_get_iclog_space()
2917 xlog_wait(&log->l_flush_wait, &log->l_icloglock); in xlog_state_get_iclog_space()
2934 ticket->t_curr_res -= log->l_iclog_hsize; in xlog_state_get_iclog_space()
2935 head->h_cycle = cpu_to_be32(log->l_curr_cycle); in xlog_state_get_iclog_space()
2937 xlog_assign_lsn(log->l_curr_cycle, log->l_curr_block)); in xlog_state_get_iclog_space()
2938 ASSERT(log->l_curr_block >= 0); in xlog_state_get_iclog_space()
2953 xlog_state_switch_iclogs(log, iclog, iclog->ic_size); in xlog_state_get_iclog_space()
2963 error = xlog_state_release_iclog(log, iclog, ticket); in xlog_state_get_iclog_space()
2964 spin_unlock(&log->l_icloglock); in xlog_state_get_iclog_space()
2979 xlog_state_switch_iclogs(log, iclog, iclog->ic_size); in xlog_state_get_iclog_space()
2983 spin_unlock(&log->l_icloglock); in xlog_state_get_iclog_space()
2998 struct xlog *log, in xfs_log_ticket_regrant() argument
3001 trace_xfs_log_ticket_regrant(log, ticket); in xfs_log_ticket_regrant()
3006 xlog_grant_sub_space(log, &log->l_reserve_head.grant, in xfs_log_ticket_regrant()
3008 xlog_grant_sub_space(log, &log->l_write_head.grant, in xfs_log_ticket_regrant()
3012 trace_xfs_log_ticket_regrant_sub(log, ticket); in xfs_log_ticket_regrant()
3016 xlog_grant_add_space(log, &log->l_reserve_head.grant, in xfs_log_ticket_regrant()
3018 trace_xfs_log_ticket_regrant_exit(log, ticket); in xfs_log_ticket_regrant()
3042 struct xlog *log, in xfs_log_ticket_ungrant() argument
3047 trace_xfs_log_ticket_ungrant(log, ticket); in xfs_log_ticket_ungrant()
3052 trace_xfs_log_ticket_ungrant_sub(log, ticket); in xfs_log_ticket_ungrant()
3064 xlog_grant_sub_space(log, &log->l_reserve_head.grant, bytes); in xfs_log_ticket_ungrant()
3065 xlog_grant_sub_space(log, &log->l_write_head.grant, bytes); in xfs_log_ticket_ungrant()
3067 trace_xfs_log_ticket_ungrant_exit(log, ticket); in xfs_log_ticket_ungrant()
3069 xfs_log_space_wake(log->l_mp); in xfs_log_ticket_ungrant()
3079 struct xlog *log, in xlog_state_switch_iclogs() argument
3084 assert_spin_locked(&log->l_icloglock); in xlog_state_switch_iclogs()
3090 iclog->ic_header.h_prev_block = cpu_to_be32(log->l_prev_block); in xlog_state_switch_iclogs()
3091 log->l_prev_block = log->l_curr_block; in xlog_state_switch_iclogs()
3092 log->l_prev_cycle = log->l_curr_cycle; in xlog_state_switch_iclogs()
3094 /* roll log?: ic_offset changed later */ in xlog_state_switch_iclogs()
3095 log->l_curr_block += BTOBB(eventual_size)+BTOBB(log->l_iclog_hsize); in xlog_state_switch_iclogs()
3097 /* Round up to next log-sunit */ in xlog_state_switch_iclogs()
3098 if (log->l_iclog_roundoff > BBSIZE) { in xlog_state_switch_iclogs()
3099 uint32_t sunit_bb = BTOBB(log->l_iclog_roundoff); in xlog_state_switch_iclogs()
3100 log->l_curr_block = roundup(log->l_curr_block, sunit_bb); in xlog_state_switch_iclogs()
3103 if (log->l_curr_block >= log->l_logBBsize) { in xlog_state_switch_iclogs()
3107 * when the log wraps to the next cycle. This is to support the in xlog_state_switch_iclogs()
3111 log->l_curr_block -= log->l_logBBsize; in xlog_state_switch_iclogs()
3112 ASSERT(log->l_curr_block >= 0); in xlog_state_switch_iclogs()
3114 log->l_curr_cycle++; in xlog_state_switch_iclogs()
3115 if (log->l_curr_cycle == XLOG_HEADER_MAGIC_NUM) in xlog_state_switch_iclogs()
3116 log->l_curr_cycle++; in xlog_state_switch_iclogs()
3118 ASSERT(iclog == log->l_iclog); in xlog_state_switch_iclogs()
3119 log->l_iclog = iclog->ic_next; in xlog_state_switch_iclogs()
3152 * Write out all data in the in-core log as of this exact moment in time.
3154 * Data may be written to the in-core log during this call. However,
3183 struct xlog *log = mp->m_log; in xfs_log_force() local
3189 xlog_cil_force(log); in xfs_log_force()
3191 spin_lock(&log->l_icloglock); in xfs_log_force()
3192 if (xlog_is_shutdown(log)) in xfs_log_force()
3195 iclog = log->l_iclog; in xfs_log_force()
3226 xlog_state_switch_iclogs(log, iclog, 0); in xfs_log_force()
3242 spin_unlock(&log->l_icloglock); in xfs_log_force()
3245 spin_unlock(&log->l_icloglock); in xfs_log_force()
3250 * Force the log to a specific LSN.
3254 * If it is in the ACTIVE state, move the in-core log into the WANT_SYNC
3260 * specific in-core log. When given in-core log finally completes its write
3265 struct xlog *log, in xlog_force_lsn() argument
3274 spin_lock(&log->l_icloglock); in xlog_force_lsn()
3275 if (xlog_is_shutdown(log)) in xlog_force_lsn()
3278 iclog = log->l_iclog; in xlog_force_lsn()
3282 if (iclog == log->l_iclog) in xlog_force_lsn()
3297 * refcnt so we can release the log (which drops the ref count). in xlog_force_lsn()
3307 &log->l_icloglock); in xlog_force_lsn()
3340 spin_unlock(&log->l_icloglock); in xlog_force_lsn()
3343 spin_unlock(&log->l_icloglock); in xlog_force_lsn()
3348 * Force the log to a specific checkpoint sequence.
3353 * a synchronous log force, we will wait on the iclog with the LSN returned by
3363 struct xlog *log = mp->m_log; in xfs_log_force_seq() local
3371 lsn = xlog_cil_force_seq(log, seq); in xfs_log_force_seq()
3375 ret = xlog_force_lsn(log, lsn, flags, log_flushed, false); in xfs_log_force_seq()
3378 ret = xlog_force_lsn(log, lsn, flags, log_flushed, true); in xfs_log_force_seq()
3405 * Figure out the total log space unit (in bytes) that would be
3406 * required for a log ticket.
3410 struct xlog *log, in xlog_calc_unit_res() argument
3418 * Permanent reservations have up to 'cnt'-1 active log operations in xlog_calc_unit_res()
3419 * in the log. A unit in this case is the amount of space for one in xlog_calc_unit_res()
3420 * of these log operations. Normal reservations have a cnt of 1 in xlog_calc_unit_res()
3424 * which occupy space in the on-disk log. in xlog_calc_unit_res()
3439 * Therefore the commit record is in its own Log Record. in xlog_calc_unit_res()
3461 * increase the space required enough to require more log and op in xlog_calc_unit_res()
3469 * Fundamentally, this means we must pass the entire log vector to in xlog_calc_unit_res()
3472 iclog_space = log->l_iclog_size - log->l_iclog_hsize; in xlog_calc_unit_res()
3484 unit_bytes += log->l_iclog_hsize * num_headers; in xlog_calc_unit_res()
3487 unit_bytes += log->l_iclog_hsize; in xlog_calc_unit_res()
3490 unit_bytes += 2 * log->l_iclog_roundoff; in xlog_calc_unit_res()
3506 * Allocate and initialise a new log ticket.
3510 struct xlog *log, in xlog_ticket_alloc() argument
3520 unit_res = xlog_calc_unit_res(log, unit_bytes, &tic->t_iclog_hdrs); in xlog_ticket_alloc()
3550 struct xlog *log) in xlog_verify_grant_tail() argument
3555 xlog_crack_grant_head(&log->l_write_head.grant, &cycle, &space); in xlog_verify_grant_tail()
3556 xlog_crack_atomic_lsn(&log->l_tail_lsn, &tail_cycle, &tail_blocks); in xlog_verify_grant_tail()
3559 !test_and_set_bit(XLOG_TAIL_WARN, &log->l_opstate)) { in xlog_verify_grant_tail()
3560 xfs_alert_tag(log->l_mp, XFS_PTAG_LOGRES, in xlog_verify_grant_tail()
3565 !test_and_set_bit(XLOG_TAIL_WARN, &log->l_opstate)) { in xlog_verify_grant_tail()
3566 xfs_alert_tag(log->l_mp, XFS_PTAG_LOGRES, in xlog_verify_grant_tail()
3575 struct xlog *log, in xlog_verify_tail_lsn() argument
3581 if (CYCLE_LSN(tail_lsn) == log->l_prev_cycle) { in xlog_verify_tail_lsn()
3583 log->l_logBBsize - (log->l_prev_block - BLOCK_LSN(tail_lsn)); in xlog_verify_tail_lsn()
3584 if (blocks < BTOBB(iclog->ic_offset)+BTOBB(log->l_iclog_hsize)) in xlog_verify_tail_lsn()
3585 xfs_emerg(log->l_mp, "%s: ran out of log space", __func__); in xlog_verify_tail_lsn()
3587 ASSERT(CYCLE_LSN(tail_lsn)+1 == log->l_prev_cycle); in xlog_verify_tail_lsn()
3589 if (BLOCK_LSN(tail_lsn) == log->l_prev_block) in xlog_verify_tail_lsn()
3590 xfs_emerg(log->l_mp, "%s: tail wrapped", __func__); in xlog_verify_tail_lsn()
3592 blocks = BLOCK_LSN(tail_lsn) - log->l_prev_block; in xlog_verify_tail_lsn()
3594 xfs_emerg(log->l_mp, "%s: ran out of log space", __func__); in xlog_verify_tail_lsn()
3604 * 4. Check fields of each log operation header for:
3607 * C. Length in log record header is correct according to the
3610 * log, check the preceding blocks of the physical log to make sure all
3615 struct xlog *log, in xlog_verify_iclog() argument
3629 spin_lock(&log->l_icloglock); in xlog_verify_iclog()
3630 icptr = log->l_iclog; in xlog_verify_iclog()
3631 for (i = 0; i < log->l_iclog_bufs; i++, icptr = icptr->ic_next) in xlog_verify_iclog()
3634 if (icptr != log->l_iclog) in xlog_verify_iclog()
3635 xfs_emerg(log->l_mp, "%s: corrupt iclog ring", __func__); in xlog_verify_iclog()
3636 spin_unlock(&log->l_icloglock); in xlog_verify_iclog()
3638 /* check log magic numbers */ in xlog_verify_iclog()
3640 xfs_emerg(log->l_mp, "%s: invalid magic num", __func__); in xlog_verify_iclog()
3646 xfs_emerg(log->l_mp, "%s: unexpected magic num", in xlog_verify_iclog()
3676 xfs_warn(log->l_mp, in xlog_verify_iclog()
3703 * Perform a forced shutdown on the log.
3705 * This can be called from low level log code to trigger a shutdown, or from the
3709 * a. if the shutdown was not due to a log IO error, flush the logs to
3711 * b. the log gets atomically marked 'XLOG_IO_ERROR' for all interested
3713 * c. Tasks sleeping on log reservations, pinned objects and
3715 * d. The mount is also marked as shut down so that log triggered shutdowns
3718 * Return true if the shutdown cause was a log IO error and we actually shut the
3719 * log down.
3723 struct xlog *log, in xlog_force_shutdown() argument
3728 if (!log) in xlog_force_shutdown()
3732 * Flush all the completed transactions to disk before marking the log in xlog_force_shutdown()
3733 * being shut down. We need to do this first as shutting down the log in xlog_force_shutdown()
3734 * before the force will prevent the log force from flushing the iclogs in xlog_force_shutdown()
3738 * we don't want to touch the log because we don't want to perturb the in xlog_force_shutdown()
3740 * avoid a log force in this case. in xlog_force_shutdown()
3742 * If we are shutting down due to a log IO error, then we must avoid in xlog_force_shutdown()
3743 * trying to write the log as that may just result in more IO errors and in xlog_force_shutdown()
3746 if (!log_error && !xlog_in_recovery(log)) in xlog_force_shutdown()
3747 xfs_log_force(log->l_mp, XFS_LOG_SYNC); in xlog_force_shutdown()
3755 * Much of the log state machine transitions assume that shutdown state in xlog_force_shutdown()
3756 * cannot change once they hold the log->l_icloglock. Hence we need to in xlog_force_shutdown()
3760 spin_lock(&log->l_icloglock); in xlog_force_shutdown()
3761 if (test_and_set_bit(XLOG_IO_ERROR, &log->l_opstate)) { in xlog_force_shutdown()
3762 spin_unlock(&log->l_icloglock); in xlog_force_shutdown()
3765 spin_unlock(&log->l_icloglock); in xlog_force_shutdown()
3768 * If this log shutdown also sets the mount shutdown state, issue a in xlog_force_shutdown()
3771 if (!test_and_set_bit(XFS_OPSTATE_SHUTDOWN, &log->l_mp->m_opstate)) { in xlog_force_shutdown()
3772 xfs_alert_tag(log->l_mp, XFS_PTAG_SHUTDOWN_LOGERROR, in xlog_force_shutdown()
3773 "Filesystem has been shut down due to log error (0x%x).", in xlog_force_shutdown()
3775 xfs_alert(log->l_mp, in xlog_force_shutdown()
3782 * We don't want anybody waiting for log reservations after this. That in xlog_force_shutdown()
3788 xlog_grant_head_wake_all(&log->l_reserve_head); in xlog_force_shutdown()
3789 xlog_grant_head_wake_all(&log->l_write_head); in xlog_force_shutdown()
3793 * as if the log writes were completed. The abort handling in the log in xlog_force_shutdown()
3797 spin_lock(&log->l_cilp->xc_push_lock); in xlog_force_shutdown()
3798 wake_up_all(&log->l_cilp->xc_start_wait); in xlog_force_shutdown()
3799 wake_up_all(&log->l_cilp->xc_commit_wait); in xlog_force_shutdown()
3800 spin_unlock(&log->l_cilp->xc_push_lock); in xlog_force_shutdown()
3802 spin_lock(&log->l_icloglock); in xlog_force_shutdown()
3803 xlog_state_shutdown_callbacks(log); in xlog_force_shutdown()
3804 spin_unlock(&log->l_icloglock); in xlog_force_shutdown()
3806 wake_up_var(&log->l_opstate); in xlog_force_shutdown()
3812 struct xlog *log) in xlog_iclogs_empty() argument
3816 iclog = log->l_iclog; in xlog_iclogs_empty()
3824 } while (iclog != log->l_iclog); in xlog_iclogs_empty()
3837 struct xlog *log = mp->m_log; in xfs_log_check_lsn() local
3841 * norecovery mode skips mount-time log processing and unconditionally in xfs_log_check_lsn()
3859 spin_lock(&log->l_icloglock); in xfs_log_check_lsn()
3864 log->l_curr_cycle, log->l_curr_block); in xfs_log_check_lsn()
3865 spin_unlock(&log->l_icloglock); in xfs_log_check_lsn()
3872 * Notify the log that we're about to start using a feature that is protected
3873 * by a log incompat feature flag. This will prevent log covering from
3878 struct xlog *log) in xlog_use_incompat_feat() argument
3880 down_read(&log->l_incompat_users); in xlog_use_incompat_feat()
3883 /* Notify the log that we've finished using log incompat features. */
3886 struct xlog *log) in xlog_drop_incompat_feat() argument
3888 up_read(&log->l_incompat_users); in xlog_drop_incompat_feat()