From: Jan Kara <jack@suse.cz>
To: xfs@oss.sgi.com
Cc: linux-ext4@vger.kernel.org, Jan Kara <jack@suse.cz>
Subject: [PATCH 3/3] 285: Test offsets over 4GB
Date: Thu, 30 May 2013 14:45:39 +0200 [thread overview]
Message-ID: <1369917939-22660-3-git-send-email-jack@suse.cz> (raw)
In-Reply-To: <1369917939-22660-1-git-send-email-jack@suse.cz>
Test whether SEEK_HOLE and SEEK_DATA works correctly with offsets over
4GB.
Signed-off-by: Jan Kara <jack@suse.cz>
---
src/seek_sanity_test.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/src/seek_sanity_test.c b/src/seek_sanity_test.c
index 7d5868b..55e7ed6 100644
--- a/src/seek_sanity_test.c
+++ b/src/seek_sanity_test.c
@@ -18,6 +18,7 @@
*/
#define _XOPEN_SOURCE 500
+#define _FILE_OFFSET_BITS 64
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/vfs.h>
@@ -191,6 +192,42 @@ static int do_lseek(int testnum, int subtest, int fd, int filsz, int origin,
return ret;
}
+/* test a huge file to check for 4G overflows */
+static int test10(int fd, int testnum)
+{
+ char *buf = NULL;
+ int bufsz = alloc_size;
+ off_t filsz = 8ULL << 30; /* 8G */
+ off_t off = filsz - 2*bufsz;
+ int ret = -1;
+
+ buf = do_malloc(bufsz);
+ if (!buf)
+ goto out;
+ memset(buf, 'a', bufsz);
+
+ ret = do_pwrite(fd, buf, bufsz, 0);
+ if (ret)
+ goto out;
+ ret = do_pwrite(fd, buf, bufsz, off);
+ if (ret)
+ goto out;
+
+ /* offset at the beginning */
+ ret += do_lseek(testnum, 1, fd, filsz, SEEK_HOLE, 0, bufsz);
+ ret += do_lseek(testnum, 2, fd, filsz, SEEK_HOLE, 1, bufsz);
+ ret += do_lseek(testnum, 3, fd, filsz, SEEK_DATA, 0, 0);
+ ret += do_lseek(testnum, 4, fd, filsz, SEEK_DATA, 1, 1);
+
+ /* offset around eof */
+ ret += do_lseek(testnum, 5, fd, filsz, SEEK_HOLE, off, off + bufsz);
+ ret += do_lseek(testnum, 6, fd, filsz, SEEK_DATA, off, off);
+ ret += do_lseek(testnum, 7, fd, filsz, SEEK_DATA, off + 1, off + 1);
+
+out:
+ do_free(buf);
+ return ret;
+}
/*
* test file with unwritten extents, have both dirty and
* writeback pages in page cache.
@@ -577,6 +614,7 @@ struct testrec seek_tests[] = {
{ 7, test07, "Test file with unwritten extents, only have dirty pages" },
{ 8, test08, "Test file with unwritten extents, only have unwritten pages" },
{ 9, test09, "Test file with unwritten extents, have both dirty && unwritten pages" },
+ { 10, test10, "Test a huge file" },
};
static int run_test(struct testrec *tr)
--
1.8.1.4
next prev parent reply other threads:[~2013-05-30 12:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-30 12:45 [PATCH 1/3] 285: Fix test for ext4 in some configurations Jan Kara
2013-05-30 12:45 ` [PATCH 2/3] 285: Fix file syncing Jan Kara
2013-05-30 13:47 ` Eric Sandeen
2013-05-30 19:57 ` Jan Kara
2013-05-30 12:45 ` Jan Kara [this message]
2013-05-30 13:48 ` [PATCH 3/3] 285: Test offsets over 4GB Eric Sandeen
2013-05-30 20:01 ` Jan Kara
2013-05-30 20:05 ` Eric Sandeen
2013-05-30 20:49 ` Jan Kara
2013-05-30 22:34 ` Dave Chinner
2013-05-31 8:22 ` Jan Kara
2013-05-30 13:45 ` [PATCH 1/3] 285: Fix test for ext4 in some configurations Eric Sandeen
2013-05-30 22:30 ` Dave Chinner
2013-05-31 8:10 ` Jan Kara
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=1369917939-22660-3-git-send-email-jack@suse.cz \
--to=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).