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 15/39] xfs_io: bmap should support querying CoW fork, shared blocks
Date: Tue, 25 Oct 2016 16:05:10 -0700	[thread overview]
Message-ID: <147743671083.11035.8607583600483038357.stgit@birch.djwong.org> (raw)
In-Reply-To: <147743661772.11035.560864407573832590.stgit@birch.djwong.org>

Teach the bmap command to report shared and delayed allocation
extents, and to be able to query the CoW fork.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 io/bmap.c           |   43 ++++++++++++++++++++++++++++++++++---------
 man/man8/xfs_bmap.8 |   14 ++++++++++++++
 man/man8/xfs_io.8   |    2 +-
 3 files changed, 49 insertions(+), 10 deletions(-)


diff --git a/io/bmap.c b/io/bmap.c
index b2e48da..2333244 100644
--- a/io/bmap.c
+++ b/io/bmap.c
@@ -41,7 +41,9 @@ bmap_help(void)
 " Holes are marked by replacing the startblock..endblock with 'hole'.\n"
 " All the file offsets and disk blocks are in units of 512-byte blocks.\n"
 " -a -- prints the attribute fork map instead of the data fork.\n"
+" -c -- prints the copy-on-write fork map instead of the data fork.\n"
 " -d -- suppresses a DMAPI read event, offline portions shown as holes.\n"
+" -e -- print delayed allocation extents.\n"
 " -l -- also displays the length of each extent in 512-byte blocks.\n"
 " -n -- query n extents.\n"
 " -p -- obtain all unwritten extents as well (w/ -v show which are unwritten.)\n"
@@ -75,6 +77,7 @@ bmap_f(
 	int			loop = 0;
 	int			flg = 0;
 	int			aflag = 0;
+	int			cflag = 0;
 	int			lflag = 0;
 	int			nflag = 0;
 	int			pflag = 0;
@@ -85,12 +88,19 @@ bmap_f(
 	int			c;
 	int			egcnt;
 
-	while ((c = getopt(argc, argv, "adln:pv")) != EOF) {
+	while ((c = getopt(argc, argv, "acdeln:pv")) != EOF) {
 		switch (c) {
 		case 'a':	/* Attribute fork. */
 			bmv_iflags |= BMV_IF_ATTRFORK;
 			aflag = 1;
 			break;
+		case 'c':	/* CoW fork. */
+			bmv_iflags |= BMV_IF_COWFORK | BMV_IF_DELALLOC;
+			cflag = 1;
+			break;
+		case 'e':
+			bmv_iflags |= BMV_IF_DELALLOC;
+			break;
 		case 'l':	/* list number of blocks with each extent */
 			lflag = 1;
 			break;
@@ -113,7 +123,7 @@ bmap_f(
 			return command_usage(&bmap_cmd);
 		}
 	}
-	if (aflag)
+	if (aflag || cflag)
 		bmv_iflags &= ~(BMV_IF_PREALLOC|BMV_IF_NO_DMAPI_READ);
 
 	if (vflag) {
@@ -273,13 +283,14 @@ bmap_f(
 #define MINRANGE_WIDTH	16
 #define MINAG_WIDTH	2
 #define MINTOT_WIDTH	5
-#define NFLG		5	/* count of flags */
-#define	FLG_NULL	000000	/* Null flag */
-#define	FLG_PRE		010000	/* Unwritten extent */
-#define	FLG_BSU		001000	/* Not on begin of stripe unit  */
-#define	FLG_ESU		000100	/* Not on end   of stripe unit  */
-#define	FLG_BSW		000010	/* Not on begin of stripe width */
-#define	FLG_ESW		000001	/* Not on end   of stripe width */
+#define NFLG		6	/* count of flags */
+#define	FLG_NULL	0000000	/* Null flag */
+#define	FLG_SHARED	0100000	/* shared extent */
+#define	FLG_PRE		0010000	/* Unwritten extent */
+#define	FLG_BSU		0001000	/* Not on begin of stripe unit  */
+#define	FLG_ESU		0000100	/* Not on end   of stripe unit  */
+#define	FLG_BSW		0000010	/* Not on begin of stripe width */
+#define	FLG_ESW		0000001	/* Not on end   of stripe width */
 		int	agno;
 		off64_t agoff, bbperag;
 		int	foff_w, boff_w, aoff_w, tot_w, agno_w;
@@ -350,6 +361,10 @@ bmap_f(
 			if (map[i + 1].bmv_oflags & BMV_OF_PREALLOC) {
 				flg |= FLG_PRE;
 			}
+			if (map[i + 1].bmv_oflags & BMV_OF_SHARED)
+				flg |= FLG_SHARED;
+			if (map[i + 1].bmv_oflags & BMV_OF_DELALLOC)
+				map[i + 1].bmv_block = -2;
 			/*
 			 * If striping enabled, determine if extent starts/ends
 			 * on a stripe unit boundary.
@@ -382,6 +397,14 @@ bmap_f(
 					agno_w, "",
 					aoff_w, "",
 					tot_w, (long long)map[i+1].bmv_length);
+			} else if (map[i + 1].bmv_block == -2) {
+				printf("%4d: %-*s %-*s %*s %-*s %*lld\n",
+					i,
+					foff_w, rbuf,
+					boff_w, _("delalloc"),
+					agno_w, "",
+					aoff_w, "",
+					tot_w, (long long)map[i+1].bmv_length);
 			} else {
 				snprintf(bbuf, sizeof(bbuf), "%lld..%lld",
 					(long long) map[i + 1].bmv_block,
@@ -413,6 +436,8 @@ bmap_f(
 		}
 		if ((flg || pflag) && vflag > 1) {
 			printf(_(" FLAG Values:\n"));
+			printf(_("    %*.*o Shared extent\n"),
+				NFLG+1, NFLG+1, FLG_SHARED);
 			printf(_("    %*.*o Unwritten preallocated extent\n"),
 				NFLG+1, NFLG+1, FLG_PRE);
 			printf(_("    %*.*o Doesn't begin on stripe unit\n"),
diff --git a/man/man8/xfs_bmap.8 b/man/man8/xfs_bmap.8
index e196559..098cfae 100644
--- a/man/man8/xfs_bmap.8
+++ b/man/man8/xfs_bmap.8
@@ -36,6 +36,10 @@ no matter what the filesystem's block size is.
 If this option is specified, information about the file's
 attribute fork is printed instead of the default data fork.
 .TP
+.B \-c
+If this option is specified, information about the file's
+copy on write fork is printed instead of the default data fork.
+.TP
 .B \-d
 If portions of the file have been migrated offline by
 a DMAPI application, a DMAPI read event will be generated to
@@ -45,6 +49,16 @@ printed.  However if the
 option is used, no DMAPI read event will be generated for a
 DMAPI file and offline portions will be reported as holes.
 .TP
+.B \-e
+If this option is used,
+.B xfs_bmap
+obtains all delayed allocation extents, and does not flush dirty pages
+to disk before querying extent data. With the
+.B \-v
+option, the
+.I flags
+column will show which extents have not yet been allocated.
+.TP
 .B \-l
 If this option is used, then
 .IP
diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8
index 2c56f09..d089524 100644
--- a/man/man8/xfs_io.8
+++ b/man/man8/xfs_io.8
@@ -256,7 +256,7 @@ See the
 .B pwrite
 command.
 .TP
-.BI "bmap [ \-adlpv ] [ \-n " nx " ]"
+.BI "bmap [ \-acdelpv ] [ \-n " nx " ]"
 Prints the block mapping for the current open file. Refer to the
 .BR xfs_bmap (8)
 manual page for complete documentation.


  parent reply	other threads:[~2016-10-25 23:05 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 ` Darrick J. Wong [this message]
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 ` [PATCH 23/39] xfs_logprint: support refcount redo items Darrick J. Wong
2016-10-26 10:37   ` 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=147743671083.11035.8607583600483038357.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.