linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] filefrag: minor code fixes and cleanups
@ 2014-07-30 20:25 Andreas Dilger
  2014-07-30 20:25 ` [PATCH 2/3] filefrag: reserve fields and new extent flags Andreas Dilger
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andreas Dilger @ 2014-07-30 20:25 UTC (permalink / raw)
  To: tytso; +Cc: linux-ext4, David Sterba, Andreas Dilger

Print filefrag_fiemap() error message to stderr instead of stdout.

Only call ioctl(EXT3_IOC_GETFLAGS) for ext{2,3,4} filesystems to
decide if the ext2 indirect block allocation heuristic shold be used.

Properly handle the the force_bmap (-B) option.

Exit with a positive error number instead of a negative one.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
---
 misc/filefrag.c |   26 +++++++++++++++-----------
 1 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/misc/filefrag.c b/misc/filefrag.c
index 2ce1b9b..d71bf43 100644
--- a/misc/filefrag.c
+++ b/misc/filefrag.c
@@ -226,9 +226,11 @@ static int filefrag_fiemap(int fd, int blk_shift, int *num_extents,
 		rc = ioctl(fd, FS_IOC_FIEMAP, (unsigned long) fiemap);
 		if (rc < 0) {
 			static int fiemap_incompat_printed;
+
 			rc = -errno;
 			if (rc == -EBADR && !fiemap_incompat_printed) {
-				printf("FIEMAP failed with unknown flags %#x\n",
+				fprintf(stderr, "FIEMAP failed with unknown "
+						"flags %x\n",
 				       fiemap->fm_flags);
 				fiemap_incompat_printed = 1;
 			}
@@ -360,7 +362,6 @@ static int frag_report(const char *filename)
 	int		num_extents = 1, expected = ~0;
 	int		is_ext2 = 0;
 	static dev_t	last_device;
-	unsigned int	flags;
 	int		width;
 	int		rc = 0;
 
@@ -398,12 +399,14 @@ static int frag_report(const char *filename)
 			       (unsigned long)fsinfo.f_type);
 	}
 	st.st_blksize = blksize;
-	if (ioctl(fd, EXT3_IOC_GETFLAGS, &flags) < 0)
-		flags = 0;
-	if (!(flags & EXT4_EXTENTS_FL) &&
-	    ((fsinfo.f_type == 0xef51) || (fsinfo.f_type == 0xef52) ||
-	     (fsinfo.f_type == 0xef53)))
-		is_ext2++;
+	if (fsinfo.f_type == 0xef51 || fsinfo.f_type == 0xef52 ||
+	    fsinfo.f_type == 0xef53) {
+		unsigned int	flags;
+
+		if (ioctl(fd, EXT3_IOC_GETFLAGS, &flags) == 0 &&
+		    !(flags & EXT4_EXTENTS_FL))
+			is_ext2 = 1;
+	}
 
 	if (is_ext2) {
 		long cylgroups = div_ceil(fsinfo.f_blocks, blksize * 8);
@@ -441,7 +444,7 @@ static int frag_report(const char *filename)
 		expected = 0;
 	}
 
-	if (force_bmap || rc < 0) {
+	if (force_bmap || rc < 0) { /* FIEMAP failed, try FIBMAP instead */
 		expected = filefrag_fibmap(fd, blk_shift, &num_extents,
 					   &st, numblocks, is_ext2);
 		if (expected < 0) {
@@ -492,7 +495,7 @@ int main(int argc, char**argv)
 	char **cpp;
 	int rc = 0, c;
 
-	while ((c = getopt(argc, argv, "Bb::eksvxX")) != EOF)
+	while ((c = getopt(argc, argv, "Bb::eksvxX")) != EOF) {
 		switch (c) {
 		case 'B':
 			force_bmap++;
@@ -551,6 +554,7 @@ int main(int argc, char**argv)
 			usage(argv[0]);
 			break;
 		}
+	}
 
 	if (optind == argc)
 		usage(argv[0]);
@@ -562,6 +566,6 @@ int main(int argc, char**argv)
 			rc = rc2;
 	}
 
-	return rc;
+	return -rc;
 }
 #endif
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] filefrag: reserve fields and new extent flags
  2014-07-30 20:25 [PATCH 1/3] filefrag: minor code fixes and cleanups Andreas Dilger
@ 2014-07-30 20:25 ` Andreas Dilger
  2014-07-30 20:32   ` Andreas Dilger
  2014-07-30 20:25 ` [PATCH 3/3] filefrag: print out physical extent length if set Andreas Dilger
  2014-08-02  2:09 ` [PATCH 1/3] filefrag: minor code fixes and cleanups Theodore Ts'o
  2 siblings, 1 reply; 5+ messages in thread
From: Andreas Dilger @ 2014-07-30 20:25 UTC (permalink / raw)
  To: tytso; +Cc: linux-ext4, David Sterba, Andreas Dilger

Reserve the FIEMAP_EXTENT_PHYS_LENGTH flag to indicate that the new
fe_phys_length field contains valid data.  This is introduced to
allow different fe_phys_length and fe_logi_length values for
compressed extents, but it is also valid to set PHYS_LENGTH and set
fe_phys_length for regular files to simplify userspace codes.  If
PHYS_LENGTH is not set, then applications should set fe_phys_length
equal to fe_logi_length, since fe_phys_length is undefined (though
typically zero).

Reserve the FIEMAP_EXTENT_DATA_COMPRESSED flag to allow reporting
extents with physical length different than logical length.  This
also sets the FIEMAP_EXTENT_ENCODED flag to indicate that the data
cannot be accessed directly.

Reserve the FIEMAP_EXTENT_NET flag, which indicates that the data
is on a network filesystem that does not have local storage devices.
This also sets FIEMAP_EXTENT_ENCODED flag to indicate the data cannot
be accessed directly.

Print out DATA_COMPRESSED and EXTENT_NET flags in filefrag if detected.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
---
 lib/ext2fs/fiemap.h |   17 +++++++++++++----
 misc/filefrag.c     |    7 ++++++-
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/lib/ext2fs/fiemap.h b/lib/ext2fs/fiemap.h
index 895cd0b..30103e2 100644
--- a/lib/ext2fs/fiemap.h
+++ b/lib/ext2fs/fiemap.h
@@ -17,15 +17,17 @@ struct fiemap_extent {
 	__u64 fe_physical; /* physical offset in bytes for the start
 			    * of the extent from the beginning of the disk */
 	__u64 fe_length;   /* length in bytes for this extent */
-	__u64 fe_reserved64[2];
+	__u64 fe_phys_length; /* physical length in bytes for this extent,
+			       * undefined if DATA_COMPRESSED not set */
+	__u64 fe_reserved64;
 	__u32 fe_flags;    /* FIEMAP_EXTENT_* flags for this extent */
 	__u32 fe_reserved[3];
 };
 
 struct fiemap {
-	__u64 fm_start;		/* logical offset (inclusive) at
+	__u64 fm_start;		/* logical offset in bytes (inclusive) at
 				 * which to start mapping (in) */
-	__u64 fm_length;	/* logical length of mapping which
+	__u64 fm_length;	/* logical length in bytes of mapping which
 				 * userspace wants (in) */
 	__u32 fm_flags;		/* FIEMAP_FLAG_* flags for request (in/out) */
 	__u32 fm_mapped_extents;/* number of extents that were mapped (out) */
@@ -51,8 +53,13 @@ struct fiemap {
 						    * Sets EXTENT_UNKNOWN. */
 #define FIEMAP_EXTENT_ENCODED		0x00000008 /* Data can not be read
 						    * while fs is unmounted */
+#define FIEMAP_EXTENT_PHYS_LENGTH	0x00000010 /* Physical length of extent
+						    * in fe_phys_length valid */
+#define FIEMAP_EXTENT_DATA_COMPRESSED	0x00000040 /* Data is compressed by fs.
+						    * Sets EXTENT_ENCODED and
+						    * PHYS_LENGTH. */
 #define FIEMAP_EXTENT_DATA_ENCRYPTED	0x00000080 /* Data is encrypted by fs.
-						    * Sets EXTENT_NO_BYPASS. */
+						    * Sets EXTENT_ENCODED. */
 #define FIEMAP_EXTENT_NOT_ALIGNED	0x00000100 /* Extent offsets may not be
 						    * block aligned. */
 #define FIEMAP_EXTENT_DATA_INLINE	0x00000200 /* Data mixed with metadata.
@@ -66,5 +73,7 @@ struct fiemap {
 						    * merged for efficiency. */
 #define FIEMAP_EXTENT_SHARED		0x00002000 /* Space shared with other
 						    * files. */
+#define FIEMAP_EXTENT_NET		0x80000000 /* Data stored remotely.
+						    * Sets EXTENT_ENCODED. */
 
 #endif /* _LINUX_FIEMAP_H */
diff --git a/misc/filefrag.c b/misc/filefrag.c
index d71bf43..7bd100c 100644
--- a/misc/filefrag.c
+++ b/misc/filefrag.c
@@ -164,6 +164,8 @@ static void print_extent_info(struct fiemap_extent *fm_extent, int cur_ex,
 	print_flag(&fe_flags, FIEMAP_EXTENT_UNKNOWN, flags, "unknown_loc,");
 	print_flag(&fe_flags, FIEMAP_EXTENT_DELALLOC, flags, "delalloc,");
 	print_flag(&fe_flags, FIEMAP_EXTENT_ENCODED, flags, "encoded,");
+	print_flag(&fe_flags, FIEMAP_EXTENT_DATA_COMPRESSED, flags,
+								"compressed,");
 	print_flag(&fe_flags, FIEMAP_EXTENT_DATA_ENCRYPTED, flags,"encrypted,");
 	print_flag(&fe_flags, FIEMAP_EXTENT_NOT_ALIGNED, flags, "not_aligned,");
 	print_flag(&fe_flags, FIEMAP_EXTENT_DATA_INLINE, flags, "inline,");
@@ -171,7 +173,10 @@ static void print_extent_info(struct fiemap_extent *fm_extent, int cur_ex,
 	print_flag(&fe_flags, FIEMAP_EXTENT_UNWRITTEN, flags, "unwritten,");
 	print_flag(&fe_flags, FIEMAP_EXTENT_MERGED, flags, "merged,");
 	print_flag(&fe_flags, FIEMAP_EXTENT_SHARED, flags, "shared,");
-	/* print any unknown flags as hex values */
+	print_flag(&fe_flags, FIEMAP_EXTENT_NET, flags, "net,");
+
+	/* Print unknown flags in hex format.  Known flags are already
+	 * printed above and will have their bit cleared from "fe_flags". */
 	for (mask = 1; fe_flags != 0 && mask != 0; mask <<= 1) {
 		char hex[6];
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] filefrag: print out physical extent length if set
  2014-07-30 20:25 [PATCH 1/3] filefrag: minor code fixes and cleanups Andreas Dilger
  2014-07-30 20:25 ` [PATCH 2/3] filefrag: reserve fields and new extent flags Andreas Dilger
@ 2014-07-30 20:25 ` Andreas Dilger
  2014-08-02  2:09 ` [PATCH 1/3] filefrag: minor code fixes and cleanups Theodore Ts'o
  2 siblings, 0 replies; 5+ messages in thread
From: Andreas Dilger @ 2014-07-30 20:25 UTC (permalink / raw)
  To: tytso; +Cc: linux-ext4, David Sterba, Andreas Dilger

Rename fe_length to be fe_logi_length to distinguish it from the
fe_phys_length field.

If FIEMAP_EXTENT_PHYS_LENGTH is set, then get the extent's physical
length from fe_phys_length instead of fe_logi_length, since it may
be different (if FIEMAP_EXTENT_DATA_COMPRESSED is also set).

If FIEMAP_EXTENT_PHYS_LENGTH is unset, then use fe_logi_length for
the extent length, but set fe_phys_length = fe_logi_length to simplify
the rest of the code.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
---
 lib/ext2fs/fiemap.h |    2 +-
 misc/filefrag.c     |   56 ++++++++++++++++++++++++++++++++++++--------------
 2 files changed, 41 insertions(+), 17 deletions(-)

diff --git a/lib/ext2fs/fiemap.h b/lib/ext2fs/fiemap.h
index 30103e2..703f164 100644
--- a/lib/ext2fs/fiemap.h
+++ b/lib/ext2fs/fiemap.h
@@ -16,7 +16,7 @@ struct fiemap_extent {
 			    * the extent from the beginning of the file */
 	__u64 fe_physical; /* physical offset in bytes for the start
 			    * of the extent from the beginning of the disk */
-	__u64 fe_length;   /* length in bytes for this extent */
+	__u64 fe_logi_length; /* logical length in bytes for this extent */
 	__u64 fe_phys_length; /* physical length in bytes for this extent,
 			       * undefined if DATA_COMPRESSED not set */
 	__u64 fe_reserved64;
diff --git a/misc/filefrag.c b/misc/filefrag.c
index 7bd100c..b4913dd 100644
--- a/misc/filefrag.c
+++ b/misc/filefrag.c
@@ -133,10 +133,14 @@ static void print_extent_info(struct fiemap_extent *fm_extent, int cur_ex,
 			      unsigned long long expected, int blk_shift,
 			      ext2fs_struct_stat *st)
 {
-	unsigned long long physical_blk;
-	unsigned long long logical_blk;
-	unsigned long long ext_len;
-	unsigned long long ext_blks;
+	unsigned long long logical_blk;	/* logical starting block of file */
+	unsigned long long logical_len;	/* logical length of extent in blocks */
+	unsigned long long logical_unit;/* logical length to end of extent, may
+					 * not be logical_len-1 if extent isn't
+					 * aligned to requested block size */
+	unsigned long long physical_blk;/* physical starting block in LUN */
+	unsigned long long physical_len;/* physical length of extent in blocks*/
+	unsigned long long physical_unit;/* physical length to end of extent */
 	__u32 fe_flags, mask;
 	char flags[256] = "";
 
@@ -144,13 +148,19 @@ static void print_extent_info(struct fiemap_extent *fm_extent, int cur_ex,
 	if (fm_extent->fe_flags & FIEMAP_EXTENT_DATA_INLINE)
 		blk_shift = 0;
 
-	ext_len = fm_extent->fe_length >> blk_shift;
-	ext_blks = (fm_extent->fe_length - 1) >> blk_shift;
 	logical_blk = fm_extent->fe_logical >> blk_shift;
+	logical_len = fm_extent->fe_logi_length >> blk_shift;
+	logical_unit = (fm_extent->fe_logi_length - 1) >> blk_shift;
 	if (fm_extent->fe_flags & FIEMAP_EXTENT_UNKNOWN) {
 		physical_blk = 0;
+		physical_len = 0;
+		physical_unit = 0;
 	} else {
+		/* FIEMAP_EXTENT_PHYS_LENGTH was checked by caller
+		 * and fixed up fe_phys_length if unset. */
 		physical_blk = fm_extent->fe_physical >> blk_shift;
+		physical_len = fm_extent->fe_phys_length >> blk_shift;
+		physical_unit = (fm_extent->fe_phys_length - 1) >> blk_shift;
 	}
 
 	if (expected)
@@ -164,6 +174,7 @@ static void print_extent_info(struct fiemap_extent *fm_extent, int cur_ex,
 	print_flag(&fe_flags, FIEMAP_EXTENT_UNKNOWN, flags, "unknown_loc,");
 	print_flag(&fe_flags, FIEMAP_EXTENT_DELALLOC, flags, "delalloc,");
 	print_flag(&fe_flags, FIEMAP_EXTENT_ENCODED, flags, "encoded,");
+	print_flag(&fe_flags, FIEMAP_EXTENT_PHYS_LENGTH, flags, "phys_length,");
 	print_flag(&fe_flags, FIEMAP_EXTENT_DATA_COMPRESSED, flags,
 								"compressed,");
 	print_flag(&fe_flags, FIEMAP_EXTENT_DATA_ENCRYPTED, flags,"encrypted,");
@@ -186,7 +197,7 @@ static void print_extent_info(struct fiemap_extent *fm_extent, int cur_ex,
 		print_flag(&fe_flags, mask, flags, hex);
 	}
 
-	if (fm_extent->fe_logical + fm_extent->fe_length >= st->st_size)
+	if (fm_extent->fe_logical + fm_extent->fe_logi_length >= st->st_size)
 		strcat(flags, "eof,");
 
 	/* Remove trailing comma, if any */
@@ -194,10 +205,10 @@ static void print_extent_info(struct fiemap_extent *fm_extent, int cur_ex,
 		flags[strnlen(flags, sizeof(flags)) - 1] = '\0';
 
 	printf(ext_fmt, cur_ex, logical_width, logical_blk,
-	       logical_width, logical_blk + ext_blks,
+	       logical_width, logical_blk + logical_unit,
 	       physical_width, physical_blk,
-	       physical_width, physical_blk + ext_blks,
-	       ext_len, flags);
+	       physical_width, physical_blk + physical_unit,
+	       logical_len, flags);
 }
 
 static int filefrag_fiemap(int fd, int blk_shift, int *num_extents,
@@ -260,18 +271,29 @@ static int filefrag_fiemap(int fd, int blk_shift, int *num_extents,
 				if (!tot_extents)
 					tot_extents = 1;
 			}
+
+			/* If PHYS_LENGTH is set, then the logical and
+			 * physical extent lengths may be different (if
+			 * DATA_COMPRESSED flag is set) and fe_phys_length
+			 * is known to be valid.
+			 * Kernels older than 3.14 did not set fe_phys_length,
+			 * so do that here to simplify the rest of the code. */
+			if (!(fm_ext[i].fe_flags & FIEMAP_EXTENT_PHYS_LENGTH))
+				fm_ext[i].fe_phys_length =
+					fm_ext[i].fe_logi_length;
+
 			if (verbose)
 				print_extent_info(&fm_ext[i], n, expected,
 						  blk_shift, st);
-
-			expected = fm_ext[i].fe_physical + fm_ext[i].fe_length;
+			expected = fm_ext[i].fe_physical +
+				   fm_ext[i].fe_phys_length;
 			if (fm_ext[i].fe_flags & FIEMAP_EXTENT_LAST)
 				last = 1;
 			n++;
 		}
 
 		fiemap->fm_start = (fm_ext[i - 1].fe_logical +
-				    fm_ext[i - 1].fe_length);
+				    fm_ext[i - 1].fe_logi_length);
 	} while (last == 0);
 
 	*num_extents = tot_extents;
@@ -330,13 +352,14 @@ static int filefrag_fibmap(int fd, int blk_shift, int *num_extents,
 		count++;
 		if (force_extent && last_block != 0 &&
 		    (block != last_block + 1 ||
-		     fm_ext.fe_logical + fm_ext.fe_length != logical)) {
+		     fm_ext.fe_logical + fm_ext.fe_logi_length != logical)) {
 			print_extent_info(&fm_ext, *num_extents - 1,
 					  (last_block + 1) * st->st_blksize,
 					  blk_shift, st);
 			fm_ext.fe_logical = logical;
 			fm_ext.fe_physical = block * st->st_blksize;
-			fm_ext.fe_length = 0;
+			fm_ext.fe_logi_length = 0;
+			fm_ext.fe_phys_length = 0;
 			(*num_extents)++;
 		} else if (last_block && (block != last_block + 1)) {
 			if (verbose)
@@ -344,7 +367,8 @@ static int filefrag_fibmap(int fd, int blk_shift, int *num_extents,
 				       "%lu)\n", i, block, last_block + 1);
 			(*num_extents)++;
 		}
-		fm_ext.fe_length += st->st_blksize;
+		fm_ext.fe_logi_length += st->st_blksize;
+		fm_ext.fe_phys_length += st->st_blksize;
 		last_block = block;
 	}
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/3] filefrag: reserve fields and new extent flags
  2014-07-30 20:25 ` [PATCH 2/3] filefrag: reserve fields and new extent flags Andreas Dilger
@ 2014-07-30 20:32   ` Andreas Dilger
  0 siblings, 0 replies; 5+ messages in thread
From: Andreas Dilger @ 2014-07-30 20:32 UTC (permalink / raw)
  To: tytso; +Cc: linux-ext4, David Sterba

[-- Attachment #1: Type: text/plain, Size: 5554 bytes --]


On Jul 30, 2014, at 2:25 PM, Andreas Dilger <adilger@dilger.ca> wrote:

> Reserve the FIEMAP_EXTENT_PHYS_LENGTH flag to indicate that the new
> fe_phys_length field contains valid data.  This is introduced to
> allow different fe_phys_length and fe_logi_length values for
> compressed extents, but it is also valid to set PHYS_LENGTH and set
> fe_phys_length for regular files to simplify userspace codes.  If
> PHYS_LENGTH is not set, then applications should set fe_phys_length
> equal to fe_logi_length, since fe_phys_length is undefined (though
> typically zero).
> 
> Reserve the FIEMAP_EXTENT_DATA_COMPRESSED flag to allow reporting
> extents with physical length different than logical length.  This
> also sets the FIEMAP_EXTENT_ENCODED flag to indicate that the data
> cannot be accessed directly.
> 
> Reserve the FIEMAP_EXTENT_NET flag, which indicates that the data
> is on a network filesystem that does not have local storage devices.
> This also sets FIEMAP_EXTENT_ENCODED flag to indicate the data cannot
> be accessed directly.
> 
> Print out DATA_COMPRESSED and EXTENT_NET flags in filefrag if detected.

This patch series is my first cut at filefrag updates to match David's
proposed changes to handle compressed extents in FIEMAP in the kernel.
See http://comments.gmane.org/gmane.comp.file-systems.btrfs/37312 for
the kernel side of things.

This patch series is not quite identical to what the kernel patches
are implementing, but rather how I think it should be implemented.

Feedback/discussion welcome, but I may not reply for a while.

Cheers, Andreas

> Signed-off-by: Andreas Dilger <adilger@dilger.ca>
> ---
> lib/ext2fs/fiemap.h |   17 +++++++++++++----
> misc/filefrag.c     |    7 ++++++-
> 2 files changed, 19 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/ext2fs/fiemap.h b/lib/ext2fs/fiemap.h
> index 895cd0b..30103e2 100644
> --- a/lib/ext2fs/fiemap.h
> +++ b/lib/ext2fs/fiemap.h
> @@ -17,15 +17,17 @@ struct fiemap_extent {
> 	__u64 fe_physical; /* physical offset in bytes for the start
> 			    * of the extent from the beginning of the disk */
> 	__u64 fe_length;   /* length in bytes for this extent */
> -	__u64 fe_reserved64[2];
> +	__u64 fe_phys_length; /* physical length in bytes for this extent,
> +			       * undefined if DATA_COMPRESSED not set */
> +	__u64 fe_reserved64;
> 	__u32 fe_flags;    /* FIEMAP_EXTENT_* flags for this extent */
> 	__u32 fe_reserved[3];
> };
> 
> struct fiemap {
> -	__u64 fm_start;		/* logical offset (inclusive) at
> +	__u64 fm_start;		/* logical offset in bytes (inclusive) at
> 				 * which to start mapping (in) */
> -	__u64 fm_length;	/* logical length of mapping which
> +	__u64 fm_length;	/* logical length in bytes of mapping which
> 				 * userspace wants (in) */
> 	__u32 fm_flags;		/* FIEMAP_FLAG_* flags for request (in/out) */
> 	__u32 fm_mapped_extents;/* number of extents that were mapped (out) */
> @@ -51,8 +53,13 @@ struct fiemap {
> 						    * Sets EXTENT_UNKNOWN. */
> #define FIEMAP_EXTENT_ENCODED		0x00000008 /* Data can not be read
> 						    * while fs is unmounted */
> +#define FIEMAP_EXTENT_PHYS_LENGTH	0x00000010 /* Physical length of extent
> +						    * in fe_phys_length valid */
> +#define FIEMAP_EXTENT_DATA_COMPRESSED	0x00000040 /* Data is compressed by fs.
> +						    * Sets EXTENT_ENCODED and
> +						    * PHYS_LENGTH. */
> #define FIEMAP_EXTENT_DATA_ENCRYPTED	0x00000080 /* Data is encrypted by fs.
> -						    * Sets EXTENT_NO_BYPASS. */
> +						    * Sets EXTENT_ENCODED. */
> #define FIEMAP_EXTENT_NOT_ALIGNED	0x00000100 /* Extent offsets may not be
> 						    * block aligned. */
> #define FIEMAP_EXTENT_DATA_INLINE	0x00000200 /* Data mixed with metadata.
> @@ -66,5 +73,7 @@ struct fiemap {
> 						    * merged for efficiency. */
> #define FIEMAP_EXTENT_SHARED		0x00002000 /* Space shared with other
> 						    * files. */
> +#define FIEMAP_EXTENT_NET		0x80000000 /* Data stored remotely.
> +						    * Sets EXTENT_ENCODED. */
> 
> #endif /* _LINUX_FIEMAP_H */
> diff --git a/misc/filefrag.c b/misc/filefrag.c
> index d71bf43..7bd100c 100644
> --- a/misc/filefrag.c
> +++ b/misc/filefrag.c
> @@ -164,6 +164,8 @@ static void print_extent_info(struct fiemap_extent *fm_extent, int cur_ex,
> 	print_flag(&fe_flags, FIEMAP_EXTENT_UNKNOWN, flags, "unknown_loc,");
> 	print_flag(&fe_flags, FIEMAP_EXTENT_DELALLOC, flags, "delalloc,");
> 	print_flag(&fe_flags, FIEMAP_EXTENT_ENCODED, flags, "encoded,");
> +	print_flag(&fe_flags, FIEMAP_EXTENT_DATA_COMPRESSED, flags,
> +								"compressed,");
> 	print_flag(&fe_flags, FIEMAP_EXTENT_DATA_ENCRYPTED, flags,"encrypted,");
> 	print_flag(&fe_flags, FIEMAP_EXTENT_NOT_ALIGNED, flags, "not_aligned,");
> 	print_flag(&fe_flags, FIEMAP_EXTENT_DATA_INLINE, flags, "inline,");
> @@ -171,7 +173,10 @@ static void print_extent_info(struct fiemap_extent *fm_extent, int cur_ex,
> 	print_flag(&fe_flags, FIEMAP_EXTENT_UNWRITTEN, flags, "unwritten,");
> 	print_flag(&fe_flags, FIEMAP_EXTENT_MERGED, flags, "merged,");
> 	print_flag(&fe_flags, FIEMAP_EXTENT_SHARED, flags, "shared,");
> -	/* print any unknown flags as hex values */
> +	print_flag(&fe_flags, FIEMAP_EXTENT_NET, flags, "net,");
> +
> +	/* Print unknown flags in hex format.  Known flags are already
> +	 * printed above and will have their bit cleared from "fe_flags". */
> 	for (mask = 1; fe_flags != 0 && mask != 0; mask <<= 1) {
> 		char hex[6];
> 
> -- 
> 1.7.3.4
> 


Cheers, Andreas






[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] filefrag: minor code fixes and cleanups
  2014-07-30 20:25 [PATCH 1/3] filefrag: minor code fixes and cleanups Andreas Dilger
  2014-07-30 20:25 ` [PATCH 2/3] filefrag: reserve fields and new extent flags Andreas Dilger
  2014-07-30 20:25 ` [PATCH 3/3] filefrag: print out physical extent length if set Andreas Dilger
@ 2014-08-02  2:09 ` Theodore Ts'o
  2 siblings, 0 replies; 5+ messages in thread
From: Theodore Ts'o @ 2014-08-02  2:09 UTC (permalink / raw)
  To: Andreas Dilger; +Cc: linux-ext4, David Sterba

On Wed, Jul 30, 2014 at 02:25:49PM -0600, Andreas Dilger wrote:
> Print filefrag_fiemap() error message to stderr instead of stdout.
> 
> Only call ioctl(EXT3_IOC_GETFLAGS) for ext{2,3,4} filesystems to
> decide if the ext2 indirect block allocation heuristic shold be used.
> 
> Properly handle the the force_bmap (-B) option.
> 
> Exit with a positive error number instead of a negative one.
> 
> Signed-off-by: Andreas Dilger <adilger@dilger.ca>

Applied, thanks.

						- Ted

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-08-02  2:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-30 20:25 [PATCH 1/3] filefrag: minor code fixes and cleanups Andreas Dilger
2014-07-30 20:25 ` [PATCH 2/3] filefrag: reserve fields and new extent flags Andreas Dilger
2014-07-30 20:32   ` Andreas Dilger
2014-07-30 20:25 ` [PATCH 3/3] filefrag: print out physical extent length if set Andreas Dilger
2014-08-02  2:09 ` [PATCH 1/3] filefrag: minor code fixes and cleanups Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).