Skip to contentSkip to conversation

xfs_io: v7 add the lseek() SEEK_DATA/SEEK_HOLE support

PATCH In review Mark Tinguely 3 participants 9 messages Aug 22, 2013 – Aug 23, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs_io: v7 add the lseek() SEEK_DATA/SEEK_HOLE support

Add the lseek SEEK_DATA/SEEK_HOLE support into xfs_io. The result from the lseek() call will be printed to the output. For example:

xfs_io> seek -h 609k
HOLE 630784

---
version 7 or 8 - Eric what number is this?

I think I added all the old Dave and new Eric changes.

Unconditionally compile the feature into xfs_io.

(Too) many comments added. This routine basically is a seek and print loop.

Removed the ending EOF, except where that was the only entry.
No output looked bad.
This print the only entry exception changed the loop/if statements.

Changed error message to perror.

Ran the fine-tune kernel test on the following XFS kernel version:
Linux 3.0 no support.
Linux 3.1 vfs default support.
Linux 3.5 XFS first support.
Linux 3.7 XFS fine-tuned support.

Each version has different output - as expected. Eric you want the output?

 io/Makefile       |    3 
 io/init.c         |    1 
 io/io.h           |    1 
 io/seek.c         |  197 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 man/man8/xfs_io.8 |   35 +++++++++
 5 files changed, 236 insertions(+), 1 deletion(-)
io/Makefile +2 -1
Index: b/io/Makefile
===================================================================
@@ -10,7 +10,8 @@ LSRCFILES = xfs_bmap.sh xfs_freeze.sh xf
 HFILES = init.h io.h
 CFILES = init.c \
 	attr.c bmap.c file.c freeze.c fsync.c getrusage.c imap.c mmap.c \
-	open.c parent.c pread.c prealloc.c pwrite.c shutdown.c truncate.c
+	open.c parent.c pread.c prealloc.c pwrite.c seek.c shutdown.c \
+	truncate.c
 
 LLDLIBS = $(LIBXCMD) $(LIBHANDLE)
 LTDEPENDENCIES = $(LIBXCMD) $(LIBHANDLE)
io/init.c +1 -0
Index: b/io/init.c
===================================================================
@@ -64,6 +64,7 @@ init_commands(void)
 	help_init();
 	imap_init();
 	inject_init();
+	seek_init();
 	madvise_init();
 	mincore_init();
 	mmap_init();
io/io.h +1 -0
Index: b/io/io.h
===================================================================
@@ -105,6 +105,7 @@ extern void		pread_init(void);
 extern void		prealloc_init(void);
 extern void		pwrite_init(void);
 extern void		quit_init(void);
+extern void		seek_init(void);
 extern void		shutdown_init(void);
 extern void		truncate_init(void);
 
io/seek.c new file +197 -0

197 lines not on this page · raw message

man/man8/xfs_io.8 +35 -0
Index: b/man/man8/xfs_io.8
===================================================================
@@ -418,6 +418,41 @@ to read (in bytes)
 .RE
 .PD
 .TP
+.TP
+.BI "seek  \-a | \-d | \-h [ \-r ] offset"
+On platforms that support the
+.BR lseek (2)
+.B SEEK_DATA
+and
+.B SEEK_HOLE
+options, display the offsets of the specified segments.
+.RS 1.0i
+.PD 0
+.TP 0.4i
+.B \-a
+Display both
+.B data
+and
+.B hole
+segments starting at the specified
+.B offset.
+.TP
+.B \-d
+Display the
+.B data
+segment starting at the specified
+.B offset.
+.TP
+.B \-h
+Display the
+.B hole
+segment starting at the specified
+.B offset.
+.TP
+.B \-r
+Recursively display all the specified segments starting at the specified
+.B offset.
+.TP
 
 .SH MEMORY MAPPED I/O COMMANDS
 .TP

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

Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Mark Tinguely

Add the lseek SEEK_DATA/SEEK_HOLE support into xfs_io. The result from the lseek() call will be printed to the output. For example:

xfs_io> seek -h 609k
HOLE 630784

---
version 7 or 8 - Eric what number is this?

Go for 13, for luck!

I think this looks ok, I won't torture you any longer. If there's anything to fix up when it really gets used in earnest we can do it then.

(it crossed my mind that for the "-r" and "-a" invocations it might be good to print out the offset which was sent for each SEEK_* "whence," but *shrug*)

Thanks for all the iterations,

Quoted 12 lines

I think I added all the old Dave and new Eric changes.

Unconditionally compile the feature into xfs_io.

(Too) many comments added. This routine basically is a seek and print loop.

Removed the ending EOF, except where that was the only entry.
No output looked bad.
This print the only entry exception changed the loop/if statements.

Changed error message to perror.

Quoted 7 lines

Ran the fine-tune kernel test on the following XFS kernel version:
Linux 3.0 no support.
Linux 3.1 vfs default support.
Linux 3.5 XFS first support.
Linux 3.7 XFS fine-tuned support.

Each version has different output - as expected. Eric you want the output?

Meh. We can fix it up as needed. I'm a bit shocked that we (the grand Linux "we") didn't just settle on "whatever Solaris did is correct."

Quoted 295 lines
 io/Makefile       |    3 
 io/init.c         |    1 
 io/io.h           |    1 
 io/seek.c         |  197 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 man/man8/xfs_io.8 |   35 +++++++++
 5 files changed, 236 insertions(+), 1 deletion(-)

Index: b/io/Makefile
===================================================================

io/Makefile +2 -1
@@ -10,7 +10,8 @@ LSRCFILES = xfs_bmap.sh xfs_freeze.sh xf
 HFILES = init.h io.h
 CFILES = init.c \
 	attr.c bmap.c file.c freeze.c fsync.c getrusage.c imap.c mmap.c \
-	open.c parent.c pread.c prealloc.c pwrite.c shutdown.c truncate.c
+	open.c parent.c pread.c prealloc.c pwrite.c seek.c shutdown.c \
+	truncate.c
 
 LLDLIBS = $(LIBXCMD) $(LIBHANDLE)
 LTDEPENDENCIES = $(LIBXCMD) $(LIBHANDLE)

Index: b/io/init.c
===================================================================

io/init.c +1 -0
@@ -64,6 +64,7 @@ init_commands(void)
 	help_init();
 	imap_init();
 	inject_init();
+	seek_init();
 	madvise_init();
 	mincore_init();
 	mmap_init();

Index: b/io/io.h
===================================================================

io/io.h +1 -0
@@ -105,6 +105,7 @@ extern void		pread_init(void);
 extern void		prealloc_init(void);
 extern void		pwrite_init(void);
 extern void		quit_init(void);
+extern void		seek_init(void);
 extern void		shutdown_init(void);
 extern void		truncate_init(void);
 

Index: b/io/seek.c
===================================================================

io/seek.c new file +197 -0
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 2013 SGI
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <xfs/xfs.h>
+#include <xfs/command.h>
+#include <xfs/input.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include "init.h"
+#include "io.h"
+
+static cmdinfo_t seek_cmd;
+
+static void
+seek_help(void)
+{
+	printf(_(
+"\n"
+" returns the next hole and/or data offset at or after the requested offset\n"
+"\n"
+" Example:\n"
+" 'seek -d 512'		- offset of data at or following offset 512\n"
+" 'seek -a -r 0'	- offsets of all data and hole in entire file\n"
+"\n"
+" Returns the offset of the next data and/or hole. There is an implied hole\n"
+" at the end of file. If the specified offset is past end of file, or there\n"
+" is no data past the specified offset, EOF is returned.\n"
+" -a	-- return the next data and hole starting at the specified offset.\n"
+" -d	-- return the next data starting at the specified offset.\n"
+" -h	-- return the next hole starting at the specified offset.\n"
+" -r	-- return all remaining type(s) starting at the specified offset.\n"
+"\n"));
+}
+
+#ifndef HAVE_SEEK_DATA
+#define	SEEK_DATA	3	/* seek to the next data */
+#define	SEEK_HOLE	4	/* seek to the next hole */
+#endif
+
+/* values for flag variable */
+#define	SEEK_DFLAG	(1 << 0)
+#define	SEEK_HFLAG	(1 << 1)
+#define	SEEK_RFLAG	(1 << 2)
+
+/* indexes into the seekinfo array */
+#define	DATA		0
+#define	HOLE		1
+
+struct seekinfo {
+	char		*name;		/* display item name */
+	int		seektype;	/* data or hole */
+	int		mask;		/* compared for print and looping */
+} seekinfo[] = {
+		{"DATA", SEEK_DATA, SEEK_DFLAG},
+		{"HOLE", SEEK_HOLE, SEEK_HFLAG}
+};
+
+/* print item type and offset. catch special cases of eof and error */
+void
+seek_output(
+	char	*type,
+	off64_t	offset)
+{
+	if (offset == -1) {
+		if (errno == ENXIO)
+			printf("%s	EOF\n", type);
+		else
+			perror("ERR");
+	} else
+		printf("%s	%lld\n", type, (long long)offset);
+}
+
+static int
+seek_f(
+	int	argc,
+	char	**argv)
+{
+	off64_t		offset, result;
+	size_t		fsblocksize, fssectsize;
+	int		flag;
+	int		current;	/* specify data or hole */
+	int		c;
+
+	flag = 0;
+	init_cvtnum(&fsblocksize, &fssectsize);
+
+	while ((c = getopt(argc, argv, "adhr")) != EOF) {
+		switch (c) {
+		case 'a':
+			flag |= (SEEK_HFLAG | SEEK_DFLAG);
+			break;
+		case 'd':
+			flag |= SEEK_DFLAG;
+			break;
+		case 'h':
+			flag |= SEEK_HFLAG;
+			break;
+		case 'r':
+			flag |= SEEK_RFLAG;
+			break;
+		default:
+			return command_usage(&seek_cmd);
+		}
+	}
+	if (!(flag & (SEEK_DFLAG | SEEK_HFLAG)) || optind != argc - 1)
+		return command_usage(&seek_cmd);
+
+	offset = cvtnum(fsblocksize, fssectsize, argv[optind]);
+	if (offset < 0)
+		return command_usage(&seek_cmd);
+
+	/*
+	 * check to see if the offset is a data or hole entry and
+	 * decide if we want to display that type of entry.
+	 */
+	if (flag & SEEK_HFLAG) {
+		result = lseek64(file->fd, offset, SEEK_HOLE);
+		if ((result == offset) || !(flag & SEEK_DFLAG)) {
+			/*
+			 * this offset is a hole or are only displaying holes.
+			 * if this offset is for data and we are displaying
+			 * data, then we will fall through below to
+			 * initialize the data search.
+			 */
+			offset = result;
+			current = HOLE;
+			goto found_hole;
+		}
+	}
+
+	/* The offset is not a hole, or we are looking just for data */
+	current = DATA;
+	offset = lseek64(file->fd, offset, SEEK_DATA);
+
+found_hole:
+	/*
+	 * At this point we know which type and the offset of the starting
+	 * item. "current" alternates between data / hole entries in
+	 * assending order - this alternation is needed even if only one
+	 * type is to be displayed.
+	 *
+	 * An error or EOF will terminate the display, otherwise "flag"
+	 * determines if there are more items to be displayed.
+	 */
+	for (c = 0; flag; c++) {
+		if (offset == -1) {
+			/* print error or eof if the only entry */
+			if (errno != ENXIO || c == 0 )
+				seek_output(seekinfo[current].name, offset);
+			return 0;	/* stop on error or EOF */
+		}
+
+		seek_output(seekinfo[current].name, offset);
+
+		/*
+		 * When displaying only a single data and/or hole item, mask
+		 * off the item as it is displayed. The loop will end when all
+		 * requested items have been displayed.
+		 */
+		if (!(flag & SEEK_RFLAG))
+			flag &= ~seekinfo[current].mask;
+
+		current ^= 1;		/* alternate between data and hole */
+		offset = lseek64(file->fd, offset, seekinfo[current].seektype);
+	}
+	return 0;
+}
+
+void
+seek_init(void)
+{
+	seek_cmd.name = "seek";
+	seek_cmd.cfunc = seek_f;
+	seek_cmd.argmin = 2;
+	seek_cmd.argmax = 5;
+	seek_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK;
+	seek_cmd.args = _("-a | -d | -h [-r] off");
+	seek_cmd.oneline = _("locate the next data and/or hole");
+	seek_cmd.help = seek_help;
+
+	add_command(&seek_cmd);
+}

Index: b/man/man8/xfs_io.8
===================================================================

man/man8/xfs_io.8 +35 -0
@@ -418,6 +418,41 @@ to read (in bytes)
 .RE
 .PD
 .TP
+.TP
+.BI "seek  \-a | \-d | \-h [ \-r ] offset"
+On platforms that support the
+.BR lseek (2)
+.B SEEK_DATA
+and
+.B SEEK_HOLE
+options, display the offsets of the specified segments.
+.RS 1.0i
+.PD 0
+.TP 0.4i
+.B \-a
+Display both
+.B data
+and
+.B hole
+segments starting at the specified
+.B offset.
+.TP
+.B \-d
+Display the
+.B data
+segment starting at the specified
+.B offset.
+.TP
+.B \-h
+Display the
+.B hole
+segment starting at the specified
+.B offset.
+.TP
+.B \-r
+Recursively display all the specified segments starting at the specified
+.B offset.
+.TP
 
 .SH MEMORY MAPPED I/O COMMANDS
 .TP
Quoted 5 lines

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

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

#2 lore raw
Quoted 18 lines · Eric Sandeen
Quoted 10 lines · Mark Tinguely

Add the lseek SEEK_DATA/SEEK_HOLE support into xfs_io. The result from the lseek() call will be printed to the output. For example:

xfs_io> seek -h 609k
HOLE 630784

---
version 7 or 8 - Eric what number is this?

Go for 13, for luck!

I think this looks ok, I won't torture you any longer. If there's anything to fix up when it really gets used in earnest we can do it then.

Quoted 6 lines

(it crossed my mind that for the "-r" and "-a" invocations it might be good to print out the offset which was sent for each SEEK_* "whence," but *shrug*)

Thanks for all the iterations,

Rich, hold off on commit, I can quickly add the whence. We can see how she sails.

--Mark

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

#3 lore raw
Quoted 24 lines · Mark Tinguely
Quoted 23 lines · Eric Sandeen
Quoted 10 lines · Mark Tinguely

Add the lseek SEEK_DATA/SEEK_HOLE support into xfs_io. The result from the lseek() call will be printed to the output. For example:

xfs_io> seek -h 609k
HOLE 630784

---
version 7 or 8 - Eric what number is this?

Go for 13, for luck!

I think this looks ok, I won't torture you any longer. If there's anything
to fix up when it really gets used in earnest we can do it then.

(it crossed my mind that for the "-r" and "-a" invocations it might be good to print
out the offset which was sent for each SEEK_* "whence," but *shrug*)

Quoted 9 lines
Quoted 3 lines

Thanks for all the iterations,

Rich, hold off on commit, I can quickly add the whence. We can see how she sails.

--Mark

OK

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

#4 lore raw
In reply to Mark Tinguely
Quoted 19 lines · Mark Tinguely
Quoted 18 lines · Eric Sandeen
Quoted 10 lines · Mark Tinguely

Add the lseek SEEK_DATA/SEEK_HOLE support into xfs_io. The result from the lseek() call will be printed to the output. For example:

xfs_io> seek -h 609k
HOLE 630784

---
version 7 or 8 - Eric what number is this?

Go for 13, for luck!

I think this looks ok, I won't torture you any longer. If there's anything to fix up when it really gets used in earnest we can do it then.

Quoted 9 lines
Quoted 6 lines

(it crossed my mind that for the "-r" and "-a" invocations it might be good to print out the offset which was sent for each SEEK_* "whence," but *shrug*)

Thanks for all the iterations,

Rich, hold off on commit, I can quickly add the whence. We can see how she sails.

Was just an idle thought... See if it makes sense I guess...

Thanks,
Eric

Quoted 7 lines

--Mark

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

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

#5 lore raw
Quoted 26 lines · Eric Sandeen
Quoted 24 lines · Mark Tinguely
Quoted 23 lines · Eric Sandeen
Quoted 10 lines · Mark Tinguely

Add the lseek SEEK_DATA/SEEK_HOLE support into xfs_io. The result from the lseek() call will be printed to the output. For example:

xfs_io> seek -h 609k
HOLE 630784

---
version 7 or 8 - Eric what number is this?

Go for 13, for luck!

I think this looks ok, I won't torture you any longer. If there's anything to fix up when it really gets used in earnest we can do it then.

(it crossed my mind that for the "-r" and "-a" invocations it might be good to print out the offset which was sent for each SEEK_* "whence," but *shrug*)

Thanks for all the iterations,

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Rich, hold off on commit, I can quickly add the whence. We can see how she sails.

Was just an idle thought... See if it makes sense I guess...

Thanks,
Eric

without whence:
xfs_io> seek -ar 0

HOLE    0
DATA    528384
HOLE    532480
DATA    819200
HOLE    823296

xfs_io> seek -dh 512k
HOLE 524288
DATA 528384

xfs_io> seek -rd 0
DATA 528384
DATA 819200

============

after with whence:
xfs_io> seek -ar 0:

HOLE    0       0
DATA    0       528384
HOLE    528384  532480
DATA    532480  819200
HOLE    819200  823296

xfs_io> seek -dh 512k:

HOLE 524288
DATA 528384

xfs_io> seek -rd 0

DATA    0       528384
DATA    532480  819200

Seems to make most sense in the case of -rd and -rh

--Mark.

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

#6 lore raw
Quoted 49 lines · Mark Tinguely
Quoted 26 lines · Eric Sandeen
Quoted 24 lines · Mark Tinguely
Quoted 23 lines · Eric Sandeen
Quoted 10 lines · Mark Tinguely

Add the lseek SEEK_DATA/SEEK_HOLE support into xfs_io. The result from the lseek() call will be printed to the output. For example:

xfs_io> seek -h 609k
HOLE 630784

---
version 7 or 8 - Eric what number is this?

Go for 13, for luck!

I think this looks ok, I won't torture you any longer. If there's anything to fix up when it really gets used in earnest we can do it then.

(it crossed my mind that for the "-r" and "-a" invocations it might be good to print out the offset which was sent for each SEEK_* "whence," but *shrug*)

Thanks for all the iterations,

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Rich, hold off on commit, I can quickly add the whence. We can see how she sails.

Was just an idle thought... See if it makes sense I guess...

Thanks,
Eric

without whence:
xfs_io> seek -ar 0

HOLE    0
DATA    528384
HOLE    532480
DATA    819200
HOLE    823296

xfs_io> seek -dh 512k
HOLE 524288
DATA 528384

Quoted 7 lines

xfs_io> seek -rd 0
DATA 528384
DATA 819200

============

after with whence:

Don't hate me, but if you do this, now I think it needs a header ;)

I dunno, what do you think, does it have value in general?

I'd propose this: Merge it as I reviewed it, if you're happy, just printing the results of the seeks.

I was thinking that down the line just for edge case testing we might want to be able to pass in other "whences."

Later enhancements could also add a "-w" option to explicitly print out the passed-in or recursively-selected "whence" if that output is desired for comparisons or sanity checking.

Might be good to stop polishing this for now and do any other enhancements in later patches.

Your call,

-Eric

Quoted 12 lines

xfs_io> seek -ar 0:

HOLE    0       0
DATA    0       528384
HOLE    528384  532480
DATA    532480  819200
HOLE    819200  823296

xfs_io> seek -dh 512k:

HOLE 524288
DATA 528384

Quoted 8 lines

xfs_io> seek -rd 0

DATA    0       528384
DATA    532480  819200

Seems to make most sense in the case of -rd and -rh

--Mark.

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

#7 lore raw
Quoted 54 lines · Eric Sandeen
Quoted 53 lines · Mark Tinguely
Quoted 26 lines · Eric Sandeen
Quoted 24 lines · Mark Tinguely
Quoted 23 lines · Eric Sandeen
Quoted 10 lines · Mark Tinguely

Add the lseek SEEK_DATA/SEEK_HOLE support into xfs_io. The result from the lseek() call will be printed to the output. For example:

xfs_io> seek -h 609k
HOLE 630784

---
version 7 or 8 - Eric what number is this?

Go for 13, for luck!

I think this looks ok, I won't torture you any longer. If there's anything to fix up when it really gets used in earnest we can do it then.

(it crossed my mind that for the "-r" and "-a" invocations it might be good to print out the offset which was sent for each SEEK_* "whence," but *shrug*)

Thanks for all the iterations,

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Rich, hold off on commit, I can quickly add the whence. We can see how she sails.

Was just an idle thought... See if it makes sense I guess...

Thanks,
Eric

without whence:
xfs_io> seek -ar 0

HOLE    0
DATA    528384
HOLE    532480
DATA    819200
HOLE    823296

xfs_io> seek -dh 512k
HOLE 524288
DATA 528384

xfs_io> seek -rd 0
DATA 528384
DATA 819200

Quoted 5 lines
Quoted 3 lines

============

after with whence:

Don't hate me, but if you do this, now I think it needs a header ;)

I was looking at the output and knew you were going to suggest it.

Quoted 2 lines

I dunno, what do you think, does it have value in general?

for -ar no because we are alternating data and hole - the last result is the new input. But for all the holes and all the data it is an improvement.

The question is should we print the starting offset in only the "-r" option or for all cases to be consistent?

I vote to just add the starting offset in all output...

Quoted 2 lines

I'd propose this: Merge it as I reviewed it, if you're happy, just printing the results of the seeks.

Make sense to have it. Let me post the new version. of course the real luck of the irish is with me today, v7 has a bug in it. "wow, I could have had a v8".

Quoted 8 lines

I was thinking that down the line just for edge case testing we might want to be able to pass in other "whences."

Later enhancements could also add a "-w" option to explicitly print out the passed-in or recursively-selected "whence" if that output is desired for comparisons or sanity checking.

Quoted 28 lines

Might be good to stop polishing this for now and do any other enhancements in later patches.

Your call,

-Eric

Quoted 20 lines

xfs_io> seek -ar 0:

HOLE    0       0
DATA    0       528384
HOLE    528384  532480
DATA    532480  819200
HOLE    819200  823296

xfs_io> seek -dh 512k:

HOLE 524288
DATA 528384

xfs_io> seek -rd 0

DATA    0       528384
DATA    532480  819200

Seems to make most sense in the case of -rd and -rh

--Mark.

--Mark.

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

#8 lore raw
Quoted 61 lines · Mark Tinguely
Quoted 54 lines · Eric Sandeen
Quoted 53 lines · Mark Tinguely
Quoted 26 lines · Eric Sandeen
Quoted 24 lines · Mark Tinguely
Quoted 23 lines · Eric Sandeen
Quoted 10 lines · Mark Tinguely

Add the lseek SEEK_DATA/SEEK_HOLE support into xfs_io. The result from the lseek() call will be printed to the output. For example:

xfs_io> seek -h 609k
HOLE 630784

---
version 7 or 8 - Eric what number is this?

Go for 13, for luck!

I think this looks ok, I won't torture you any longer. If there's anything to fix up when it really gets used in earnest we can do it then.

(it crossed my mind that for the "-r" and "-a" invocations it might be good to print out the offset which was sent for each SEEK_* "whence," but *shrug*)

Thanks for all the iterations,

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Rich, hold off on commit, I can quickly add the whence. We can see how she sails.

Was just an idle thought... See if it makes sense I guess...

Thanks,
Eric

without whence:
xfs_io> seek -ar 0

HOLE    0
DATA    528384
HOLE    532480
DATA    819200
HOLE    823296

xfs_io> seek -dh 512k
HOLE 524288
DATA 528384

xfs_io> seek -rd 0
DATA 528384
DATA 819200

Quoted 5 lines
Quoted 3 lines

============

after with whence:

Don't hate me, but if you do this, now I think it needs a header ;)

Quoted 8 lines

I was looking at the output and knew you were going to suggest it.

Quoted 2 lines

I dunno, what do you think, does it have value in general?

for -ar no because we are alternating data and hole - the last result is the new input. But for all the holes and all the data it is an improvement.

The question is should we print the starting offset in only the "-r" option or for all cases to be consistent?

I'd say either make it consistent across all outputs, or add a "-w" to explicitly print the whence, and skip it otherwise.

-Eric

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