Skip to contentSkip to conversation

Xfsprogs: add fiemap command to xfs_io V2

PATCH New Josef Bacik 1 participant 1 message Nov 19, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Xfsprogs: add fiemap command to xfs_io V2

When trying to add a test for hole punching I noticed that the "bmap" command only works on XFS, which makes testing hole punching on other fs's kind of difficult. To fix this I've added an fiemap command that works almost exactly like bmap. It is formatted similarly and takes similar flags, the only thing thats different is obviously it doesn't spit out AG info and it doesn't make finding prealloc space optional. This is my first foray into all of this stuff so a good hard look would be appreciated. I tested it with a few different files to make sure bmap and fiemap both looked the same. Thanks,

---
V1->V2:
-various formatting problems
-loop calling fiemap with a max of 32 extents at a time

 configure.in          |    1 +
 include/builddefs.in  |    1 +
 io/Makefile           |    7 +
 io/fiemap.c           |  347 +++++++++++++++++++++++++++++++++++++++++++++++++
 io/init.c             |    1 +
 io/io.h               |    6 +
 m4/package_libcdev.m4 |    8 +
 7 files changed, 371 insertions(+), 0 deletions(-)
 create mode 100644 io/fiemap.c
configure.in +1 -0
index 30907de..16441ce 100644
@@ -103,6 +103,7 @@ AC_HAVE_SENDFILE
 AC_HAVE_GETMNTENT
 AC_HAVE_GETMNTINFO
 AC_HAVE_FALLOCATE
+AC_HAVE_FIEMAP
 AC_HAVE_BLKID_TOPO($enable_blkid)
 
 AC_TYPE_PSINT
include/builddefs.in +1 -0
index 93d1e67..f895ed9 100644
@@ -98,6 +98,7 @@ HAVE_SENDFILE = @have_sendfile@
 HAVE_GETMNTENT = @have_getmntent@
 HAVE_GETMNTINFO = @have_getmntinfo@
 HAVE_FALLOCATE = @have_fallocate@
+HAVE_FIEMAP = @have_fiemap@
 
 GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall 
 #	   -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
io/Makefile +7 -0
index fc98166..9d79dca 100644
@@ -44,6 +44,13 @@ else
 LSRCFILES += sendfile.c
 endif
 
+ifeq ($(HAVE_FIEMAP),yes)
+CFILES += fiemap.c
+LCFLAGS += -DHAVE_FIEMAP
+else
+LSRCFILES += fiemap.c
+endif
+
 ifeq ($(PKG_PLATFORM),irix)
 LSRCFILES += inject.c resblks.c
 else
io/fiemap.c new file +347 -0

347 lines not on this page · raw message

io/init.c +1 -0
index f8fc25d..a166ad1 100644
@@ -71,6 +71,7 @@ init_commands(void)
 	parent_init();
 	pread_init();
 	prealloc_init();
+	fiemap_init();
 	pwrite_init();
 	quit_init();
 	resblks_init();
io/io.h +6 -0
index 630897d..2923362 100644
@@ -135,3 +135,9 @@ extern void		mincore_init(void);
 #else
 #define mincore_init()	do { } while (0)
 #endif
+
+#ifdef HAVE_FIEMAP
+extern void		fiemap_init(void);
+#else
+#define fiemap_init()	do { } while (0)
+#endif
m4/package_libcdev.m4 +8 -0
index 1c1859d..8192181 100644
@@ -116,3 +116,11 @@ AC_DEFUN([AC_HAVE_FALLOCATE],
        AC_MSG_RESULT(no))
     AC_SUBST(have_fallocate)
   ])
+
+#
+# Check if we have the fiemap ioctl (Linux)
+#
+AC_DEFUN([AC_HAVE_FIEMAP],
+  [ AC_CHECK_HEADERS([linux/fiemap.h], [ have_fiemap=yes ], [ have_fiemap=no ])
+    AC_SUBST(have_fiemap)
+  ])
Signature · 6 lines
1.6.6.1

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs