All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: linux-xfs@vger.kernel.org
Subject: [PATCH 03/16] xfs: embed the xlog_op_header in the unmount record
Date: Fri, 19 Nov 2021 10:13:39 +1100	[thread overview]
Message-ID: <20211118231352.2051947-4-david@fromorbit.com> (raw)
In-Reply-To: <20211118231352.2051947-1-david@fromorbit.com>

From: Dave Chinner <dchinner@redhat.com>

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: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
---
 fs/xfs/xfs_log.c | 39 ++++++++++++++++++++++++++++-----------
 1 file changed, 28 insertions(+), 11 deletions(-)

diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index e2953ce470de..e5515d0c85c4 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -915,12 +915,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 = {
@@ -928,8 +938,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);
 }
@@ -2267,6 +2281,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;
@@ -2472,12 +2488,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,
@@ -2541,6 +2556,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);
@@ -2571,7 +2588,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.
-- 
2.33.0


  parent reply	other threads:[~2021-11-18 23:13 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-18 23:13 [PATCH 00/16 v7] xfs: rework xlog_write() Dave Chinner
2021-11-18 23:13 ` [PATCH 01/16] xfs: factor out the CIL transaction header building Dave Chinner
2021-11-22 10:48   ` Chandan Babu R
2021-11-18 23:13 ` [PATCH 02/16] xfs: only CIL pushes require a start record Dave Chinner
2021-11-22 11:29   ` Chandan Babu R
2021-11-18 23:13 ` Dave Chinner [this message]
2021-11-22 11:30   ` [PATCH 03/16] xfs: embed the xlog_op_header in the unmount record Chandan Babu R
2021-11-18 23:13 ` [PATCH 04/16] xfs: embed the xlog_op_header in the commit record Dave Chinner
2021-11-22 11:31   ` Chandan Babu R
2021-11-18 23:13 ` [PATCH 05/16] xfs: log tickets don't need log client id Dave Chinner
2021-11-22 11:37   ` Chandan Babu R
2021-11-18 23:13 ` [PATCH 06/16] xfs: move log iovec alignment to preparation function Dave Chinner
2021-11-22 11:37   ` Chandan Babu R
2021-11-18 23:13 ` [PATCH 07/16] xfs: reserve space and initialise xlog_op_header in item formatting Dave Chinner
2021-11-22 11:39   ` Chandan Babu R
2021-11-18 23:13 ` [PATCH 08/16] xfs: log ticket region debug is largely useless Dave Chinner
2021-11-22 11:39   ` Chandan Babu R
2021-11-18 23:13 ` [PATCH 09/16] xfs: pass lv chain length into xlog_write() Dave Chinner
2021-11-22 11:39   ` Chandan Babu R
2021-11-18 23:13 ` [PATCH 10/16] xfs: change the type of ic_datap Dave Chinner
2021-11-18 23:13 ` [PATCH 11/16] xfs: introduce xlog_write_full() Dave Chinner
2021-11-22 11:40   ` Chandan Babu R
2021-11-18 23:13 ` [PATCH 12/16] xfs: introduce xlog_write_partial() Dave Chinner
2021-11-23 16:13   ` Chandan Babu R
2021-11-23 21:47   ` Darrick J. Wong
2021-11-18 23:13 ` [PATCH 13/16] xfs: remove xlog_verify_dest_ptr Dave Chinner
2021-11-18 23:13 ` [PATCH 14/16] xfs: xlog_write() no longer needs contwr state Dave Chinner
2021-11-24  8:54   ` Chandan Babu R
2021-11-18 23:13 ` [PATCH 15/16] xfs: xlog_write() doesn't need optype anymore Dave Chinner
2021-11-24  8:55   ` Chandan Babu R
2021-11-18 23:13 ` [PATCH 16/16] xfs: CIL context doesn't need to count iovecs Dave Chinner
2021-11-24  8:55   ` Chandan Babu R
  -- strict thread matches above, loose matches on Subject: below --
2022-03-09  5:29 [PATCH 00/16 v8] xfs: rework xlog_write() Dave Chinner
2022-03-09  5:29 ` [PATCH 03/16] xfs: embed the xlog_op_header in the unmount record Dave Chinner
2021-11-09  1:50 [PATCH 00/16 v6] xfs: rework xlog_write() Dave Chinner
2021-11-09  1:50 ` [PATCH 03/16] xfs: embed the xlog_op_header in the unmount record Dave Chinner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211118231352.2051947-4-david@fromorbit.com \
    --to=david@fromorbit.com \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.