Skip to content

Commit c8bdea7

Browse files
committed
stress-rofs: reduce seeking to 1 seek for small files
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
1 parent ed4593e commit c8bdea7

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

stress-rofs.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,14 @@ static int stress_rofs_file_read(
358358
{
359359
int fd;
360360
int i;
361+
const int n = info->statbuf.st_size > 512 ? 16 : 1;
361362
char buffer[READ_BUF_SIZE] ALIGN64;
362363

363364
fd = stres_rofs_file_open(args, path, info);
364365
if (fd < 0)
365366
return -1;
366367

367-
for (i = 0; stress_continue(args) && (i < 32); i++) {
368+
for (i = 0; stress_continue(args) && (i < n); i++) {
368369
ssize_t ret;
369370

370371
(void)stress_rofs_lseek(fd, info);
@@ -387,25 +388,17 @@ static int stress_rofs_file_lseek(
387388
double *count,
388389
stress_rofs_info_t *info)
389390
{
390-
struct stat *statbuf = &info->statbuf;
391391
int fd;
392-
off_t offset = statbuf->st_size;
393-
off_t seeks = offset >> 9;
394-
off_t i;
392+
int i;
393+
const int n = info->statbuf.st_size > 512 ? 16 : 1;
395394

396395
fd = stres_rofs_file_open(args, path, info);
397396
if (fd < 0)
398397
return -1;
399398

400-
for (i = 0; stress_continue(args) && (i < seeks); i++) {
401-
if (lseek(fd, offset, SEEK_SET) == offset) {
399+
for (i = 0; stress_continue(args) && (i < n); i++) {
400+
if (stress_rofs_lseek(fd, info) >= 0)
402401
(*count) += 1.0;
403-
} else {
404-
pr_fail("%s: lseek on '%s' at offset %" PRIdMAX
405-
" failed, errno=%d (%s)\n",
406-
args->name, path, (intmax_t)i,
407-
errno, strerror(errno));
408-
}
409402
}
410403

411404
(void)close(fd);

0 commit comments

Comments
 (0)