Skip to contentSkip to conversation

xfsprogs: add -p for hole punching to falloc command

RFC PATCH In review Josef Bacik 2 participants 3 messages Nov 12, 2010 – Nov 18, 2010

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 xfsprogs: add -p for hole punching to falloc command

Obviously this is highly dependant upon my current implementation of hole punching via fallocate going in, but this is the support code for falloc to deal with hole punching. This is necessary to run the xfstest I have to make sure the punching stuff is working properly. Thanks,

---
 io/prealloc.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
io/prealloc.c +16 -1
index c8b7df6..4b14da7 100644
@@ -153,12 +153,23 @@ fallocate_f(
 	xfs_flock64_t	segment;
 	int		mode = 0;
 	int		c;
+	const char	*opts;
 
-	while ((c = getopt(argc, argv, "k")) != EOF) {
+#if defined (FALLOC_FL_PUNCH_HOLE)
+	opts = "kp";
+#else
+	opts = "k";
+#endif
+	while ((c = getopt(argc, argv, opts)) != EOF) {
 		switch (c) {
 		case 'k':
 			mode = FALLOC_FL_KEEP_SIZE;
 			break;
+#if defined (FALLOC_FL_PUNCH_HOLE)
+		case 'p':
+			mode = FALLOC_FL_PUNCH_HOLE;
+			break;
+#endif
 		default:
 			command_usage(&falloc_cmd);
 		}
@@ -236,7 +247,11 @@ prealloc_init(void)
 	falloc_cmd.argmin = 2;
 	falloc_cmd.argmax = -1;
 	falloc_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK;
+#if defined (FALLOC_FL_PUNCH_HOLE)
+	falloc_cmd.args = _("[-k] [-p] off len");
+#else
 	falloc_cmd.args = _("[-k] off len");
+#endif
 	falloc_cmd.oneline =
 		_("allocates space associated with part of a file via fallocate");
 
Signature · 6 lines
1.6.6.1

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#1 lore raw
Quoted 40 lines · Josef Bacik

Obviously this is highly dependant upon my current implementation of hole punching via fallocate going in, but this is the support code for falloc to deal with hole punching. This is necessary to run the xfstest I have to make sure the punching stuff is working properly. Thanks,

---
 io/prealloc.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
io/prealloc.c +12 -1
index c8b7df6..4b14da7 100644
@@ -153,12 +153,23 @@ fallocate_f(
 	xfs_flock64_t	segment;
 	int		mode = 0;
 	int		c;
+	const char	*opts;
 
-	while ((c = getopt(argc, argv, "k")) != EOF) {
+#if defined (FALLOC_FL_PUNCH_HOLE)
+	opts = "kp";
+#else
+	opts = "k";
+#endif
+	while ((c = getopt(argc, argv, opts)) != EOF) {
 		switch (c) {
 		case 'k':
 			mode = FALLOC_FL_KEEP_SIZE;
 			break;
+#if defined (FALLOC_FL_PUNCH_HOLE)
+		case 'p':
+			mode = FALLOC_FL_PUNCH_HOLE;
+			break;
+#endif
 		default:
 			command_usage(&falloc_cmd);
 		}

io/prealloc.c prealloc_init(void) · line 256

Quoted 10 lines
io/prealloc.c +4 -0
@@ -236,7 +247,11 @@ prealloc_init(void)
 	falloc_cmd.argmin = 2;
 	falloc_cmd.argmax = -1;
 	falloc_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK;
+#if defined (FALLOC_FL_PUNCH_HOLE)
+	falloc_cmd.args = _("[-k] [-p] off len");
+#else
 	falloc_cmd.args = _("[-k] off len");
+#endif
 	falloc_cmd.oneline =
 		_("allocates space associated with part of a file via fallocate");

I'd prefer that there is a separate command for FALLOC_FL_PUNCH_HOLE rather than a flag that changed the behaviour of the falloc command completely. This is the way we've done resvsp/unresvsp, so I think it makes sense to follow this command structure e.g. falloc/fpunch.

Cheers,

Dave.

Quoted 9 lines
Signature · 7 lines
-- 
1.6.6.1

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#2 lore raw
Quoted 48 lines · Dave Chinner
Quoted 47 lines · Josef Bacik

Obviously this is highly dependant upon my current implementation of hole punching via fallocate going in, but this is the support code for falloc to deal with hole punching. This is necessary to run the xfstest I have to make sure the punching stuff is working properly. Thanks,

---
 io/prealloc.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
io/prealloc.c +15 -1
index c8b7df6..4b14da7 100644
@@ -153,12 +153,23 @@ fallocate_f(
 	xfs_flock64_t	segment;
 	int		mode = 0;
 	int		c;
+	const char	*opts;
 
-	while ((c = getopt(argc, argv, "k")) != EOF) {
+#if defined (FALLOC_FL_PUNCH_HOLE)
+	opts = "kp";
+#else
+	opts = "k";
+#endif
+	while ((c = getopt(argc, argv, opts)) != EOF) {
 		switch (c) {
 		case 'k':
 			mode = FALLOC_FL_KEEP_SIZE;
 			break;
+#if defined (FALLOC_FL_PUNCH_HOLE)
+		case 'p':
+			mode = FALLOC_FL_PUNCH_HOLE;
+			break;
+#endif
 		default:
 			command_usage(&falloc_cmd);
 		}
@@ -236,7 +247,11 @@ prealloc_init(void)
 	falloc_cmd.argmin = 2;
 	falloc_cmd.argmax = -1;
 	falloc_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK;
+#if defined (FALLOC_FL_PUNCH_HOLE)
+	falloc_cmd.args = _("[-k] [-p] off len");
+#else
 	falloc_cmd.args = _("[-k] off len");
Quoted 9 lines

io/prealloc.c prealloc_init(void) · line 256

Quoted 3 lines
io/prealloc.c +1 -0
+#endif
 	falloc_cmd.oneline =
 		_("allocates space associated with part of a file via fallocate");

I'd prefer that there is a separate command for FALLOC_FL_PUNCH_HOLE rather than a flag that changed the behaviour of the falloc command completely. This is the way we've done resvsp/unresvsp, so I think it makes sense to follow this command structure e.g. falloc/fpunch.

Fair enough, I can do that. Thanks,

Josef

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