projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
manpage: update URL links to HOWTO/README
[fio.git]
/
filesetup.c
diff --git
a/filesetup.c
b/filesetup.c
index bcf95bd5a78785b2b4431db3b522fc12378d7bcb..612e79474dc4b43c0707d6a43dccf3d98a2f9e8f 100644
(file)
--- a/
filesetup.c
+++ b/
filesetup.c
@@
-159,11
+159,18
@@
static int extend_file(struct thread_data *td, struct fio_file *f)
}
}
}
}
- b = malloc(td->o.max_bs[DDIR_WRITE]);
-
left = f->real_file_size;
left = f->real_file_size;
+ bs = td->o.max_bs[DDIR_WRITE];
+ if (bs > left)
+ bs = left;
+
+ b = malloc(bs);
+ if (!b) {
+ td_verror(td, errno, "malloc");
+ goto err;
+ }
+
while (left && !td->terminate) {
while (left && !td->terminate) {
- bs = td->o.max_bs[DDIR_WRITE];
if (bs > left)
bs = left;
if (bs > left)
bs = left;
@@
-228,7
+235,11
@@
static int pre_read_file(struct thread_data *td, struct fio_file *f)
unsigned int bs;
char *b;
unsigned int bs;
char *b;
- if (td_ioengine_flagged(td, FIO_PIPEIO))
+ if (td_ioengine_flagged(td, FIO_PIPEIO) ||
+ td_ioengine_flagged(td, FIO_NOIO))
+ return 0;
+
+ if (f->filetype == FIO_TYPE_CHAR)
return 0;
if (!fio_file_open(f)) {
return 0;
if (!fio_file_open(f)) {
@@
-241,8
+252,17
@@
static int pre_read_file(struct thread_data *td, struct fio_file *f)
old_runstate = td_bump_runstate(td, TD_PRE_READING);
old_runstate = td_bump_runstate(td, TD_PRE_READING);
+ left = f->io_size;
bs = td->o.max_bs[DDIR_READ];
bs = td->o.max_bs[DDIR_READ];
+ if (bs > left)
+ bs = left;
+
b = malloc(bs);
b = malloc(bs);
+ if (!b) {
+ td_verror(td, errno, "malloc");
+ ret = 1;
+ goto error;
+ }
memset(b, 0, bs);
if (lseek(f->fd, f->file_offset, SEEK_SET) < 0) {
memset(b, 0, bs);
if (lseek(f->fd, f->file_offset, SEEK_SET) < 0) {
@@
-252,8
+272,6
@@
static int pre_read_file(struct thread_data *td, struct fio_file *f)
goto error;
}
goto error;
}
- left = f->io_size;
-
while (left && !td->terminate) {
if (bs > left)
bs = left;
while (left && !td->terminate) {
if (bs > left)
bs = left;
@@
-1104,10
+1122,11
@@
int pre_read_files(struct thread_data *td)
dprint(FD_FILE, "pre_read files\n");
for_each_file(td, f, i) {
dprint(FD_FILE, "pre_read files\n");
for_each_file(td, f, i) {
- pre_read_file(td, f);
+ if (pre_read_file(td, f))
+ return -1;
}
}
- return
1
;
+ return
0
;
}
static int __init_rand_distribution(struct thread_data *td, struct fio_file *f)
}
static int __init_rand_distribution(struct thread_data *td, struct fio_file *f)