rteval-loads/SOURCES/0012-stress-dev-add-block-d...

74 lines
1.8 KiB
Diff

From c6e63723e33a65cb93348a3f32a1a5828159786f Mon Sep 17 00:00:00 2001
From: Colin Ian King <colin.king@canonical.com>
Date: Tue, 19 May 2020 12:37:24 +0100
Subject: [PATCH 12/28] stress-dev: add block device lseeks and force return to
be stashed
Block devices can be lseek'd so add this. For all lseeks stash the
return offset to force compiler to not optimize anything away.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
stress-dev.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/stress-dev.c b/stress-dev.c
index 2eeb72c8cc21..b3c156ba5eb9 100644
--- a/stress-dev.c
+++ b/stress-dev.c
@@ -503,6 +503,8 @@ static void stress_dev_blk(
const int fd,
const char *devpath)
{
+ off_t offset;
+
(void)name;
(void)fd;
(void)devpath;
@@ -633,6 +635,14 @@ static void stress_dev_blk(
(void)ret;
}
#endif
+ offset = lseek(fd, 0, SEEK_END);
+ stress_uint64_put((uint64_t)offset);
+
+ offset = lseek(fd, 0, SEEK_SET);
+ stress_uint64_put((uint64_t)offset);
+
+ offset = lseek(fd, 0, SEEK_CUR);
+ stress_uint64_put((uint64_t)offset);
}
#if defined(__linux__)
@@ -1167,7 +1177,7 @@ static inline void stress_dev_rw(
int32_t loops)
{
int fd, ret;
- off_t off;
+ off_t offset;
struct stat buf;
struct pollfd fds[1];
fd_set rfds;
@@ -1231,12 +1241,12 @@ static inline void stress_dev_rw(
stress_dev_tty(args->name, fd, path);
#endif
- off = lseek(fd, 0, SEEK_SET);
- (void)off;
- off = lseek(fd, 0, SEEK_CUR);
- (void)off;
- off = lseek(fd, 0, SEEK_END);
- (void)off;
+ offset = lseek(fd, 0, SEEK_SET);
+ stress_uint64_put((uint64_t)offset);
+ offset = lseek(fd, 0, SEEK_CUR);
+ stress_uint64_put((uint64_t)offset);
+ offset = lseek(fd, 0, SEEK_END);
+ stress_uint64_put((uint64_t)offset);
if (stress_time_now() - t_start > threshold) {
timeout = true;
--
2.21.3