From: Petr Vorel <pvorel@suse.cz>
To: Wei Gao <wegao@suse.com>
Cc: Jan Kara <jack@suse.cz>, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1] msync04: Check disk content if dirty bit check failed
Date: Tue, 28 May 2024 01:16:36 +0200 [thread overview]
Message-ID: <20240527231636.GA375669@pevik> (raw)
In-Reply-To: <20240522124754.9599-1-wegao@suse.com>
Hi Jan, Wei,
> msync04 test is inherently racy and nothing guarantees that the page
> is not written out before get_dirty_page() manages to read the page state.
> Hence the test should be reworked to verify the page contents is on disk
> when it finds dirty bit isn't set anymore...
@Jan some time ago [1] you asked to:
mmap file, write to mmap, msync, abort fs, mount fs again, check the data is
there.
Could you please have a look if this is enough? Or is it aborting fs and mounting
again necessary?
Kind regards,
Petr
[1] https://lore.kernel.org/ltp/20220125121746.wrs4254pfs2mwexb@quack3.lan/
> Signed-off-by: Wei Gao <wegao@suse.com>
> ---
> testcases/kernel/syscalls/msync/msync04.c | 34 ++++++++++++++---------
> 1 file changed, 21 insertions(+), 13 deletions(-)
> diff --git a/testcases/kernel/syscalls/msync/msync04.c b/testcases/kernel/syscalls/msync/msync04.c
> index 72ddc27a4..c296c8b20 100644
> --- a/testcases/kernel/syscalls/msync/msync04.c
> +++ b/testcases/kernel/syscalls/msync/msync04.c
> @@ -46,6 +46,7 @@ uint64_t get_dirty_bit(void *data)
> static void test_msync(void)
> {
> uint64_t dirty;
> + char buffer[20];
> test_fd = SAFE_OPEN("msync04/testfile", O_CREAT | O_TRUNC | O_RDWR,
> 0644);
> @@ -56,20 +57,27 @@ static void test_msync(void)
> mmaped_area[8] = 'B';
> dirty = get_dirty_bit(mmaped_area);
> if (!dirty) {
> - tst_res(TFAIL, "Expected dirty bit to be set after writing to"
> - " mmap()-ed area");
> - goto clean;
> - }
> - if (msync(mmaped_area, pagesize, MS_SYNC) < 0) {
> - tst_res(TFAIL | TERRNO, "msync() failed");
> - goto clean;
> + tst_res(TINFO, "Not see dirty bit so we check content of file instead");
> + test_fd = SAFE_OPEN("msync04/testfile", O_RDONLY);
> + SAFE_READ(0, test_fd, buffer, 9);
> + if (buffer[8] == 'B')
> + tst_res(TCONF, "write file ok but msync couldn't be tested"
> + " because the storage was written to too quickly");
> + else
> + tst_res(TFAIL, "write file failed");
> + } else {
> + if (msync(mmaped_area, pagesize, MS_SYNC) < 0) {
> + tst_res(TFAIL | TERRNO, "msync() failed");
> + goto clean;
> + }
> + dirty = get_dirty_bit(mmaped_area);
> + if (dirty)
> + tst_res(TFAIL, "msync() failed to write dirty page despite"
> + " succeeding");
> + else
> + tst_res(TPASS, "msync() working correctly");
> +
> }
> - dirty = get_dirty_bit(mmaped_area);
> - if (dirty)
> - tst_res(TFAIL, "msync() failed to write dirty page despite"
> - " succeeding");
> - else
> - tst_res(TPASS, "msync() working correctly");
> clean:
> SAFE_MUNMAP(mmaped_area, pagesize);
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2024-05-27 23:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-22 12:47 [LTP] [PATCH v1] msync04: Check disk content if dirty bit check failed Wei Gao via ltp
2024-05-27 23:16 ` Petr Vorel [this message]
2024-05-28 9:50 ` Jan Kara
2024-05-28 12:39 ` Petr Vorel
2024-05-29 6:03 ` Wei Gao via ltp
2024-05-27 23:18 ` 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=20240527231636.GA375669@pevik \
--to=pvorel@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 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.