From patchwork Wed Aug 7 11:25:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Gruenbacher X-Patchwork-Id: 11081925 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 D26851399 for ; Wed, 7 Aug 2019 11:25:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0365285B5 for ; Wed, 7 Aug 2019 11:25:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1823289CC; Wed, 7 Aug 2019 11:25:19 +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=-7.9 required=2.0 tests=BAYES_00,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 53EB3285B5 for ; Wed, 7 Aug 2019 11:25:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387690AbfHGLZT (ORCPT ); Wed, 7 Aug 2019 07:25:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13726 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387625AbfHGLZS (ORCPT ); Wed, 7 Aug 2019 07:25:18 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AAADFC00A163; Wed, 7 Aug 2019 11:25:18 +0000 (UTC) Received: from max.com (unknown [10.40.205.105]) by smtp.corp.redhat.com (Postfix) with ESMTP id 835125D717; Wed, 7 Aug 2019 11:25:17 +0000 (UTC) From: Andreas Gruenbacher To: fstests@vger.kernel.org, Amir Goldstein Cc: Andreas Gruenbacher Subject: [PATCH] seek_sanity_test: Repair check for unwritten extent support Date: Wed, 7 Aug 2019 13:25:14 +0200 Message-Id: <20190807112514.1903-1-agruenba@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 07 Aug 2019 11:25:18 +0000 (UTC) Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In test_basic_support, commit f3c1bca7fb25 ("generic: Test that SEEK_HOLE can find a punched hole") cleverly punched a hole in the test file in the middle of the check for unwritten extent support, making sure we would never detect when unwritten extent support is missing. Fix that. While at it, explicitly check for SEEK_DATA support as well: so far, we were assuming that SEEK_HOLE support implies SEEK_DATA support, but it won't hurt to actually check. Signed-off-by: Andreas Gruenbacher --- src/seek_sanity_test.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/seek_sanity_test.c b/src/seek_sanity_test.c index 30e996e2..080ca7eb 100644 --- a/src/seek_sanity_test.c +++ b/src/seek_sanity_test.c @@ -1156,7 +1156,16 @@ static int test_basic_support(void) if (ret) goto out; - /* Is SEEK_DATA and SEEK_HOLE supported in the kernel? */ + /* Is SEEK_DATA supported in the kernel? */ + pos = lseek(fd, 0, SEEK_DATA); + if (pos == -1) { + fprintf(stderr, "Kernel does not support llseek(2) extension " + "SEEK_DATA. Aborting.\n"); + ret = -1; + goto out; + } + + /* Is SEEK_HOLE supported in the kernel? */ pos = lseek(fd, 0, SEEK_HOLE); if (pos == -1) { fprintf(stderr, "Kernel does not support llseek(2) extension " @@ -1186,19 +1195,21 @@ static int test_basic_support(void) 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 { - punch_hole = 1; } pos = lseek(fd, 0, SEEK_DATA); if (pos == 0) { fprintf(stderr, "File system does not support unwritten extents.\n"); - goto out; + } else { + unwritten_extents = 1; + } + + 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 { + punch_hole = 1; } - unwritten_extents = 1; printf("\n");