2 * Note: This is similar to a very basic setup
5 * Specify fdp=1 (With char devices /dev/ng0n1)
16 #include "dataplacement.h"
18 static int fdp_ruh_info(struct thread_data *td, struct fio_file *f,
19 struct fio_ruhs_info *ruhs)
24 log_err("fio: no ops set in fdp init?!\n");
28 if (td->io_ops->fdp_fetch_ruhs) {
29 ret = td->io_ops->fdp_fetch_ruhs(td, f, ruhs);
31 td_verror(td, errno, "fdp fetch ruhs failed");
32 log_err("%s: fdp fetch ruhs failed (%d)\n",
36 log_err("%s: engine (%s) lacks fetch ruhs\n",
37 f->file_name, td->io_ops->name);
43 static int init_ruh_info(struct thread_data *td, struct fio_file *f)
45 struct fio_ruhs_info *ruhs, *tmp;
48 ruhs = scalloc(1, sizeof(*ruhs) + FDP_MAX_RUHS * sizeof(*ruhs->plis));
52 /* set up the data structure used for FDP to work with the supplied stream IDs */
53 if (td->o.dp_type == FIO_DP_STREAMS) {
54 if (!td->o.dp_nr_ids) {
55 log_err("fio: stream IDs must be provided for dataplacement=streams\n");
58 ruhs->nr_ruhs = td->o.dp_nr_ids;
59 for (int i = 0; i < ruhs->nr_ruhs; i++)
60 ruhs->plis[i] = td->o.dp_ids[i];
66 ret = fdp_ruh_info(td, f, ruhs);
68 log_info("fio: ruh info failed for %s (%d)\n",
73 if (ruhs->nr_ruhs > FDP_MAX_RUHS)
74 ruhs->nr_ruhs = FDP_MAX_RUHS;
76 if (td->o.dp_nr_ids == 0) {
81 for (i = 0; i < td->o.dp_nr_ids; i++) {
82 if (td->o.dp_ids[i] >= ruhs->nr_ruhs) {
88 tmp = scalloc(1, sizeof(*tmp) + ruhs->nr_ruhs * sizeof(*tmp->plis));
94 tmp->nr_ruhs = td->o.dp_nr_ids;
95 for (i = 0; i < td->o.dp_nr_ids; i++)
96 tmp->plis[i] = ruhs->plis[td->o.dp_ids[i]];
103 int dp_init(struct thread_data *td)
108 for_each_file(td, f, i) {
109 ret = init_ruh_info(td, f);
116 void fdp_free_ruhs_info(struct fio_file *f)
124 void dp_fill_dspec_data(struct thread_data *td, struct io_u *io_u)
126 struct fio_file *f = io_u->file;
127 struct fio_ruhs_info *ruhs = f->ruhs_info;
130 if (!ruhs || io_u->ddir != DDIR_WRITE) {
136 if (td->o.dp_id_select == FIO_DP_RR) {
137 if (ruhs->pli_loc >= ruhs->nr_ruhs)
140 dspec = ruhs->plis[ruhs->pli_loc++];
142 ruhs->pli_loc = rand_between(&td->fdp_state, 0, ruhs->nr_ruhs - 1);
143 dspec = ruhs->plis[ruhs->pli_loc];
146 io_u->dtype = td->o.dp_type == FIO_DP_FDP ? FDP_DIR_DTYPE : STREAMS_DIR_DTYPE;
148 dprint(FD_IO, "dtype set to 0x%x, dspec set to 0x%x\n", io_u->dtype, io_u->dspec);