···77777878#define XLOG_UNMOUNT_TYPE 0x556e /* Un for Unmount */79798080+/*8181+ * Log item for unmount records.8282+ *8383+ * The unmount record used to have a string "Unmount filesystem--" in the8484+ * data section where the "Un" was really a magic number (XLOG_UNMOUNT_TYPE).8585+ * We just write the magic number now; see xfs_log_unmount_write.8686+ */8787+struct xfs_unmount_log_format {8888+ uint16_t magic; /* XLOG_UNMOUNT_TYPE */8989+ uint16_t pad1;9090+ uint32_t pad2; /* may as well make it 64 bits */9191+};9292+8093/* Region types for iovec's i_type */8194#define XLOG_REG_TYPE_BFORMAT 18295#define XLOG_REG_TYPE_BCHUNK 2
+69-62
fs/xfs/xfs_log.c
···826826 * deallocation must not be done until source-end.827827 */828828829829+/* Actually write the unmount record to disk. */830830+static void831831+xfs_log_write_unmount_record(832832+ struct xfs_mount *mp)833833+{834834+ /* the data section must be 32 bit size aligned */835835+ struct xfs_unmount_log_format magic = {836836+ .magic = XLOG_UNMOUNT_TYPE,837837+ };838838+ struct xfs_log_iovec reg = {839839+ .i_addr = &magic,840840+ .i_len = sizeof(magic),841841+ .i_type = XLOG_REG_TYPE_UNMOUNT,842842+ };843843+ struct xfs_log_vec vec = {844844+ .lv_niovecs = 1,845845+ .lv_iovecp = ®,846846+ };847847+ struct xlog *log = mp->m_log;848848+ struct xlog_in_core *iclog;849849+ struct xlog_ticket *tic = NULL;850850+ xfs_lsn_t lsn;851851+ int error;852852+853853+ error = xfs_log_reserve(mp, 600, 1, &tic, XFS_LOG, 0);854854+ if (error)855855+ goto out_err;856856+857857+ /* remove inited flag, and account for space used */858858+ tic->t_flags = 0;859859+ tic->t_curr_res -= sizeof(magic);860860+ error = xlog_write(log, &vec, tic, &lsn, NULL, XLOG_UNMOUNT_TRANS);861861+ /*862862+ * At this point, we're umounting anyway, so there's no point in863863+ * transitioning log state to IOERROR. Just continue...864864+ */865865+out_err:866866+ if (error)867867+ xfs_alert(mp, "%s: unmount record failed", __func__);868868+869869+ spin_lock(&log->l_icloglock);870870+ iclog = log->l_iclog;871871+ atomic_inc(&iclog->ic_refcnt);872872+ xlog_state_want_sync(log, iclog);873873+ spin_unlock(&log->l_icloglock);874874+ error = xlog_state_release_iclog(log, iclog);875875+876876+ spin_lock(&log->l_icloglock);877877+ switch (iclog->ic_state) {878878+ default:879879+ if (!XLOG_FORCED_SHUTDOWN(log)) {880880+ xlog_wait(&iclog->ic_force_wait, &log->l_icloglock);881881+ break;882882+ }883883+ /* fall through */884884+ case XLOG_STATE_ACTIVE:885885+ case XLOG_STATE_DIRTY:886886+ spin_unlock(&log->l_icloglock);887887+ break;888888+ }889889+890890+ if (tic) {891891+ trace_xfs_log_umount_write(log, tic);892892+ xlog_ungrant_log_space(log, tic);893893+ xfs_log_ticket_put(tic);894894+ }895895+}896896+829897/*830898 * Unmount record used to have a string "Unmount filesystem--" in the831899 * data section where the "Un" was really a magic number (XLOG_UNMOUNT_TYPE).···910842#ifdef DEBUG911843 xlog_in_core_t *first_iclog;912844#endif913913- xlog_ticket_t *tic = NULL;914914- xfs_lsn_t lsn;915845 int error;916846917847 /*···936870 } while (iclog != first_iclog);937871#endif938872 if (! (XLOG_FORCED_SHUTDOWN(log))) {939939- error = xfs_log_reserve(mp, 600, 1, &tic, XFS_LOG, 0);940940- if (!error) {941941- /* the data section must be 32 bit size aligned */942942- struct {943943- uint16_t magic;944944- uint16_t pad1;945945- uint32_t pad2; /* may as well make it 64 bits */946946- } magic = {947947- .magic = XLOG_UNMOUNT_TYPE,948948- };949949- struct xfs_log_iovec reg = {950950- .i_addr = &magic,951951- .i_len = sizeof(magic),952952- .i_type = XLOG_REG_TYPE_UNMOUNT,953953- };954954- struct xfs_log_vec vec = {955955- .lv_niovecs = 1,956956- .lv_iovecp = ®,957957- };958958-959959- /* remove inited flag, and account for space used */960960- tic->t_flags = 0;961961- tic->t_curr_res -= sizeof(magic);962962- error = xlog_write(log, &vec, tic, &lsn,963963- NULL, XLOG_UNMOUNT_TRANS);964964- /*965965- * At this point, we're umounting anyway,966966- * so there's no point in transitioning log state967967- * to IOERROR. Just continue...968968- */969969- }970970-971971- if (error)972972- xfs_alert(mp, "%s: unmount record failed", __func__);973973-974974-975975- spin_lock(&log->l_icloglock);976976- iclog = log->l_iclog;977977- atomic_inc(&iclog->ic_refcnt);978978- xlog_state_want_sync(log, iclog);979979- spin_unlock(&log->l_icloglock);980980- error = xlog_state_release_iclog(log, iclog);981981-982982- spin_lock(&log->l_icloglock);983983- if (!(iclog->ic_state == XLOG_STATE_ACTIVE ||984984- iclog->ic_state == XLOG_STATE_DIRTY)) {985985- if (!XLOG_FORCED_SHUTDOWN(log)) {986986- xlog_wait(&iclog->ic_force_wait,987987- &log->l_icloglock);988988- } else {989989- spin_unlock(&log->l_icloglock);990990- }991991- } else {992992- spin_unlock(&log->l_icloglock);993993- }994994- if (tic) {995995- trace_xfs_log_umount_write(log, tic);996996- xlog_ungrant_log_space(log, tic);997997- xfs_log_ticket_put(tic);998998- }873873+ xfs_log_write_unmount_record(mp);999874 } else {1000875 /*1001876 * We're already in forced_shutdown mode, couldn't