Re: [PATCH 1/3] fdp: use macro for max ruhs and fix placement id check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/11/23 08:54, Ankit Kumar wrote:
Use macro for max ruhs.
Number of reclaim unit handle descriptors are 1 based, whereas the
input placement id index / indices are 0 based. Add the correct check
for that.

Signed-off-by: Ankit Kumar <ankit.kumar@xxxxxxxxxxx>
---
  engines/io_uring.c | 2 +-
  fdp.c              | 8 ++++----
  fdp.h              | 2 ++
  3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/engines/io_uring.c b/engines/io_uring.c
index 5021239e..407d65ce 100644
--- a/engines/io_uring.c
+++ b/engines/io_uring.c
@@ -1310,7 +1310,7 @@ static int fio_ioring_cmd_fetch_ruhs(struct thread_data *td, struct fio_file *f,
  	struct nvme_fdp_ruh_status *ruhs;
  	int bytes, ret, i;
- bytes = sizeof(*ruhs) + 128 * sizeof(struct nvme_fdp_ruh_status_desc);
+	bytes = sizeof(*ruhs) + FDP_MAX_RUHS * sizeof(struct nvme_fdp_ruh_status_desc);
  	ruhs = scalloc(1, bytes);
  	if (!ruhs)
  		return -ENOMEM;
diff --git a/fdp.c b/fdp.c
index d92dbc67..72afca01 100644
--- a/fdp.c
+++ b/fdp.c
@@ -45,7 +45,7 @@ static int init_ruh_info(struct thread_data *td, struct fio_file *f)
  	struct fio_ruhs_info *ruhs, *tmp;
  	int i, ret;
- ruhs = scalloc(1, sizeof(*ruhs) + 128 * sizeof(*ruhs->plis));
+	ruhs = scalloc(1, sizeof(*ruhs) + FDP_MAX_RUHS * sizeof(*ruhs->plis));
  	if (!ruhs)
  		return -ENOMEM;
@@ -56,8 +56,8 @@ static int init_ruh_info(struct thread_data *td, struct fio_file *f)
  		goto out;
  	}
- if (ruhs->nr_ruhs > 128)
-		ruhs->nr_ruhs = 128;
+	if (ruhs->nr_ruhs > FDP_MAX_RUHS)
+		ruhs->nr_ruhs = FDP_MAX_RUHS;
if (td->o.fdp_nrpli == 0) {
  		f->ruhs_info = ruhs;
@@ -65,7 +65,7 @@ static int init_ruh_info(struct thread_data *td, struct fio_file *f)
  	}
for (i = 0; i < td->o.fdp_nrpli; i++) {
-		if (td->o.fdp_plis[i] > ruhs->nr_ruhs) {
+		if (td->o.fdp_plis[i] >= ruhs->nr_ruhs) {
  			ret = -EINVAL;
  			goto out;
  		}
diff --git a/fdp.h b/fdp.h
index 81691f62..4a5e0e54 100644
--- a/fdp.h
+++ b/fdp.h
@@ -3,6 +3,8 @@
#include "io_u.h" +#define FDP_MAX_RUHS 128
+
  struct fio_ruhs_info {
  	uint32_t nr_ruhs;
  	uint32_t pli_loc;


Ankit, the commit history will be cleaner if the refactoring change and the bug fix were split into separate commits. Would you mind doing that?

Vincent



[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux