From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 1/2] syscalls/sync_file_range: add partial file sync test-case
Date: Tue, 5 Mar 2019 15:19:03 +0100 [thread overview]
Message-ID: <20190305141903.GD13703@rei> (raw)
In-Reply-To: <1551770065-20444-1-git-send-email-sumit.garg@linaro.org>
Hi!
> +static void verify_sync_partial_file(void)
> +{
> + int fd;
> + unsigned long written;
> +
> + fd = SAFE_OPEN(FNAME, O_RDWR|O_CREAT, MODE);
> +
> + tst_dev_bytes_written(tst_device->dev);
> +
> + tst_fill_fd(fd, 0xff, TST_MB, FILE_SIZE_MB);
> +
> + TEST(sync_file_range(fd, FILE_SIZE/4, FILE_SIZE/2,
> + SYNC_FILE_RANGE_WAIT_BEFORE |
> + SYNC_FILE_RANGE_WRITE |
> + SYNC_FILE_RANGE_WAIT_AFTER));
> +
> + if (TST_RET)
> + tst_brk(TFAIL | TTERRNO, "sync_file_range() failed");
> +
> + written = tst_dev_bytes_written(tst_device->dev);
> +
> + SAFE_CLOSE(fd);
> +
> + if (written >= FILE_SIZE/2)
> + tst_res(TPASS, "Test file range synced to device");
> + else
> + tst_res(TFAIL, "Synced %li, expected %i", written,
> + FILE_SIZE/2);
> +}
Looking at this the function is nearly the same as the other one, I
guess that we may as well define the function as:
static void verify_sync_file_range(off64_t off, off64_t size, char byte)
{
...
}
Also I'm not sure I was clear enough, but I was suggesting to check for
upper bound for the synced size as well, which is why I suggested to do
full write, sync only part of it, then check that the size was within
bounds, i.e. >= size and <= size + epsilon.
I guess that we can even extend this to call the sync over a range that
has been only partially written, but for that we would have to be
careful and make sure all the data has been either synced@the end of
the test function or use a different file for each test.
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2019-03-05 14:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-05 7:14 [LTP] [PATCH v2 1/2] syscalls/sync_file_range: add partial file sync test-case Sumit Garg
2019-03-05 14:19 ` Cyril Hrubis [this message]
2019-03-06 6:48 ` Sumit Garg
2019-03-06 8:54 ` Cyril Hrubis
2019-03-07 9:24 ` 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=20190305141903.GD13703@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