#include <assert.h>
#include <string.h>
#include <sys/poll.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include "../fio.h"
for (i = 0; i < events; i++) {
struct b_user_cmd *buc = (struct b_user_cmd *) buf + i;
- bd->events[ev_index] = (struct io_u *) buc->usr_ptr;
+ bd->events[ev_index] = (struct io_u *) (unsigned long) buc->usr_ptr;
ev_index++;
}
}
buc->type = B_TYPE_READ;
} else if (io_u->ddir == DDIR_WRITE) {
binject_buc_init(bd, io_u);
- buc->type = B_TYPE_WRITE;
+ if (io_u->flags & IO_U_F_BARRIER)
+ buc->type = B_TYPE_WRITEBARRIER;
+ else
+ buc->type = B_TYPE_WRITE;
} else if (io_u->ddir == DDIR_TRIM) {
binject_buc_init(bd, io_u);
buc->type = B_TYPE_DISCARD;
return bd->events[event];
}
+static int binject_open_ctl(struct thread_data *td)
+{
+ int fd;
+
+ fd = open("/dev/binject-ctl", O_RDWR);
+ if (fd < 0)
+ td_verror(td, errno, "open binject-ctl");
+
+ return fd;
+}
+
static void binject_unmap_dev(struct thread_data *td, struct binject_file *bf)
{
struct b_ioctl_cmd bic;
bf->fd = -1;
}
- fdb = open("/dev/binject-ctl", O_RDWR);
- if (fdb < 0) {
- td_verror(td, errno, "open binject-ctl");
+ fdb = binject_open_ctl(td);
+ if (fdb < 0)
return;
- }
bic.minor = bf->minor;
- if (ioctl(fdb, 1, &bic) < 0) {
+ if (ioctl(fdb, B_IOCTL_DEL, &bic) < 0)
td_verror(td, errno, "binject dev unmap");
- close(fdb);
- return;
- }
close(fdb);
}
struct stat sb;
int fdb, dev_there, loops;
- fdb = open("/dev/binject-ctl", O_RDWR);
- if (fdb < 0) {
- td_verror(td, errno, "binject ctl open");
+ fdb = binject_open_ctl(td);
+ if (fdb < 0)
return 1;
- }
bic.fd = fd;
- if (ioctl(fdb, 0, &bic) < 0) {
+ if (ioctl(fdb, B_IOCTL_ADD, &bic) < 0) {
td_verror(td, errno, "binject dev map");
close(fdb);
return 1;
.open_file = fio_binject_open_file,
.close_file = fio_binject_close_file,
.get_file_size = generic_get_file_size,
- .flags = FIO_RAWIO,
+ .flags = FIO_RAWIO | FIO_BARRIER | FIO_MEMALIGN,
};
#else /* FIO_HAVE_BINJECT */