All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: david@fromorbit.com, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 23/39] xfs_logprint: support refcount redo items
Date: Tue, 25 Oct 2016 16:06:02 -0700	[thread overview]
Message-ID: <147743676212.11035.6341580285293427233.stgit@birch.djwong.org> (raw)
In-Reply-To: <147743661772.11035.560864407573832590.stgit@birch.djwong.org>

Print reference count update redo items.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 logprint/log_misc.c      |   11 +++
 logprint/log_print_all.c |   12 ++++
 logprint/log_redo.c      |  148 ++++++++++++++++++++++++++++++++++++++++++++++
 logprint/logprint.h      |    5 ++
 4 files changed, 176 insertions(+)


diff --git a/logprint/log_misc.c b/logprint/log_misc.c
index dbe5729..8284206 100644
--- a/logprint/log_misc.c
+++ b/logprint/log_misc.c
@@ -962,6 +962,17 @@ xlog_print_record(
 					be32_to_cpu(op_head->oh_len));
 			break;
 		    }
+		    case XFS_LI_CUI: {
+			skip = xlog_print_trans_cui(&ptr,
+					be32_to_cpu(op_head->oh_len),
+					continued);
+			break;
+		    }
+		    case XFS_LI_CUD: {
+			skip = xlog_print_trans_cud(&ptr,
+					be32_to_cpu(op_head->oh_len));
+			break;
+		    }
 		    case XFS_LI_QUOTAOFF: {
 			skip = xlog_print_trans_qoff(&ptr,
 					be32_to_cpu(op_head->oh_len));
diff --git a/logprint/log_print_all.c b/logprint/log_print_all.c
index 46952c4..eb3e326 100644
--- a/logprint/log_print_all.c
+++ b/logprint/log_print_all.c
@@ -418,6 +418,12 @@ xlog_recover_print_logitem(
 	case XFS_LI_RUI:
 		xlog_recover_print_rui(item);
 		break;
+	case XFS_LI_CUD:
+		xlog_recover_print_cud(item);
+		break;
+	case XFS_LI_CUI:
+		xlog_recover_print_cui(item);
+		break;
 	case XFS_LI_DQUOT:
 		xlog_recover_print_dquot(item);
 		break;
@@ -458,6 +464,12 @@ xlog_recover_print_item(
 	case XFS_LI_RUI:
 		printf("RUI");
 		break;
+	case XFS_LI_CUD:
+		printf("CUD");
+		break;
+	case XFS_LI_CUI:
+		printf("CUI");
+		break;
 	case XFS_LI_DQUOT:
 		printf("DQ ");
 		break;
diff --git a/logprint/log_redo.c b/logprint/log_redo.c
index 40e0727..6be073e 100644
--- a/logprint/log_redo.c
+++ b/logprint/log_redo.c
@@ -378,3 +378,151 @@ xlog_recover_print_rud(
 	f = item->ri_buf[0].i_addr;
 	xlog_print_trans_rud(&f, sizeof(struct xfs_rud_log_format));
 }
+
+/* Reference Count Update Items */
+
+static int
+xfs_cui_copy_format(
+	char			  *buf,
+	uint			  len,
+	struct xfs_cui_log_format *dst_fmt,
+	int			  continued)
+{
+	uint nextents = ((struct xfs_cui_log_format *)buf)->cui_nextents;
+	uint dst_len = xfs_cui_log_format_sizeof(nextents);
+
+	if (len == dst_len || continued) {
+		memcpy((char *)dst_fmt, buf, len);
+		return 0;
+	}
+	fprintf(stderr, _("%s: bad size of CUI format: %u; expected %u; nextents = %u\n"),
+		progname, len, dst_len, nextents);
+	return 1;
+}
+
+int
+xlog_print_trans_cui(
+	char			**ptr,
+	uint			src_len,
+	int			continued)
+{
+	struct xfs_cui_log_format	*src_f, *f = NULL;
+	uint			dst_len;
+	uint			nextents;
+	struct xfs_phys_extent	*ex;
+	int			i;
+	int			error = 0;
+	int			core_size;
+
+	core_size = offsetof(struct xfs_cui_log_format, cui_extents);
+
+	/*
+	 * memmove to ensure 8-byte alignment for the long longs in
+	 * struct xfs_cui_log_format structure
+	 */
+	src_f = malloc(src_len);
+	if (src_f == NULL) {
+		fprintf(stderr, _("%s: %s: malloc failed\n"),
+			progname, __func__);
+		exit(1);
+	}
+	memmove((char*)src_f, *ptr, src_len);
+	*ptr += src_len;
+
+	/* convert to native format */
+	nextents = src_f->cui_nextents;
+	dst_len = xfs_cui_log_format_sizeof(nextents);
+
+	if (continued && src_len < core_size) {
+		printf(_("CUI: Not enough data to decode further\n"));
+		error = 1;
+		goto error;
+	}
+
+	f = malloc(dst_len);
+	if (f == NULL) {
+		fprintf(stderr, _("%s: %s: malloc failed\n"),
+			progname, __func__);
+		exit(1);
+	}
+	if (xfs_cui_copy_format((char *)src_f, src_len, f, continued)) {
+		error = 1;
+		goto error;
+	}
+
+	printf(_("CUI:  #regs: %d	num_extents: %d  id: 0x%llx\n"),
+		f->cui_size, f->cui_nextents, (unsigned long long)f->cui_id);
+
+	if (continued) {
+		printf(_("CUI extent data skipped (CONTINUE set, no space)\n"));
+		goto error;
+	}
+
+	ex = f->cui_extents;
+	for (i=0; i < f->cui_nextents; i++) {
+		printf("(s: 0x%llx, l: %d, f: 0x%x) ",
+			(unsigned long long)ex->pe_startblock, ex->pe_len,
+			ex->pe_flags);
+		printf("\n");
+		ex++;
+	}
+error:
+	free(src_f);
+	free(f);
+	return error;
+}
+
+void
+xlog_recover_print_cui(
+	struct xlog_recover_item	*item)
+{
+	char				*src_f;
+	uint				src_len;
+
+	src_f = item->ri_buf[0].i_addr;
+	src_len = item->ri_buf[0].i_len;
+
+	xlog_print_trans_cui(&src_f, src_len, 0);
+}
+
+int
+xlog_print_trans_cud(
+	char				**ptr,
+	uint				len)
+{
+	struct xfs_cud_log_format	*f;
+	struct xfs_cud_log_format	lbuf;
+
+	/* size without extents at end */
+	uint core_size = sizeof(struct xfs_cud_log_format);
+
+	/*
+	 * memmove to ensure 8-byte alignment for the long longs in
+	 * xfs_efd_log_format_t structure
+	 */
+	memmove(&lbuf, *ptr, MIN(core_size, len));
+	f = &lbuf;
+	*ptr += len;
+	if (len >= core_size) {
+		printf(_("CUD:  #regs: %d	                 id: 0x%llx\n"),
+			f->cud_size,
+			(unsigned long long)f->cud_cui_id);
+
+		/* don't print extents as they are not used */
+
+		return 0;
+	} else {
+		printf(_("CUD: Not enough data to decode further\n"));
+		return 1;
+	}
+}
+
+void
+xlog_recover_print_cud(
+	struct xlog_recover_item	*item)
+{
+	char				*f;
+
+	f = item->ri_buf[0].i_addr;
+	xlog_print_trans_cud(&f, sizeof(struct xfs_cud_log_format));
+}
diff --git a/logprint/logprint.h b/logprint/logprint.h
index bdd0ee1..ae63c2e 100644
--- a/logprint/logprint.h
+++ b/logprint/logprint.h
@@ -54,4 +54,9 @@ extern void xlog_recover_print_rui(struct xlog_recover_item *item);
 extern int xlog_print_trans_rud(char **ptr, uint len);
 extern void xlog_recover_print_rud(struct xlog_recover_item *item);
 
+extern int xlog_print_trans_cui(char **ptr, uint src_len, int continued);
+extern void xlog_recover_print_cui(struct xlog_recover_item *item);
+extern int xlog_print_trans_cud(char **ptr, uint len);
+extern void xlog_recover_print_cud(struct xlog_recover_item *item);
+
 #endif	/* LOGPRINT_H */


  parent reply	other threads:[~2016-10-25 23:06 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-25 23:03 [PATCH v10 00/39] xfsprogs: add reflink and dedupe support Darrick J. Wong
2016-10-25 23:03 ` [PATCH 01/39] xfs: convert RUI log formats to use variable length arrays Darrick J. Wong
2016-10-26 10:21   ` Christoph Hellwig
2016-10-25 23:03 ` [PATCH 02/39] xfs_buflock: handling parsing errors more gracefully Darrick J. Wong
2016-10-26 10:22   ` Christoph Hellwig
2016-10-25 23:03 ` [PATCH 03/39] xfs: define the on-disk refcount btree format Darrick J. Wong
2016-10-26 10:23   ` Christoph Hellwig
2016-10-25 23:04 ` [PATCH 04/39] xfs: add refcount btree operations Darrick J. Wong
2016-10-26 10:23   ` Christoph Hellwig
2016-10-25 23:04 ` [PATCH 05/39] xfs: connect refcount adjust functions to upper layers Darrick J. Wong
2016-10-26 10:24   ` Christoph Hellwig
2016-10-26 18:06     ` Darrick J. Wong
2016-10-25 23:04 ` [PATCH 06/39] xfs: implement deferred bmbt map/unmap operations Darrick J. Wong
2016-10-25 23:04 ` [PATCH 07/39] xfs: introduce the CoW fork Darrick J. Wong
2016-10-26 10:25   ` Christoph Hellwig
2016-10-26 17:59     ` Darrick J. Wong
2016-10-25 23:04 ` [PATCH 08/39] xfs: create a separate cow extent size hint for the allocator Darrick J. Wong
2016-10-25 23:04 ` [PATCH 09/39] xfs_db: dump refcount btree data Darrick J. Wong
2016-10-26 10:28   ` Christoph Hellwig
2016-10-26 17:52     ` Darrick J. Wong
2016-10-25 23:04 ` [PATCH 10/39] xfs_db: add support for checking the refcount btree Darrick J. Wong
2016-10-26  0:49   ` Dave Chinner
2016-10-26  1:13     ` Darrick J. Wong
2016-10-26  3:26       ` Dave Chinner
2016-10-26  6:29         ` Darrick J. Wong
2016-10-25 23:04 ` [PATCH 11/39] xfs_db: metadump should copy the refcount btree too Darrick J. Wong
2016-10-26 10:29   ` Christoph Hellwig
2016-10-26 16:33     ` Darrick J. Wong
2016-10-25 23:04 ` [PATCH 12/39] xfs_db: deal with the CoW extent size hint Darrick J. Wong
2016-10-26 10:28   ` Christoph Hellwig
2016-10-25 23:04 ` [PATCH 13/39] xfs_db: print one array element per line Darrick J. Wong
2016-10-26  0:51   ` Dave Chinner
2016-10-26  1:13     ` Darrick J. Wong
2016-10-26  3:23       ` Dave Chinner
2016-10-26  3:34         ` Darrick J. Wong
2016-10-26  5:48           ` Dave Chinner
2016-10-25 23:05 ` [PATCH 14/39] xfs_growfs: report the presence of the reflink feature Darrick J. Wong
2016-10-26 10:31   ` Christoph Hellwig
2016-10-25 23:05 ` [PATCH 15/39] xfs_io: bmap should support querying CoW fork, shared blocks Darrick J. Wong
2016-10-25 23:05 ` [PATCH 16/39] libxfs: add configure option to override system header fsxattr Darrick J. Wong
2016-10-26  0:56   ` Dave Chinner
2016-10-26  1:16     ` Darrick J. Wong
2016-10-26 10:32   ` Christoph Hellwig
2016-10-26 19:04     ` Darrick J. Wong
2016-10-25 23:05 ` [PATCH 17/39] xfs_io: get and set the CoW extent size hint Darrick J. Wong
2016-10-26  1:06   ` Dave Chinner
2016-10-25 23:05 ` [PATCH 18/39] xfs_io: add refcount+bmap error injection types Darrick J. Wong
2016-10-26 10:33   ` Christoph Hellwig
2016-10-25 23:05 ` [PATCH 19/39] xfs_io: support injecting the 'per-AG reservation critically low' error Darrick J. Wong
2016-10-26 10:33   ` Christoph Hellwig
2016-10-25 23:05 ` [PATCH 20/39] xfs_io: provide long-format help for falloc Darrick J. Wong
2016-10-26 10:34   ` Christoph Hellwig
2016-10-26 16:37     ` Darrick J. Wong
2016-10-25 23:05 ` [PATCH 21/39] xfs_io: try to unshare copy-on-write blocks via fallocate Darrick J. Wong
2016-10-26 10:34   ` Christoph Hellwig
2016-10-25 23:05 ` [PATCH 22/39] xfs_logprint: support cowextsize reporting in log contents Darrick J. Wong
2016-10-26 10:34   ` Christoph Hellwig
2016-10-25 23:06 ` Darrick J. Wong [this message]
2016-10-26 10:37   ` [PATCH 23/39] xfs_logprint: support refcount redo items Christoph Hellwig
2016-10-26 17:31     ` Darrick J. Wong
2016-10-25 23:06 ` [PATCH 24/39] xfs_logprint: support bmap " Darrick J. Wong
2016-10-26 10:38   ` Christoph Hellwig
2016-10-25 23:06 ` [PATCH 25/39] man: document the inode cowextsize flags & fields Darrick J. Wong
2016-10-26 10:39   ` Christoph Hellwig
2016-10-26 17:20     ` Darrick J. Wong
2016-10-25 23:06 ` [PATCH 26/39] xfs_repair: fix get_agino_buf to avoid corrupting inodes Darrick J. Wong
2016-10-26 10:48   ` Christoph Hellwig
2016-10-25 23:06 ` [PATCH 27/39] xfs_repair: check the existing refcount btree Darrick J. Wong
2016-10-26 10:49   ` Christoph Hellwig
2016-10-25 23:06 ` [PATCH 28/39] xfs_repair: handle multiple owners of data blocks Darrick J. Wong
2016-10-26 10:57   ` Christoph Hellwig
2016-10-26 17:15     ` Darrick J. Wong
2016-10-26 21:15       ` Dave Chinner
2016-10-26 21:59         ` Darrick J. Wong
2016-10-25 23:06 ` [PATCH 29/39] xfs_repair: process reverse-mapping data into refcount data Darrick J. Wong
2016-10-25 23:06 ` [PATCH 30/39] xfs_repair: record reflink inode state Darrick J. Wong
2016-10-25 23:06 ` [PATCH 31/39] xfs_repair: fix inode reflink flags Darrick J. Wong
2016-10-25 23:07 ` [PATCH 32/39] xfs_repair: check the refcount btree against our observed reference counts when -n Darrick J. Wong
2016-10-25 23:07 ` [PATCH 33/39] xfs_repair: rebuild the refcount btree Darrick J. Wong
2016-10-25 23:07 ` [PATCH 34/39] xfs_repair: complain about copy-on-write leftovers Darrick J. Wong
2016-10-25 23:07 ` [PATCH 35/39] xfs_repair: check the CoW extent size hint Darrick J. Wong
2016-10-25 23:07 ` [PATCH 36/39] xfs_repair: use range query when while checking rmaps Darrick J. Wong
2016-10-25 23:07 ` [PATCH 37/39] xfs_repair: check for mergeable refcount records Darrick J. Wong
2016-10-25 23:07 ` [PATCH 38/39] xfs_repair: use thread pools to sort rmap data Darrick J. Wong
2016-10-25 23:07 ` [PATCH 39/39] mkfs.xfs: format reflink enabled filesystems Darrick J. Wong

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=147743676212.11035.6341580285293427233.stgit@birch.djwong.org \
    --to=darrick.wong@oracle.com \
    --cc=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.