From: Cyril Hrubis <chrubis@suse.cz>
To: Wei Gao <wegao@suse.com>
Cc: Jan Kara <jack@suse.cz>, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1] msync04.c: Use direct IO to verify the data is stored on disk
Date: Thu, 13 Jun 2024 10:31:47 +0200 [thread overview]
Message-ID: <Zmquc-biCPBV2DCr@yuki> (raw)
In-Reply-To: <20240530044029.15474-1-wegao@suse.com>
Hi!
> Signed-off-by: Wei Gao <wegao@suse.com>
> Suggested-by: Jan Kara <jack@suse.cz>
> ---
> testcases/kernel/syscalls/msync/msync04.c | 56 +++++++++++++----------
> 1 file changed, 33 insertions(+), 23 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/msync/msync04.c b/testcases/kernel/syscalls/msync/msync04.c
> index 1718bd7dc..c0580d1b0 100644
> --- a/testcases/kernel/syscalls/msync/msync04.c
> +++ b/testcases/kernel/syscalls/msync/msync04.c
> @@ -11,6 +11,7 @@
> * is no longer dirty after msync() call.
> */
>
> +#define _GNU_SOURCE
> #include <errno.h>
> #include "tst_test.h"
>
> @@ -43,10 +44,35 @@ static uint64_t get_dirty_bit(void *data)
> return pageflag_entry & (1ULL << 4);
> }
>
> -static void test_msync(void)
> +static void verify_mmaped(void)
> +{
> + void *buffer = SAFE_MEMALIGN(getpagesize(), getpagesize());
> +
> + tst_res(TINFO, "Not see dirty bit so we check content of file instead");
^
Haven't seen dirty...
> + test_fd = SAFE_OPEN("msync04/testfile", O_RDONLY | O_DIRECT);
> + SAFE_READ(0, test_fd, buffer, getpagesize());
> +
> + char *char_buffer = (char *)buffer;
You can declare the buffer directly as char * instead, there is no need
for this indirection.
> + if (char_buffer[8] == 'B')
> + tst_res(TCONF, "write file ok but msync couldn't be tested"
> + " because the storage was written to too quickly");
This could be shorter and stil to the point:
"Write was too fast, couldn't test msync()"
> + else
> + tst_res(TFAIL, "write file failed");
We should free() allocated the memory here.
Other than these minor issues the rest looks good to me.
You can add my Reviewed-by: once these issues are fixed.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2024-06-13 8:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-30 4:40 [LTP] [PATCH v1] msync04.c: Use direct IO to verify the data is stored on disk Wei Gao via ltp
2024-05-30 8:39 ` Jan Kara
2024-06-13 8:31 ` Cyril Hrubis [this message]
2024-06-13 23:20 ` [LTP] [PATCH v2] " Wei Gao via ltp
2024-06-14 12:51 ` Petr Vorel
2024-06-14 15:28 ` Cyril Hrubis
2024-06-17 12:13 ` Petr Vorel
2024-06-17 10:13 ` Petr Vorel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zmquc-biCPBV2DCr@yuki \
--to=chrubis@suse.cz \
--cc=jack@suse.cz \
--cc=ltp@lists.linux.it \
--cc=wegao@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox