xfs
[Top] [All Lists]

[PATCH 3/4] xfstests: check llseek(2) SEEK_DATA/HOLE and unwritten exten

To: xfs@xxxxxxxxxxx, linux-ext4@xxxxxxxxxxxxxxx
Subject: [PATCH 3/4] xfstests: check llseek(2) SEEK_DATA/HOLE and unwritten extent preallocation in 285
From: Zheng Liu <gnehzuil.liu@xxxxxxxxx>
Date: Mon, 28 Jan 2013 15:32:50 +0800
Cc: Zheng Liu <wenqing.lz@xxxxxxxxxx>, "Theodore Ts'o" <tytso@xxxxxxx>, Dave Chinner <david@xxxxxxxxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=HeUGESSVj6wWNYyUl9PYmYWUdidcQrSADNTdwiXmCkk=; b=ATXutGHYvoOBCUktgrmMP89YqyYK2ue2t2wFOo6kX6aHqi+gRvXbTyLLvyYY8sZZi6 iTtOvk8binlCca2coix6Db4ssvmI65J9q4yBLemYgqZ4FQ9G9i6TYRS9YMZMFmOL8U0B ITTMCX37WjXbSiV4WGCqP2jMDiV4ZE2DeXgA8sR84NjnD+xEiEm8rUSyKvqOppTotonW vu/aXa4O1Q8gLcivzBaVBsMDnw4B47yftvsNhvl4diJqJShjlDGRprBfBMJqMLsRVXmQ X2EzFjwSNflmQoTL4sBuWRO1e0GBr/gHqcRqbEf4VaDpiCvpsJ/gfe61sspAoeLzHJwt tvnQ==
In-reply-to: <1359358371-21411-1-git-send-email-wenqing.lz@xxxxxxxxxx>
References: <1359358371-21411-1-git-send-email-wenqing.lz@xxxxxxxxxx>
From: Zheng Liu <wenqing.lz@xxxxxxxxxx>

In 285 it has its own check for seek data/hole support.  This commit
turns into an equivalent _require_seek_data_hole.

Meanwhile in 285 it doesn't check unwritten extent preallocation.  Now
ext4 file system has supported seek data/hole for a file w/o unwritten
extent.  Thus, in 285, it needs to call the _require_xfs_io_falloc to
check unwritten extent prealloction.

Signed-off-by: Zheng Liu <wenqing.lz@xxxxxxxxxx>
Cc: "Theodore Ts'o" <tytso@xxxxxxx>
Cc: Dave Chinner <david@xxxxxxxxxxxxx>
---
 285                    |  7 +++++--
 common.rc              | 12 ++++++++++++
 src/seek_sanity_test.c | 18 +++++++++++++-----
 3 files changed, 30 insertions(+), 7 deletions(-)
 mode change 100644 => 100755 285

diff --git a/285 b/285
old mode 100644
new mode 100755
index a18fc71..6224673
--- a/285
+++ b/285
@@ -1,7 +1,7 @@
 #! /bin/bash
 # FS QA Test No. 285
 #
-# SEEK_DATA/SEEK_HOLE sanity tests.
+# SEEK_DATA/SEEK_HOLE sanity tests w/ unwritten extent.
 #
 # Improved by Jeff.liu@xxxxxxxxxx
 # Creater: josef@xxxxxxxxxx
@@ -41,9 +41,12 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 _supported_fs generic
 _supported_os Linux
 
+_require_seek_data_hole
+_require_xfs_io_falloc
+
 BASE_TEST_FILE=$TEST_DIR/seek_sanity_testfile
 
-[ -x $here/src/seek_sanity_test ] || _notrun "seek_sanitfy_tester not built"
+[ -x $here/src/seek_sanity_test ] || _notrun "seek_sanity_tester not built"
 
 _cleanup()
 {
diff --git a/common.rc b/common.rc
index 2e8581e..35a5f52 100644
--- a/common.rc
+++ b/common.rc
@@ -1049,6 +1049,18 @@ _require_sparse_files()
     esac
 }
 
+#
+# Check if the filesystem supports seek_data/hole.
+#
+_require_seek_data_hole()
+{
+       testfile=$TEST_DIR/$$.seek
+       testseek=`$here/src/seek_sanity_test -t $testfile 2>&1`
+       rm -f $testfile 2>&1 > /dev/null
+       echo $testseek | grep -q "Kernel does not support" && \
+               _notrun "File system does not support llseek(2) SEEK_DATA/HOLE"
+}
+
 # check that a FS on a device is mounted
 # if so, return mount point
 #
diff --git a/src/seek_sanity_test.c b/src/seek_sanity_test.c
index 3897f02..b1ef006 100644
--- a/src/seek_sanity_test.c
+++ b/src/seek_sanity_test.c
@@ -660,17 +660,25 @@ int main(int argc, char **argv)
 {
        int ret = -1;
        int i = 0;
+       int opt;
+       int check_support = 0;
        int numtests = sizeof(seek_tests) / sizeof(struct testrec);
 
-       if (argc != 2) {
-               fprintf(stdout, "Usage: %s base_file_path\n", argv[0]);
-               return ret;
+       while ((opt = getopt(argc, argv, "t")) != -1) {
+               switch (opt) {
+               case 't':
+                       check_support++;
+                       break;
+               default:
+                       fprintf(stdout, "Usage: %s [-t] base_file_path\n", 
argv[0]);
+                       return ret;
+               }
        }
 
-       base_file_path = (char *)strdup(argv[1]);
+       base_file_path = (char *)strdup(argv[optind]);
 
        ret = test_basic_support();
-       if (ret)
+       if (ret || check_support)
                goto out;
 
        for (i = 0; i < numtests; ++i) {
-- 
1.7.12.rc2.18.g61b472e

<Prev in Thread] Current Thread [Next in Thread>