From patchwork Thu Oct 11 14:41:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10636723 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 D006015E2 for ; Thu, 11 Oct 2018 14:41:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEC752B910 for ; Thu, 11 Oct 2018 14:41:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC9A22B994; Thu, 11 Oct 2018 14:41:29 +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 63D352B910 for ; Thu, 11 Oct 2018 14:41:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728395AbeJKWI4 (ORCPT ); Thu, 11 Oct 2018 18:08:56 -0400 Received: from mail-wm1-f53.google.com ([209.85.128.53]:33995 "EHLO mail-wm1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727510AbeJKWI4 (ORCPT ); Thu, 11 Oct 2018 18:08:56 -0400 Received: by mail-wm1-f53.google.com with SMTP id z25-v6so15938772wmf.1; Thu, 11 Oct 2018 07:41:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=wX0RDcPjrCtWAfGH4lI264YxA439A73M1ybZioxpAY4=; b=Yb7t72oNwJhli7xXkV1xDWxRgb7WUXlVLbUAH1JaTKgL+OrX7cu3y33jYzzMhL4mX7 AMHEuzCYnd/Riz+wiQxATtrEzlxyw3ddvLm485nZR/YaLarmKGQ9Iwjpvc+CmnuGu2KY w+nwzZjPPFWT9CYAIv1hjcQEllr+iG+RgNf4QWhnUpxX3qhyg5R94LAEzURU40JtSdUe K+B0IOX1L7hi3ONsxkKKSgkP0pYMo4VYUYhA47tTjZvIn6E9ikxGqB45uPmfNq/pTRDF mHrLKq+mbCdwD6PuIsJj54RS0ZA+Mqqf7t16W1Fo4z3W0GJP7abcQWcVxlalFslYamCF nrDQ== 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=wX0RDcPjrCtWAfGH4lI264YxA439A73M1ybZioxpAY4=; b=Vfx8mT/TZK4XMp3rWZX9wze8p3e5XEeB2ByOazV1JAajGgEY88q3ol9E78YZlP7hpm AlQFz2uo9WOKftreTyPTSYKdlaWL65QanxDyA54VHj4RTq2zXNdzidfXpozOy0NSTplv UJS4RbexZPwDKe+MAreNwi6QZrwlgY/JVF/NVfv5gs4Thfb/nr4Dka8911N6J/PCo+f7 ufDwnnRsEULwCjlRueFVlWkvNHYXIm+KR7bUMyqCa5Vz/sQ4MwruKbLnPWzpCjn22jbz BRa0GYHChNWQFC6vmieT5mKWb/7iD3mqMuvt81NOQNaZK9b02Inco0uSad5nTvp2U7Uy OrBA== X-Gm-Message-State: ABuFfoihc8VBhL9MCyjFmf1xQZyJHosLtMDeGx6j7NXLFzT2I2l8LxVp uJfWkGYC3EGTWRFXNgL9P4Q= X-Google-Smtp-Source: ACcGV60iXeCCnJTWAkB9PoVsZa7IkEE8hqUSdgdw0OYzVuS14j9kHL1kXA2OCYH5t+uccjDeJYFr1g== X-Received: by 2002:a1c:b402:: with SMTP id d2-v6mr2024670wmf.37.1539268887085; Thu, 11 Oct 2018 07:41:27 -0700 (PDT) Received: from localhost.localdomain ([141.226.14.107]) by smtp.gmail.com with ESMTPSA id a12-v6sm20109204wrr.71.2018.10.11.07.41.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Oct 2018 07:41:26 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH v2] src/fiemap-tester: fix getting blocksize on overlayfs Date: Thu, 11 Oct 2018 17:41:06 +0300 Message-Id: <20181011144106.14481-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 There was a regression in v4.19-rc1 that caused FIGETBSZ ioctl to return 0 on an overlayfs file. That regression went unnoticed because the xfstests that run fiemap-tester program terminated in success status after not doing much instead of failing. Check for invalid value of block size returned by FIGETBSZ ioctl, so these tests can detect the regression. Fallback to statfs(2) for getting the filesystem blocksize if FIGETBSZ ioctl fails (i.e. on overlayfs). Signed-off-by: Amir Goldstein --- src/fiemap-tester.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/fiemap-tester.c b/src/fiemap-tester.c index 97ac5ad0..3db24daa 100644 --- a/src/fiemap-tester.c +++ b/src/fiemap-tester.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -556,7 +557,19 @@ main(int argc, char **argv) } if (ioctl(fd, FIGETBSZ, &blocksize) < 0) { - perror("Can't get filesystem block size"); + struct statfs buf; + + if (fstatfs(fd, &buf) == 0) { + blocksize = buf.f_bsize; + } else { + perror("Can't get filesystem block size"); + close(fd); + exit(1); + } + } + + if (blocksize <= 0) { + printf("Illegal filesystem block size\n"); close(fd); exit(1); }