option is false, then fio will error out if the files it
needs to use don't already exist. Default: true.
+allow_mounted_write=bool If this isn't set, fio will abort jobs that
+ are destructive (eg that write) to what appears to be a
+ mounted device or partition. This should help catch creating
+ inadvertently destructive tests, not realizing that the test
+ will destroy data on the mounted file system. Default: false.
+
pre_read=bool If this is given, files will be pre-read into memory before
starting the given IO operation. This will also clear
the 'invalidate' flag, since it is pointless to pre-read
#include "err.h"
#include "lib/tp.h"
#include "workqueue.h"
+#include "lib/mountcheck.h"
static pthread_t helper_thread;
static pthread_mutex_t helper_lock;
usleep(usecs);
}
+static int check_mount_writes(struct thread_data *td)
+{
+ struct fio_file *f;
+ unsigned int i;
+
+ if (!td_write(td) || td->o.allow_mounted_write)
+ return 0;
+
+ for_each_file(td, f, i) {
+ if (f->filetype != FIO_TYPE_BD)
+ continue;
+ if (device_is_mounted(f->file_name))
+ goto mounted;
+ }
+
+ return 0;
+mounted:
+ log_err("fio: %s appears mounted, and 'allow_mounted_write' isn't set. Aborting.", f->file_name);
+ return 1;
+}
+
/*
* Main function for kicking off and reaping jobs, as needed.
*/
nr_thread = nr_process = 0;
for_each_td(td, i) {
+ if (check_mount_writes(td))
+ return;
if (td->o.use_thread)
nr_thread++;
else
the default behavior. If this option is false, then fio will error out if the
files it needs to use don't already exist. Default: true.
.TP
+.BI allow_mounted_write \fR=\fPbool
+If this isn't set, fio will abort jobs that are destructive (eg that write)
+to what appears to be a mounted device or partition. This should help catch
+creating inadvertently destructive tests, not realizing that the test will
+destroy data on the mounted file system. Default: false.
+.TP
.BI pre_read \fR=\fPbool
If this is given, files will be pre-read into memory before starting the given
IO operation. This will also clear the \fR \fBinvalidate\fR flag, since it is
--- /dev/null
+#ifndef FIO_MOUNT_CHECK_H
+#define FIO_MOUNT_CHECK_H
+
+extern int device_is_mounted(const char *);
+
+#endif
},
{
.name = "allow_file_create",
+ .lname = "Allow file create",
.type = FIO_OPT_BOOL,
.off1 = td_var_offset(allow_create),
.help = "Permit fio to create files, if they don't exist",
.category = FIO_OPT_C_FILE,
.group = FIO_OPT_G_FILENAME,
},
+ {
+ .name = "allow_mounted_write",
+ .lname = "Allow mounted write",
+ .type = FIO_OPT_BOOL,
+ .off1 = td_var_offset(allow_mounted_write),
+ .help = "Allow writes to a mounted partition",
+ .def = "0",
+ .category = FIO_OPT_C_FILE,
+ .group = FIO_OPT_G_FILENAME,
+ },
{
.name = "pre_read",
.lname = "Pre-read files",
unsigned int per_job_logs;
unsigned int allow_create;
+ unsigned int allow_mounted_write;
};
#define FIO_TOP_STR_MAX 256
uint32_t per_job_logs;
uint32_t allow_create;
+ uint32_t allow_mounted_write;
} __attribute__((packed));
extern void convert_thread_options_to_cpu(struct thread_options *o, struct thread_options_pack *top);