* [LTP] [PATCH v2] fanotify/fanotify04: Bugfix for running with option of "-i 500"
@ 2022-02-09 8:05 Zhao Gongyi via ltp
2022-02-09 8:19 ` Petr Vorel
2022-02-09 11:23 ` Jan Kara
0 siblings, 2 replies; 4+ messages in thread
From: Zhao Gongyi via ltp @ 2022-02-09 8:05 UTC (permalink / raw)
To: ltp; +Cc: jack
When we running the testcase with option of "-i 500", the test
will fail:
...
fanotify04.c:163: TPASS: No event as expected
fanotify04.c:71: TPASS: fanotify_mark (3, FAN_MARK_ADD | 0, FAN_OPEN, AT_FDCWD, 'symlink_160172') succeeded
fanotify04.c:127: TPASS: event generated properly for type 100000
fanotify04.c:113: TBROK: read(3,0x55c783185280,0) failed, returned -1: EINVAL (22)
...
Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
v1->v2: Clear the compile warnings.
.../kernel/syscalls/fanotify/fanotify04.c | 21 ++++++-------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/testcases/kernel/syscalls/fanotify/fanotify04.c b/testcases/kernel/syscalls/fanotify/fanotify04.c
index b23d7a9a3..8c3c179b1 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify04.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify04.c
@@ -24,11 +24,8 @@
#ifdef HAVE_SYS_FANOTIFY_H
#include "fanotify.h"
-#define EVENT_MAX 1024
/* size of the event structure, not counting name */
#define EVENT_SIZE (sizeof (struct fanotify_event_metadata))
-/* reasonable guess as to size of 1024 events */
-#define EVENT_BUF_LEN (EVENT_MAX * EVENT_SIZE)
#define BUF_SIZE 256
#define TST_TOTAL 9
@@ -37,9 +34,7 @@ static char fname[BUF_SIZE];
static char sname[BUF_SIZE];
static char dir[BUF_SIZE];
static int fd_notify;
-
-static int len;
-static char event_buf[EVENT_BUF_LEN];
+static char event_buf[EVENT_SIZE];
static char *expect_str_fail(int expect)
{
@@ -104,16 +99,12 @@ static void open_dir(char *file)
static void verify_event(int mask)
{
- int ret;
struct fanotify_event_metadata *event;
struct stat st;
/* Read the event */
- ret = SAFE_READ(0, fd_notify, event_buf + len,
- EVENT_BUF_LEN - len);
- event = (struct fanotify_event_metadata *)&event_buf[len];
- len += ret;
-
+ SAFE_READ(0, fd_notify, event_buf, EVENT_SIZE);
+ event = (struct fanotify_event_metadata *)&event_buf;
if (event->mask != FAN_OPEN) {
tst_res(TFAIL, "got unexpected event %llx",
(unsigned long long)event->mask);
@@ -146,11 +137,11 @@ static void verify_no_event(void)
{
int ret;
- ret = read(fd_notify, event_buf + len, EVENT_BUF_LEN - len);
+ ret = read(fd_notify, event_buf, EVENT_SIZE);
if (ret != -1) {
struct fanotify_event_metadata *event;
- event = (struct fanotify_event_metadata *)&event_buf[len];
+ event = (struct fanotify_event_metadata *)&event_buf;
tst_res(TFAIL, "seen unexpected event (mask %llx)",
(unsigned long long)event->mask);
/* Cleanup fd from the event */
@@ -158,7 +149,7 @@ static void verify_no_event(void)
SAFE_CLOSE(event->fd);
} else if (errno != EAGAIN) {
tst_res(TFAIL | TERRNO, "read(%d, buf, %zu) failed", fd_notify,
- EVENT_BUF_LEN);
+ EVENT_SIZE);
} else {
tst_res(TPASS, "No event as expected");
}
--
2.17.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [LTP] [PATCH v2] fanotify/fanotify04: Bugfix for running with option of "-i 500"
2022-02-09 8:05 [LTP] [PATCH v2] fanotify/fanotify04: Bugfix for running with option of "-i 500" Zhao Gongyi via ltp
@ 2022-02-09 8:19 ` Petr Vorel
2022-02-09 11:23 ` Jan Kara
1 sibling, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2022-02-09 8:19 UTC (permalink / raw)
To: Zhao Gongyi; +Cc: Matthew Bobrowski, Jan Kara, ltp
Hi Zhao,
> When we running the testcase with option of "-i 500", the test
> will fail:
> ...
> fanotify04.c:163: TPASS: No event as expected
> fanotify04.c:71: TPASS: fanotify_mark (3, FAN_MARK_ADD | 0, FAN_OPEN, AT_FDCWD, 'symlink_160172') succeeded
> fanotify04.c:127: TPASS: event generated properly for type 100000
> fanotify04.c:113: TBROK: read(3,0x55c783185280,0) failed, returned -1: EINVAL (22)
> ...
[ Cc: kernel also Amir and Matthew ]
https://lore.kernel.org/ltp/20220209080510.167709-1-zhaogongyi@huawei.com/T/#u
Reviewed-by: Petr Vorel <pvorel@suse.cz>
LGTM, works as expected, I don't see any performance impact.
Also don't think buffer containing all events was important for testing and can
be replaced with buffer for just single event. But please correct me if I'm
wrong.
> Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
> ---
> v1->v2: Clear the compile warnings.
Thanks! I was going to send a diff, not only because the warnings, but also
patch didn't apply.
Kind regards,
Petr
> .../kernel/syscalls/fanotify/fanotify04.c | 21 ++++++-------------
> 1 file changed, 6 insertions(+), 15 deletions(-)
> diff --git a/testcases/kernel/syscalls/fanotify/fanotify04.c b/testcases/kernel/syscalls/fanotify/fanotify04.c
> index b23d7a9a3..8c3c179b1 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify04.c
> +++ b/testcases/kernel/syscalls/fanotify/fanotify04.c
> @@ -24,11 +24,8 @@
> #ifdef HAVE_SYS_FANOTIFY_H
> #include "fanotify.h"
> -#define EVENT_MAX 1024
> /* size of the event structure, not counting name */
> #define EVENT_SIZE (sizeof (struct fanotify_event_metadata))
> -/* reasonable guess as to size of 1024 events */
> -#define EVENT_BUF_LEN (EVENT_MAX * EVENT_SIZE)
> #define BUF_SIZE 256
> #define TST_TOTAL 9
> @@ -37,9 +34,7 @@ static char fname[BUF_SIZE];
> static char sname[BUF_SIZE];
> static char dir[BUF_SIZE];
> static int fd_notify;
> -
> -static int len;
> -static char event_buf[EVENT_BUF_LEN];
> +static char event_buf[EVENT_SIZE];
> static char *expect_str_fail(int expect)
> {
> @@ -104,16 +99,12 @@ static void open_dir(char *file)
> static void verify_event(int mask)
> {
> - int ret;
> struct fanotify_event_metadata *event;
> struct stat st;
> /* Read the event */
> - ret = SAFE_READ(0, fd_notify, event_buf + len,
> - EVENT_BUF_LEN - len);
> - event = (struct fanotify_event_metadata *)&event_buf[len];
> - len += ret;
> -
> + SAFE_READ(0, fd_notify, event_buf, EVENT_SIZE);
> + event = (struct fanotify_event_metadata *)&event_buf;
> if (event->mask != FAN_OPEN) {
> tst_res(TFAIL, "got unexpected event %llx",
> (unsigned long long)event->mask);
> @@ -146,11 +137,11 @@ static void verify_no_event(void)
> {
> int ret;
> - ret = read(fd_notify, event_buf + len, EVENT_BUF_LEN - len);
> + ret = read(fd_notify, event_buf, EVENT_SIZE);
> if (ret != -1) {
> struct fanotify_event_metadata *event;
> - event = (struct fanotify_event_metadata *)&event_buf[len];
> + event = (struct fanotify_event_metadata *)&event_buf;
> tst_res(TFAIL, "seen unexpected event (mask %llx)",
> (unsigned long long)event->mask);
> /* Cleanup fd from the event */
> @@ -158,7 +149,7 @@ static void verify_no_event(void)
> SAFE_CLOSE(event->fd);
> } else if (errno != EAGAIN) {
> tst_res(TFAIL | TERRNO, "read(%d, buf, %zu) failed", fd_notify,
> - EVENT_BUF_LEN);
> + EVENT_SIZE);
> } else {
> tst_res(TPASS, "No event as expected");
> }
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [LTP] [PATCH v2] fanotify/fanotify04: Bugfix for running with option of "-i 500"
2022-02-09 8:05 [LTP] [PATCH v2] fanotify/fanotify04: Bugfix for running with option of "-i 500" Zhao Gongyi via ltp
2022-02-09 8:19 ` Petr Vorel
@ 2022-02-09 11:23 ` Jan Kara
2022-03-09 12:43 ` Cyril Hrubis
1 sibling, 1 reply; 4+ messages in thread
From: Jan Kara @ 2022-02-09 11:23 UTC (permalink / raw)
To: Zhao Gongyi; +Cc: jack, ltp
On Wed 09-02-22 16:05:10, Zhao Gongyi wrote:
> When we running the testcase with option of "-i 500", the test
> will fail:
> ...
> fanotify04.c:163: TPASS: No event as expected
> fanotify04.c:71: TPASS: fanotify_mark (3, FAN_MARK_ADD | 0, FAN_OPEN, AT_FDCWD, 'symlink_160172') succeeded
> fanotify04.c:127: TPASS: event generated properly for type 100000
> fanotify04.c:113: TBROK: read(3,0x55c783185280,0) failed, returned -1: EINVAL (22)
> ...
>
> Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
Looks good to me. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> v1->v2: Clear the compile warnings.
>
> .../kernel/syscalls/fanotify/fanotify04.c | 21 ++++++-------------
> 1 file changed, 6 insertions(+), 15 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/fanotify/fanotify04.c b/testcases/kernel/syscalls/fanotify/fanotify04.c
> index b23d7a9a3..8c3c179b1 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify04.c
> +++ b/testcases/kernel/syscalls/fanotify/fanotify04.c
> @@ -24,11 +24,8 @@
> #ifdef HAVE_SYS_FANOTIFY_H
> #include "fanotify.h"
>
> -#define EVENT_MAX 1024
> /* size of the event structure, not counting name */
> #define EVENT_SIZE (sizeof (struct fanotify_event_metadata))
> -/* reasonable guess as to size of 1024 events */
> -#define EVENT_BUF_LEN (EVENT_MAX * EVENT_SIZE)
>
> #define BUF_SIZE 256
> #define TST_TOTAL 9
> @@ -37,9 +34,7 @@ static char fname[BUF_SIZE];
> static char sname[BUF_SIZE];
> static char dir[BUF_SIZE];
> static int fd_notify;
> -
> -static int len;
> -static char event_buf[EVENT_BUF_LEN];
> +static char event_buf[EVENT_SIZE];
>
> static char *expect_str_fail(int expect)
> {
> @@ -104,16 +99,12 @@ static void open_dir(char *file)
>
> static void verify_event(int mask)
> {
> - int ret;
> struct fanotify_event_metadata *event;
> struct stat st;
>
> /* Read the event */
> - ret = SAFE_READ(0, fd_notify, event_buf + len,
> - EVENT_BUF_LEN - len);
> - event = (struct fanotify_event_metadata *)&event_buf[len];
> - len += ret;
> -
> + SAFE_READ(0, fd_notify, event_buf, EVENT_SIZE);
> + event = (struct fanotify_event_metadata *)&event_buf;
> if (event->mask != FAN_OPEN) {
> tst_res(TFAIL, "got unexpected event %llx",
> (unsigned long long)event->mask);
> @@ -146,11 +137,11 @@ static void verify_no_event(void)
> {
> int ret;
>
> - ret = read(fd_notify, event_buf + len, EVENT_BUF_LEN - len);
> + ret = read(fd_notify, event_buf, EVENT_SIZE);
> if (ret != -1) {
> struct fanotify_event_metadata *event;
>
> - event = (struct fanotify_event_metadata *)&event_buf[len];
> + event = (struct fanotify_event_metadata *)&event_buf;
> tst_res(TFAIL, "seen unexpected event (mask %llx)",
> (unsigned long long)event->mask);
> /* Cleanup fd from the event */
> @@ -158,7 +149,7 @@ static void verify_no_event(void)
> SAFE_CLOSE(event->fd);
> } else if (errno != EAGAIN) {
> tst_res(TFAIL | TERRNO, "read(%d, buf, %zu) failed", fd_notify,
> - EVENT_BUF_LEN);
> + EVENT_SIZE);
> } else {
> tst_res(TPASS, "No event as expected");
> }
> --
> 2.17.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-03-09 12:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-09 8:05 [LTP] [PATCH v2] fanotify/fanotify04: Bugfix for running with option of "-i 500" Zhao Gongyi via ltp
2022-02-09 8:19 ` Petr Vorel
2022-02-09 11:23 ` Jan Kara
2022-03-09 12:43 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox