From patchwork Tue Apr 30 04:39:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Murphy Zhou X-Patchwork-Id: 1092960 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 ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44tTNT14Vdz9s70 for ; Tue, 30 Apr 2019 14:40:23 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id A4FF33EA0B8 for ; Tue, 30 Apr 2019 06:40:19 +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 [IPv6:2001:4b78:1:20::4]) by picard.linux.it (Postfix) with ESMTP id 4996B3EA0B8 for ; Tue, 30 Apr 2019 06:40:17 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id C92D61000AE1 for ; Tue, 30 Apr 2019 06:40:13 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 83A3130842B0; Tue, 30 Apr 2019 04:40:14 +0000 (UTC) Received: from localhost (dhcp-12-130.nay.redhat.com [10.66.12.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9938E75270; Tue, 30 Apr 2019 04:40:13 +0000 (UTC) From: Murphy Zhou To: ltp@lists.linux.it Date: Tue, 30 Apr 2019 12:39:57 +0800 Message-Id: <20190430043957.479-1-xzhou@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 30 Apr 2019 04:40:14 +0000 (UTC) X-Virus-Scanned: clamav-milter 0.99.2 at in-4.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-4.smtp.seeweb.it Subject: [LTP] [PATCH] OVL_MNT: put overlayfs lower, upper, work, mnt dir in separated mountpoint 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Some tests are mounting overlayfs internally and run tests on it. This mount can fail if the filesystem we are running on does not support overlay mount upon it. For example, we are already running tests on overlayfs or NFS, or CIFS. Test will report broken and failure. Fixing this by put overlayfs dirs in a separaed mountpoint, like readahead02 by Amir. Signed-off-by: Xiong Zhou Reviewed-by: Li Wang Acked-by: Petr Vorel --- .../kernel/syscalls/execveat/execveat03.c | 21 ++++++++++----- testcases/kernel/syscalls/inotify/inotify07.c | 24 +++++++++++------ testcases/kernel/syscalls/inotify/inotify08.c | 26 ++++++++++++------- 3 files changed, 48 insertions(+), 23 deletions(-) diff --git a/testcases/kernel/syscalls/execveat/execveat03.c b/testcases/kernel/syscalls/execveat/execveat03.c index def33923b..8ba6a656f 100644 --- a/testcases/kernel/syscalls/execveat/execveat03.c +++ b/testcases/kernel/syscalls/execveat/execveat03.c @@ -55,10 +55,17 @@ #include "lapi/fcntl.h" #include "execveat.h" -#define OVL_MNT "ovl" +#define MNTPOINT "mntpoint" +#define OVL_LOWER MNTPOINT"/lower" +#define OVL_UPPER MNTPOINT"/upper" +#define OVL_WORK MNTPOINT"/work" +#define OVL_MNT MNTPOINT"/ovl" + #define TEST_APP "execveat_child" #define TEST_FILE_PATH OVL_MNT"/"TEST_APP +static const char mntpoint[] = MNTPOINT; + static int ovl_mounted; static void do_child(void) @@ -91,12 +98,12 @@ static void setup(void) check_execveat(); /* Setup an overlay mount with lower file */ - SAFE_MKDIR("lower", 0755); - SAFE_MKDIR("upper", 0755); - SAFE_MKDIR("work", 0755); + 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=lower,upperdir=upper,workdir=work"); + ret = mount("overlay", OVL_MNT, "overlay", 0, "lowerdir="OVL_LOWER + ",upperdir="OVL_UPPER",workdir="OVL_WORK); if (ret < 0) { if (errno == ENODEV) { tst_brk(TCONF, @@ -121,6 +128,8 @@ static const char *const resource_files[] = { static struct tst_test test = { .needs_root = 1, .needs_tmpdir = 1, + .mount_device = 1, + .mntpoint = mntpoint, .forks_child = 1, .child_needs_reinit = 1, .setup = setup, diff --git a/testcases/kernel/syscalls/inotify/inotify07.c b/testcases/kernel/syscalls/inotify/inotify07.c index 96370b5cf..3e2d06485 100644 --- a/testcases/kernel/syscalls/inotify/inotify07.c +++ b/testcases/kernel/syscalls/inotify/inotify07.c @@ -73,13 +73,19 @@ struct event_t { unsigned int mask; }; -#define OVL_MNT "ovl" +#define MNTPOINT "mntpoint" +#define OVL_LOWER MNTPOINT"/lower" +#define OVL_UPPER MNTPOINT"/upper" +#define OVL_WORK MNTPOINT"/work" +#define OVL_MNT MNTPOINT"/ovl" + #define DIR_NAME "test_dir" #define DIR_PATH OVL_MNT"/"DIR_NAME #define FILE_NAME "test_file" #define FILE_PATH OVL_MNT"/"DIR_NAME"/"FILE_NAME static int ovl_mounted; +static const char mntpoint[] = MNTPOINT; static struct event_t event_set[EVENT_MAX]; @@ -164,14 +170,14 @@ static void setup(void) int ret; /* Setup an overlay mount with lower dir and file */ - SAFE_MKDIR("lower", 0755); - SAFE_MKDIR("lower/"DIR_NAME, 0755); - SAFE_TOUCH("lower/"DIR_NAME"/"FILE_NAME, 0644, NULL); - SAFE_MKDIR("upper", 0755); - SAFE_MKDIR("work", 0755); + SAFE_MKDIR(OVL_LOWER, 0755); + SAFE_MKDIR(OVL_LOWER"/"DIR_NAME, 0755); + SAFE_TOUCH(OVL_LOWER"/"DIR_NAME"/"FILE_NAME, 0644, NULL); + SAFE_MKDIR(OVL_UPPER, 0755); + SAFE_MKDIR(OVL_WORK, 0755); SAFE_MKDIR(OVL_MNT, 0755); - ret = mount("overlay", OVL_MNT, "overlay", 0, - "lowerdir=lower,upperdir=upper,workdir=work"); + ret = mount("overlay", OVL_MNT, "overlay", 0, "lowerdir="OVL_LOWER + ",upperdir="OVL_UPPER",workdir="OVL_WORK); if (ret < 0) { if (errno == ENODEV) { tst_brk(TCONF, @@ -234,6 +240,8 @@ static void cleanup(void) static struct tst_test test = { .needs_root = 1, .needs_tmpdir = 1, + .mount_device = 1, + .mntpoint = mntpoint, .setup = setup, .cleanup = cleanup, .test_all = verify_inotify, diff --git a/testcases/kernel/syscalls/inotify/inotify08.c b/testcases/kernel/syscalls/inotify/inotify08.c index acdb95345..a512dfe22 100644 --- a/testcases/kernel/syscalls/inotify/inotify08.c +++ b/testcases/kernel/syscalls/inotify/inotify08.c @@ -74,11 +74,17 @@ struct event_t { unsigned int mask; }; -#define OVL_MNT "ovl" +#define MNTPOINT "mntpoint" +#define OVL_LOWER MNTPOINT"/lower" +#define OVL_UPPER MNTPOINT"/upper" +#define OVL_WORK MNTPOINT"/work" +#define OVL_MNT MNTPOINT"/ovl" + #define FILE_NAME "test_file" #define FILE_PATH OVL_MNT"/"FILE_NAME static int ovl_mounted; +static const char mntpoint[] = MNTPOINT; static struct event_t event_set[EVENT_MAX]; @@ -104,8 +110,8 @@ void verify_inotify(void) test_cnt++; /* Make sure events on upper/lower do not show in overlay watch */ - SAFE_TOUCH("lower/"FILE_NAME, 0644, NULL); - SAFE_TOUCH("upper/"FILE_NAME, 0644, NULL); + SAFE_TOUCH(OVL_LOWER"/"FILE_NAME, 0644, NULL); + SAFE_TOUCH(OVL_LOWER"/"FILE_NAME, 0644, NULL); int len = read(fd_notify, event_buf, EVENT_BUF_LEN); if (len == -1 && errno != EAGAIN) { @@ -157,13 +163,13 @@ static void setup(void) int ret; /* Setup an overlay mount with lower file */ - SAFE_MKDIR("lower", 0755); - SAFE_TOUCH("lower/"FILE_NAME, 0644, NULL); - SAFE_MKDIR("upper", 0755); - SAFE_MKDIR("work", 0755); + SAFE_MKDIR(OVL_LOWER, 0755); + SAFE_TOUCH(OVL_LOWER"/"FILE_NAME, 0644, NULL); + SAFE_MKDIR(OVL_UPPER, 0755); + SAFE_MKDIR(OVL_WORK, 0755); SAFE_MKDIR(OVL_MNT, 0755); - ret = mount("overlay", OVL_MNT, "overlay", 0, - "lowerdir=lower,upperdir=upper,workdir=work"); + ret = mount("overlay", OVL_MNT, "overlay", 0, "lowerdir="OVL_LOWER + ",upperdir="OVL_UPPER",workdir="OVL_WORK); if (ret < 0) { if (errno == ENODEV) { tst_brk(TCONF, @@ -230,6 +236,8 @@ static void cleanup(void) static struct tst_test test = { .needs_root = 1, .needs_tmpdir = 1, + .mount_device = 1, + .mntpoint = mntpoint, .setup = setup, .cleanup = cleanup, .test_all = verify_inotify,