if (o->cmd_type == FIO_URING_CMD_NVME) {
struct nvme_data *data = NULL;
if (o->cmd_type == FIO_URING_CMD_NVME) {
struct nvme_data *data = NULL;
- unsigned int nsid, lba_size = 0;
- __u32 ms = 0;
+ unsigned int lba_size = 0;
__u64 nlba = 0;
int ret;
/* Store the namespace-id and lba size. */
data = FILE_ENG_DATA(f);
if (data == NULL) {
__u64 nlba = 0;
int ret;
/* Store the namespace-id and lba size. */
data = FILE_ENG_DATA(f);
if (data == NULL) {
- ret = fio_nvme_get_info(f, &nsid, &lba_size, &ms, &nlba);
- if (ret)
- return ret;
-
data = calloc(1, sizeof(struct nvme_data));
data = calloc(1, sizeof(struct nvme_data));
- data->nsid = nsid;
- if (ms)
- data->lba_ext = lba_size + ms;
- else
- data->lba_shift = ilog2(lba_size);
+ ret = fio_nvme_get_info(f, &nlba, data);
+ if (ret) {
+ free(data);
+ return ret;
+ }
FILE_SET_ENG_DATA(f, data);
}
FILE_SET_ENG_DATA(f, data);
}
- assert(data->lba_shift < 32);
- lba_size = data->lba_ext ? data->lba_ext : (1U << data->lba_shift);
+ lba_size = data->lba_ext ? data->lba_ext : data->lba_size;
for_each_rw_ddir(ddir) {
if (td->o.min_bs[ddir] % lba_size ||
for_each_rw_ddir(ddir) {
if (td->o.min_bs[ddir] % lba_size ||
if (o->cmd_type == FIO_URING_CMD_NVME) {
struct nvme_data *data = NULL;
if (o->cmd_type == FIO_URING_CMD_NVME) {
struct nvme_data *data = NULL;
- unsigned int nsid, lba_size = 0;
- __u32 ms = 0;
- ret = fio_nvme_get_info(f, &nsid, &lba_size, &ms, &nlba);
- if (ret)
- return ret;
-
data = calloc(1, sizeof(struct nvme_data));
data = calloc(1, sizeof(struct nvme_data));
- data->nsid = nsid;
- if (ms)
- data->lba_ext = lba_size + ms;
- else
- data->lba_shift = ilog2(lba_size);
+ ret = fio_nvme_get_info(f, &nlba, data);
+ if (ret) {
+ free(data);
+ return ret;
+ }
- f->real_file_size = lba_size * nlba;
+ f->real_file_size = data->lba_size * nlba;
fio_file_set_size_known(f);
FILE_SET_ENG_DATA(f, data);
fio_file_set_size_known(f);
FILE_SET_ENG_DATA(f, data);
return ioctl(fd, NVME_IOCTL_ADMIN_CMD, &cmd);
}
return ioctl(fd, NVME_IOCTL_ADMIN_CMD, &cmd);
}
-int fio_nvme_get_info(struct fio_file *f, __u32 *nsid, __u32 *lba_sz,
- __u32 *ms, __u64 *nlba)
+int fio_nvme_get_info(struct fio_file *f, __u64 *nlba, struct nvme_data *data)
{
struct nvme_id_ns ns;
int namespace_id;
{
struct nvme_id_ns ns;
int namespace_id;
+ data->nsid = namespace_id;
/*
* 16 or 64 as maximum number of supported LBA formats.
/*
* 16 or 64 as maximum number of supported LBA formats.
else
format_idx = (ns.flbas & 0xf) + (((ns.flbas >> 5) & 0x3) << 4);
else
format_idx = (ns.flbas & 0xf) + (((ns.flbas >> 5) & 0x3) << 4);
- *lba_sz = 1 << ns.lbaf[format_idx].ds;
+ data->lba_size = 1 << ns.lbaf[format_idx].ds;
/*
* Only extended LBA can be supported.
* Bit 4 for flbas indicates if metadata is transferred at the end of
* logical block creating an extended LBA.
*/
/*
* Only extended LBA can be supported.
* Bit 4 for flbas indicates if metadata is transferred at the end of
* logical block creating an extended LBA.
*/
- *ms = le16_to_cpu(ns.lbaf[format_idx].ms);
- if (*ms && !((ns.flbas >> 4) & 0x1)) {
+ data->ms = le16_to_cpu(ns.lbaf[format_idx].ms);
+ if (data->ms && !((ns.flbas >> 4) & 0x1)) {
log_err("%s: only extended logical block can be supported\n",
f->file_name);
err = -ENOTSUP;
goto out;
}
log_err("%s: only extended logical block can be supported\n",
f->file_name);
err = -ENOTSUP;
goto out;
}
+ if (data->ms)
+ data->lba_ext = data->lba_size + data->ms;
+ else
+ data->lba_shift = ilog2(data->lba_size);
+
/* Check for end to end data protection support */
if (ns.dps & 0x3) {
log_err("%s: end to end data protection not supported\n",
/* Check for end to end data protection support */
if (ns.dps & 0x3) {
log_err("%s: end to end data protection not supported\n",
struct nvme_data {
__u32 nsid;
__u32 lba_shift;
struct nvme_data {
__u32 nsid;
__u32 lba_shift;
int fio_nvme_iomgmt_ruhs(struct thread_data *td, struct fio_file *f,
struct nvme_fdp_ruh_status *ruhs, __u32 bytes);
int fio_nvme_iomgmt_ruhs(struct thread_data *td, struct fio_file *f,
struct nvme_fdp_ruh_status *ruhs, __u32 bytes);
-int fio_nvme_get_info(struct fio_file *f, __u32 *nsid, __u32 *lba_sz,
- __u32 *ms, __u64 *nlba);
+int fio_nvme_get_info(struct fio_file *f, __u64 *nlba, struct nvme_data *data);
int fio_nvme_uring_cmd_prep(struct nvme_uring_cmd *cmd, struct io_u *io_u,
struct iovec *iov, struct nvme_dsm_range *dsm);
int fio_nvme_uring_cmd_prep(struct nvme_uring_cmd *cmd, struct io_u *io_u,
struct iovec *iov, struct nvme_dsm_range *dsm);