Fix issue with dangling pointer in the rbd engine
[fio.git] / engines / rbd.c
index 39fa0ceb21c8f97c6c1ac1bcc3e83bcace424903..dc6e7db674ba38c6252a61fde337f061938f0555 100644 (file)
@@ -131,8 +131,10 @@ static int _fio_rbd_connect(struct thread_data *td)
 
 failed_open:
        rados_ioctx_destroy(rbd_data->io_ctx);
+       rbd_data->io_ctx = NULL;
 failed_shutdown:
        rados_shutdown(rbd_data->cluster);
+       rbd_data->cluster = NULL;
 failed_early:
        return 1;
 }
@@ -377,8 +379,9 @@ static int fio_rbd_setup(struct thread_data *td)
         * The size of the RBD is set instead of a artificial file.
         */
        if (!td->files_index) {
-               add_file(td, td->o.filename ? : "rbd", 0);
+               add_file(td, td->o.filename ? : "rbd", 0, 0);
                td->o.nr_files = td->o.nr_files ? : 1;
+               td->o.open_files++;
        }
        f = td->files[0];
        f->real_file_size = info.size;
@@ -422,7 +425,7 @@ static int fio_rbd_io_u_init(struct thread_data *td, struct io_u *io_u)
        return 0;
 }
 
-struct ioengine_ops ioengine = {
+static struct ioengine_ops ioengine = {
        .name               = "rbd",
        .version            = FIO_IOOPS_VERSION,
        .setup              = fio_rbd_setup,