xfsprogs: add fallocate command to xfs_io
PATCH 1/1 xfsprogs: add fallocate command to xfs_io
Based on Dave's earlier patch, but now we have an fallocate glibc call... this also adds autoconf magic and a manpage update.
(hopefully not too #ifdef-heavy....)
---
configure.in +1 -0
@@ -66,6 +66,7 @@ AC_HAVE_MINCORE AC_HAVE_SENDFILE AC_HAVE_GETMNTENT AC_HAVE_GETMNTINFO +AC_HAVE_FALLOCATE AC_TYPE_PSINT AC_TYPE_PSUNSIGNED
include/builddefs.in +1 -0
@@ -94,6 +94,7 @@ HAVE_MINCORE = @have_mincore@ HAVE_SENDFILE = @have_sendfile@ HAVE_GETMNTENT = @have_getmntent@ HAVE_GETMNTINFO = @have_getmntinfo@ +HAVE_FALLOCATE = @have_fallocate@ GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall # -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
io/Makefile +4 -0
@@ -59,6 +59,10 @@ ifeq ($(ENABLE_EDITLINE),yes) LLDLIBS += $(LIBEDITLINE) $(LIBTERMCAP) endif +ifeq ($(HAVE_FALLOCATE),yes) +LCFLAGS += -DHAVE_FALLOCATE +endif + default: $(LTCOMMAND) include $(BUILDRULES)
io/prealloc.c +53 -0
75 lines not on this page · raw message
m4/package_libcdev.m4 +15 -0
@@ -98,3 +98,18 @@ AC_DEFUN([AC_HAVE_GETMNTINFO], AC_MSG_RESULT(no)) AC_SUBST(have_getmntinfo) ]) + +# +# Check if we have a fallocate libc call (Linux) +# +AC_DEFUN([AC_HAVE_FALLOCATE], + [ AC_MSG_CHECKING([for fallocate]) + AC_TRY_COMPILE([ +#include <linux/falloc.h> + ], [ + fallocate(0, 0, 0, 0); + ], have_fallocate=yes + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no)) + AC_SUBST(have_fallocate) + ])
man/man8/xfs_io.8 +14 -0
@@ -295,6 +295,20 @@ system call described in the .BR xfsctl (3) manual page. .TP +.BI "falloc [ \-k ]" " offset length" +Allocates reserved, unwritten space for part of a file using the +fallocate routine as described in the +.BR fallocate (3) +manual page. +.RS 1.0i +.PD 0 +.TP 0.4i +.B \-k +will set the FALLOC_FL_KEEP_SIZE flag as described in +.BR fallocate (3). +.PD +.RE +.TP .BI truncate " offset" Truncates the current file at the given offset using .BR ftruncate (2).
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 5 lines · Eric Sandeen
Based on Dave's earlier patch, but now we have an fallocate glibc call... this also adds autoconf magic and a manpage update.
(hopefully not too #ifdef-heavy....)
Looks good to me and seems to work.
io/prealloc.c line 21
Quoted 3 lines
io/prealloc.c +3
-0+#if defined(HAVE_FALLOCATE ) +#include <linux/falloc.h> +#endif
What about just using #ifdef HAVE_FALLOCATE everywhere?
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 8 lines · Christoph Hellwig
Quoted 5 lines · Eric Sandeen
Based on Dave's earlier patch, but now we have an fallocate glibc call... this also adds autoconf magic and a manpage update.
(hopefully not too #ifdef-heavy....)
Looks good to me and seems to work.
Actually that was spoken too fast. On my Debian -testing system it detects fallocate as available because <linux/falloc.h> exists, but the glibc doesn't actually support a falloc(3) yet. So either the detection needs to be improved or we need to use the raw syscall.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 6 lines · Christoph Hellwig
Quoted 5 lines · Christoph Hellwig
Quoted 4 lines · Eric Sandeen
Based on Dave's earlier patch, but now we have an fallocate glibc call... this also adds autoconf magic and a manpage update.
Quoted 7 lines
Quoted 2 lines
Quoted 1 line
(hopefully not too #ifdef-heavy....)
Looks good to me and seems to work.
Actually that was spoken too fast. On my Debian -testing system it detects fallocate as available because <
linux/falloc.h> exists, but the glibc doesn't actually support a falloc(3) yet. So either the detection needs to be improved or we need to use the raw syscall.
Ok, I think I know how to make the detection work better, I'll fix that up.
-Eric
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 7 lines · Eric Sandeen
Quoted 6 lines · Christoph Hellwig
Quoted 5 lines · Christoph Hellwig
Quoted 4 lines · Eric Sandeen
Based on Dave's earlier patch, but now we have an fallocate glibc call... this also adds autoconf magic and a manpage update.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
(hopefully not too #ifdef-heavy....)
Looks good to me and seems to work.
Actually that was spoken too fast. On my Debian -testing system it detects fallocate as available because <
linux/falloc.h> exists, but the glibc doesn't actually support a falloc(3) yet. So either the detection needs to be improved or we need to use the raw syscall.Ok, I think I know how to make the detection work better, I'll fix that up.
oh, hrm. It's already doing what I thought was sufficient but it won't link will it:
(from m4/package_libcdev.m4)
+#
+# Check if we have a fallocate libc call (Linux)
+#
+AC_DEFUN([AC_HAVE_FALLOCATE],
+ [ AC_MSG_CHECKING([for fallocate])
+ AC_TRY_COMPILE([
+#include <linux/falloc.h>
+ ], [
+ fallocate(0, 0, 0, 0);
+ ], have_fallocate=yes
+ AC_MSG_RESULT(yes),
+ AC_MSG_RESULT(no))
+ AC_SUBST(have_fallocate)
+ ])
Instead of above does this work better?
(just change AC_TRY_COMPILE to AC_TRY_LINK)
AC_DEFUN([AC_HAVE_FALLOCATE],
[ AC_MSG_CHECKING([for fallocate])
AC_TRY_LINK([
#include <linux/falloc.h>
], [
fallocate(0, 0, 0, 0);
], have_fallocate=yes
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))
AC_SUBST(have_fallocate)])
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 3 lines · Eric Sandeen
Instead of above does this work better?
(just change
AC_TRY_COMPILEtoAC_TRY_LINK)
Yes, that correctly detects fallocate as not present for me and thus gives a working fallocate.
Quoted 7 lines
AC_DEFUN([AC_HAVE_FALLOCATE],
[AC_MSG_CHECKING([for fallocate])AC_TRY_LINK([ #include <linux/falloc.h> ], [ fallocate(0, 0, 0, 0);
Why do you nee to include <linux/falloc.h> here anyway? You don't use any of the constants, and the fallocate libc call must be in another headers, so it obviously compiles even without a defintion for it.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 15 lines · Christoph Hellwig
Quoted 3 lines · Eric Sandeen
Instead of above does this work better?
(just change
AC_TRY_COMPILEtoAC_TRY_LINK)Yes, that correctly detects fallocate as not present for me and thus gives a working fallocate.
Quoted 6 lines
AC_DEFUN([AC_HAVE_FALLOCATE],
[AC_MSG_CHECKING([for fallocate])AC_TRY_LINK([ #include <linux/falloc.h> ], [ fallocate(0, 0, 0, 0);
Quoted 3 lines
Why do you nee to include <
linux/falloc.h> here anyway? You don't use any of the constants, and the fallocate libc call must be in another headers, so it obviously compiles even without a defintion for it.
Well, the actual patch includes it for FALLOC_FL_KEEP_SIZE so it'd be better to detect it at config time and if not there fail?
Or we could #ifndef and have a local define ...
-Eric
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs