From: Jens Axboe Date: Wed, 24 Oct 2012 07:14:24 +0000 (+0200) Subject: rdma: use private random state X-Git-Tag: fio-2.0.11~44 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=ea6209ad989dfb437aec487d26d4209bcf755d2c;hp=7d7803fa331bec4b53edf7bfa3c70ccd7f2920d9 rdma: use private random state We can't reuse td->__random_state as that will impact the sequence of offsets we generate for random IO. Signed-off-by: Jens Axboe --- diff --git a/engines/rdma.c b/engines/rdma.c index 26334328..87b061a2 100644 --- a/engines/rdma.c +++ b/engines/rdma.c @@ -119,6 +119,8 @@ struct rdmaio_data { int io_u_flight_nr; struct io_u **io_us_completed; int io_u_completed_nr; + + struct frand_state rand_state; }; static int client_recv(struct thread_data *td, struct ibv_wc *wc) @@ -617,7 +619,7 @@ static int fio_rdmaio_send(struct thread_data *td, struct io_u **io_us, if (td->o.use_os_rand) index = os_random_long(&td->random_state) % rd->rmt_nr; else - index = __rand(&td->__random_state) % rd->rmt_nr; + index = __rand(&rd->rand_state) % rd->rmt_nr; r_io_u_d->sq_wr.opcode = IBV_WR_RDMA_WRITE; r_io_u_d->sq_wr.wr.rdma.rkey = rd->rmt_us[index].rkey; r_io_u_d->sq_wr.wr.rdma.remote_addr = \ @@ -630,7 +632,7 @@ static int fio_rdmaio_send(struct thread_data *td, struct io_u **io_us, if (td->o.use_os_rand) index = os_random_long(&td->random_state) % rd->rmt_nr; else - index = __rand(&td->__random_state) % rd->rmt_nr; + index = __rand(&rd->rand_state) % rd->rmt_nr; r_io_u_d->sq_wr.opcode = IBV_WR_RDMA_READ; r_io_u_d->sq_wr.wr.rdma.rkey = rd->rmt_us[index].rkey; r_io_u_d->sq_wr.wr.rdma.remote_addr = \ @@ -1210,6 +1212,7 @@ static int fio_rdmaio_setup(struct thread_data *td) rd = malloc(sizeof(*rd));; memset(rd, 0, sizeof(*rd)); + init_rand_seed(&rd->rand_state, GOLDEN_RATIO_PRIME); td->io_ops->data = rd; }