From patchwork Wed Jun 13 10:52:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Stancek X-Patchwork-Id: 928800 X-Patchwork-Delegate: petr.vorel@gmail.com 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=redhat.com Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 415Nrg21lbz9s19 for ; Wed, 13 Jun 2018 20:53:07 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 1CC351B9D64 for ; Wed, 13 Jun 2018 12:53:02 +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 509371A96F2 for ; Wed, 13 Jun 2018 12:53:00 +0200 (CEST) Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 6417F1A01016 for ; Wed, 13 Jun 2018 12:52:58 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1E8AF859BA for ; Wed, 13 Jun 2018 10:52:57 +0000 (UTC) Received: from dustball.brq.redhat.com (unknown [10.43.17.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4C4C1C5B0 for ; Wed, 13 Jun 2018 10:52:56 +0000 (UTC) From: Jan Stancek To: ltp@lists.linux.it Date: Wed, 13 Jun 2018 12:52:48 +0200 Message-Id: <94d4c00514e5f57d488199e0aa146e342f5b4403.1528887039.git.jstancek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 13 Jun 2018 10:52:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 13 Jun 2018 10:52:57 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jstancek@redhat.com' RCPT:'' X-Virus-Scanned: clamav-milter 0.99.2 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_HELO_PASS,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 Subject: [LTP] [PATCH] readahead02: create loop device if TMPDIR is tmpfs 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" readahead doesn't work on tmpfs. Detect it and create loop device if necessary. After patch (4.16.0, /tmp if tmpfs): readahead02 0 TINFO : TMPFS detected, creating loop device readahead02 0 TINFO : Found free device '/dev/loop1' readahead02 0 TINFO : Formatting /dev/loop1 with ext2 opts='' extra opts='' mke2fs 1.43.6 (29-Aug-2017) readahead02 0 TINFO : creating test file of size: 67108864 readahead02 0 TINFO : read_testfile(0) readahead02 0 TINFO : read_testfile(1) readahead02 0 TINFO : max ra estimate: 1118208 readahead02 0 TINFO : readahead calls made: 61 readahead02 1 TPASS : offset is still at 0 as expected readahead02 0 TINFO : read_testfile(0) took: 25650 usec readahead02 0 TINFO : read_testfile(1) took: 17931 usec readahead02 0 TINFO : read_testfile(0) read: 67108864 bytes readahead02 0 TINFO : read_testfile(1) read: 0 bytes readahead02 2 TPASS : readahead saved some I/O readahead02 0 TINFO : cache can hold at least: 66516 kB readahead02 0 TINFO : read_testfile(0) used cache: 65156 kB readahead02 0 TINFO : read_testfile(1) used cache: 65156 kB readahead02 3 TPASS : using cache as expected Signed-off-by: Jan Stancek Reviewed-by: Petr Vorel --- This is follow-up to: https://github.com/linux-test-project/ltp/pull/307 testcases/kernel/syscalls/readahead/readahead02.c | 31 ++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/testcases/kernel/syscalls/readahead/readahead02.c b/testcases/kernel/syscalls/readahead/readahead02.c index 319dc91f5fda..c9d92a6a475c 100644 --- a/testcases/kernel/syscalls/readahead/readahead02.c +++ b/testcases/kernel/syscalls/readahead/readahead02.c @@ -51,14 +51,18 @@ char *TCID = "readahead02"; int TST_TOTAL = 1; #if defined(__NR_readahead) -static const char testfile[] = "testfile"; +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[] = { @@ -382,12 +386,37 @@ static void setup(void) ltp_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"); + } 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(); }