Skip to content

Commit d1a1be2

Browse files
calebsanderigaw
authored andcommitted
ioctl: pass NSID in Get/Set Features commands that use it
Several features are configured on a per-namespace basis by setting the NSID in the Set Features and Get Features commands. But the corresponding nvme_{g,s}et_features_*() functions aren't passing the NSID in the commands. For the functions missing a NSID parameter, define new variants with the NSID argument added and mark the old functions as deprecated. Signed-off-by: Caleb Sander <[email protected]>
1 parent 61bdbec commit d1a1be2

3 files changed

Lines changed: 238 additions & 9 deletions

File tree

src/libnvme.map

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@ LIBNVME_1_6 {
55
nvme_ctrl_find;
66
nvme_ctrl_get_src_addr;
77
nvme_ctrl_release_fd;
8+
nvme_get_features_err_recovery2;
89
nvme_get_features_host_mem_buf2;
910
nvme_get_features_iocs_profile;
11+
nvme_get_features_lba_range2;
12+
nvme_get_features_resv_mask2;
13+
nvme_get_features_resv_persist2;
1014
nvme_host_release_fds;
1115
nvme_ns_release_fd;
1216
nvme_root_release_fds;
1317
nvme_set_features_iocs_profile;
18+
nvme_set_features_resv_mask2;
19+
nvme_set_features_resv_persist2;
20+
nvme_set_features_write_protect2;
1421
nvme_subsystem_get_iopolicy;
1522
nvme_subsystem_release_fds;
1623
nvme_set_debug;

src/nvme/ioctl.c

Lines changed: 96 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,8 +615,8 @@ int nvme_set_features_err_recovery(int fd, __u32 nsid, __u16 tler, bool dulbe,
615615
__u32 value = NVME_SET(tler, FEAT_ERROR_RECOVERY_TLER) |
616616
NVME_SET(!!dulbe, FEAT_ERROR_RECOVERY_DULBE);
617617

618-
return __nvme_set_features(fd, NVME_FEAT_FID_ERR_RECOVERY, value, save,
619-
result);
618+
return nvme_set_features_simple(
619+
fd, NVME_FEAT_FID_ERR_RECOVERY, nsid, value, save, result);
620620
}
621621

622622
int nvme_set_features_volatile_wc(int fd, bool wce, bool save, __u32 *result)
@@ -874,19 +874,41 @@ int nvme_set_features_resv_mask(int fd, __u32 mask, bool save, __u32 *result)
874874
result);
875875
}
876876

877+
int nvme_set_features_resv_mask2(int fd, __u32 nsid, __u32 mask, bool save,
878+
__u32 *result)
879+
{
880+
return nvme_set_features_simple(
881+
fd, NVME_FEAT_FID_RESV_MASK, nsid, mask, save, result);
882+
}
883+
877884
int nvme_set_features_resv_persist(int fd, bool ptpl, bool save, __u32 *result)
878885
{
879886
return __nvme_set_features(fd, NVME_FEAT_FID_RESV_PERSIST, !!ptpl, save,
880887
result);
881888
}
882889

890+
int nvme_set_features_resv_persist2(int fd, __u32 nsid, bool ptpl, bool save,
891+
__u32 *result)
892+
{
893+
return nvme_set_features_simple(
894+
fd, NVME_FEAT_FID_RESV_PERSIST, nsid, !!ptpl, save, result);
895+
}
896+
883897
int nvme_set_features_write_protect(int fd, enum nvme_feat_nswpcfg_state state,
884898
bool save, __u32 *result)
885899
{
886900
return __nvme_set_features(fd, NVME_FEAT_FID_WRITE_PROTECT, state,
887901
false, result);
888902
}
889903

904+
int nvme_set_features_write_protect2(int fd, __u32 nsid,
905+
enum nvme_feat_nswpcfg_state state,
906+
bool save, __u32 *result)
907+
{
908+
return nvme_set_features_simple(
909+
fd, NVME_FEAT_FID_WRITE_PROTECT, nsid, state, false, result);
910+
}
911+
890912
int nvme_set_features_iocs_profile(int fd, __u16 iocsi, bool save)
891913
{
892914
__u32 value = NVME_SET(iocsi, FEAT_IOCSP_IOCSCI);
@@ -972,6 +994,26 @@ int nvme_get_features_lba_range(int fd, enum nvme_get_features_sel sel,
972994
return nvme_get_features(&args);
973995
}
974996

997+
int nvme_get_features_lba_range2(int fd, enum nvme_get_features_sel sel,
998+
__u32 nsid, struct nvme_lba_range_type *data,
999+
__u32 *result)
1000+
{
1001+
struct nvme_get_features_args args = {
1002+
.args_size = sizeof(args),
1003+
.fd = fd,
1004+
.fid = NVME_FEAT_FID_LBA_RANGE,
1005+
.nsid = nsid,
1006+
.sel = sel,
1007+
.uuidx = NVME_UUID_NONE,
1008+
.data = data,
1009+
.data_len = sizeof(*data),
1010+
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1011+
.result = result,
1012+
};
1013+
1014+
return nvme_get_features(&args);
1015+
}
1016+
9751017
int nvme_get_features_temp_thresh(int fd, enum nvme_get_features_sel sel,
9761018
__u32 *result)
9771019
{
@@ -985,6 +1027,24 @@ int nvme_get_features_err_recovery(int fd, enum nvme_get_features_sel sel,
9851027
result);
9861028
}
9871029

1030+
int nvme_get_features_err_recovery2(int fd, enum nvme_get_features_sel sel,
1031+
__u32 nsid, __u32 *result)
1032+
{
1033+
1034+
struct nvme_get_features_args args = {
1035+
.args_size = sizeof(args),
1036+
.fd = fd,
1037+
.fid = NVME_FEAT_FID_ERR_RECOVERY,
1038+
.nsid = nsid,
1039+
.sel = sel,
1040+
.uuidx = NVME_UUID_NONE,
1041+
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1042+
.result = result,
1043+
};
1044+
1045+
return nvme_get_features(&args);
1046+
}
1047+
9881048
int nvme_get_features_volatile_wc(int fd, enum nvme_get_features_sel sel,
9891049
__u32 *result)
9901050
{
@@ -1250,12 +1310,46 @@ int nvme_get_features_resv_mask(int fd, enum nvme_get_features_sel sel,
12501310
return __nvme_get_features(fd, NVME_FEAT_FID_RESV_MASK, sel, result);
12511311
}
12521312

1313+
int nvme_get_features_resv_mask2(int fd, enum nvme_get_features_sel sel,
1314+
__u32 nsid, __u32 *result)
1315+
{
1316+
struct nvme_get_features_args args = {
1317+
.args_size = sizeof(args),
1318+
.fd = fd,
1319+
.fid = NVME_FEAT_FID_RESV_MASK,
1320+
.nsid = nsid,
1321+
.sel = sel,
1322+
.uuidx = NVME_UUID_NONE,
1323+
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1324+
.result = result,
1325+
};
1326+
1327+
return nvme_get_features(&args);
1328+
}
1329+
12531330
int nvme_get_features_resv_persist(int fd, enum nvme_get_features_sel sel,
12541331
__u32 *result)
12551332
{
12561333
return __nvme_get_features(fd, NVME_FEAT_FID_RESV_PERSIST, sel, result);
12571334
}
12581335

1336+
int nvme_get_features_resv_persist2(int fd, enum nvme_get_features_sel sel,
1337+
__u32 nsid, __u32 *result)
1338+
{
1339+
struct nvme_get_features_args args = {
1340+
.args_size = sizeof(args),
1341+
.fd = fd,
1342+
.fid = NVME_FEAT_FID_RESV_PERSIST,
1343+
.nsid = nsid,
1344+
.sel = sel,
1345+
.uuidx = NVME_UUID_NONE,
1346+
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1347+
.result = result,
1348+
};
1349+
1350+
return nvme_get_features(&args);
1351+
}
1352+
12591353
int nvme_get_features_write_protect(int fd, __u32 nsid,
12601354
enum nvme_get_features_sel sel,
12611355
__u32 *result)

0 commit comments

Comments
 (0)