From patchwork Tue Jun 4 15:10:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 1109968 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=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="YV5RxoXX"; 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 45JFjp32WTz9s3l for ; Wed, 5 Jun 2019 01:10:51 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 953FE3EAB13 for ; Tue, 4 Jun 2019 17:10:44 +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 931893EAA54 for ; Tue, 4 Jun 2019 17:10:42 +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-5.smtp.seeweb.it (Postfix) with ESMTPS id 65432600710 for ; Tue, 4 Jun 2019 17:10:44 +0200 (CEST) Received: by mail-wr1-x441.google.com with SMTP id f9so1509860wre.12 for ; Tue, 04 Jun 2019 08:10:41 -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=CVe8GNIy/jQT2Xib23+VR1m07gUIdS0n/O8YMNvFuQU=; b=YV5RxoXXaXO3ffWGqNRG9787gKuJ4vqkGLKaBQSzDKk3614orRzvJXG9oE8mfj5zTa +mi6Pc5RtnhjUay9dHSScFM7FPwQ+1SFUUIJo/E1woWbb7ygGydVD1yCxpUVWbfxOpQY lYY4E8Ba1aPmqMeVFuyaPo/mKqWewpGAsVa1yqzwAkZKqHRWPfs4Juy2WIeSwfMniPt0 jvwqwipqQ+Zl7EeZ11CLwOZZUuWlhtM9FvbblLEm7GbcM13Tz744A28F9/SmxDSHP84Q cI6atxgu2lEUgl+D5Ibu4r8w4FUDSro/sL3DYULBWYrJwprcYxPIl5Mkw3ekhvmtrfMj gtfA== 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=CVe8GNIy/jQT2Xib23+VR1m07gUIdS0n/O8YMNvFuQU=; b=GQnnAK5Wb55RWqOzGcH39ofhAoIR1BxRklmC0kYtJvImoM31P2JVScyyUiwsCZsnXh SLZnh664vuCPQWUJCANfqxnXXMHq63+yD8Tv+6I330hj7h/wJkjrU55VK3JTtL7wWNGS cgQ8qe5IkMmfJUrDEiqPF0mVifjIhjAoNJ1drvpsjkkCygC36ql3SJ34ajANgCY9Z7tO XwTMmtpPiw1yY8ykgqsCygN7ro4yjz003BajMw5aTJeDqVBQaa3lj0Vx38Z3nE2Rqz1m j1AL+dQOF56PNHHt6gxJi6eDFoMQlXbMOQRsf8z10fPahEr1rB/KFU0kWZPpoZv9Po1q amfg== X-Gm-Message-State: APjAAAWglp3udHNOTxmoJjFCmLFTNjx4t+yBH8HN4RX06DLbyumPHx/s B03zPUnlE9abbKPKaHh/60Q= X-Google-Smtp-Source: APXvYqyQxF4n08JLQREYaGKaXOmoa21LoiTQNR4fiDJ1Li0myH8dw3ML6w7yb3PkmrU2GRg41Ey7vQ== X-Received: by 2002:adf:c5c1:: with SMTP id v1mr3636700wrg.129.1559661041439; Tue, 04 Jun 2019 08:10:41 -0700 (PDT) Received: from localhost.localdomain (p548C66C4.dip0.t-ipconnect.de. [84.140.102.196]) by smtp.gmail.com with ESMTPSA id l7sm9077326wmh.20.2019.06.04.08.10.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jun 2019 08:10:40 -0700 (PDT) From: Amir Goldstein To: Petr Vorel Date: Tue, 4 Jun 2019 18:10:34 +0300 Message-Id: <20190604151035.6123-1-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 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_HELO_NONE, 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: Jan Kara , Miklos Szeredi , linux-unionfs@vger.kernel.org, ltp@lists.linux.it Subject: [LTP] [PATCH v2 1/2] fanotify06: add a test case for overlayfs 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" This test fails on overlayfs since kernel v4.19. Added a test case for overlayfs mount. Signed-off-by: Amir Goldstein --- Changes since v1: - Use new overlayfs mount helpers - Add patch to fix EBUSY error on overlayfs umount .../kernel/syscalls/fanotify/fanotify06.c | 61 +++++++++++++------ 1 file changed, 43 insertions(+), 18 deletions(-) diff --git a/testcases/kernel/syscalls/fanotify/fanotify06.c b/testcases/kernel/syscalls/fanotify/fanotify06.c index 6a2e2494f..e053da0e5 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify06.c +++ b/testcases/kernel/syscalls/fanotify/fanotify06.c @@ -15,6 +15,14 @@ * Date: Thu Nov 13 15:19:33 2014 -0800 * * fanotify: fix notification of groups with inode & mount marks + * + * The overlayfs test case is a regression test for: + * + * commit d989903058a83e8536cc7aadf9256a47d5c173fe + * Author: Amir Goldstein + * Date: Wed Apr 24 19:39:50 2019 +0300 + * + * ovl: do not generate duplicate fsnotify events for "fake" path */ #define _GNU_SOURCE #include "config.h" @@ -54,8 +62,18 @@ static int fd_notify[FANOTIFY_PRIORITIES][GROUPS_PER_PRIO]; static char event_buf[EVENT_BUF_LEN]; -#define MOUNT_NAME "mntpoint" -static int mount_created; +static const char mntpoint[] = OVL_BASE_MNTPOINT; + +static int ovl_mounted; + +static struct tcase { + const char *tname; + const char *mnt; + int use_overlay; +} tcases[] = { + { "Fanotify merge mount mark", mntpoint, 0 }, + { "Fanotify merge overlayfs mount mark", OVL_MNT, 1 }, +}; static void create_fanotify_groups(void) { @@ -72,12 +90,12 @@ static void create_fanotify_groups(void) ret = fanotify_mark(fd_notify[p][i], FAN_MARK_ADD | FAN_MARK_MOUNT, FAN_MODIFY, - AT_FDCWD, "."); + AT_FDCWD, fname); if (ret < 0) { tst_brk(TBROK | TERRNO, "fanotify_mark(%d, FAN_MARK_ADD | " "FAN_MARK_MOUNT, FAN_MODIFY, AT_FDCWD," - " '.') failed", fd_notify[p][i]); + " %s) failed", fd_notify[p][i], fname); } /* Add ignore mark for groups with higher priority */ if (p == 0) @@ -130,11 +148,23 @@ static void verify_event(int group, struct fanotify_event_metadata *event) } } -void test01(void) +void test_fanotify(unsigned int n) { int ret; unsigned int p, i; struct fanotify_event_metadata *event; + struct tcase *tc = &tcases[n]; + + tst_res(TINFO, "Test #%d: %s", n, tc->tname); + + if (tc->use_overlay && !ovl_mounted) { + tst_res(TCONF, + "overlayfs is not configured in this kernel."); + return; + } + + sprintf(fname, "%s/tfile_%d", tc->mnt, getpid()); + SAFE_TOUCH(fname, 0644, NULL); create_fanotify_groups(); @@ -196,31 +226,26 @@ void test01(void) static void setup(void) { - SAFE_MKDIR(MOUNT_NAME, 0755); - SAFE_MOUNT(MOUNT_NAME, MOUNT_NAME, "none", MS_BIND, NULL); - mount_created = 1; - SAFE_CHDIR(MOUNT_NAME); - - sprintf(fname, "tfile_%d", getpid()); - SAFE_FILE_PRINTF(fname, "1"); + ovl_mounted = TST_MOUNT_OVERLAY(); } static void cleanup(void) { cleanup_fanotify_groups(); - SAFE_CHDIR("../"); - - if (mount_created && tst_umount(MOUNT_NAME) < 0) - tst_brk(TBROK | TERRNO, "umount failed"); + if (ovl_mounted) + SAFE_UMOUNT(OVL_MNT); } static struct tst_test test = { - .test_all = test01, + .test = test_fanotify, + .tcnt = ARRAY_SIZE(tcases), .setup = setup, .cleanup = cleanup, .needs_tmpdir = 1, - .needs_root = 1 + .needs_root = 1, + .mount_device = 1, + .mntpoint = mntpoint, }; #else From patchwork Tue Jun 4 15:10:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 1109969 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=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="by4JaETl"; 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 45JFjs25Bpz9s3l for ; Wed, 5 Jun 2019 01:10:56 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 616513EAB95 for ; Tue, 4 Jun 2019 17:10:49 +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 9B4763EAA54 for ; Tue, 4 Jun 2019 17:10:43 +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-5.smtp.seeweb.it (Postfix) with ESMTPS id ACB0160071D for ; Tue, 4 Jun 2019 17:10:45 +0200 (CEST) Received: by mail-wm1-x341.google.com with SMTP id d17so445424wmb.3 for ; Tue, 04 Jun 2019 08:10:43 -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=cd0jL1l37AnAOITWAtpWiSM2eipoS5jrsZBNVNTYX+Y=; b=by4JaETlUxK8Sj9bFkvoi3uSw1FzFALFVuZ6ZhcaO1IaDAWVoYYXdcyqjV6oxKHydJ 7oYR74yw8/jy3ZI/jmJM3esmrz4+Ga0s4cUX5oYA5hue8pN/KMo9/T+jIio075E7g/M0 m0RaDsD+hverwxYkoNmaWfrKlNEGPIG7wRqY+gn/yfgzqvz8mGsnPnpg3sWofoj3f+dE KHwZxv8fIM0FufqVCztUJ1hDE6J91XHmSohxw2w99y9daSuJRwGHLGSjq9gXgzJdNrCF rjpy4SR/KJPMjcTmwjT2I6HaDEkkdNArJun+k4ttKMHRs4T4Rw/0+jDaoRsZl19xXRPc ZGJA== 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=cd0jL1l37AnAOITWAtpWiSM2eipoS5jrsZBNVNTYX+Y=; b=rk7S19lK59ac+t92vh7+mIW2j1ZpUJcaBdgneX9RIPuJHZDkqE77+K9tbPmKx+gJ9Y Yl+VeyTD2ngaFhrJZ1EHe491RGzd6DbwtYsr3ddzCj9kOKScwooc19P55WQFRdQFf23z kTV5Wl5eKHF3IWkSfzZTDALfruFxot8bLXK+c42uoaAxf3iXUGoARiIEe1EZEH0OpT5D BDWvpwANU9fQZkjDZHQZBpJ1Yjd5Y388h44uDUCjeR/TvWvPwe4c1SefrDcoYIo5LzMB 9VFTbAsb/DnYhJLmnbm3i4YViQ+uG+fIxWwGTdK0XB0Eotelee0efERZKqzUyyl+zkbd WRzg== X-Gm-Message-State: APjAAAV8SPYi5pK+Be/VZ2hrRmfhUAD8HdnegtcOQtcsz9FOBq3pVqM1 MA5EGAzQVw3ZEJc/v2wveF8= X-Google-Smtp-Source: APXvYqzoS/F608X6NNxHUoRRU3U0zMg5YiNwbZPvcZGzR8gnpSKhAL2mhiJPhhiZAemkXoBv4RgvvQ== X-Received: by 2002:a1c:f901:: with SMTP id x1mr6430198wmh.157.1559661042766; Tue, 04 Jun 2019 08:10:42 -0700 (PDT) Received: from localhost.localdomain (p548C66C4.dip0.t-ipconnect.de. [84.140.102.196]) by smtp.gmail.com with ESMTPSA id l7sm9077326wmh.20.2019.06.04.08.10.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jun 2019 08:10:42 -0700 (PDT) From: Amir Goldstein To: Petr Vorel Date: Tue, 4 Jun 2019 18:10:35 +0300 Message-Id: <20190604151035.6123-2-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190604151035.6123-1-amir73il@gmail.com> References: <20190604151035.6123-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_HELO_NONE, 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: Jan Kara , Miklos Szeredi , linux-unionfs@vger.kernel.org, ltp@lists.linux.it Subject: [LTP] [PATCH v2 2/2] fanotify06: Close all file descriptors of read events 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" With overlayfs test case on kernel v4.19, we get extra events. If we do not close the event->fd file descriptros of all the events that we read, overlayfs will fail to unmount at the end of the test and test will retry un-mounting for a while. Signed-off-by: Amir Goldstein --- .../kernel/syscalls/fanotify/fanotify06.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/testcases/kernel/syscalls/fanotify/fanotify06.c b/testcases/kernel/syscalls/fanotify/fanotify06.c index e053da0e5..273c1f0c4 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify06.c +++ b/testcases/kernel/syscalls/fanotify/fanotify06.c @@ -148,6 +148,17 @@ static void verify_event(int group, struct fanotify_event_metadata *event) } } +/* Close all file descriptors of read events */ +static void close_events_fd(struct fanotify_event_metadata *event, int buflen) +{ + while (buflen >= (int)FAN_EVENT_METADATA_LEN) { + if (event->fd != FAN_NOFD) + SAFE_CLOSE(event->fd); + buflen -= (int)FAN_EVENT_METADATA_LEN; + event++; + } +} + void test_fanotify(unsigned int n) { int ret; @@ -198,17 +209,16 @@ void test_fanotify(unsigned int n) } else { verify_event(i, event); } - if (event->fd != FAN_NOFD) - SAFE_CLOSE(event->fd); + close_events_fd(event, ret); } + for (p = 1; p < FANOTIFY_PRIORITIES; p++) { for (i = 0; i < GROUPS_PER_PRIO; i++) { ret = read(fd_notify[p][i], event_buf, EVENT_BUF_LEN); if (ret > 0) { tst_res(TFAIL, "group %d got event", p*GROUPS_PER_PRIO + i); - if (event->fd != FAN_NOFD) - SAFE_CLOSE(event->fd); + close_events_fd((void *)event_buf, ret); } else if (ret == 0) { tst_brk(TBROK, "zero length " "read from fanotify fd");