From patchwork Tue Feb 26 14:09:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10830301 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 828E013B5 for ; Tue, 26 Feb 2019 14:09:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DCAB2AC6A for ; Tue, 26 Feb 2019 14:09:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C9022AE2B; Tue, 26 Feb 2019 14:09:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 026952AC6A for ; Tue, 26 Feb 2019 14:09:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726547AbfBZOJN (ORCPT ); Tue, 26 Feb 2019 09:09:13 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:37943 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726020AbfBZOJN (ORCPT ); Tue, 26 Feb 2019 09:09:13 -0500 Received: by mail-wm1-f67.google.com with SMTP id v26so2390295wmh.3; Tue, 26 Feb 2019 06:09:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=fze605TjWJGBwvvZ8dLki8CksOvK2Lut9ulWz/B7j4Q=; b=jROqHXJZeWdu8P+qu5aIDD47ZhajoS9SGQthWmr7LsYeoYCkzpS2FFrt4fV29+PREo u6EZdVOQ+VkH+9p2qVKW/5y2ZOPy1QqLcCa8p/2TJEQT7ZHGOsdY2A+5YqNdE1PRpasq E9wvHjg8KkWDIXbHXqTrnWE56/WFdhga/vdlt9lPJqDMyIxsKWSqhSD8YyGBZa0HA2x7 Er0aiknEOiYJby3P6P902QAong2eqQs3HjqFkDVs/QKQASVt4FO6i3FlUkvRgdu0Be+C 8ybCagZ6yDFHo1IaW24XbKLqzTuf4yDWKkG/Xl3HfM5VkC/nngLP4rtMHXoCPna8MrjB OsYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=fze605TjWJGBwvvZ8dLki8CksOvK2Lut9ulWz/B7j4Q=; b=tKE7hH88gRIQ5yTQhG/X+6rDRYQyiKO4M2KGlKA9Zd/2JCkGyGl5MXi464+JFPjtSa qnGHpCiNNlFxgsojK53xp7O61Vx6xgLRler4gSStvIVSosUQUsANXB5X/YTMhmeVceQO WmmJgNSOusO7raDV0wkia9gn/eCMEp9dfEuVOIw44abOya8nSVQgCm4u2gREGg3GOouj GyCavmqgB1hB6xXKWWztuVMoFTPihIIfq/HCrcN4uqmnPYxxJMKqZuzdX6KkU2X4Yjf8 MWhKkFsOOAR7EMEuPA/TQHYwMPTrMlXTVDIH1Ypyc/V1P1Q43kiGZ9Hxn6NpopI0ioYK lvjw== X-Gm-Message-State: AHQUAuYdajln5P0OxLWf9lE1JJnrGsthfw0En/DortIsWSXB8DjxkELr Pc9jzJWfLbyvKN0yYdikVGM= X-Google-Smtp-Source: AHgI3IYZBk2AMy6UTDr8x+Jn7PhcnXoRA/pvkhsV4gI10GqM/+T/Mm899z5RwGYrpD5+ruTIJuBbyg== X-Received: by 2002:a1c:9c02:: with SMTP id f2mr2705007wme.91.1551190150672; Tue, 26 Feb 2019 06:09:10 -0800 (PST) Received: from amir-VirtualBox.ctera.local (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id 93sm40434831wrh.15.2019.02.26.06.09.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Feb 2019 06:09:09 -0800 (PST) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , Eddie Horng , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH 1/2] generic/{436,445}: check falloc support Date: Tue, 26 Feb 2019 16:09:01 +0200 Message-Id: <20190226140902.32219-1-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The sanity test case in those tests (i.e. 13..17) are all skipped in fs with no falloc support, but the tests are reported to pass. For example, from 445.full: File system supports the default behavior. File system does not support fallocate. Allocation size: 4096 17. Test file with unwritten extents, data-hole-data inside page Test skipped as fs doesn't support unwritten extents. Explicitly check for falloc support before running those tests so they would be properly reported as skipped. Signed-off-by: Amir Goldstein --- tests/generic/436 | 2 ++ tests/generic/445 | 2 ++ tests/generic/group | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/generic/436 b/tests/generic/436 index 3ed22c96..a3ef70e5 100755 --- a/tests/generic/436 +++ b/tests/generic/436 @@ -24,6 +24,8 @@ _supported_os Linux _require_test _require_seek_data_hole +# All the seek sanity test cases here do falloc +_require_xfs_io_command "falloc" BASE_TEST_FILE=$TEST_DIR/seek_sanity_testfile diff --git a/tests/generic/445 b/tests/generic/445 index e697cca0..694913ae 100755 --- a/tests/generic/445 +++ b/tests/generic/445 @@ -24,6 +24,8 @@ _supported_os Linux _require_test _require_seek_data_hole +# All the seek sanity test cases here do falloc +_require_xfs_io_command "falloc" BASE_TEST_FILE=$TEST_DIR/seek_sanity_testfile diff --git a/tests/generic/group b/tests/generic/group index 31011ac8..15227b67 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -438,7 +438,7 @@ 433 auto quick copy 434 auto quick copy 435 auto encrypt -436 auto quick rw seek +436 auto quick rw seek prealloc 437 auto quick dax 438 auto 439 auto quick punch @@ -447,7 +447,7 @@ 442 blockdev 443 auto quick rw 444 auto quick acl -445 auto quick rw seek +445 auto quick rw seek prealloc 446 auto quick rw punch 447 auto clone 448 auto quick rw seek From patchwork Tue Feb 26 14:09:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10830303 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A66CC13B5 for ; Tue, 26 Feb 2019 14:09:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 909062AC6A for ; Tue, 26 Feb 2019 14:09:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84CBE2AE2B; Tue, 26 Feb 2019 14:09:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E84C12AC6A for ; Tue, 26 Feb 2019 14:09:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726602AbfBZOJO (ORCPT ); Tue, 26 Feb 2019 09:09:14 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:37798 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726099AbfBZOJO (ORCPT ); Tue, 26 Feb 2019 09:09:14 -0500 Received: by mail-wr1-f66.google.com with SMTP id w6so10847196wrs.4; Tue, 26 Feb 2019 06:09:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=L6b7dJE/kgCHejHRyU9JJEEYSfekLaHpbDLPapjCMA0=; b=SBXxRJFIpklxlQtr5+wb2K//1Sq9KcnVWPdRr+nUSbEu1kXWXon7RG/IShWyYOX2dB Lym0OZ9cZYRlSWOGQV8dtMq3CwpfJsQBXoIQH6OqZ1GBtDxqnr4KUPstmRG+RrwDWSWJ rujkRQ63cS+zLGG8h6rY0L2MIAJ7phGfewJWRiRDutER50eh+8dRchdd593+UQEw0AP7 subdj87uQSFir8H9Mg9nYJgd+/Ibd8OK5clj4gzFTxuWKNANkm3QE1HuiSnFGr/JJrBT TeU4Adlt8+EK9Ux4z9razStsJhJ39Gfv+g0arp0Cp1flfWHO5ihGwscYkwAsW0h0A9tu FCrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=L6b7dJE/kgCHejHRyU9JJEEYSfekLaHpbDLPapjCMA0=; b=Y7nJiKV8idCs0LSrOOdMixCZ8xItOch5kK66n297s73ZYCRzxMrd9fW7sb2ATx8sFM tvefQl12YWojzr3JDLJ08mZ0quPBhs5lHaNNr6JXnSIA6P0qquWd6Sb3Xlny8BRa/tsq N1s9uQeDmFvJ9yZ83jZko1nZvXjXrC1ISvoCNV1uaJoyktxGZP9OKmZW0AujLuj5E1dw dLFa8D4JQgsBj/TU3x6liGaV84e+ZhL9sAWy1rT+LTFw2YAWyr/lIfWH5K0eKDeDMNcE eGVyU7oqw7Pu0BlaLFbK/M8rWoJ9Hk75/4z6fizHCs1pmHThO9RfDIAWQPg5hTPO1JYY marg== X-Gm-Message-State: AHQUAubylRxjZ0P0sUsT6xFZTJBTrkPrki8AUbQ7/z62Neev8r+IjwD1 QREnx3KeR4q8XVQkq2hIo+g= X-Google-Smtp-Source: AHgI3IYK7fxEqnn+jtduSMJ/epO2HknNKQ21xmM4d00G4m8wzJUzheRB4stkq1lAPyCgaB6MUBFF7A== X-Received: by 2002:adf:fdcd:: with SMTP id i13mr15797415wrs.212.1551190152012; Tue, 26 Feb 2019 06:09:12 -0800 (PST) Received: from amir-VirtualBox.ctera.local (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id 93sm40434831wrh.15.2019.02.26.06.09.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Feb 2019 06:09:11 -0800 (PST) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , Eddie Horng , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH 2/2] generic: Test that SEEK_HOLE can find a punched hole Date: Tue, 26 Feb 2019 16:09:02 +0200 Message-Id: <20190226140902.32219-2-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190226140902.32219-1-amir73il@gmail.com> References: <20190226140902.32219-1-amir73il@gmail.com> Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Added a test case to seek_sanity_test and a test to run it. When checking for SEEK_HOLE support, abort if filesystem supports punching holes that SEEK_HOLE will not find, because this configuration doesn't make any sense. This kind of senless behavior was introduced to overlayfs in v4.19 with stacked file operations, because overlay fallocate op is stacked and llseek op is not stacked. Signed-off-by: Amir Goldstein --- Eryu, After this change, the generic/seek group tests will start failing with overlayfs on upstream kernel. We had missing coverage of SEEK_HOLE, so we missed a regression in kernel v4.19 when overlayfs SEEK_HOLE stopped finding punched holes (or any holes for that matter). Thanks, Amir. src/seek_sanity_test.c | 63 +++++++++++++++++++++++++++++++++++++++--- tests/generic/999 | 44 +++++++++++++++++++++++++++++ tests/generic/999.out | 1 + tests/generic/group | 1 + 4 files changed, 105 insertions(+), 4 deletions(-) create mode 100755 tests/generic/999 create mode 100644 tests/generic/999.out diff --git a/src/seek_sanity_test.c b/src/seek_sanity_test.c index e9938d1b..a98bae03 100644 --- a/src/seek_sanity_test.c +++ b/src/seek_sanity_test.c @@ -16,6 +16,7 @@ #include #include #include +#include "global.h" #ifndef SEEK_DATA #define SEEK_DATA 3 @@ -25,6 +26,7 @@ static blksize_t alloc_size; int default_behavior = 0; int unwritten_extents = 0; +int punch_hole = 0; char *base_file_path; static void get_file_system(int fd) @@ -117,8 +119,9 @@ static int do_fallocate(int fd, off_t offset, off_t length, int mode) ret = fallocate(fd, mode, offset, length); if (ret) - fprintf(stderr, " ERROR %d: Failed to preallocate " - "space to %ld bytes\n", errno, (long) length); + fprintf(stderr, " ERROR %d: Failed to %s of %ld bytes\n", + errno, (mode & FALLOC_FL_PUNCH_HOLE) ? "punch hole" : + "preallocate space", (long) length); return ret; } @@ -261,6 +264,47 @@ out: return ret; } +/* + * Make sure hole size is properly reported when punched in the middle of a file + */ +static int test21(int fd, int testnum) +{ + char *buf = NULL; + int bufsz, filsz; + int ret = 0; + + if (!punch_hole) { + fprintf(stdout, "Test skipped as fs doesn't support punch hole.\n"); + goto out; + } + + bufsz = alloc_size * 3; + buf = do_malloc(bufsz); + if (!buf) { + ret = -1; + goto out; + } + memset(buf, 'a', bufsz); + + ret = do_pwrite(fd, buf, bufsz, 0); + if (ret) + goto out; + + filsz = bufsz; + ret = do_fallocate(fd, alloc_size, alloc_size, + FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE); + if (ret < 0) + goto out; + + ret += do_lseek(testnum, 1, fd, filsz, SEEK_DATA, 0, 0); + ret += do_lseek(testnum, 2, fd, filsz, SEEK_HOLE, 0, alloc_size); + ret += do_lseek(testnum, 3, fd, filsz, SEEK_DATA, alloc_size, alloc_size * 2); +out: + if (buf) + free(buf); + return ret; +} + /* * Make sure hole size is properly reported when starting in the middle of a * hole in ext? doubly indirect tree @@ -1049,6 +1093,7 @@ struct testrec seek_tests[] = { { 18, test18, "Test file with negative SEEK_{HOLE,DATA} offsets" }, { 19, test19, "Test file SEEK_DATA from middle of a large hole" }, { 20, test20, "Test file SEEK_DATA from middle of a huge hole" }, + { 21, test21, "Test file SEEK_HOLE that was created by PUNCH_HOLE" }, }; static int run_test(struct testrec *tr) @@ -1120,15 +1165,25 @@ static int test_basic_support(void) } ftruncate(fd, 0); - if (fallocate(fd, 0, 0, alloc_size) == -1) { + if (fallocate(fd, 0, 0, alloc_size * 2) == -1) { if (errno == EOPNOTSUPP) - fprintf(stderr, "File system does not support fallocate."); + fprintf(stderr, "File system does not support fallocate.\n"); else { fprintf(stderr, "ERROR %d: Failed to preallocate " "space to %ld bytes. Aborting.\n", errno, (long) alloc_size); ret = -1; } goto out; + } else if (fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, + 0, alloc_size) == -1) { + fprintf(stderr, "File system does not support punch hole.\n"); + } else if (default_behavior) { + fprintf(stderr, "File system supports punch hole, but does not support " + "finding holes with SEEK_HOLE. Aborting.\n"); + ret = -1; + goto out; + } else { + punch_hole = 1; } pos = lseek(fd, 0, SEEK_DATA); diff --git a/tests/generic/999 b/tests/generic/999 new file mode 100755 index 00000000..b52f6985 --- /dev/null +++ b/tests/generic/999 @@ -0,0 +1,44 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2019, CTERA Networks. All Rights Reserved. +# +# FS QA Test No. 999 +# +# Check that SEEK_HOLE can find a punched hole. +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common/rc + +_supported_fs generic +_supported_os Linux + +_require_test +_require_seek_data_hole +_require_xfs_io_command "fpunch" + +base_test_file=$TEST_DIR/seek_sanity_testfile.$seq + +_require_test_program "seek_sanity_test" + +_cleanup() +{ + cd / + rm -f $tmp.* + rm -f $base_test_file* +} + +$here/src/seek_sanity_test -s 21 -e 21 $base_test_file > $seqres.full 2>&1 || + _fail "seek sanity check failed!" + +# success, all done +status=0 +exit diff --git a/tests/generic/999.out b/tests/generic/999.out new file mode 100644 index 00000000..7fbc6768 --- /dev/null +++ b/tests/generic/999.out @@ -0,0 +1 @@ +QA output created by 999 diff --git a/tests/generic/group b/tests/generic/group index 15227b67..14ac9b2c 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -534,3 +534,4 @@ 529 auto quick attr 530 auto quick unlink 531 auto quick unlink +999 auto quick punch seek