Commit ffa04c1f authored by Dave Chinner's avatar Dave Chinner Committed by Dave Chinner

xfs: embed the xlog_op_header in the unmount record

Remove another case where xlog_write() has to prepend an opheader to
a log transaction. The unmount record + ophdr is smaller than the
minimum amount of space guaranteed to be free in an iclog (2 *
sizeof(ophdr)) and so we don't have to care about an unmount record
being split across 2 iclogs.
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarChandan Babu R <chandan.babu@oracle.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent 6eaed95e
......@@ -901,12 +901,22 @@ xlog_write_unmount_record(
struct xlog *log,
struct xlog_ticket *ticket)
{
struct xfs_unmount_log_format ulf = {
.magic = XLOG_UNMOUNT_TYPE,
struct {
struct xlog_op_header ophdr;
struct xfs_unmount_log_format ulf;
} unmount_rec = {
.ophdr = {
.oh_clientid = XFS_LOG,
.oh_tid = cpu_to_be32(ticket->t_tid),
.oh_flags = XLOG_UNMOUNT_TRANS,
},
.ulf = {
.magic = XLOG_UNMOUNT_TYPE,
},
};
struct xfs_log_iovec reg = {
.i_addr = &ulf,
.i_len = sizeof(ulf),
.i_addr = &unmount_rec,
.i_len = sizeof(unmount_rec),
.i_type = XLOG_REG_TYPE_UNMOUNT,
};
struct xfs_log_vec vec = {
......@@ -914,8 +924,12 @@ xlog_write_unmount_record(
.lv_iovecp = &reg,
};
BUILD_BUG_ON((sizeof(struct xlog_op_header) +
sizeof(struct xfs_unmount_log_format)) !=
sizeof(unmount_rec));
/* account for space used by record data */
ticket->t_curr_res -= sizeof(ulf);
ticket->t_curr_res -= sizeof(unmount_rec);
return xlog_write(log, NULL, &vec, ticket, XLOG_UNMOUNT_TRANS);
}
......@@ -2253,6 +2267,8 @@ xlog_write_calc_vec_length(
/* Don't account for regions with embedded ophdrs */
if (optype && headers > 0) {
if (optype & XLOG_UNMOUNT_TRANS)
headers--;
if (optype & XLOG_START_TRANS) {
ASSERT(headers >= 2);
headers -= 2;
......@@ -2458,12 +2474,11 @@ xlog_write(
/*
* If this is a commit or unmount transaction, we don't need a start
* record to be written. We do, however, have to account for the
* commit or unmount header that gets written. Hence we always have
* to account for an extra xlog_op_header here for commit and unmount
* records.
* record to be written. We do, however, have to account for the commit
* header that gets written. Hence we always have to account for an
* extra xlog_op_header here for commit records.
*/
if (optype & (XLOG_COMMIT_TRANS | XLOG_UNMOUNT_TRANS))
if (optype & XLOG_COMMIT_TRANS)
ticket->t_curr_res -= sizeof(struct xlog_op_header);
if (ticket->t_curr_res < 0) {
xfs_alert_tag(log->l_mp, XFS_PTAG_LOGRES,
......@@ -2527,6 +2542,8 @@ xlog_write(
ophdr = reg->i_addr;
if (index)
optype &= ~XLOG_START_TRANS;
} else if (optype & XLOG_UNMOUNT_TRANS) {
ophdr = reg->i_addr;
} else {
ophdr = xlog_write_setup_ophdr(log, ptr,
ticket, optype);
......@@ -2557,7 +2574,7 @@ xlog_write(
/*
* Copy region.
*
* Commit and unmount records just log an opheader, so
* Commit records just log an opheader, so
* we can have empty payloads with no data region to
* copy. Hence we only copy the payload if the vector
* says it has data to copy.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment