* [LTP] [PATCH] fanotify06: add a test case for overlayfs
@ 2019-04-24 8:53 Amir Goldstein
2019-04-24 8:55 ` [LTP] " Amir Goldstein
0 siblings, 1 reply; 7+ messages in thread
From: Amir Goldstein @ 2019-04-24 8:53 UTC (permalink / raw)
To: ltp
This test fails on overlayfs since kernel v4.19.
Added a test case for overlayfs mount.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
Hi Cyril,
The new test case covers a bug reported by Murphy Zhou:
https://lore.kernel.org/linux-fsdevel/20190423065024.12695-1-jencce.kernel@gmail.com/
Once again, I tried looking at making overlayfs test variant generic.
Once again, I gave it up.
Thanks,
Amir.
.../kernel/syscalls/fanotify/fanotify06.c | 74 +++++++++++++++----
1 file changed, 61 insertions(+), 13 deletions(-)
diff --git a/testcases/kernel/syscalls/fanotify/fanotify06.c b/testcases/kernel/syscalls/fanotify/fanotify06.c
index 6a2e2494f..62defb23c 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify06.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify06.c
@@ -54,8 +54,23 @@ static int fd_notify[FANOTIFY_PRIORITIES][GROUPS_PER_PRIO];
static char event_buf[EVENT_BUF_LEN];
-#define MOUNT_NAME "mntpoint"
+#define MNTPOINT "mntpoint"
+#define OVL_LOWER "ovl-lower"
+#define OVL_UPPER "ovl-upper"
+#define OVL_WORK "ovl-work"
+#define OVL_MNT "ovl-mnt"
+
static int mount_created;
+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 +87,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 +145,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();
@@ -194,29 +221,50 @@ void test01(void)
cleanup_fanotify_groups();
}
+static void setup_overlay(void)
+{
+ int ret;
+
+ 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)
{
- SAFE_MKDIR(MOUNT_NAME, 0755);
- SAFE_MOUNT(MOUNT_NAME, MOUNT_NAME, "none", MS_BIND, NULL);
+ SAFE_MKDIR(MNTPOINT, 0755);
+ SAFE_MOUNT(MNTPOINT, MNTPOINT, "none", MS_BIND, NULL);
mount_created = 1;
- SAFE_CHDIR(MOUNT_NAME);
- sprintf(fname, "tfile_%d", getpid());
- SAFE_FILE_PRINTF(fname, "1");
+ setup_overlay();
}
static void cleanup(void)
{
cleanup_fanotify_groups();
- SAFE_CHDIR("../");
+ if (ovl_mounted)
+ SAFE_UMOUNT(OVL_MNT);
- if (mount_created && tst_umount(MOUNT_NAME) < 0)
- tst_brk(TBROK | TERRNO, "umount failed");
+ if (mount_created)
+ SAFE_UMOUNT(MNTPOINT);
}
static struct tst_test test = {
- .test_all = test01,
+ .test = test_fanotify,
+ .tcnt = ARRAY_SIZE(tcases),
.setup = setup,
.cleanup = cleanup,
.needs_tmpdir = 1,
--
2.17.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] fanotify06: add a test case for overlayfs
2019-04-24 8:53 [LTP] [PATCH] fanotify06: add a test case for overlayfs Amir Goldstein
@ 2019-04-24 8:55 ` Amir Goldstein
0 siblings, 0 replies; 7+ messages in thread
From: Amir Goldstein @ 2019-04-24 8:55 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: Murphy Zhou, ltp, Jan Kara, overlayfs
CC: <linux-unionfs@vger.kernel.org>
On Wed, Apr 24, 2019 at 11:53 AM Amir Goldstein <amir73il@gmail.com> wrote:
>
> This test fails on overlayfs since kernel v4.19.
> Added a test case for overlayfs mount.
>
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
>
> Hi Cyril,
>
> The new test case covers a bug reported by Murphy Zhou:
> https://lore.kernel.org/linux-fsdevel/20190423065024.12695-1-jencce.kernel@gmail.com/
>
> Once again, I tried looking at making overlayfs test variant generic.
> Once again, I gave it up.
>
> Thanks,
> Amir.
>
> .../kernel/syscalls/fanotify/fanotify06.c | 74 +++++++++++++++----
> 1 file changed, 61 insertions(+), 13 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/fanotify/fanotify06.c b/testcases/kernel/syscalls/fanotify/fanotify06.c
> index 6a2e2494f..62defb23c 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify06.c
> +++ b/testcases/kernel/syscalls/fanotify/fanotify06.c
> @@ -54,8 +54,23 @@ static int fd_notify[FANOTIFY_PRIORITIES][GROUPS_PER_PRIO];
>
> static char event_buf[EVENT_BUF_LEN];
>
> -#define MOUNT_NAME "mntpoint"
> +#define MNTPOINT "mntpoint"
> +#define OVL_LOWER "ovl-lower"
> +#define OVL_UPPER "ovl-upper"
> +#define OVL_WORK "ovl-work"
> +#define OVL_MNT "ovl-mnt"
> +
> static int mount_created;
> +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 +87,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 +145,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();
>
> @@ -194,29 +221,50 @@ void test01(void)
> cleanup_fanotify_groups();
> }
>
> +static void setup_overlay(void)
> +{
> + int ret;
> +
> + 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)
> {
> - SAFE_MKDIR(MOUNT_NAME, 0755);
> - SAFE_MOUNT(MOUNT_NAME, MOUNT_NAME, "none", MS_BIND, NULL);
> + SAFE_MKDIR(MNTPOINT, 0755);
> + SAFE_MOUNT(MNTPOINT, MNTPOINT, "none", MS_BIND, NULL);
> mount_created = 1;
> - SAFE_CHDIR(MOUNT_NAME);
>
> - sprintf(fname, "tfile_%d", getpid());
> - SAFE_FILE_PRINTF(fname, "1");
> + setup_overlay();
> }
>
> static void cleanup(void)
> {
> cleanup_fanotify_groups();
>
> - SAFE_CHDIR("../");
> + if (ovl_mounted)
> + SAFE_UMOUNT(OVL_MNT);
>
> - if (mount_created && tst_umount(MOUNT_NAME) < 0)
> - tst_brk(TBROK | TERRNO, "umount failed");
> + if (mount_created)
> + SAFE_UMOUNT(MNTPOINT);
> }
>
> static struct tst_test test = {
> - .test_all = test01,
> + .test = test_fanotify,
> + .tcnt = ARRAY_SIZE(tcases),
> .setup = setup,
> .cleanup = cleanup,
> .needs_tmpdir = 1,
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [LTP] [PATCH] fanotify06: add a test case for overlayfs
@ 2019-04-24 8:55 ` Amir Goldstein
0 siblings, 0 replies; 7+ messages in thread
From: Amir Goldstein @ 2019-04-24 8:55 UTC (permalink / raw)
To: ltp
CC: <linux-unionfs@vger.kernel.org>
On Wed, Apr 24, 2019 at 11:53 AM Amir Goldstein <amir73il@gmail.com> wrote:
>
> This test fails on overlayfs since kernel v4.19.
> Added a test case for overlayfs mount.
>
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
>
> Hi Cyril,
>
> The new test case covers a bug reported by Murphy Zhou:
> https://lore.kernel.org/linux-fsdevel/20190423065024.12695-1-jencce.kernel@gmail.com/
>
> Once again, I tried looking at making overlayfs test variant generic.
> Once again, I gave it up.
>
> Thanks,
> Amir.
>
> .../kernel/syscalls/fanotify/fanotify06.c | 74 +++++++++++++++----
> 1 file changed, 61 insertions(+), 13 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/fanotify/fanotify06.c b/testcases/kernel/syscalls/fanotify/fanotify06.c
> index 6a2e2494f..62defb23c 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify06.c
> +++ b/testcases/kernel/syscalls/fanotify/fanotify06.c
> @@ -54,8 +54,23 @@ static int fd_notify[FANOTIFY_PRIORITIES][GROUPS_PER_PRIO];
>
> static char event_buf[EVENT_BUF_LEN];
>
> -#define MOUNT_NAME "mntpoint"
> +#define MNTPOINT "mntpoint"
> +#define OVL_LOWER "ovl-lower"
> +#define OVL_UPPER "ovl-upper"
> +#define OVL_WORK "ovl-work"
> +#define OVL_MNT "ovl-mnt"
> +
> static int mount_created;
> +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 +87,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 +145,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();
>
> @@ -194,29 +221,50 @@ void test01(void)
> cleanup_fanotify_groups();
> }
>
> +static void setup_overlay(void)
> +{
> + int ret;
> +
> + 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)
> {
> - SAFE_MKDIR(MOUNT_NAME, 0755);
> - SAFE_MOUNT(MOUNT_NAME, MOUNT_NAME, "none", MS_BIND, NULL);
> + SAFE_MKDIR(MNTPOINT, 0755);
> + SAFE_MOUNT(MNTPOINT, MNTPOINT, "none", MS_BIND, NULL);
> mount_created = 1;
> - SAFE_CHDIR(MOUNT_NAME);
>
> - sprintf(fname, "tfile_%d", getpid());
> - SAFE_FILE_PRINTF(fname, "1");
> + setup_overlay();
> }
>
> static void cleanup(void)
> {
> cleanup_fanotify_groups();
>
> - SAFE_CHDIR("../");
> + if (ovl_mounted)
> + SAFE_UMOUNT(OVL_MNT);
>
> - if (mount_created && tst_umount(MOUNT_NAME) < 0)
> - tst_brk(TBROK | TERRNO, "umount failed");
> + if (mount_created)
> + SAFE_UMOUNT(MNTPOINT);
> }
>
> static struct tst_test test = {
> - .test_all = test01,
> + .test = test_fanotify,
> + .tcnt = ARRAY_SIZE(tcases),
> .setup = setup,
> .cleanup = cleanup,
> .needs_tmpdir = 1,
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [LTP] [PATCH] fanotify06: add a test case for overlayfs
2019-04-24 8:55 ` [LTP] " Amir Goldstein
@ 2019-04-30 14:33 ` Petr Vorel
-1 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2019-04-30 14:33 UTC (permalink / raw)
To: Amir Goldstein; +Cc: Cyril Hrubis, Murphy Zhou, Jan Kara, overlayfs, ltp
Hi Amir,
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Thanks for your patch!
Kind regards,
Petr
^ permalink raw reply [flat|nested] 7+ messages in thread
* [LTP] [PATCH] fanotify06: add a test case for overlayfs
2019-04-24 8:55 ` [LTP] " Amir Goldstein
(?)
(?)
@ 2019-06-03 14:18 ` Petr Vorel
2019-06-03 16:07 ` Amir Goldstein
-1 siblings, 1 reply; 7+ messages in thread
From: Petr Vorel @ 2019-06-03 14:18 UTC (permalink / raw)
To: ltp
Hi Amir,
...
> > diff --git a/testcases/kernel/syscalls/fanotify/fanotify06.c b/testcases/kernel/syscalls/fanotify/fanotify06.c
> > index 6a2e2494f..62defb23c 100644
> > --- a/testcases/kernel/syscalls/fanotify/fanotify06.c
> > +++ b/testcases/kernel/syscalls/fanotify/fanotify06.c
> > @@ -54,8 +54,23 @@ static int fd_notify[FANOTIFY_PRIORITIES][GROUPS_PER_PRIO];
> > static char event_buf[EVENT_BUF_LEN];
> > -#define MOUNT_NAME "mntpoint"
> > +#define MNTPOINT "mntpoint"
> > +#define OVL_LOWER "ovl-lower"
> > +#define OVL_UPPER "ovl-upper"
> > +#define OVL_WORK "ovl-work"
> > +#define OVL_MNT "ovl-mnt"
I guess you're going to send v2 with {SAFE,TST}_MOUNT_OVERLAY() or .needs_overlay usage from library.
...
Kind regards,
Petr
^ permalink raw reply [flat|nested] 7+ messages in thread
* [LTP] [PATCH] fanotify06: add a test case for overlayfs
2019-06-03 14:18 ` Petr Vorel
@ 2019-06-03 16:07 ` Amir Goldstein
0 siblings, 0 replies; 7+ messages in thread
From: Amir Goldstein @ 2019-06-03 16:07 UTC (permalink / raw)
To: ltp
On Mon, Jun 3, 2019 at 5:18 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi Amir,
>
> ...
> > > diff --git a/testcases/kernel/syscalls/fanotify/fanotify06.c b/testcases/kernel/syscalls/fanotify/fanotify06.c
> > > index 6a2e2494f..62defb23c 100644
> > > --- a/testcases/kernel/syscalls/fanotify/fanotify06.c
> > > +++ b/testcases/kernel/syscalls/fanotify/fanotify06.c
> > > @@ -54,8 +54,23 @@ static int fd_notify[FANOTIFY_PRIORITIES][GROUPS_PER_PRIO];
>
> > > static char event_buf[EVENT_BUF_LEN];
>
> > > -#define MOUNT_NAME "mntpoint"
> > > +#define MNTPOINT "mntpoint"
> > > +#define OVL_LOWER "ovl-lower"
> > > +#define OVL_UPPER "ovl-upper"
> > > +#define OVL_WORK "ovl-work"
> > > +#define OVL_MNT "ovl-mnt"
> I guess you're going to send v2 with {SAFE,TST}_MOUNT_OVERLAY() or .needs_overlay usage from library.
Sure. I'll find a time to do that.
Thanks,
Amir.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-06-03 16:07 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24 8:53 [LTP] [PATCH] fanotify06: add a test case for overlayfs Amir Goldstein
2019-04-24 8:55 ` Amir Goldstein
2019-04-24 8:55 ` [LTP] " Amir Goldstein
2019-04-30 14:33 ` Petr Vorel
2019-04-30 14:33 ` Petr Vorel
2019-06-03 14:18 ` Petr Vorel
2019-06-03 16:07 ` Amir Goldstein
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.