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()
1545 INIT_LIST_HEAD(&log->r_dfops); in xlog_alloc_log()
1547 log->l_prev_block = -1; in xlog_alloc_log()
1548 /* log->l_tail_lsn = 0x100000000LL; cycle = 1; current block = 0 */ in xlog_alloc_log()
1549 xlog_assign_atomic_lsn(&log->l_tail_lsn, 1, 0); in xlog_alloc_log()
1550 xlog_assign_atomic_lsn(&log->l_last_sync_lsn, 1, 0); in xlog_alloc_log()
1551 log->l_curr_cycle = 1; /* 0 is bad since this is initial value */ in xlog_alloc_log()
1554 log->l_iclog_roundoff = mp->m_sb.sb_logsunit; in xlog_alloc_log()
1556 log->l_iclog_roundoff = BBSIZE; in xlog_alloc_log()
1558 xlog_grant_head_init(&log->l_reserve_head); in xlog_alloc_log()
1559 xlog_grant_head_init(&log->l_write_head); in xlog_alloc_log()
1565 xfs_warn(mp, "Log sector size too small (0x%x < 0x%x)", in xlog_alloc_log()
1572 xfs_warn(mp, "Log sector size too large (0x%x > 0x%x)", in xlog_alloc_log()
1577 /* for larger sector sizes, must have v2 or external log */ in xlog_alloc_log()
1578 if (log2_size && log->l_logBBstart > 0 && in xlog_alloc_log()
1581 "log sector size (0x%x) invalid for configuration.", in xlog_alloc_log()
1586 log->l_sectBBsize = 1 << log2_size; in xlog_alloc_log()
1588 init_rwsem(&log->l_incompat_users); in xlog_alloc_log()
1590 xlog_get_iclog_buffer_size(mp, log); in xlog_alloc_log()
1592 spin_lock_init(&log->l_icloglock); in xlog_alloc_log()
1593 init_waitqueue_head(&log->l_flush_wait); in xlog_alloc_log()
1595 iclogp = &log->l_iclog; in xlog_alloc_log()
1603 ASSERT(log->l_iclog_size >= 4096); in xlog_alloc_log()
1604 for (i = 0; i < log->l_iclog_bufs; i++) { in xlog_alloc_log()
1605 size_t bvec_size = howmany(log->l_iclog_size, PAGE_SIZE) * in xlog_alloc_log()
1616 iclog->ic_data = kvzalloc(log->l_iclog_size, in xlog_alloc_log()
1624 xfs_has_logv2(log->l_mp) ? 2 : 1); in xlog_alloc_log()
1625 head->h_size = cpu_to_be32(log->l_iclog_size); in xlog_alloc_log()
1630 iclog->ic_size = log->l_iclog_size - log->l_iclog_hsize; in xlog_alloc_log()
1632 iclog->ic_log = log; in xlog_alloc_log()
1635 iclog->ic_datap = (void *)iclog->ic_data + log->l_iclog_hsize; in xlog_alloc_log()
1644 *iclogp = log->l_iclog; /* complete ring */ in xlog_alloc_log()
1645 log->l_iclog->ic_prev = prev_iclog; /* re-write 1st prev ptr */ in xlog_alloc_log()
1647 log->l_ioend_workqueue = alloc_workqueue("xfs-log/%s", in xlog_alloc_log()
1651 if (!log->l_ioend_workqueue) in xlog_alloc_log()
1654 error = xlog_cil_init(log); in xlog_alloc_log()
1657 return log; in xlog_alloc_log()
1660 destroy_workqueue(log->l_ioend_workqueue); in xlog_alloc_log()
1662 for (iclog = log->l_iclog; iclog; iclog = prev_iclog) { in xlog_alloc_log()
1666 if (prev_iclog == log->l_iclog) in xlog_alloc_log()
1670 kmem_free(log); in xlog_alloc_log()
1676 * Compute the LSN that we'd need to push the log tail towards in order to have
1677 * (a) enough on-disk log space to log the number of bytes specified, (b) at
1678 * least 25% of the log space free, and (c) at least 256 blocks free. If the
1679 * log free space already meets all three thresholds, this function returns
1684 struct xlog *log, in xlog_grant_push_threshold() argument
1695 ASSERT(BTOBB(need_bytes) < log->l_logBBsize); in xlog_grant_push_threshold()
1697 free_bytes = xlog_space_left(log, &log->l_reserve_head.grant); in xlog_grant_push_threshold()
1702 * log to the maximum of what the caller needs, one quarter of the in xlog_grant_push_threshold()
1703 * log, and 256 blocks. in xlog_grant_push_threshold()
1706 free_threshold = max(free_threshold, (log->l_logBBsize >> 2)); in xlog_grant_push_threshold()
1711 xlog_crack_atomic_lsn(&log->l_tail_lsn, &threshold_cycle, in xlog_grant_push_threshold()
1714 if (threshold_block >= log->l_logBBsize) { in xlog_grant_push_threshold()
1715 threshold_block -= log->l_logBBsize; in xlog_grant_push_threshold()
1722 * log record known to be on disk. Use a snapshot of the last sync lsn in xlog_grant_push_threshold()
1725 last_sync_lsn = atomic64_read(&log->l_last_sync_lsn); in xlog_grant_push_threshold()
1733 * Push the tail of the log if we need to do so to maintain the free log space
1735 * policy which pushes on an lsn which is further along in the log once we
1741 struct xlog *log, in xlog_grant_push_ail() argument
1746 threshold_lsn = xlog_grant_push_threshold(log, need_bytes); in xlog_grant_push_ail()
1747 if (threshold_lsn == NULLCOMMITLSN || xlog_is_shutdown(log)) in xlog_grant_push_ail()
1755 xfs_ail_push(log->l_ailp, threshold_lsn); in xlog_grant_push_ail()
1763 struct xlog *log, in xlog_pack_data() argument
1783 if (xfs_has_logv2(log->l_mp)) { in xlog_pack_data()
1794 for (i = 1; i < log->l_iclog_heads; i++) in xlog_pack_data()
1800 * Calculate the checksum for a log buffer.
1807 struct xlog *log, in xlog_cksum() argument
1820 if (xfs_has_logv2(log->l_mp)) { in xlog_cksum()
1872 struct xlog *log, in xlog_write_iclog() argument
1877 ASSERT(bno < log->l_logBBsize); in xlog_write_iclog()
1886 * across the log IO to archieve that. in xlog_write_iclog()
1889 if (xlog_is_shutdown(log)) { in xlog_write_iclog()
1892 * the log state machine to propagate I/O errors instead of in xlog_write_iclog()
1903 * writeback throttle from throttling log writes behind background in xlog_write_iclog()
1906 bio_init(&iclog->ic_bio, log->l_targ->bt_bdev, iclog->ic_bvec, in xlog_write_iclog()
1909 iclog->ic_bio.bi_iter.bi_sector = log->l_logBBstart + bno; in xlog_write_iclog()
1916 * For external log devices, we also need to flush the data in xlog_write_iclog()
1919 * but it *must* complete before we issue the external log IO. in xlog_write_iclog()
1922 * writeback from the log succeeded. Repeating the flush is in xlog_write_iclog()
1923 * not possible, hence we must shut down with log IO error to in xlog_write_iclog()
1926 if (log->l_targ != log->l_mp->m_ddev_targp && in xlog_write_iclog()
1927 blkdev_issue_flush(log->l_mp->m_ddev_targp->bt_bdev)) in xlog_write_iclog()
1942 * If this log buffer would straddle the end of the log we will have in xlog_write_iclog()
1945 if (bno + BTOBB(count) > log->l_logBBsize) { in xlog_write_iclog()
1948 split = bio_split(&iclog->ic_bio, log->l_logBBsize - bno, in xlog_write_iclog()
1954 iclog->ic_bio.bi_iter.bi_sector = log->l_logBBstart; in xlog_write_iclog()
1960 xlog_force_shutdown(log, SHUTDOWN_LOG_IO_ERROR); in xlog_write_iclog()
1968 * written to the start of the log. Watch out for the header magic
1973 struct xlog *log, in xlog_split_iclog() argument
1978 unsigned int split_offset = BBTOB(log->l_logBBsize - bno); in xlog_split_iclog()
1992 struct xlog *log, in xlog_calc_iclog_size() argument
1999 count_init = log->l_iclog_hsize + iclog->ic_offset; in xlog_calc_iclog_size()
2000 count = roundup(count_init, log->l_iclog_roundoff); in xlog_calc_iclog_size()
2005 ASSERT(*roundoff < log->l_iclog_roundoff); in xlog_calc_iclog_size()
2010 * Flush out the in-core log (iclog) to the on-disk log in an asynchronous
2012 * ptr in the log to point to the next available iclog. This allows further
2014 * Before an in-core log can be written out, the data section must be scanned
2026 * log will require grabbing the lock though.
2028 * The entire log manager uses a logical block numbering scheme. Only
2029 * xlog_write_iclog knows about the fact that the log may not start with
2034 struct xlog *log, in xlog_sync() argument
2046 count = xlog_calc_iclog_size(log, iclog, &roundoff); in xlog_sync()
2056 xlog_grant_add_space(log, &log->l_reserve_head.grant, roundoff); in xlog_sync()
2057 xlog_grant_add_space(log, &log->l_write_head.grant, roundoff); in xlog_sync()
2061 xlog_pack_data(log, iclog, roundoff); in xlog_sync()
2065 if (xfs_has_logv2(log->l_mp)) in xlog_sync()
2069 XFS_STATS_INC(log->l_mp, xs_log_writes); in xlog_sync()
2070 XFS_STATS_ADD(log->l_mp, xs_log_blocks, BTOBB(count)); in xlog_sync()
2075 if (bno + BTOBB(count) > log->l_logBBsize) in xlog_sync()
2076 xlog_split_iclog(log, &iclog->ic_header, bno, count); in xlog_sync()
2079 iclog->ic_header.h_crc = xlog_cksum(log, &iclog->ic_header, in xlog_sync()
2082 * Intentionally corrupt the log record CRC based on the error injection in xlog_sync()
2083 * frequency, if defined. This facilitates testing log recovery in the in xlog_sync()
2084 * event of torn writes. Hence, set the IOABORT state to abort the log in xlog_sync()
2089 if (XFS_TEST_ERROR(false, log->l_mp, XFS_ERRTAG_LOG_BAD_CRC)) { in xlog_sync()
2092 xfs_warn(log->l_mp, in xlog_sync()
2093 "Intentionally corrupted log record at LSN 0x%llx. Shutdown imminent.", in xlog_sync()
2097 xlog_verify_iclog(log, iclog, count); in xlog_sync()
2098 xlog_write_iclog(log, iclog, bno, count); in xlog_sync()
2102 * Deallocate a log structure
2106 struct xlog *log) in xlog_dealloc_log() argument
2113 * iclog EIO error will try to shut down the log, which accesses the in xlog_dealloc_log()
2116 xlog_cil_destroy(log); in xlog_dealloc_log()
2118 iclog = log->l_iclog; in xlog_dealloc_log()
2119 for (i = 0; i < log->l_iclog_bufs; i++) { in xlog_dealloc_log()
2126 log->l_mp->m_log = NULL; in xlog_dealloc_log()
2127 destroy_workqueue(log->l_ioend_workqueue); in xlog_dealloc_log()
2128 kmem_free(log); in xlog_dealloc_log()
2136 struct xlog *log, in xlog_state_finish_copy() argument
2141 lockdep_assert_held(&log->l_icloglock); in xlog_state_finish_copy()
2175 xfs_warn(mp, " log res = %d", tp->t_log_res); in xlog_print_trans()
2176 xfs_warn(mp, " log count = %d", tp->t_log_count); in xlog_print_trans()
2181 /* dump each log item */ in xlog_print_trans()
2187 xfs_warn(mp, "log item: "); in xlog_print_trans()
2197 /* dump each iovec for the log item */ in xlog_print_trans()
2235 * Write log vectors into a single iclog which is guaranteed by the caller
2236 * to have enough space to write the entire log vector into.
2254 * Ordered log vectors have no regions to write so this in xlog_write_full()
2277 struct xlog *log = iclog->ic_log; in xlog_write_get_more_iclog_space() local
2280 spin_lock(&log->l_icloglock); in xlog_write_get_more_iclog_space()
2282 xlog_state_finish_copy(log, iclog, *record_cnt, *data_cnt); in xlog_write_get_more_iclog_space()
2283 error = xlog_state_release_iclog(log, iclog, ticket); in xlog_write_get_more_iclog_space()
2284 spin_unlock(&log->l_icloglock); in xlog_write_get_more_iclog_space()
2288 error = xlog_state_get_iclog_space(log, len, &iclog, ticket, in xlog_write_get_more_iclog_space()
2299 * Write log vectors into a single iclog which is smaller than the current chain
2301 * and then stop. We return the log vector that is to be written that cannot
2327 * length otherwise log recovery will just skip over it and in xlog_write_partial()
2374 * space for log transaction opheaders left in the current in xlog_write_partial()
2428 * No more iovecs remain in this logvec so return the next log vec to in xlog_write_partial()
2436 * Write some region out to in-core log
2450 * 2. Write log operation header (header per region)
2457 * 5. Release iclog for potential flush to on-disk log.
2467 * on all log operation writes which don't contain the end of the
2468 * region. The XLOG_END_TRANS bit is used for the in-core log
2477 struct xlog *log, in xlog_write() argument
2492 xfs_alert_tag(log->l_mp, XFS_PTAG_LOGRES, in xlog_write()
2494 xlog_print_tic_res(log->l_mp, ticket); in xlog_write()
2495 xlog_force_shutdown(log, SHUTDOWN_LOG_IO_ERROR); in xlog_write()
2498 error = xlog_state_get_iclog_space(log, len, &iclog, ticket, in xlog_write()
2515 * If the entire log vec does not fit in the iclog, punt it to in xlog_write()
2543 spin_lock(&log->l_icloglock); in xlog_write()
2544 xlog_state_finish_copy(log, iclog, record_cnt, 0); in xlog_write()
2545 error = xlog_state_release_iclog(log, iclog, ticket); in xlog_write()
2546 spin_unlock(&log->l_icloglock); in xlog_write()
2591 struct xlog *log, in xlog_state_activate_iclogs() argument
2594 struct xlog_in_core *iclog = log->l_iclog; in xlog_state_activate_iclogs()
2605 } while ((iclog = iclog->ic_next) != log->l_iclog); in xlog_state_activate_iclogs()
2644 struct xlog *log, in xlog_state_clean_iclog() argument
2653 xlog_state_activate_iclogs(log, &iclogs_changed); in xlog_state_clean_iclog()
2657 log->l_covered_state = xlog_covered_state(log->l_covered_state, in xlog_state_clean_iclog()
2664 struct xlog *log) in xlog_get_lowest_lsn() argument
2666 struct xlog_in_core *iclog = log->l_iclog; in xlog_get_lowest_lsn()
2677 } while ((iclog = iclog->ic_next) != log->l_iclog); in xlog_get_lowest_lsn()
2685 * tail of the log half way through a transaction as this may be the only
2686 * transaction in the log and moving the tail to point to the middle of it
2697 * amount of log space bound up in this committing transaction then the
2699 * freeing space in the log. Hence once we've updated the last_sync_lsn we
2701 * no longer bound by the old log head location and can move forwards and make
2706 struct xlog *log, in xlog_state_set_callback() argument
2713 ASSERT(XFS_LSN_CMP(atomic64_read(&log->l_last_sync_lsn), in xlog_state_set_callback()
2719 atomic64_set(&log->l_last_sync_lsn, header_lsn); in xlog_state_set_callback()
2720 xlog_grant_push_ail(log, 0); in xlog_state_set_callback()
2730 struct xlog *log, in xlog_state_iodone_process_iclog() argument
2751 lowest_lsn = xlog_get_lowest_lsn(log); in xlog_state_iodone_process_iclog()
2754 xlog_state_set_callback(log, iclog, header_lsn); in xlog_state_iodone_process_iclog()
2775 struct xlog *log) in xlog_state_do_iclog_callbacks() argument
2776 __releases(&log->l_icloglock) in xlog_state_do_iclog_callbacks()
2777 __acquires(&log->l_icloglock) in xlog_state_do_iclog_callbacks()
2779 struct xlog_in_core *first_iclog = log->l_iclog; in xlog_state_do_iclog_callbacks()
2786 if (xlog_state_iodone_process_iclog(log, iclog)) in xlog_state_do_iclog_callbacks()
2793 spin_unlock(&log->l_icloglock); in xlog_state_do_iclog_callbacks()
2800 spin_lock(&log->l_icloglock); in xlog_state_do_iclog_callbacks()
2801 xlog_state_clean_iclog(log, iclog); in xlog_state_do_iclog_callbacks()
2815 struct xlog *log) in xlog_state_do_callback() argument
2820 spin_lock(&log->l_icloglock); in xlog_state_do_callback()
2821 while (xlog_state_do_iclog_callbacks(log)) { in xlog_state_do_callback()
2822 if (xlog_is_shutdown(log)) in xlog_state_do_callback()
2828 xfs_warn(log->l_mp, in xlog_state_do_callback()
2834 if (log->l_iclog->ic_state == XLOG_STATE_ACTIVE) in xlog_state_do_callback()
2835 wake_up_all(&log->l_flush_wait); in xlog_state_do_callback()
2837 spin_unlock(&log->l_icloglock); in xlog_state_do_callback()
2845 * global state machine log lock.
2851 struct xlog *log = iclog->ic_log; in xlog_state_done_syncing() local
2853 spin_lock(&log->l_icloglock); in xlog_state_done_syncing()
2859 * split log writes, on the second, we shut down the file system and in xlog_state_done_syncing()
2862 if (!xlog_is_shutdown(log)) { in xlog_state_done_syncing()
2873 spin_unlock(&log->l_icloglock); in xlog_state_done_syncing()
2874 xlog_state_do_callback(log); in xlog_state_done_syncing()
2878 * If the head of the in-core log ring is not (ACTIVE or DIRTY), then we must
2888 * log's data space.
2889 * * in-core log pointer to which xlog_write() should write.
2890 * * boolean indicating this is a continued write to an in-core log.
2891 * If this is the last write, then the in-core log's offset field
2897 struct xlog *log, in xlog_state_get_iclog_space() argument
2908 spin_lock(&log->l_icloglock); in xlog_state_get_iclog_space()
2909 if (xlog_is_shutdown(log)) { in xlog_state_get_iclog_space()
2910 spin_unlock(&log->l_icloglock); in xlog_state_get_iclog_space()
2914 iclog = log->l_iclog; in xlog_state_get_iclog_space()
2916 XFS_STATS_INC(log->l_mp, xs_log_noiclogs); in xlog_state_get_iclog_space()
2918 /* Wait for log writes to have flushed */ in xlog_state_get_iclog_space()
2919 xlog_wait(&log->l_flush_wait, &log->l_icloglock); in xlog_state_get_iclog_space()
2936 ticket->t_curr_res -= log->l_iclog_hsize; in xlog_state_get_iclog_space()
2937 head->h_cycle = cpu_to_be32(log->l_curr_cycle); in xlog_state_get_iclog_space()
2939 xlog_assign_lsn(log->l_curr_cycle, log->l_curr_block)); in xlog_state_get_iclog_space()
2940 ASSERT(log->l_curr_block >= 0); in xlog_state_get_iclog_space()
2955 xlog_state_switch_iclogs(log, iclog, iclog->ic_size); in xlog_state_get_iclog_space()
2965 error = xlog_state_release_iclog(log, iclog, ticket); in xlog_state_get_iclog_space()
2966 spin_unlock(&log->l_icloglock); in xlog_state_get_iclog_space()
2981 xlog_state_switch_iclogs(log, iclog, iclog->ic_size); in xlog_state_get_iclog_space()
2985 spin_unlock(&log->l_icloglock); in xlog_state_get_iclog_space()
3000 struct xlog *log, in xfs_log_ticket_regrant() argument
3003 trace_xfs_log_ticket_regrant(log, ticket); in xfs_log_ticket_regrant()
3008 xlog_grant_sub_space(log, &log->l_reserve_head.grant, in xfs_log_ticket_regrant()
3010 xlog_grant_sub_space(log, &log->l_write_head.grant, in xfs_log_ticket_regrant()
3014 trace_xfs_log_ticket_regrant_sub(log, ticket); in xfs_log_ticket_regrant()
3018 xlog_grant_add_space(log, &log->l_reserve_head.grant, in xfs_log_ticket_regrant()
3020 trace_xfs_log_ticket_regrant_exit(log, ticket); in xfs_log_ticket_regrant()
3044 struct xlog *log, in xfs_log_ticket_ungrant() argument
3049 trace_xfs_log_ticket_ungrant(log, ticket); in xfs_log_ticket_ungrant()
3054 trace_xfs_log_ticket_ungrant_sub(log, ticket); in xfs_log_ticket_ungrant()
3066 xlog_grant_sub_space(log, &log->l_reserve_head.grant, bytes); in xfs_log_ticket_ungrant()
3067 xlog_grant_sub_space(log, &log->l_write_head.grant, bytes); in xfs_log_ticket_ungrant()
3069 trace_xfs_log_ticket_ungrant_exit(log, ticket); in xfs_log_ticket_ungrant()
3071 xfs_log_space_wake(log->l_mp); in xfs_log_ticket_ungrant()
3081 struct xlog *log, in xlog_state_switch_iclogs() argument
3086 assert_spin_locked(&log->l_icloglock); in xlog_state_switch_iclogs()
3092 iclog->ic_header.h_prev_block = cpu_to_be32(log->l_prev_block); in xlog_state_switch_iclogs()
3093 log->l_prev_block = log->l_curr_block; in xlog_state_switch_iclogs()
3094 log->l_prev_cycle = log->l_curr_cycle; in xlog_state_switch_iclogs()
3096 /* roll log?: ic_offset changed later */ in xlog_state_switch_iclogs()
3097 log->l_curr_block += BTOBB(eventual_size)+BTOBB(log->l_iclog_hsize); in xlog_state_switch_iclogs()
3099 /* Round up to next log-sunit */ in xlog_state_switch_iclogs()
3100 if (log->l_iclog_roundoff > BBSIZE) { in xlog_state_switch_iclogs()
3101 uint32_t sunit_bb = BTOBB(log->l_iclog_roundoff); in xlog_state_switch_iclogs()
3102 log->l_curr_block = roundup(log->l_curr_block, sunit_bb); in xlog_state_switch_iclogs()
3105 if (log->l_curr_block >= log->l_logBBsize) { in xlog_state_switch_iclogs()
3109 * when the log wraps to the next cycle. This is to support the in xlog_state_switch_iclogs()
3113 log->l_curr_block -= log->l_logBBsize; in xlog_state_switch_iclogs()
3114 ASSERT(log->l_curr_block >= 0); in xlog_state_switch_iclogs()
3116 log->l_curr_cycle++; in xlog_state_switch_iclogs()
3117 if (log->l_curr_cycle == XLOG_HEADER_MAGIC_NUM) in xlog_state_switch_iclogs()
3118 log->l_curr_cycle++; in xlog_state_switch_iclogs()
3120 ASSERT(iclog == log->l_iclog); in xlog_state_switch_iclogs()
3121 log->l_iclog = iclog->ic_next; in xlog_state_switch_iclogs()
3154 * Write out all data in the in-core log as of this exact moment in time.
3156 * Data may be written to the in-core log during this call. However,
3185 struct xlog *log = mp->m_log; in xfs_log_force() local
3191 xlog_cil_force(log); in xfs_log_force()
3193 spin_lock(&log->l_icloglock); in xfs_log_force()
3194 if (xlog_is_shutdown(log)) in xfs_log_force()
3197 iclog = log->l_iclog; in xfs_log_force()
3228 xlog_state_switch_iclogs(log, iclog, 0); in xfs_log_force()
3244 spin_unlock(&log->l_icloglock); in xfs_log_force()
3247 spin_unlock(&log->l_icloglock); in xfs_log_force()
3252 * Force the log to a specific LSN.
3256 * If it is in the ACTIVE state, move the in-core log into the WANT_SYNC
3262 * specific in-core log. When given in-core log finally completes its write
3267 struct xlog *log, in xlog_force_lsn() argument
3276 spin_lock(&log->l_icloglock); in xlog_force_lsn()
3277 if (xlog_is_shutdown(log)) in xlog_force_lsn()
3280 iclog = log->l_iclog; in xlog_force_lsn()
3284 if (iclog == log->l_iclog) in xlog_force_lsn()
3299 * refcnt so we can release the log (which drops the ref count). in xlog_force_lsn()
3309 &log->l_icloglock); in xlog_force_lsn()
3342 spin_unlock(&log->l_icloglock); in xlog_force_lsn()
3345 spin_unlock(&log->l_icloglock); in xlog_force_lsn()
3350 * Force the log to a specific checkpoint sequence.
3355 * a synchronous log force, we will wait on the iclog with the LSN returned by
3365 struct xlog *log = mp->m_log; in xfs_log_force_seq() local
3373 lsn = xlog_cil_force_seq(log, seq); in xfs_log_force_seq()
3377 ret = xlog_force_lsn(log, lsn, flags, log_flushed, false); in xfs_log_force_seq()
3380 ret = xlog_force_lsn(log, lsn, flags, log_flushed, true); in xfs_log_force_seq()
3407 * Figure out the total log space unit (in bytes) that would be
3408 * required for a log ticket.
3412 struct xlog *log, in xlog_calc_unit_res() argument
3420 * Permanent reservations have up to 'cnt'-1 active log operations in xlog_calc_unit_res()
3421 * in the log. A unit in this case is the amount of space for one in xlog_calc_unit_res()
3422 * of these log operations. Normal reservations have a cnt of 1 in xlog_calc_unit_res()
3426 * which occupy space in the on-disk log. in xlog_calc_unit_res()
3441 * Therefore the commit record is in its own Log Record. in xlog_calc_unit_res()
3463 * increase the space required enough to require more log and op in xlog_calc_unit_res()
3471 * Fundamentally, this means we must pass the entire log vector to in xlog_calc_unit_res()
3474 iclog_space = log->l_iclog_size - log->l_iclog_hsize; in xlog_calc_unit_res()
3486 unit_bytes += log->l_iclog_hsize * num_headers; in xlog_calc_unit_res()
3489 unit_bytes += log->l_iclog_hsize; in xlog_calc_unit_res()
3492 unit_bytes += 2 * log->l_iclog_roundoff; in xlog_calc_unit_res()
3508 * Allocate and initialise a new log ticket.
3512 struct xlog *log, in xlog_ticket_alloc() argument
3522 unit_res = xlog_calc_unit_res(log, unit_bytes, &tic->t_iclog_hdrs); in xlog_ticket_alloc()
3552 struct xlog *log) in xlog_verify_grant_tail() argument
3557 xlog_crack_grant_head(&log->l_write_head.grant, &cycle, &space); in xlog_verify_grant_tail()
3558 xlog_crack_atomic_lsn(&log->l_tail_lsn, &tail_cycle, &tail_blocks); in xlog_verify_grant_tail()
3561 !test_and_set_bit(XLOG_TAIL_WARN, &log->l_opstate)) { in xlog_verify_grant_tail()
3562 xfs_alert_tag(log->l_mp, XFS_PTAG_LOGRES, in xlog_verify_grant_tail()
3567 !test_and_set_bit(XLOG_TAIL_WARN, &log->l_opstate)) { in xlog_verify_grant_tail()
3568 xfs_alert_tag(log->l_mp, XFS_PTAG_LOGRES, in xlog_verify_grant_tail()
3577 struct xlog *log, in xlog_verify_tail_lsn() argument
3583 if (CYCLE_LSN(tail_lsn) == log->l_prev_cycle) { in xlog_verify_tail_lsn()
3585 log->l_logBBsize - (log->l_prev_block - BLOCK_LSN(tail_lsn)); in xlog_verify_tail_lsn()
3586 if (blocks < BTOBB(iclog->ic_offset)+BTOBB(log->l_iclog_hsize)) in xlog_verify_tail_lsn()
3587 xfs_emerg(log->l_mp, "%s: ran out of log space", __func__); in xlog_verify_tail_lsn()
3589 ASSERT(CYCLE_LSN(tail_lsn)+1 == log->l_prev_cycle); in xlog_verify_tail_lsn()
3591 if (BLOCK_LSN(tail_lsn) == log->l_prev_block) in xlog_verify_tail_lsn()
3592 xfs_emerg(log->l_mp, "%s: tail wrapped", __func__); in xlog_verify_tail_lsn()
3594 blocks = BLOCK_LSN(tail_lsn) - log->l_prev_block; in xlog_verify_tail_lsn()
3596 xfs_emerg(log->l_mp, "%s: ran out of log space", __func__); in xlog_verify_tail_lsn()
3606 * 4. Check fields of each log operation header for:
3609 * C. Length in log record header is correct according to the
3612 * log, check the preceding blocks of the physical log to make sure all
3617 struct xlog *log, in xlog_verify_iclog() argument
3631 spin_lock(&log->l_icloglock); in xlog_verify_iclog()
3632 icptr = log->l_iclog; in xlog_verify_iclog()
3633 for (i = 0; i < log->l_iclog_bufs; i++, icptr = icptr->ic_next) in xlog_verify_iclog()
3636 if (icptr != log->l_iclog) in xlog_verify_iclog()
3637 xfs_emerg(log->l_mp, "%s: corrupt iclog ring", __func__); in xlog_verify_iclog()
3638 spin_unlock(&log->l_icloglock); in xlog_verify_iclog()
3640 /* check log magic numbers */ in xlog_verify_iclog()
3642 xfs_emerg(log->l_mp, "%s: invalid magic num", __func__); in xlog_verify_iclog()
3648 xfs_emerg(log->l_mp, "%s: unexpected magic num", in xlog_verify_iclog()
3678 xfs_warn(log->l_mp, in xlog_verify_iclog()
3705 * Perform a forced shutdown on the log.
3707 * This can be called from low level log code to trigger a shutdown, or from the
3711 * a. if the shutdown was not due to a log IO error, flush the logs to
3713 * b. the log gets atomically marked 'XLOG_IO_ERROR' for all interested
3715 * c. Tasks sleeping on log reservations, pinned objects and
3717 * d. The mount is also marked as shut down so that log triggered shutdowns
3720 * Return true if the shutdown cause was a log IO error and we actually shut the
3721 * log down.
3725 struct xlog *log, in xlog_force_shutdown() argument
3730 if (!log) in xlog_force_shutdown()
3734 * Flush all the completed transactions to disk before marking the log in xlog_force_shutdown()
3735 * being shut down. We need to do this first as shutting down the log in xlog_force_shutdown()
3736 * before the force will prevent the log force from flushing the iclogs in xlog_force_shutdown()
3740 * we don't want to touch the log because we don't want to perturb the in xlog_force_shutdown()
3742 * avoid a log force in this case. in xlog_force_shutdown()
3744 * If we are shutting down due to a log IO error, then we must avoid in xlog_force_shutdown()
3745 * trying to write the log as that may just result in more IO errors and in xlog_force_shutdown()
3748 if (!log_error && !xlog_in_recovery(log)) in xlog_force_shutdown()
3749 xfs_log_force(log->l_mp, XFS_LOG_SYNC); in xlog_force_shutdown()
3757 * Much of the log state machine transitions assume that shutdown state in xlog_force_shutdown()
3758 * cannot change once they hold the log->l_icloglock. Hence we need to in xlog_force_shutdown()
3762 spin_lock(&log->l_icloglock); in xlog_force_shutdown()
3763 if (test_and_set_bit(XLOG_IO_ERROR, &log->l_opstate)) { in xlog_force_shutdown()
3764 spin_unlock(&log->l_icloglock); in xlog_force_shutdown()
3767 spin_unlock(&log->l_icloglock); in xlog_force_shutdown()
3770 * If this log shutdown also sets the mount shutdown state, issue a in xlog_force_shutdown()
3773 if (!test_and_set_bit(XFS_OPSTATE_SHUTDOWN, &log->l_mp->m_opstate)) { in xlog_force_shutdown()
3774 xfs_alert_tag(log->l_mp, XFS_PTAG_SHUTDOWN_LOGERROR, in xlog_force_shutdown()
3775 "Filesystem has been shut down due to log error (0x%x).", in xlog_force_shutdown()
3777 xfs_alert(log->l_mp, in xlog_force_shutdown()
3784 * We don't want anybody waiting for log reservations after this. That in xlog_force_shutdown()
3790 xlog_grant_head_wake_all(&log->l_reserve_head); in xlog_force_shutdown()
3791 xlog_grant_head_wake_all(&log->l_write_head); in xlog_force_shutdown()
3795 * as if the log writes were completed. The abort handling in the log in xlog_force_shutdown()
3799 spin_lock(&log->l_cilp->xc_push_lock); in xlog_force_shutdown()
3800 wake_up_all(&log->l_cilp->xc_start_wait); in xlog_force_shutdown()
3801 wake_up_all(&log->l_cilp->xc_commit_wait); in xlog_force_shutdown()
3802 spin_unlock(&log->l_cilp->xc_push_lock); in xlog_force_shutdown()
3804 spin_lock(&log->l_icloglock); in xlog_force_shutdown()
3805 xlog_state_shutdown_callbacks(log); in xlog_force_shutdown()
3806 spin_unlock(&log->l_icloglock); in xlog_force_shutdown()
3808 wake_up_var(&log->l_opstate); in xlog_force_shutdown()
3814 struct xlog *log) in xlog_iclogs_empty() argument
3818 iclog = log->l_iclog; in xlog_iclogs_empty()
3826 } while (iclog != log->l_iclog); in xlog_iclogs_empty()
3839 struct xlog *log = mp->m_log; in xfs_log_check_lsn() local
3843 * norecovery mode skips mount-time log processing and unconditionally in xfs_log_check_lsn()
3861 spin_lock(&log->l_icloglock); in xfs_log_check_lsn()
3866 log->l_curr_cycle, log->l_curr_block); in xfs_log_check_lsn()
3867 spin_unlock(&log->l_icloglock); in xfs_log_check_lsn()
3874 * Notify the log that we're about to start using a feature that is protected
3875 * by a log incompat feature flag. This will prevent log covering from
3880 struct xlog *log) in xlog_use_incompat_feat() argument
3882 down_read(&log->l_incompat_users); in xlog_use_incompat_feat()
3885 /* Notify the log that we've finished using log incompat features. */
3888 struct xlog *log) in xlog_drop_incompat_feat() argument
3890 up_read(&log->l_incompat_users); in xlog_drop_incompat_feat()