public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Tao Ma <tao.ma@oracle.com>
To: xfs@oss.sgi.com
Cc: Eric Sandeen <sandeen@redhat.com>, Christoph Hellwig <hch@lst.de>,
	Tao Ma <tao.ma@oracle.com>, Alex Elder <aelder@sgi.com>
Subject: [PATCH] xfstests: Add query fiemap count test.
Date: Wed, 28 Apr 2010 14:50:50 +0800	[thread overview]
Message-ID: <1272437450-4654-1-git-send-email-tao.ma@oracle.com> (raw)
In-Reply-To: <20100428015035.GC9783@dastard>

According to Documentation/filesystems/fiemap.txt, If fm_extent_count
is zero, then the fm_extents[] array is ignored (no extents will be
returned), and the fm_mapped_extents count will hold the number of
extents needed.

This is broken by commit 97db39a1f6f69e906e98118392400de5217aa33a.
So add this test case in fiemap tester to avoid future regression.

Cc: Dave Chinner <david@fromorbit.com>
Cc: Eric Sandeen <sandeen@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Alex Elder <aelder@sgi.com>
Signed-off-by: Tao Ma <tao.ma@oracle.com>
---
 src/fiemap-tester.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/src/fiemap-tester.c b/src/fiemap-tester.c
index 8be7ddf..9d57a7e 100644
--- a/src/fiemap-tester.c
+++ b/src/fiemap-tester.c
@@ -406,6 +406,20 @@ check_hole(struct fiemap *fiemap, int fd, __u64 logical_offset, int blocksize)
 	return 0;
 }
 
+static int query_fiemap_count(int fd, int blocks, int blocksize)
+{
+	struct fiemap fiemap = { 0, };
+
+	fiemap.fm_length = blocks * blocksize;
+
+	if (ioctl(fd, FS_IOC_FIEMAP, (unsigned long)&fiemap) < 0) {
+		perror("FIEMAP query ioctl failed");
+		return -1;
+	}
+
+	return 0;
+}
+
 static int
 compare_fiemap_and_map(int fd, char *map, int blocks, int blocksize)
 {
@@ -415,6 +429,9 @@ compare_fiemap_and_map(int fd, char *map, int blocks, int blocksize)
 	__u64 map_start, map_length;
 	int i, c;
 
+	if (query_fiemap_count(fd, blocks, blocksize) < 0)
+		return -1;
+
 	blocks_to_map = (random() % blocks) + 1;
 	fiebuf = malloc(sizeof(struct fiemap) +
 			(blocks_to_map * sizeof(struct fiemap_extent)));
-- 
1.6.3.3.334.g916e1.dirty

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2010-04-28  6:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-27  6:17 [PATCH] XFS: Let the broken fiemap work in query mode Tao Ma
2010-04-28  1:50 ` Dave Chinner
2010-04-28  2:00   ` Tao Ma
2010-04-28  2:30     ` Dave Chinner
2010-04-28  3:00       ` [PATCH v2] " Tao Ma
2010-04-28 11:33         ` Christoph Hellwig
2010-04-28 14:39           ` [PATCH v3] " Tao Ma
2010-04-28  6:50   ` Tao Ma [this message]
2010-04-29  5:35     ` [PATCH] xfstests: Add query fiemap count test Dave Chinner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1272437450-4654-1-git-send-email-tao.ma@oracle.com \
    --to=tao.ma@oracle.com \
    --cc=aelder@sgi.com \
    --cc=hch@lst.de \
    --cc=sandeen@redhat.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox