engines/xnvme: allocate fdp ruhs buffer as per actual
authorAnkit Kumar <ankit.kumar@samsung.com>
Mon, 15 Jul 2024 15:34:56 +0000 (21:04 +0530)
committerVincent Fu <vincent.fu@samsung.com>
Mon, 15 Jul 2024 20:01:46 +0000 (16:01 -0400)
Remove the restriction on maximum number of ruhs, fetch and fill the
ruhs buffer as requested by fdp backend.

Signed-off-by: Ankit Kumar <ankit.kumar@samsung.com>
Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
engines/xnvme.c

index 6ba4aa467d5501408c52604ddf7daa55e6d3fc10..5f1af78d3de34a0e3d7786c527b9a2ff63474957 100644 (file)
@@ -1253,7 +1253,7 @@ static int xnvme_fioe_fetch_ruhs(struct thread_data *td, struct fio_file *f,
        struct xnvme_dev *dev;
        struct xnvme_spec_ruhs *ruhs;
        struct xnvme_cmd_ctx ctx;
-       uint32_t ruhs_nbytes;
+       uint32_t ruhs_nbytes, nr_ruhs;
        uint32_t nsid;
        int err = 0, err_lock;
 
@@ -1276,7 +1276,8 @@ static int xnvme_fioe_fetch_ruhs(struct thread_data *td, struct fio_file *f,
                goto exit;
        }
 
-       ruhs_nbytes = sizeof(*ruhs) + (FDP_MAX_RUHS * sizeof(struct xnvme_spec_ruhs_desc));
+       nr_ruhs = fruhs_info->nr_ruhs;
+       ruhs_nbytes = sizeof(*ruhs) + (fruhs_info->nr_ruhs * sizeof(struct xnvme_spec_ruhs_desc));
        ruhs = xnvme_buf_alloc(dev, ruhs_nbytes);
        if (!ruhs) {
                err = -errno;
@@ -1296,7 +1297,7 @@ static int xnvme_fioe_fetch_ruhs(struct thread_data *td, struct fio_file *f,
        }
 
        fruhs_info->nr_ruhs = ruhs->nruhsd;
-       for (uint32_t idx = 0; idx < fruhs_info->nr_ruhs; ++idx) {
+       for (uint32_t idx = 0; idx < nr_ruhs; ++idx) {
                fruhs_info->plis[idx] = le16_to_cpu(ruhs->desc[idx].pi);
        }