From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v4] syscalls/sync_file_range: add partial file sync test-cases
Date: Mon, 17 Jun 2019 17:06:40 +0200 [thread overview]
Message-ID: <20190617150640.GD16831@rei> (raw)
In-Reply-To: <1560161596-30156-1-git-send-email-sumit.garg@linaro.org>
Hi!
Pushed with following modifications, thanks.
With these modification the test was stable and worked fine for more
than 100 iterations for me. It still fails for FUSE based filesystems
but that is to be expected since FUSE does not implement sync_file_range
yet.
diff --git a/testcases/kernel/syscalls/sync_file_range/sync_file_range02.c b/testcases/kernel/syscalls/sync_file_range/sync_file_range02.c
index 9454a560a..d4c29f9c2 100644
--- a/testcases/kernel/syscalls/sync_file_range/sync_file_range02.c
+++ b/testcases/kernel/syscalls/sync_file_range/sync_file_range02.c
@@ -36,6 +36,7 @@ struct testcase {
size_t exp_sync_size;
off64_t write_off;
size_t write_size_mb;
+ const char *desc;
};
static void verify_sync_file_range(struct testcase *tc)
@@ -61,20 +62,34 @@ static void verify_sync_file_range(struct testcase *tc)
written = tst_dev_bytes_written(tst_device->dev);
+ fsync(fd);
+
> Let's make sure there are no outstanding writes schedulled, fixes
> running the test with -i 10
SAFE_CLOSE(fd);
if ((written >= tc->exp_sync_size) &&
(written <= (tc->exp_sync_size + tc->exp_sync_size/10)))
- tst_res(TPASS, "Test file range synced to device");
+ tst_res(TPASS, "%s", tc->desc);
else
- tst_res(TFAIL, "Synced %li, expected %li", written,
- tc->exp_sync_size);
+ tst_res(TFAIL, "%s: Synced %li, expected %li", tc->desc,
+ written, tc->exp_sync_size);
}
static struct testcase testcases[] = {
- { FNAME1, 0, FILE_SZ, FILE_SZ, 0, FILE_SZ_MB },
- { FNAME2, FILE_SZ/4, FILE_SZ/2, FILE_SZ/2, 0, FILE_SZ_MB },
- { FNAME3, FILE_SZ/4, FILE_SZ/2, FILE_SZ/4, FILE_SZ/2, FILE_SZ_MB/4 },
+ {FNAME1,
+ 0, FILE_SZ,
+ FILE_SZ,
+ 0, FILE_SZ_MB,
+ "Sync equals write"},
+ {FNAME2,
+ FILE_SZ/4, FILE_SZ/2,
+ FILE_SZ/2,
+ 0, FILE_SZ_MB,
+ "Sync inside of write"},
+ {FNAME3,
+ FILE_SZ/4, FILE_SZ/2,
+ FILE_SZ/4,
+ FILE_SZ/2, FILE_SZ_MB/4,
+ "Sync overlaps with write"},
};
> This simply adds test description so that it's clear which subtest
> failed.
static void run(unsigned int i)
@@ -87,10 +102,17 @@ static void setup(void)
if (!check_sync_file_range())
tst_brk(TCONF, "sync_file_range() not supported");
+ /*
+ * Fat does not support sparse files, we have to pre-fill the file so
+ * that the zero-filled start of the file has been written to disk
+ * before the test starts.
+ */
if (!strcmp(tst_device->fs_type, "vfat")) {
tst_res(TINFO, "Pre-filling file");
tst_fill_file(FNAME3, 0, TST_MB, FILE_SZ_MB);
- sync();
+ int fd = SAFE_OPEN(FNAME3, O_RDONLY);
+ fsync(fd);
+ SAFE_CLOSE(fd);
}
> Strangely doing sync(); here failed for me, that may be actually a
> kernel bug however there is no need for using the big hammer and sync
> everything in the system anyways.
}
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2019-06-17 15:06 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-10 10:13 [LTP] [PATCH v4] syscalls/sync_file_range: add partial file sync test-cases Sumit Garg
2019-06-10 12:04 ` Li Wang
2019-06-17 12:26 ` Sumit Garg
2019-06-17 13:06 ` Cyril Hrubis
2019-06-17 15:06 ` Cyril Hrubis [this message]
2019-06-18 15:49 ` Amir Goldstein
2019-06-19 9:58 ` Cyril Hrubis
2019-06-19 10:28 ` Amir Goldstein
2019-09-29 13:27 ` Caspar Zhang
2019-10-04 7:33 ` Sumit Garg
2019-10-16 2:54 ` Caspar Zhang
2019-10-16 6:23 ` Sumit Garg
2019-10-17 7:36 ` Caspar Zhang
2019-10-29 6:08 ` Naresh Kamboju
2019-10-30 9:45 ` Sumit Garg
2019-11-05 9:05 ` Naresh Kamboju
2019-10-30 9:40 ` Sumit Garg
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=20190617150640.GD16831@rei \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/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