Skip to content

Commit 3c702f9

Browse files
Dave Chinnerdjwong
authored andcommitted
xfs: refactor unmount record writing
Separate out the unmount record writing from the rest of the ticket and log state futzing necessary to make it work. This is a no-op, just makes the code cleaner and places the unmount record formatting and writing alongside the commit record formatting and writing code. We can also get rid of the ticket flag clearing before the xlog_write() call because it no longer cares about the state of XLOG_TIC_INITED. Signed-off-by: Dave Chinner <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Brian Foster <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent f10e925 commit 3c702f9

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

fs/xfs/xfs_log.c

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -795,32 +795,44 @@ xlog_wait_on_iclog(
795795
}
796796

797797
/*
798-
* Final log writes as part of unmount.
799-
*
800-
* Mark the filesystem clean as unmount happens. Note that during relocation
801-
* this routine needs to be executed as part of source-bag while the
802-
* deallocation must not be done until source-end.
798+
* Write out an unmount record using the ticket provided. We have to account for
799+
* the data space used in the unmount ticket as this write is not done from a
800+
* transaction context that has already done the accounting for us.
803801
*/
804-
805-
/* Actually write the unmount record to disk. */
806-
static void
807-
xfs_log_write_unmount_record(
808-
struct xfs_mount *mp)
802+
static int
803+
xlog_write_unmount_record(
804+
struct xlog *log,
805+
struct xlog_ticket *ticket,
806+
xfs_lsn_t *lsn,
807+
uint flags)
809808
{
810-
/* the data section must be 32 bit size aligned */
811-
struct xfs_unmount_log_format magic = {
809+
struct xfs_unmount_log_format ulf = {
812810
.magic = XLOG_UNMOUNT_TYPE,
813811
};
814812
struct xfs_log_iovec reg = {
815-
.i_addr = &magic,
816-
.i_len = sizeof(magic),
813+
.i_addr = &ulf,
814+
.i_len = sizeof(ulf),
817815
.i_type = XLOG_REG_TYPE_UNMOUNT,
818816
};
819817
struct xfs_log_vec vec = {
820818
.lv_niovecs = 1,
821819
.lv_iovecp = &reg,
822820
};
823-
struct xlog *log = mp->m_log;
821+
822+
/* account for space used by record data */
823+
ticket->t_curr_res -= sizeof(ulf);
824+
return xlog_write(log, &vec, ticket, lsn, NULL, flags, false);
825+
}
826+
827+
/*
828+
* Mark the filesystem clean by writing an unmount record to the head of the
829+
* log.
830+
*/
831+
static void
832+
xlog_unmount_write(
833+
struct xlog *log)
834+
{
835+
struct xfs_mount *mp = log->l_mp;
824836
struct xlog_in_core *iclog;
825837
struct xlog_ticket *tic = NULL;
826838
xfs_lsn_t lsn;
@@ -844,10 +856,7 @@ xfs_log_write_unmount_record(
844856
flags &= ~XLOG_UNMOUNT_TRANS;
845857
}
846858

847-
/* remove inited flag, and account for space used */
848-
tic->t_flags = 0;
849-
tic->t_curr_res -= sizeof(magic);
850-
error = xlog_write(log, &vec, tic, &lsn, NULL, flags, false);
859+
error = xlog_write_unmount_record(log, tic, &lsn, flags);
851860
/*
852861
* At this point, we're umounting anyway, so there's no point in
853862
* transitioning log state to IOERROR. Just continue...
@@ -913,7 +922,7 @@ xfs_log_unmount_write(
913922
if (XLOG_FORCED_SHUTDOWN(log))
914923
return;
915924
xfs_log_unmount_verify_iclog(log);
916-
xfs_log_write_unmount_record(mp);
925+
xlog_unmount_write(log);
917926
}
918927

919928
/*

0 commit comments

Comments
 (0)