From patchwork Wed Oct 10 23:34:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 982142 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="uqXlFBD5"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42Vr6x3Hj6z9s3l for ; Thu, 11 Oct 2018 10:35:05 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 7016C3E70C1 for ; Thu, 11 Oct 2018 01:35:02 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [217.194.8.6]) by picard.linux.it (Postfix) with ESMTP id 12F943E6722 for ; Thu, 11 Oct 2018 01:34:51 +0200 (CEST) Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 94D7B1400549 for ; Thu, 11 Oct 2018 01:34:50 +0200 (CEST) Received: by mail-wm1-x341.google.com with SMTP id a8-v6so7405657wmf.1 for ; Wed, 10 Oct 2018 16:34:50 -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:in-reply-to:references; bh=VklIHkoZXk4CZxyaaGizzmMiENpn27JP7ULYyAEIY2A=; b=uqXlFBD5+UQE6KjRHplS69IZrGqb7ZCOD7BaLIqlgHzw3TuuA9STZbrUTN+CbaQVs0 QmbXONvFrrD5XJXcUHJmqZxI+sZ5diXaS3VR9uRYrnCd9RrgSCRoxkSRfosAeDVxr5VO ndJEeCekm/MptuvKxyHG7wq+cmgY7i1sY4xjFXDDy1WLtZ7Tqi03s2J/KGShiJQuDEA0 X8ferrg81tfSiX5snh+3eLwvwq83fx3geqyroKKMfhLv4sb4kLPhNULvJkJ8HiB7oRIy AL/dmlmHqU+DYwhq3XV8ZUHWWftnFU2dQj5LoKQLIJLUjSdgxfGc5d9zuLxtx0Ac18mV o4RA== 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=VklIHkoZXk4CZxyaaGizzmMiENpn27JP7ULYyAEIY2A=; b=Q6KfpnLPCYVeo7KoJnm7/qZnq8dCLwaRF9Ia5ahCvvD5CaSyQZlGRTNgZMexZA+xaS jRXRD9uStlGT1tAOvHu6YlZgaERlIo+R2s6TA3/Pv3OZnXrkyjfcYfaVWdDmgZj0puLb S3qJA1Oj382d2vjy3RHOWT/DywPEA01wR01j444L9DaO/+P+uNVzqOxhw1KpNhXugWMh FAwsLrrebrHMirJ2xHBShWsgk6y1+f/YljSxWg7ltx0vFceXoiy9Z3U3ebQEpC3NHx8W 0v/YJiNYxzho3GS4n9aAajsXPLXFF8zQfQsPe/GPuJvRcrTyJHN9SHGhyKHoC+skmdUR nfDg== X-Gm-Message-State: ABuFfogGlXSVyztFEJyIpLx3ed4AUCiMVKErHYEPVRSI4KqhA1lG4qru esg8TX4X4EL03Ae4HIwq+pIDTgsn X-Google-Smtp-Source: ACcGV60n/Hs/Rs4ftU7XsRqPGttIZ6Lbd0y2xC39W34Zsxee9F8NLKSoTfpnVFpNHe2PH7LBuT9/cg== X-Received: by 2002:a1c:d105:: with SMTP id i5-v6mr2330345wmg.69.1539214490028; Wed, 10 Oct 2018 16:34:50 -0700 (PDT) Received: from localhost.localdomain ([141.226.14.107]) by smtp.gmail.com with ESMTPSA id h2-v6sm21768484wrs.34.2018.10.10.16.34.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 16:34:49 -0700 (PDT) From: Amir Goldstein To: Cyril Hrubis Date: Thu, 11 Oct 2018 02:34:36 +0300 Message-Id: <20181010233441.5337-2-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181010233441.5337-1-amir73il@gmail.com> References: <20181010233441.5337-1-amir73il@gmail.com> X-Virus-Scanned: clamav-milter 0.99.2 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-6.smtp.seeweb.it Cc: linux-unionfs@vger.kernel.org, ltp@lists.linux.it, Miklos Szeredi Subject: [LTP] [PATCH v3 1/6] syscalls/readahead01: Convert to newlib X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" * Use SPDX-License-Identifier Signed-off-by: Amir Goldstein Acked-by: Jan Stancek --- .../kernel/syscalls/readahead/readahead01.c | 119 +++++------------- 1 file changed, 34 insertions(+), 85 deletions(-) diff --git a/testcases/kernel/syscalls/readahead/readahead01.c b/testcases/kernel/syscalls/readahead/readahead01.c index f35019488..682b524b3 100644 --- a/testcases/kernel/syscalls/readahead/readahead01.c +++ b/testcases/kernel/syscalls/readahead/readahead01.c @@ -1,25 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2012 Linux Test Project, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it - * is free of the rightful claim of any third person regarding - * infringement or the like. Any license provided herein, whether - * implied or otherwise, applies only to this software file. Patent - * licenses, if any, provided herein do not apply to combinations of - * this program with other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. */ /* @@ -36,47 +17,36 @@ #include #include #include "config.h" -#include "test.h" -#include "safe_macros.h" +#include "tst_test.h" #include "lapi/syscalls.h" -char *TCID = "readahead01"; -int TST_TOTAL = 1; - -option_t options[] = { - {NULL, NULL, NULL} -}; - #if defined(__NR_readahead) -static void setup(void); -static void cleanup(void); - static int check_ret(long expected_ret) { - if (expected_ret == TEST_RETURN) { - tst_resm(TPASS, "expected ret success - " - "returned value = %ld", TEST_RETURN); + if (expected_ret == TST_RET) { + tst_res(TPASS, "expected ret success - " + "returned value = %ld", TST_RET); return 0; } - tst_resm(TFAIL, "unexpected failure - " - "returned value = %ld, expected: %ld", - TEST_RETURN, expected_ret); + tst_res(TFAIL, "unexpected failure - " + "returned value = %ld, expected: %ld", + TST_RET, expected_ret); return 1; } static int check_errno(long expected_errno) { - if (TEST_ERRNO == expected_errno) { - tst_resm(TPASS | TTERRNO, "expected failure"); + if (TST_ERR == expected_errno) { + tst_res(TPASS | TTERRNO, "expected failure"); return 0; } - if (TEST_ERRNO == 0) - tst_resm(TFAIL, "call succeeded unexpectedly"); + if (TST_ERR == 0) + tst_res(TFAIL, "call succeeded unexpectedly"); else - tst_resm(TFAIL | TTERRNO, "unexpected failure - " - "expected = %ld : %s, actual", - expected_errno, strerror(expected_errno)); + tst_res(TFAIL | TTERRNO, "unexpected failure - " + "expected = %ld : %s, actual", + expected_errno, strerror(expected_errno)); return 1; } @@ -85,19 +55,17 @@ static void test_bad_fd(void) char tempname[PATH_MAX] = "readahead01_XXXXXX"; int fd; - tst_resm(TINFO, "test_bad_fd -1"); + tst_res(TINFO, "test_bad_fd -1"); TEST(readahead(-1, 0, getpagesize())); check_ret(-1); check_errno(EBADF); - tst_resm(TINFO, "test_bad_fd O_WRONLY"); + tst_res(TINFO, "test_bad_fd O_WRONLY"); fd = mkstemp(tempname); if (fd == -1) - tst_resm(TBROK | TERRNO, "mkstemp failed"); + tst_res(TBROK | TERRNO, "mkstemp failed"); close(fd); - fd = open(tempname, O_WRONLY); - if (fd == -1) - tst_resm(TBROK | TERRNO, "Failed to open testfile"); + fd = SAFE_OPEN(tempname, O_WRONLY); TEST(readahead(fd, 0, getpagesize())); check_ret(-1); check_errno(EBADF); @@ -109,60 +77,41 @@ static void test_invalid_fd(void) { int fd[2]; - tst_resm(TINFO, "test_invalid_fd pipe"); - if (pipe(fd) < 0) - tst_resm(TBROK | TERRNO, "Failed to create pipe"); + tst_res(TINFO, "test_invalid_fd pipe"); + SAFE_PIPE(fd); TEST(readahead(fd[0], 0, getpagesize())); check_ret(-1); check_errno(EINVAL); close(fd[0]); close(fd[1]); - tst_resm(TINFO, "test_invalid_fd socket"); - fd[0] = socket(AF_INET, SOCK_STREAM, 0); - if (fd[0] < 0) - tst_resm(TBROK | TERRNO, "Failed to create socket"); + tst_res(TINFO, "test_invalid_fd socket"); + fd[0] = SAFE_SOCKET(AF_INET, SOCK_STREAM, 0); TEST(readahead(fd[0], 0, getpagesize())); check_ret(-1); check_errno(EINVAL); close(fd[0]); } -int main(int argc, char *argv[]) +void test_readahead(void) { - int lc; - - tst_parse_opts(argc, argv, options, NULL); - - setup(); - for (lc = 0; TEST_LOOPING(lc); lc++) { - tst_count = 0; - test_bad_fd(); - test_invalid_fd(); - } - cleanup(); - tst_exit(); + test_bad_fd(); + test_invalid_fd(); } static void setup(void) { - tst_require_root(); - tst_tmpdir(); - /* check if readahead syscall is supported */ - ltp_syscall(__NR_readahead, 0, 0, 0); - - TEST_PAUSE; + tst_syscall(__NR_readahead, 0, 0, 0); } -static void cleanup(void) -{ - tst_rmdir(); -} +static struct tst_test test = { + .needs_root = 1, + .needs_tmpdir = 1, + .setup = setup, + .test_all = test_readahead, +}; #else /* __NR_readahead */ -int main(void) -{ - tst_brkm(TCONF, NULL, "System doesn't support __NR_readahead"); -} + TST_TEST_TCONF("System doesn't support __NR_readahead"); #endif From patchwork Wed Oct 10 23:34:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 982143 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DhuLsgXq"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42Vr745NcFz9s3l for ; Thu, 11 Oct 2018 10:35:12 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 3E4903E7098 for ; Thu, 11 Oct 2018 01:35:10 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [217.194.8.7]) by picard.linux.it (Postfix) with ESMTP id 345283E708F for ; Thu, 11 Oct 2018 01:34:53 +0200 (CEST) Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 60015200744 for ; Thu, 11 Oct 2018 01:34:52 +0200 (CEST) Received: by mail-wr1-x441.google.com with SMTP id 61-v6so7547462wrb.6 for ; Wed, 10 Oct 2018 16:34:52 -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:in-reply-to:references; bh=g2o3HnloOkAmBCKQzTWBqQev3i6knqbyNx/GQGmn5Pk=; b=DhuLsgXq6NDOjWWuQq+1t2Qw0PtMudAARFQR/VrbS/MtYm4Wbi/llqYGRkBwifIYKg QvTCubxlSRc5JzcN/GCueWiLT2BsTMGsCxDH+oWDYVMPfy/HJrWc1wOrjXJ34gH8mXe/ 9FgEFlucwbvmbUmQIFM60DNrqw30e0bZ88K4oqf61zDN0QP/b/YD0UtQ9nJYjk3ZS6r5 35jnDbYabvRl1EmA4qM+A+QV7TsDeVYYAHuIS0Jo2IvOzt9quhudRdXPXOzV7Ji95c8v Jkc4rVrI313/V9B81olwPzBr8jyiHMURxhrMqUuktzZrsj8u7oXxNnq1HvnZkYZEOc3I QRYw== 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=g2o3HnloOkAmBCKQzTWBqQev3i6knqbyNx/GQGmn5Pk=; b=XouaoyW1EwYKEd876deOiEhid/LhRBvWiKZK90h6EU9DyQJxZrKW97NGdtkvCuJi10 QC9jTWX/+obRqx6PhJghNWShByEfDAFS0/pIqb7Y0g7hN24pKSMUnCAq8vqRwqLzwv/C xQwGk9s9u0Jkrb06twYmci9wsTJHgeNDLFK29DdYsnFLZ2pD33UudSgxapyBvPn4+Ehx OX1BcZkJFRUp2/okLHDuElVvoa/Wc56XLUy8b5iPrSrOVklrmi17a+OCeEkvTcKIVRDa knTZucRZXHy7LW4Ehf3A1PjNjR+ggDlgtrPW24O/Yf1hhbkt2PSoXHtW1iDHTKhEW9Ef Jhcw== X-Gm-Message-State: ABuFfojS4uGAotC+5hZ1RVP6yiRamoYiYk7bYVLabmlpG86JkH1zFaGc /LN9bVSR0ffCnpSGkcnedAQ= X-Google-Smtp-Source: ACcGV62+KzCJ2hdTdyyYLW4SVCBy/+EQmt9j/ADwH9rcZgCg+5MfRIugmv5LOwMgmgpR4DqHSPncng== X-Received: by 2002:adf:f986:: with SMTP id f6-v6mr3844303wrr.293.1539214491755; Wed, 10 Oct 2018 16:34:51 -0700 (PDT) Received: from localhost.localdomain ([141.226.14.107]) by smtp.gmail.com with ESMTPSA id h2-v6sm21768484wrs.34.2018.10.10.16.34.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 16:34:50 -0700 (PDT) From: Amir Goldstein To: Cyril Hrubis Date: Thu, 11 Oct 2018 02:34:37 +0300 Message-Id: <20181010233441.5337-3-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181010233441.5337-1-amir73il@gmail.com> References: <20181010233441.5337-1-amir73il@gmail.com> X-Virus-Scanned: clamav-milter 0.99.2 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-7.smtp.seeweb.it Cc: linux-unionfs@vger.kernel.org, ltp@lists.linux.it, Miklos Szeredi Subject: [LTP] [PATCH v3 2/6] syscalls/readahead02: Convert to newlib and cleanup X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" * Use SAFE macros * Use SPDX-License-Identifier * No need to cleanup test file from temp dir Signed-off-by: Amir Goldstein --- .../kernel/syscalls/readahead/readahead02.c | 248 +++++------------- 1 file changed, 72 insertions(+), 176 deletions(-) diff --git a/testcases/kernel/syscalls/readahead/readahead02.c b/testcases/kernel/syscalls/readahead/readahead02.c index c9d92a6a4..c739d3ba2 100644 --- a/testcases/kernel/syscalls/readahead/readahead02.c +++ b/testcases/kernel/syscalls/readahead/readahead02.c @@ -1,25 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2012 Linux Test Project, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it - * is free of the rightful claim of any third person regarding - * infringement or the like. Any license provided herein, whether - * implied or otherwise, applies only to this software file. Patent - * licenses, if any, provided herein do not apply to combinations of - * this program with other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. */ /* @@ -43,86 +24,57 @@ #include #include #include "config.h" -#include "test.h" -#include "safe_macros.h" +#include "tst_test.h" #include "lapi/syscalls.h" -char *TCID = "readahead02"; -int TST_TOTAL = 1; - #if defined(__NR_readahead) static char testfile[PATH_MAX] = "testfile"; static const char drop_caches_fname[] = "/proc/sys/vm/drop_caches"; static const char meminfo_fname[] = "/proc/meminfo"; static size_t testfile_size = 64 * 1024 * 1024; -static int opt_fsize; static char *opt_fsizestr; static int pagesize; -static const char *fs_type; -static const char *device; -static int mount_flag; #define MNTPOINT "mntpoint" #define MIN_SANE_READAHEAD (4u * 1024u) -option_t options[] = { - {"s:", &opt_fsize, &opt_fsizestr}, +static const char mntpoint[] = MNTPOINT; + +static struct tst_option options[] = { + {"s:", &opt_fsizestr, "-s testfile size (default 64MB)"}, {NULL, NULL, NULL} }; -static void setup(void); -static void cleanup(void); - -static void help(void) -{ - printf(" -s x testfile size (default 64MB)\n"); -} - static int check_ret(long expected_ret) { - if (expected_ret == TEST_RETURN) { - tst_resm(TPASS, "expected ret success - " - "returned value = %ld", TEST_RETURN); + if (expected_ret == TST_RET) { + tst_res(TPASS, "expected ret success - " + "returned value = %ld", TST_RET); return 0; } - tst_resm(TFAIL | TTERRNO, "unexpected failure - " - "returned value = %ld, expected: %ld", - TEST_RETURN, expected_ret); + tst_res(TFAIL | TTERRNO, "unexpected failure - " + "returned value = %ld, expected: %ld", + TST_RET, expected_ret); return 1; } static int has_file(const char *fname, int required) { - int ret; struct stat buf; - ret = stat(fname, &buf); - if (ret == -1) { - if (errno == ENOENT) - if (required) - tst_brkm(TCONF, cleanup, "%s not available", - fname); - else - return 0; - else - tst_brkm(TBROK | TERRNO, cleanup, "stat %s", fname); + + if (stat(fname, &buf) == -1) { + if (errno != ENOENT) + tst_brk(TBROK | TERRNO, "stat %s", fname); + if (required) + tst_brk(TCONF, "%s not available", fname); + return 0; } return 1; } static void drop_caches(void) { - int ret; - FILE *f; - - f = fopen(drop_caches_fname, "w"); - if (f) { - ret = fprintf(f, "1"); - fclose(f); - if (ret < 1) - tst_brkm(TBROK, cleanup, "Failed to drop caches"); - } else { - tst_brkm(TBROK, cleanup, "Failed to open drop_caches"); - } + SAFE_FILE_PRINTF(drop_caches_fname, "1"); } static unsigned long parse_entry(const char *fname, const char *entry) @@ -161,32 +113,21 @@ static unsigned long get_cached_size(void) static void create_testfile(void) { - FILE *f; + int fd; char *tmp; size_t i; - tst_resm(TINFO, "creating test file of size: %zu", testfile_size); - tmp = SAFE_MALLOC(cleanup, pagesize); + tst_res(TINFO, "creating test file of size: %zu", testfile_size); + tmp = SAFE_MALLOC(pagesize); /* round to page size */ testfile_size = testfile_size & ~((long)pagesize - 1); - f = fopen(testfile, "w"); - if (!f) { - free(tmp); - tst_brkm(TBROK | TERRNO, cleanup, "Failed to create %s", - testfile); - } - + fd = SAFE_CREAT(testfile, 0644); for (i = 0; i < testfile_size; i += pagesize) - if (fwrite(tmp, pagesize, 1, f) < 1) { - free(tmp); - tst_brkm(TBROK, cleanup, "Failed to create %s", - testfile); - } - fflush(f); - fsync(fileno(f)); - fclose(f); + SAFE_WRITE(1, fd, tmp, pagesize); + SAFE_FSYNC(fd); + SAFE_CLOSE(fd); free(tmp); } @@ -215,13 +156,13 @@ static void read_testfile(int do_readahead, const char *fname, size_t fsize, off_t offset = 0; struct timeval now; - fd = SAFE_OPEN(cleanup, fname, O_RDONLY); + fd = SAFE_OPEN(fname, O_RDONLY); if (do_readahead) { cached_start = get_cached_size(); do { TEST(readahead(fd, offset, fsize - offset)); - if (TEST_RETURN != 0) { + if (TST_RET != 0) { check_ret(0); break; } @@ -232,7 +173,7 @@ static void read_testfile(int do_readahead, const char *fname, size_t fsize, if (*cached > cached_start) { max_ra_estimate = (1024 * (*cached - cached_start)); - tst_resm(TINFO, "max ra estimate: %lu", + tst_res(TINFO, "max ra estimate: %lu", max_ra_estimate); } max_ra_estimate = MAX(max_ra_estimate, @@ -242,27 +183,23 @@ static void read_testfile(int do_readahead, const char *fname, size_t fsize, i++; offset += max_ra_estimate; } while ((size_t)offset < fsize); - tst_resm(TINFO, "readahead calls made: %zu", i); + tst_res(TINFO, "readahead calls made: %zu", i); *cached = get_cached_size(); /* offset of file shouldn't change after readahead */ - offset = lseek(fd, 0, SEEK_CUR); - if (offset == (off_t) - 1) - tst_brkm(TBROK | TERRNO, cleanup, "lseek failed"); + offset = SAFE_LSEEK(fd, 0, SEEK_CUR); if (offset == 0) - tst_resm(TPASS, "offset is still at 0 as expected"); + tst_res(TPASS, "offset is still at 0 as expected"); else - tst_resm(TFAIL, "offset has changed to: %lu", offset); + tst_res(TFAIL, "offset has changed to: %lu", offset); } if (gettimeofday(&now, NULL) == -1) - tst_brkm(TBROK | TERRNO, cleanup, "gettimeofday failed"); + tst_brk(TBROK | TERRNO, "gettimeofday failed"); time_start_usec = now.tv_sec * 1000000 + now.tv_usec; read_bytes_start = get_bytes_read(); - p = mmap(NULL, fsize, PROT_READ, MAP_SHARED | MAP_POPULATE, fd, 0); - if (p == MAP_FAILED) - tst_brkm(TBROK | TERRNO, cleanup, "mmap failed"); + p = SAFE_MMAP(NULL, fsize, PROT_READ, MAP_SHARED | MAP_POPULATE, fd, 0); /* for old kernels, where MAP_POPULATE doesn't work, touch each page */ tmp = 0; @@ -270,20 +207,20 @@ static void read_testfile(int do_readahead, const char *fname, size_t fsize, tmp = tmp ^ p[i]; /* prevent gcc from optimizing out loop above */ if (tmp != 0) - tst_brkm(TBROK, NULL, "This line should not be reached"); + tst_brk(TBROK, "This line should not be reached"); if (!do_readahead) *cached = get_cached_size(); - SAFE_MUNMAP(cleanup, p, fsize); + SAFE_MUNMAP(p, fsize); *read_bytes = get_bytes_read() - read_bytes_start; if (gettimeofday(&now, NULL) == -1) - tst_brkm(TBROK | TERRNO, cleanup, "gettimeofday failed"); + tst_brk(TBROK | TERRNO, "gettimeofday failed"); time_end_usec = now.tv_sec * 1000000 + now.tv_usec; *usec = time_end_usec - time_start_usec; - SAFE_CLOSE(cleanup, fd); + SAFE_CLOSE(fd); } static void test_readahead(void) @@ -302,7 +239,7 @@ static void test_readahead(void) cached_low = get_cached_size(); cached_max = cached_max - cached_low; - tst_resm(TINFO, "read_testfile(0)"); + tst_res(TINFO, "read_testfile(0)"); read_testfile(0, testfile, testfile_size, &read_bytes, &usec, &cached); if (cached > cached_low) cached = cached - cached_low; @@ -312,7 +249,7 @@ static void test_readahead(void) sync(); drop_caches(); cached_low = get_cached_size(); - tst_resm(TINFO, "read_testfile(1)"); + tst_res(TINFO, "read_testfile(1)"); read_testfile(1, testfile, testfile_size, &read_bytes_ra, &usec_ra, &cached_ra); if (cached_ra > cached_low) @@ -320,25 +257,25 @@ static void test_readahead(void) else cached_ra = 0; - tst_resm(TINFO, "read_testfile(0) took: %ld usec", usec); - tst_resm(TINFO, "read_testfile(1) took: %ld usec", usec_ra); + tst_res(TINFO, "read_testfile(0) took: %ld usec", usec); + tst_res(TINFO, "read_testfile(1) took: %ld usec", usec_ra); if (has_file(proc_io_fname, 0)) { - tst_resm(TINFO, "read_testfile(0) read: %ld bytes", read_bytes); - tst_resm(TINFO, "read_testfile(1) read: %ld bytes", - read_bytes_ra); + tst_res(TINFO, "read_testfile(0) read: %ld bytes", read_bytes); + tst_res(TINFO, "read_testfile(1) read: %ld bytes", + read_bytes_ra); /* actual number of read bytes depends on total RAM */ if (read_bytes_ra < read_bytes) - tst_resm(TPASS, "readahead saved some I/O"); + tst_res(TPASS, "readahead saved some I/O"); else - tst_resm(TFAIL, "readahead failed to save any I/O"); + tst_res(TFAIL, "readahead failed to save any I/O"); } else { - tst_resm(TCONF, "Your system doesn't have /proc/pid/io," - " unable to determine read bytes during test"); + tst_res(TCONF, "Your system doesn't have /proc/pid/io," + " unable to determine read bytes during test"); } - tst_resm(TINFO, "cache can hold at least: %ld kB", cached_max); - tst_resm(TINFO, "read_testfile(0) used cache: %ld kB", cached); - tst_resm(TINFO, "read_testfile(1) used cache: %ld kB", cached_ra); + tst_res(TINFO, "cache can hold at least: %ld kB", cached_max); + tst_res(TINFO, "read_testfile(0) used cache: %ld kB", cached); + tst_res(TINFO, "read_testfile(1) used cache: %ld kB", cached_ra); if (cached_max * 1024 >= testfile_size) { /* @@ -346,83 +283,42 @@ static void test_readahead(void) * for readahead should be at least testfile_size/2 */ if (cached_ra * 1024 > testfile_size / 2) - tst_resm(TPASS, "using cache as expected"); + tst_res(TPASS, "using cache as expected"); else - tst_resm(TWARN, "using less cache than expected"); + tst_res(TWARN, "using less cache than expected"); } else { - tst_resm(TCONF, "Page cache on your system is too small " - "to hold whole testfile."); + tst_res(TCONF, "Page cache on your system is too small " + "to hold whole testfile."); } } -int main(int argc, char *argv[]) -{ - int lc; - - tst_parse_opts(argc, argv, options, help); - - if (opt_fsize) - testfile_size = atoi(opt_fsizestr); - - setup(); - for (lc = 0; TEST_LOOPING(lc); lc++) { - tst_count = 0; - test_readahead(); - } - cleanup(); - tst_exit(); -} - static void setup(void) { - tst_require_root(); - tst_tmpdir(); - TEST_PAUSE; + if (opt_fsizestr) + testfile_size = SAFE_STRTOL(opt_fsizestr, 1, INT_MAX); has_file(drop_caches_fname, 1); has_file(meminfo_fname, 1); /* check if readahead is supported */ - ltp_syscall(__NR_readahead, 0, 0, 0); + tst_syscall(__NR_readahead, 0, 0, 0); pagesize = getpagesize(); - if (tst_fs_type(cleanup, ".") == TST_TMPFS_MAGIC) { - tst_resm(TINFO, "TMPFS detected, creating loop device"); - - fs_type = tst_dev_fs_type(); - device = tst_acquire_device(cleanup); - if (!device) { - tst_brkm(TCONF, cleanup, - "Failed to obtain block device"); - } - - tst_mkfs(cleanup, device, fs_type, NULL, NULL); - - SAFE_MKDIR(cleanup, MNTPOINT, 0755); - SAFE_MOUNT(cleanup, device, MNTPOINT, fs_type, 0, NULL); - mount_flag = 1; - - sprintf(testfile, MNTPOINT"/testfile"); - } + sprintf(testfile, "%s/testfile", mntpoint); create_testfile(); } -static void cleanup(void) -{ - unlink(testfile); - if (mount_flag && tst_umount(MNTPOINT) < 0) - tst_resm(TWARN | TERRNO, "umount device:%s failed", device); - - if (device) - tst_release_device(device); - - tst_rmdir(); -} +static struct tst_test test = { + .needs_root = 1, + .needs_tmpdir = 1, + .mount_device = 1, + .mntpoint = mntpoint, + .setup = setup, + .options = options, + .test_all = test_readahead, +}; #else /* __NR_readahead */ -int main(void) -{ - tst_brkm(TCONF, NULL, "System doesn't support __NR_readahead"); -} + TST_TEST_TCONF("System doesn't support __NR_readahead"); #endif From patchwork Wed Oct 10 23:34:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 982144 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="GKXP2pVT"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42Vr7B5S3Lz9s3l for ; Thu, 11 Oct 2018 10:35:18 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 4694C3E70D2 for ; Thu, 11 Oct 2018 01:35:16 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) by picard.linux.it (Postfix) with ESMTP id 304093E708A for ; Thu, 11 Oct 2018 01:34:54 +0200 (CEST) Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id A5FC8600704 for ; Thu, 11 Oct 2018 01:34:53 +0200 (CEST) Received: by mail-wm1-x343.google.com with SMTP id 189-v6so7142458wmw.2 for ; Wed, 10 Oct 2018 16:34:53 -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:in-reply-to:references; bh=C13AiG3HS0KXQvkRrgcd24JHcNbH3rjSJLiutVIPscE=; b=GKXP2pVT4nnD2jr74Jizetx8tBpcEwdSALviCWqdxZyQsKTDcxxwmlxCJtdC+WGSIG /N66xti15d7DyhOWzPZ1ix3bz6sGsJC1Iao8W8uNLSdpvbQ+rbO17iFtbBI2X6YBld2c ur/Jc5mE+CaiC3JgDNqyrQVKCnubEk4H3W6sI5CvR2uonTkl17pHP0gwOdywsTxPrWrx fgAM6fPhn4ULb3Ab2T9WnkzrGVYSb1+yE0EO98vh6auf1FoxEUPzSRr2dMwpB3ZdpkCz CUSIKeuVxc0yrGyXq5eQunFUcqJsqF/2qTStjhwSx1EHewD2TNxF5GqZus8WybuU3BXV pi6Q== 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=C13AiG3HS0KXQvkRrgcd24JHcNbH3rjSJLiutVIPscE=; b=t6DRQZ6iT1TK1CcZ7anE0dkM3ZXBw+64Q0siOgq66ULhJ+nnrMBYjJVSp8ZjpCe+3a zbD6IAb+czu+1ne05TJfTx+yt5AUsq11iWpAt12t7r/9ks0a3yD2Z/075TEO1NeSbddn RLmLJghVPgziqcW3XSWNfopB9aBZ+53rQccsykaPcdXQ+CPvWb2ave91IChHCuMzWNC9 oQvLA7sL7rZ57OLaaA5PnnWVZupXDRFVVFxcds23oNuWkppSLupPSkAnn3Wyo6CshzR5 n0VtJjFF975JkPdZ34gCGRkPZfTV+IWtINN7YRgcjugdNRDku3Z0vLbqZhmCAV1jN9UB Zdiw== X-Gm-Message-State: ABuFfogQpTPlnNh8g3KYyYkRJGtanir/6HzCB//gqU47KbHRqvFybcNJ 3PhzXWmKK1CXGPjBx+HypeZznrw2 X-Google-Smtp-Source: ACcGV63kaWmY9DdBXiqnoTvHgsLUrGGWe3vGt/Kp20AhUmGRyvO7841tQN8NX0M1ifYu8gZXL3KmMw== X-Received: by 2002:a1c:288a:: with SMTP id o132-v6mr2328292wmo.28.1539214493271; Wed, 10 Oct 2018 16:34:53 -0700 (PDT) Received: from localhost.localdomain ([141.226.14.107]) by smtp.gmail.com with ESMTPSA id h2-v6sm21768484wrs.34.2018.10.10.16.34.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 16:34:52 -0700 (PDT) From: Amir Goldstein To: Cyril Hrubis Date: Thu, 11 Oct 2018 02:34:38 +0300 Message-Id: <20181010233441.5337-4-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181010233441.5337-1-amir73il@gmail.com> References: <20181010233441.5337-1-amir73il@gmail.com> X-Virus-Scanned: clamav-milter 0.99.2 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-5.smtp.seeweb.it Cc: linux-unionfs@vger.kernel.org, ltp@lists.linux.it, Miklos Szeredi Subject: [LTP] [PATCH v3 3/6] syscalls/readahead02: abort test if readahead syscall fails X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" There is no reason to continue the test if readahead syscall fails and we can also check and report TCONF if filesystem does not support readahead. Signed-off-by: Amir Goldstein --- .../kernel/syscalls/readahead/readahead02.c | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/testcases/kernel/syscalls/readahead/readahead02.c b/testcases/kernel/syscalls/readahead/readahead02.c index c739d3ba2..f77e7c66c 100644 --- a/testcases/kernel/syscalls/readahead/readahead02.c +++ b/testcases/kernel/syscalls/readahead/readahead02.c @@ -45,16 +45,17 @@ static struct tst_option options[] = { {NULL, NULL, NULL} }; -static int check_ret(long expected_ret) +static int check_ret(void) { - if (expected_ret == TST_RET) { - tst_res(TPASS, "expected ret success - " - "returned value = %ld", TST_RET); + if (TST_RET == 0) return 0; + if (TST_ERR == EINVAL) { + tst_res(TCONF, "readahead not supported on %s", + tst_device->fs_type); + } else { + tst_res(TFAIL | TTERRNO, "readahead failed on %s", + tst_device->fs_type); } - tst_res(TFAIL | TTERRNO, "unexpected failure - " - "returned value = %ld, expected: %ld", - TST_RET, expected_ret); return 1; } @@ -163,8 +164,8 @@ static void read_testfile(int do_readahead, const char *fname, size_t fsize, do { TEST(readahead(fd, offset, fsize - offset)); if (TST_RET != 0) { - check_ret(0); - break; + SAFE_CLOSE(fd); + return; } /* estimate max readahead size based on first call */ @@ -252,6 +253,8 @@ static void test_readahead(void) tst_res(TINFO, "read_testfile(1)"); read_testfile(1, testfile, testfile_size, &read_bytes_ra, &usec_ra, &cached_ra); + if (check_ret()) + return; if (cached_ra > cached_low) cached_ra = cached_ra - cached_low; else From patchwork Wed Oct 10 23:34:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 982145 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ExkB8klG"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42Vr7L21S3z9s3l for ; Thu, 11 Oct 2018 10:35:26 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 94FDE3E7098 for ; Thu, 11 Oct 2018 01:35:23 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4]) by picard.linux.it (Postfix) with ESMTP id CBDAA3E709C for ; Thu, 11 Oct 2018 01:34:55 +0200 (CEST) Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 39F991000644 for ; Thu, 11 Oct 2018 01:34:55 +0200 (CEST) Received: by mail-wr1-x444.google.com with SMTP id l6-v6so7133120wrt.1 for ; Wed, 10 Oct 2018 16:34:55 -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:in-reply-to:references; bh=P+31eZRVT+5jjtkQIwPRwe/NzobuKI40sf7Q/83A9Qg=; b=ExkB8klGV83v2TVDAIatSSiwLty8PLZYlgTXohEDRoNUxOHWn9Xm7Nh8uT+sBbweFx 4g/6fW1NsVqatRcRFtb2niS9FrHBlmWrwZFddfbnulvpcAQmABiSR1eFWMUhI6YFIM+Y pgQ4u3icZqbHGMngBbMUwrvI2THrX4K1M57+CbFDMf+UKorgCdJgo0VnEfIyvjUu+vjh ijkkxzKlLJTSzMLil30YwF7NQUOaWjKvUaZthIT6ljHPjxsrGZw9rlv1+NTe4pq5IQLC rma5OpdYECXeAU8I4cBvctYrK6FIy+2/2oIZhnP30GRL37ZPg1tYssNGbYctpHrAGtNS 8RAg== 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=P+31eZRVT+5jjtkQIwPRwe/NzobuKI40sf7Q/83A9Qg=; b=k8co8Ip+ho6rygiKkpZfmLxddqomLiHHwF5vxbyInH8WbGDoFYhCwnokrRqbllYXMV XcJAw3d+68O2t4Pu0GXfjbVAL4xVwfEodSTETYTgyFqeDhPjzbfZTw8AzdqSXSTDl5RF u7IIWWGnuEprxPnag/EPowIVZA/mAL3mFxaXCBlTqRiMYVV2WlGCjU9dCpEgHU0UrVnv EMgk9wWw8ZlOQ2a6pFFl6NWt/hVt8wad3GYfDpHi9ZZrZ32/0ff6+gZDdJ3C4MqasvVP PWCO8AMRlpSqREP6KArFUf66shdJuVQp8+OyfCpJ5hN1ixdnlJuWYw/uGXiavePJ3BCv 20Og== X-Gm-Message-State: ABuFfoiYGaE12rZklqOlO/oDWSpzqGy4btMRyIZ93r89VIeUJ6HThd9j vfHxptmhDiMLxlpLpxyEGbA= X-Google-Smtp-Source: ACcGV61dJH1UnJII7L84vQrR1CdoIgJz8yv1hZ65B8hniO1j1dhUp7HaCec947Ou627HEHxrGMUzrA== X-Received: by 2002:adf:8103:: with SMTP id 3-v6mr24705487wrm.106.1539214494699; Wed, 10 Oct 2018 16:34:54 -0700 (PDT) Received: from localhost.localdomain ([141.226.14.107]) by smtp.gmail.com with ESMTPSA id h2-v6sm21768484wrs.34.2018.10.10.16.34.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 16:34:54 -0700 (PDT) From: Amir Goldstein To: Cyril Hrubis Date: Thu, 11 Oct 2018 02:34:39 +0300 Message-Id: <20181010233441.5337-5-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181010233441.5337-1-amir73il@gmail.com> References: <20181010233441.5337-1-amir73il@gmail.com> X-Virus-Scanned: clamav-milter 0.99.2 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-4.smtp.seeweb.it Cc: linux-unionfs@vger.kernel.org, ltp@lists.linux.it, Miklos Szeredi Subject: [LTP] [PATCH v3 4/6] syscalls/readahead02: test readahead() on an overlayfs file X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Repeat the test case on an overlayfs file. The new test case is a regression test for kernel commit b833a3660394 ("ovl: add ovl_fadvise()") which fixes a regression of readahead() on an overlay file that was introduced by kernel commit 5b910bd615ba ("ovl: fix GPF in swapfile_activate of file from overlayfs over xfs"). Signed-off-by: Amir Goldstein --- .../kernel/syscalls/readahead/readahead02.c | 85 ++++++++++++++++--- 1 file changed, 73 insertions(+), 12 deletions(-) diff --git a/testcases/kernel/syscalls/readahead/readahead02.c b/testcases/kernel/syscalls/readahead/readahead02.c index f77e7c66c..56a8496ff 100644 --- a/testcases/kernel/syscalls/readahead/readahead02.c +++ b/testcases/kernel/syscalls/readahead/readahead02.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -34,8 +35,14 @@ static const char meminfo_fname[] = "/proc/meminfo"; static size_t testfile_size = 64 * 1024 * 1024; static char *opt_fsizestr; static int pagesize; +static unsigned long cached_max; +static int ovl_mounted; #define MNTPOINT "mntpoint" +#define OVL_LOWER MNTPOINT"/lower" +#define OVL_UPPER MNTPOINT"/upper" +#define OVL_WORK MNTPOINT"/work" +#define OVL_MNT MNTPOINT"/ovl" #define MIN_SANE_READAHEAD (4u * 1024u) static const char mntpoint[] = MNTPOINT; @@ -45,16 +52,28 @@ static struct tst_option options[] = { {NULL, NULL, NULL} }; -static int check_ret(void) +static struct tcase { + const char *tname; + int use_overlay; +} tcases[] = { + { "readahead on file", 0 }, + { "readahead on overlayfs file", 1 }, +}; + +static int readahead_supported = 1; + +static int check_ret(struct tcase *tc) { if (TST_RET == 0) return 0; - if (TST_ERR == EINVAL) { + if (TST_ERR == EINVAL && + (!tc->use_overlay || !readahead_supported)) { + readahead_supported = 0; tst_res(TCONF, "readahead not supported on %s", tst_device->fs_type); } else { tst_res(TFAIL | TTERRNO, "readahead failed on %s", - tst_device->fs_type); + tc->use_overlay ? "overlayfs" : tst_device->fs_type); } return 1; } @@ -112,12 +131,13 @@ static unsigned long get_cached_size(void) return parse_entry(meminfo_fname, entry); } -static void create_testfile(void) +static void create_testfile(int use_overlay) { int fd; char *tmp; size_t i; + sprintf(testfile, "%s/testfile", use_overlay ? OVL_MNT : MNTPOINT); tst_res(TINFO, "creating test file of size: %zu", testfile_size); tmp = SAFE_MALLOC(pagesize); @@ -224,21 +244,33 @@ static void read_testfile(int do_readahead, const char *fname, size_t fsize, SAFE_CLOSE(fd); } -static void test_readahead(void) +static void test_readahead(unsigned int n) { unsigned long read_bytes, read_bytes_ra; long usec, usec_ra; - unsigned long cached_max, cached_low, cached, cached_ra; + unsigned long cached_high, cached_low, cached, cached_ra; char proc_io_fname[128]; + struct tcase *tc = &tcases[n]; + + tst_res(TINFO, "Test #%d: %s", n, tc->tname); + sprintf(proc_io_fname, "/proc/%u/io", getpid()); + if (tc->use_overlay && !ovl_mounted) { + tst_res(TCONF, + "overlayfs is not configured in this kernel."); + return; + } + + create_testfile(tc->use_overlay); + /* find out how much can cache hold if we read whole file */ read_testfile(0, testfile, testfile_size, &read_bytes, &usec, &cached); - cached_max = get_cached_size(); + cached_high = get_cached_size(); sync(); drop_caches(); cached_low = get_cached_size(); - cached_max = cached_max - cached_low; + cached_max = MAX(cached_max, cached_high - cached_low); tst_res(TINFO, "read_testfile(0)"); read_testfile(0, testfile, testfile_size, &read_bytes, &usec, &cached); @@ -253,7 +285,7 @@ static void test_readahead(void) tst_res(TINFO, "read_testfile(1)"); read_testfile(1, testfile, testfile_size, &read_bytes_ra, &usec_ra, &cached_ra); - if (check_ret()) + if (check_ret(tc)) return; if (cached_ra > cached_low) cached_ra = cached_ra - cached_low; @@ -295,6 +327,28 @@ static void test_readahead(void) } } +static void setup_overlay(void) +{ + int ret; + + /* Setup an overlay mount with lower dir and file */ + SAFE_MKDIR(OVL_LOWER, 0755); + SAFE_MKDIR(OVL_UPPER, 0755); + SAFE_MKDIR(OVL_WORK, 0755); + SAFE_MKDIR(OVL_MNT, 0755); + ret = mount("overlay", OVL_MNT, "overlay", 0, "lowerdir="OVL_LOWER + ",upperdir="OVL_UPPER",workdir="OVL_WORK); + if (ret < 0) { + if (errno == ENODEV) { + tst_res(TINFO, + "overlayfs is not configured in this kernel."); + return; + } + tst_brk(TBROK | TERRNO, "overlayfs mount failed"); + } + ovl_mounted = 1; +} + static void setup(void) { if (opt_fsizestr) @@ -308,8 +362,13 @@ static void setup(void) pagesize = getpagesize(); - sprintf(testfile, "%s/testfile", mntpoint); - create_testfile(); + setup_overlay(); +} + +static void cleanup(void) +{ + if (ovl_mounted) + SAFE_UMOUNT(OVL_MNT); } static struct tst_test test = { @@ -318,8 +377,10 @@ static struct tst_test test = { .mount_device = 1, .mntpoint = mntpoint, .setup = setup, + .cleanup = cleanup, .options = options, - .test_all = test_readahead, + .test = test_readahead, + .tcnt = ARRAY_SIZE(tcases), }; #else /* __NR_readahead */ From patchwork Wed Oct 10 23:34:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 982146 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="E/+pHEAs"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42Vr7R4ZcLz9s3l for ; Thu, 11 Oct 2018 10:35:31 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 231843E708F for ; Thu, 11 Oct 2018 01:35:29 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [217.194.8.6]) by picard.linux.it (Postfix) with ESMTP id 1D8173E70BB for ; Thu, 11 Oct 2018 01:34:57 +0200 (CEST) Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 93A36140054D for ; Thu, 11 Oct 2018 01:34:56 +0200 (CEST) Received: by mail-wr1-x443.google.com with SMTP id w5-v6so7564313wrt.2 for ; Wed, 10 Oct 2018 16:34:56 -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:in-reply-to:references; bh=bBO7rRPu5FDESQOq2udKjdxu0pAKbTF8JtLbmGTcg6I=; b=E/+pHEAsCWjf3rzu8J9ggag/1T8w08N9OUYzRsz6yoWMjePjsPGvZzstm+hV9sFeYD 16IH6UAYLDhcSvAZ5Tkz7IAyIPjezG2Kk11ueJGQ9iN9PUSEKHUlh0tVRbjxJpuUcrDM oXv00VjZXEMgDiZ6qYrRYyhY1vyoLNuv3A1KRjRQJyVoyW1o/SDkSckrsvtYVEHxNrA2 t1A2+w5sUrAn7JMloJmRQAFF3cIbVxCXxA/CnhWLyJCrx/I7xQe4mijSqX30smR8uM0l 9jzovhlU/GhRXTB5MnUv3SmtJ57Y7u26xy8NZBo3srYSJE4ymgRTUseoct8Lpl7odEK2 VWVQ== 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=bBO7rRPu5FDESQOq2udKjdxu0pAKbTF8JtLbmGTcg6I=; b=mP/5IJKqeKxbHTYFu6BzuMoQgdjTylbGTkPqqv3PQdj+255ZT/kLC1ipijlfvmQPYm Y2p22TvOto8xJhbNJSOSfAPPzV18+CBk39irCriPSHrY5BVUllsQ9ciUJ36o94y0yD2p or5jk+w6rXeivararOoaTiP9oAzOAvBVZuyaM4CvVdQWTEiYgtd6zUyGQylBpdBvNUUZ ZyQd94vZHITHwi73E3HOhxvSz2APnj0dnzn84zNRdcvCd7VIAhGD35nX3A0JGl4A/epN KA1yvrFA3fFB25sV0vK1CUjuiJqqAAj9lJspqaqjRmKiQhXHEn78zSUvzfjXsfz8I34j tldw== X-Gm-Message-State: ABuFfohEL+Lgdi8+Sb6a1+kXlj8gakPxNA8XIBDiiFzyJNm4T8vaua4u 0pGl7bd/FKqmpTIoLoyCHEg= X-Google-Smtp-Source: ACcGV621bCwaQPh4oVbwyIsDtU1bOkmQsQQ0rYGz8/mWkl+dAA4CS00AULMcxOJOqUu90KhLwEHMvA== X-Received: by 2002:adf:dc4a:: with SMTP id m10-v6mr24318999wrj.84.1539214496173; Wed, 10 Oct 2018 16:34:56 -0700 (PDT) Received: from localhost.localdomain ([141.226.14.107]) by smtp.gmail.com with ESMTPSA id h2-v6sm21768484wrs.34.2018.10.10.16.34.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 16:34:55 -0700 (PDT) From: Amir Goldstein To: Cyril Hrubis Date: Thu, 11 Oct 2018 02:34:40 +0300 Message-Id: <20181010233441.5337-6-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181010233441.5337-1-amir73il@gmail.com> References: <20181010233441.5337-1-amir73il@gmail.com> X-Virus-Scanned: clamav-milter 0.99.2 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-6.smtp.seeweb.it Cc: linux-unionfs@vger.kernel.org, ltp@lists.linux.it, Miklos Szeredi Subject: [LTP] [PATCH v3 5/6] syscalls/readahead02: test readahead using posix_fadvise() X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" The call to posix_fadvise(POSIX_FADV_WILLNEED) should have the same effect as the call to readahead() syscall. Repeat the test cases for local file and overlayfs file with posix_fadvise(). The new test case is a regression test for kernel commit b833a3660394 ("ovl: add ovl_fadvise()") which fixes a regression of fadvise() on an overlay file that was introduced by kernel commit 5b910bd615ba ("ovl: fix GPF in swapfile_activate of file from overlayfs over xfs"). Signed-off-by: Amir Goldstein --- .../kernel/syscalls/readahead/readahead02.c | 41 +++++++++++++++---- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/testcases/kernel/syscalls/readahead/readahead02.c b/testcases/kernel/syscalls/readahead/readahead02.c index 56a8496ff..d5cc7677b 100644 --- a/testcases/kernel/syscalls/readahead/readahead02.c +++ b/testcases/kernel/syscalls/readahead/readahead02.c @@ -55,24 +55,49 @@ static struct tst_option options[] = { static struct tcase { const char *tname; int use_overlay; + int use_fadvise; } tcases[] = { - { "readahead on file", 0 }, - { "readahead on overlayfs file", 1 }, + { "readahead on file", 0, 0 }, + { "readahead on overlayfs file", 1, 0 }, + { "POSIX_FADV_WILLNEED on file", 0, 1 }, + { "POSIX_FADV_WILLNEED on overlayfs file", 1, 1 }, }; +static int fadvise_willneed(int fd, off_t offset, size_t len) +{ + /* Should have the same effect as readahead() syscall */ + return posix_fadvise(fd, offset, len, POSIX_FADV_WILLNEED); +} + +static int libc_readahead(int fd, off_t offset, size_t len) +{ + return readahead(fd, offset, len); +} + +typedef int (*readahead_func_t)(int, off_t, size_t); +static readahead_func_t readahead_func = libc_readahead; + static int readahead_supported = 1; +static int fadvise_supported = 1; static int check_ret(struct tcase *tc) { if (TST_RET == 0) return 0; - if (TST_ERR == EINVAL && - (!tc->use_overlay || !readahead_supported)) { + /* posix_fadvise returns error number (not in errno) */ + if (tc->use_fadvise && (TST_ERR = TST_RET) == EINVAL && + (!tc->use_overlay || !fadvise_supported)) { + fadvise_supported = 0; + tst_res(TCONF, "fadvise not supported on %s", + tst_device->fs_type); + } else if (TST_ERR == EINVAL && + (!tc->use_overlay || !readahead_supported)) { readahead_supported = 0; tst_res(TCONF, "readahead not supported on %s", tst_device->fs_type); } else { - tst_res(TFAIL | TTERRNO, "readahead failed on %s", + tst_res(TFAIL | TTERRNO, "%s failed on %s", + tc->use_fadvise ? "fadvise" : "readahead", tc->use_overlay ? "overlayfs" : tst_device->fs_type); } return 1; @@ -152,7 +177,6 @@ static void create_testfile(int use_overlay) free(tmp); } - /* read_testfile - mmap testfile and read every page. * This functions measures how many I/O and time it takes to fully * read contents of test file. @@ -182,7 +206,7 @@ static void read_testfile(int do_readahead, const char *fname, size_t fsize, if (do_readahead) { cached_start = get_cached_size(); do { - TEST(readahead(fd, offset, fsize - offset)); + TEST(readahead_func(fd, offset, fsize - offset)); if (TST_RET != 0) { SAFE_CLOSE(fd); return; @@ -264,6 +288,9 @@ static void test_readahead(unsigned int n) create_testfile(tc->use_overlay); + /* Use either readahead() syscall or POSIX_FADV_WILLNEED */ + readahead_func = tc->use_fadvise ? fadvise_willneed : libc_readahead; + /* find out how much can cache hold if we read whole file */ read_testfile(0, testfile, testfile_size, &read_bytes, &usec, &cached); cached_high = get_cached_size(); From patchwork Wed Oct 10 23:34:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 982147 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="YOslIeoL"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42Vr7Y2q3mz9s4Z for ; Thu, 11 Oct 2018 10:35:37 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 997363E70D2 for ; Thu, 11 Oct 2018 01:35:34 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) by picard.linux.it (Postfix) with ESMTP id 4714F3E70A5 for ; Thu, 11 Oct 2018 01:34:58 +0200 (CEST) Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id F3B2C1A006E5 for ; Thu, 11 Oct 2018 01:34:57 +0200 (CEST) Received: by mail-wr1-x441.google.com with SMTP id d2-v6so7555581wro.7 for ; Wed, 10 Oct 2018 16:34:57 -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:in-reply-to:references; bh=8JBysDH3gdIhIID7hbG0vNGcorVxBHvqkKAA5hy08ZQ=; b=YOslIeoLFYzBPaoH0oUIKnXwIm2I9W0RP+8Skgo/coRootw23Tkf+Yb6hG9cbrWGkU BN0JF+BPuBbt2ipj8SFMm1QYdMgNO6LcPar0ZvHOOw/GVJKtzsXo+700YFaCQ8WA7dE0 8p9vA1kQoptHWl3If5ZoPNrROVHYeLw+UcsYqqoc9Z8hqa69t/nQ7mReFXKpmCQQEh5p tszPiqaDk9gvcbnhS3+0S+6LVgsj/LojZSDYYY182u95B/MEfTWc2YmEmI9ZND+Z3ZRP tr4KiEnqPipxX5KL5iHtTYs7LGsWEoTCtuip2rELDjqHVQ8sbKMrfztr76StAlBEjXCn EMJA== 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=8JBysDH3gdIhIID7hbG0vNGcorVxBHvqkKAA5hy08ZQ=; b=bG1a12VyCH4Samj4S4/aSujMsHItQv9CxbMVLq//9oMH4YeaTF9l1wTkQkb9Ot7B/V hsxz2oxabucOF7RFlQBo47OG9a64gMUi09xx0EjfECbBJWm4WcVCR9gad1EMldAaWv7p 8TdCMjJajypcpnfUg2YjNnmpxt0V47F7rRTfpOijOdKqhjSVIzflc6TgnXkF1GctbN0Z s+3RnomAP/lnPp9H8xl3u2cmxVqQbn0zE6Tf4L1VEtfSRH5P6nF1QxVeBw0G4hKVg9RZ 4UN8N5T3f1qSEpmxoTc3bNAfmfY09WsIfSECVDRHv3AdKioZggcaDvuRlufG5u66XGmb onVg== X-Gm-Message-State: ABuFfohzzOLoqRiCWfRv9QQRYOTQ92vCsWSMQOz3tQLrU8fYlySDRKGC BCrD+r0LGrrUqa6ZOXKAIp4= X-Google-Smtp-Source: ACcGV60tLnlenb7tLppXQlRfjkQV6moblp4jm8RSJMKLlSfpwEU4qY+pHd4lk1ruPCgASmWF7HwRXA== X-Received: by 2002:a5d:61ca:: with SMTP id q10-v6mr22913925wrv.33.1539214497536; Wed, 10 Oct 2018 16:34:57 -0700 (PDT) Received: from localhost.localdomain ([141.226.14.107]) by smtp.gmail.com with ESMTPSA id h2-v6sm21768484wrs.34.2018.10.10.16.34.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 16:34:57 -0700 (PDT) From: Amir Goldstein To: Cyril Hrubis Date: Thu, 11 Oct 2018 02:34:41 +0300 Message-Id: <20181010233441.5337-7-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181010233441.5337-1-amir73il@gmail.com> References: <20181010233441.5337-1-amir73il@gmail.com> X-Virus-Scanned: clamav-milter 0.99.2 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-3.smtp.seeweb.it Cc: linux-unionfs@vger.kernel.org, ltp@lists.linux.it, Miklos Szeredi Subject: [LTP] [PATCH v3 6/6] syscalls/readahead02: fail test if readahead did not use any cache X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" The heuristic of failing the test only if not saving any io has false negatives with overlayfs readahead() bug, but readahead() with overlayfs always warns on "using less cache then expected", when actually, it is using no cache at all. Add another condition to fail the test if readahead did not use any cache at all, which always detected the overlayfs bug. Signed-off-by: Amir Goldstein Acked-by: Jan Stancek --- testcases/kernel/syscalls/readahead/readahead02.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testcases/kernel/syscalls/readahead/readahead02.c b/testcases/kernel/syscalls/readahead/readahead02.c index d5cc7677b..657461905 100644 --- a/testcases/kernel/syscalls/readahead/readahead02.c +++ b/testcases/kernel/syscalls/readahead/readahead02.c @@ -346,6 +346,8 @@ static void test_readahead(unsigned int n) */ if (cached_ra * 1024 > testfile_size / 2) tst_res(TPASS, "using cache as expected"); + else if (!cached_ra) + tst_res(TFAIL, "readahead failed to use any cache"); else tst_res(TWARN, "using less cache than expected"); } else {