engines/io_uring: fdp allocate ruhs buffer as per actual
authorAnkit Kumar <ankit.kumar@samsung.com>
Mon, 15 Jul 2024 10:07:24 +0000 (15:37 +0530)
committerVincent Fu <vincent.fu@samsung.com>
Mon, 15 Jul 2024 20:01:46 +0000 (16:01 -0400)
Use calloc instead of scalloc as ruhs buffer allocation is temporary.
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/io_uring.c

index 7e0830102c625c868b8355c8a845662f281dad5a..334c77b9edb1f8ca014f731569bca16c4a34e506 100644 (file)
@@ -1533,10 +1533,12 @@ static int fio_ioring_cmd_fetch_ruhs(struct thread_data *td, struct fio_file *f,
                                     struct fio_ruhs_info *fruhs_info)
 {
        struct nvme_fdp_ruh_status *ruhs;
-       int bytes, ret, i;
+       int bytes, nr_ruhs, ret, i;
 
-       bytes = sizeof(*ruhs) + FDP_MAX_RUHS * sizeof(struct nvme_fdp_ruh_status_desc);
-       ruhs = scalloc(1, bytes);
+       nr_ruhs = fruhs_info->nr_ruhs;
+       bytes = sizeof(*ruhs) + fruhs_info->nr_ruhs * sizeof(struct nvme_fdp_ruh_status_desc);
+
+       ruhs = calloc(1, bytes);
        if (!ruhs)
                return -ENOMEM;
 
@@ -1545,12 +1547,10 @@ static int fio_ioring_cmd_fetch_ruhs(struct thread_data *td, struct fio_file *f,
                goto free;
 
        fruhs_info->nr_ruhs = le16_to_cpu(ruhs->nruhsd);
-       if (fruhs_info->nr_ruhs > FDP_MAX_RUHS)
-               fruhs_info->nr_ruhs = FDP_MAX_RUHS;
-       for (i = 0; i < fruhs_info->nr_ruhs; i++)
+       for (i = 0; i < nr_ruhs; i++)
                fruhs_info->plis[i] = le16_to_cpu(ruhs->ruhss[i].pid);
 free:
-       sfree(ruhs);
+       free(ruhs);
        return ret;
 }