Skip to content

Commit 9a10fac

Browse files
committed
lib: update function names to follow pattern
Make the naming more consistent. Functions are grouped by common prefixes. Generic top-level functions use the nvme_ prefix, while functions operating on specific objects use the object type as a prefix (e.g., nvme_ns_). The prefix is typically followed by a verb, such as nvme_create_ctrl. Signed-off-by: Daniel Wagner <[email protected]>
1 parent 2bf083e commit 9a10fac

26 files changed

Lines changed: 156 additions & 156 deletions

File tree

libnvme/examples/discover-loop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ int main()
6969
nvme_free_global_ctx(ctx);
7070
return 1;
7171
}
72-
ret = nvme_host_get(ctx, NULL, NULL, &h);
72+
ret = nvme_get_host(ctx, NULL, NULL, &h);
7373
if (ret) {
7474
fprintf(stderr, "Failed to allocated memory\n");
7575
return 1;

libnvme/libnvme/nvme.i

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,21 @@
3838
PyDict_SetItemString(p, key, val); /* Does NOT steal reference to val .. */
3939
Py_XDECREF(val); /* .. therefore decrement ref. count. */
4040
}
41-
PyObject *hostnqn_from_file() {
42-
char * val = nvme_hostnqn_from_file();
41+
PyObject *read_hostnqn() {
42+
char * val = nvme_read_hostnqn();
4343
PyObject * obj = PyUnicode_FromString(val);
4444
free(val);
4545
return obj;
4646
}
47-
PyObject *hostid_from_file() {
48-
char * val = nvme_hostid_from_file();
47+
PyObject *read_hostid() {
48+
char * val = nvme_read_hostid();
4949
PyObject * obj = PyUnicode_FromString(val);
5050
free(val);
5151
return obj;
5252
}
5353
%}
54-
PyObject *hostnqn_from_file();
55-
PyObject *hostid_from_file();
54+
PyObject *read_hostnqn();
55+
PyObject *read_hostid();
5656

5757
%exception nvme_ctrl::connect {
5858
connect_err = 0;
@@ -557,7 +557,7 @@ struct nvme_ns {
557557
const char *hostkey = NULL,
558558
const char *hostsymname = NULL) {
559559
nvme_host_t h;
560-
if (nvme_host_get(ctx, hostnqn, hostid, &h))
560+
if (nvme_get_host(ctx, hostnqn, hostid, &h))
561561
return NULL;
562562
if (hostsymname)
563563
nvme_host_set_hostsymname(h, hostsymname);
@@ -613,7 +613,7 @@ struct nvme_ns {
613613
const char *name = NULL) {
614614
struct nvme_subsystem *s;
615615

616-
if (nvme_subsystem_get(ctx, host, name, subsysnqn, &s))
616+
if (nvme_get_subsystem(ctx, host, name, subsysnqn, &s))
617617
return NULL;
618618

619619
return s;
@@ -1245,13 +1245,13 @@ struct nvme_ns {
12451245
PyObject *output;
12461246
int ret;
12471247

1248-
ret = nvme_nbft_read(ctx, &nbft, filename);
1248+
ret = nvme_read_nbft(ctx, &nbft, filename);
12491249
if (ret) {
12501250
Py_RETURN_NONE;
12511251
}
12521252

12531253
output = nbft_to_pydict(nbft);
1254-
nvme_nbft_free(ctx, nbft);
1254+
nvme_free_nbft(ctx, nbft);
12551255
return output;
12561256
}
12571257
%};

libnvme/src/libnvme.ld

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LIBNVME_3 {
66
nvme_close;
77
nvme_create_ctrl;
88
nvme_create_global_ctx;
9-
nvme_ctrl_config_match;
9+
nvme_ctrl_match_config;
1010
nvme_ctrl_first_ns;
1111
nvme_ctrl_first_path;
1212
nvme_ctrl_get_address;
@@ -25,9 +25,9 @@ LIBNVME_3 {
2525
nvme_ctrl_next_ns;
2626
nvme_ctrl_next_path;
2727
nvme_ctrl_release_transport_handle;
28-
nvme_ctrl_reset;
28+
nvme_reset_ctrl;
2929
nvme_ctrl_set_dhchap_host_key;
30-
nvme_ctrls_filter;
30+
nvme_filter_ctrls;
3131
nvme_describe_key_serial;
3232
nvme_disconnect_ctrl;
3333
nvme_dump_config;
@@ -68,17 +68,17 @@ LIBNVME_3 {
6868
nvme_get_telemetry_max;
6969
nvme_get_uuid_list;
7070
nvme_get_version;
71-
nvme_host_get;
71+
nvme_get_host;
7272
nvme_host_get_global_ctx;
7373
nvme_host_get_ids;
7474
nvme_host_is_pdc_enabled;
7575
nvme_host_release_fds;
7676
nvme_host_set_pdc_enabled;
77-
nvme_hostid_from_file;
78-
nvme_hostid_generate;
79-
nvme_hostnqn_from_file;
80-
nvme_hostnqn_generate;
81-
nvme_hostnqn_generate_from_hostid;
77+
nvme_read_hostid;
78+
nvme_generate_hostid;
79+
nvme_read_hostnqn;
80+
nvme_generate_hostnqn;
81+
nvme_generate_hostnqn_from_hostid;
8282
nvme_import_tls_key;
8383
nvme_import_tls_key_versioned;
8484
nvme_init_ctrl;
@@ -123,11 +123,11 @@ LIBNVME_3 {
123123
nvme_mi_submit_exit;
124124
nvme_namespace_attach_ctrls;
125125
nvme_namespace_detach_ctrls;
126-
nvme_namespace_filter;
126+
nvme_filter_namespace;
127127
nvme_namespace_first_path;
128128
nvme_namespace_next_path;
129-
nvme_nbft_free;
130-
nvme_nbft_read;
129+
nvme_free_nbft;
130+
nvme_read_nbft;
131131
nvme_next_host;
132132
nvme_next_subsystem;
133133
nvme_ns_attach;
@@ -145,7 +145,7 @@ LIBNVME_3 {
145145
nvme_ns_get_uuid;
146146
nvme_ns_identify;
147147
nvme_ns_read;
148-
nvme_ns_rescan;
148+
nvme_rescan_ns;
149149
nvme_ns_verify;
150150
nvme_ns_write;
151151
nvme_ns_write_uncorrectable;
@@ -155,7 +155,7 @@ LIBNVME_3 {
155155
nvme_path_get_ctrl;
156156
nvme_path_get_ns;
157157
nvme_path_get_queue_depth;
158-
nvme_paths_filter;
158+
nvme_filter_paths;
159159
nvme_read_config;
160160
nvme_read_key;
161161
nvme_refresh_topology;
@@ -186,10 +186,10 @@ LIBNVME_3 {
186186
nvme_strerror;
187187
nvme_submit_admin_passthru;
188188
nvme_submit_io_passthru;
189-
nvme_subsys_filter;
189+
nvme_filter_subsys;
190190
nvme_subsystem_first_ctrl;
191191
nvme_subsystem_first_ns;
192-
nvme_subsystem_get;
192+
nvme_get_subsystem;
193193
nvme_subsystem_get_fw_rev;
194194
nvme_subsystem_get_host;
195195
nvme_subsystem_get_nqn;
@@ -198,7 +198,7 @@ LIBNVME_3 {
198198
nvme_subsystem_next_ctrl;
199199
nvme_subsystem_next_ns;
200200
nvme_subsystem_release_fds;
201-
nvme_subsystem_reset;
201+
nvme_reset_subsystem;
202202
nvme_transport_handle_get_fd;
203203
nvme_transport_handle_get_name;
204204
nvme_transport_handle_is_blkdev;
@@ -210,9 +210,9 @@ LIBNVME_3 {
210210
nvme_transport_handle_set_submit_exit;
211211
nvme_unlink_ctrl;
212212
nvme_update_key;
213-
nvme_uuid_find;
213+
nvme_find_uuid;
214214
nvme_uuid_from_string;
215-
nvme_uuid_random;
215+
nvme_random_uuid;
216216
nvme_uuid_to_string;
217217
local:
218218
*;

libnvme/src/nvme/fabrics.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2425,9 +2425,9 @@ int nvmf_config_modify(struct nvme_global_ctx *ctx,
24252425
struct nvme_ctrl *c;
24262426

24272427
if (!fctx->hostnqn)
2428-
fctx->hostnqn = hnqn = nvme_hostnqn_from_file();
2428+
fctx->hostnqn = hnqn = nvme_read_hostnqn();
24292429
if (!fctx->hostid && hnqn)
2430-
fctx->hostid = hid = nvme_hostid_from_file();
2430+
fctx->hostid = hid = nvme_read_hostid();
24312431

24322432
h = nvme_lookup_host(ctx, fctx->hostnqn, fctx->hostid);
24332433
if (!h) {
@@ -2489,7 +2489,7 @@ int nvmf_nbft_read_files(struct nvme_global_ctx *ctx, char *path,
24892489
snprintf(filename, sizeof(filename), "%s/%s", path,
24902490
dent[i]->d_name);
24912491

2492-
ret = nvme_nbft_read(ctx, &nbft, filename);
2492+
ret = nvme_read_nbft(ctx, &nbft, filename);
24932493
if (!ret) {
24942494
struct nbft_file_entry *new;
24952495

@@ -2516,7 +2516,7 @@ void nvmf_nbft_free(struct nvme_global_ctx *ctx, struct nbft_file_entry *head)
25162516
while (head) {
25172517
struct nbft_file_entry *next = head->next;
25182518

2519-
nvme_nbft_free(ctx, head->nbft);
2519+
nvme_free_nbft(ctx, head->nbft);
25202520
free(head);
25212521

25222522
head = next;
@@ -3041,7 +3041,7 @@ int nvmf_discovery(struct nvme_global_ctx *ctx, struct nvmf_context *fctx,
30413041
ret = nvme_scan_ctrl(ctx, fctx->device, &c);
30423042
if (!ret) {
30433043
/* Check if device matches command-line options */
3044-
if (!nvme_ctrl_config_match(c, fctx->transport,
3044+
if (!nvme_ctrl_match_config(c, fctx->transport,
30453045
fctx->traddr, fctx->trsvcid,
30463046
fctx->subsysnqn, fctx->host_traddr,
30473047
fctx->host_iface)) {

libnvme/src/nvme/filters.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include "private.h"
1616

17-
int nvme_namespace_filter(const struct dirent *d)
17+
int nvme_filter_namespace(const struct dirent *d)
1818
{
1919
int i, n;
2020

@@ -28,7 +28,7 @@ int nvme_namespace_filter(const struct dirent *d)
2828
return 0;
2929
}
3030

31-
int nvme_paths_filter(const struct dirent *d)
31+
int nvme_filter_paths(const struct dirent *d)
3232
{
3333
int i, c, n;
3434

@@ -42,7 +42,7 @@ int nvme_paths_filter(const struct dirent *d)
4242
return 0;
4343
}
4444

45-
int nvme_ctrls_filter(const struct dirent *d)
45+
int nvme_filter_ctrls(const struct dirent *d)
4646
{
4747
int i, c, n;
4848

@@ -61,7 +61,7 @@ int nvme_ctrls_filter(const struct dirent *d)
6161
return 0;
6262
}
6363

64-
int nvme_subsys_filter(const struct dirent *d)
64+
int nvme_filter_subsys(const struct dirent *d)
6565
{
6666
int i;
6767

@@ -80,7 +80,7 @@ int nvme_scan_subsystems(struct dirent ***subsys)
8080
const char *dir = nvme_subsys_sysfs_dir();
8181
int ret;
8282

83-
ret = scandir(dir, subsys, nvme_subsys_filter, alphasort);
83+
ret = scandir(dir, subsys, nvme_filter_subsys, alphasort);
8484
if (ret < 0)
8585
return -errno;
8686

@@ -92,7 +92,7 @@ int nvme_scan_subsystem_namespaces(nvme_subsystem_t s, struct dirent ***ns)
9292
int ret;
9393

9494
ret = scandir(nvme_subsystem_get_sysfs_dir(s), ns,
95-
nvme_namespace_filter, alphasort);
95+
nvme_filter_namespace, alphasort);
9696
if (ret < 0)
9797
return -errno;
9898

@@ -104,7 +104,7 @@ int nvme_scan_ctrls(struct dirent ***ctrls)
104104
const char *dir = nvme_ctrl_sysfs_dir();
105105
int ret;
106106

107-
ret = scandir(dir, ctrls, nvme_ctrls_filter, alphasort);
107+
ret = scandir(dir, ctrls, nvme_filter_ctrls, alphasort);
108108
if (ret < 0)
109109
return -errno;
110110

@@ -116,7 +116,7 @@ int nvme_scan_ctrl_namespace_paths(nvme_ctrl_t c, struct dirent ***paths)
116116
int ret;
117117

118118
ret = scandir(nvme_ctrl_get_sysfs_dir(c), paths,
119-
nvme_paths_filter, alphasort);
119+
nvme_filter_paths, alphasort);
120120
if (ret < 0)
121121
return -errno;
122122

@@ -128,7 +128,7 @@ int nvme_scan_ctrl_namespaces(nvme_ctrl_t c, struct dirent ***ns)
128128
int ret;
129129

130130
ret = scandir(nvme_ctrl_get_sysfs_dir(c), ns,
131-
nvme_namespace_filter, alphasort);
131+
nvme_filter_namespace, alphasort);
132132
if (ret < 0)
133133
return -errno;
134134

@@ -140,7 +140,7 @@ int nvme_scan_ns_head_paths(nvme_ns_head_t head, struct dirent ***paths)
140140
int ret;
141141

142142
ret = scandir(nvme_ns_head_get_sysfs_dir(head), paths,
143-
nvme_paths_filter, alphasort);
143+
nvme_filter_paths, alphasort);
144144
if (ret < 0)
145145
return -errno;
146146

libnvme/src/nvme/filters.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,36 @@
2020
*/
2121

2222
/**
23-
* nvme_namespace_filter() - Filter for namespaces
23+
* nvme_filter_namespace() - Filter for namespaces
2424
* @d: dirent to check
2525
*
2626
* Return: 1 if @d matches, 0 otherwise
2727
*/
28-
int nvme_namespace_filter(const struct dirent *d);
28+
int nvme_filter_namespace(const struct dirent *d);
2929

3030
/**
31-
* nvme_paths_filter() - Filter for paths
31+
* nvme_filter_paths() - Filter for paths
3232
* @d: dirent to check
3333
*
3434
* Return: 1 if @d matches, 0 otherwise
3535
*/
36-
int nvme_paths_filter(const struct dirent *d);
36+
int nvme_filter_paths(const struct dirent *d);
3737

3838
/**
39-
* nvme_ctrls_filter() - Filter for controllers
39+
* nvme_filter_ctrls() - Filter for controllers
4040
* @d: dirent to check
4141
*
4242
* Return: 1 if @d matches, 0 otherwise
4343
*/
44-
int nvme_ctrls_filter(const struct dirent *d);
44+
int nvme_filter_ctrls(const struct dirent *d);
4545

4646
/**
47-
* nvme_subsys_filter() - Filter for subsystems
47+
* nvme_filter_subsys() - Filter for subsystems
4848
* @d: dirent to check
4949
*
5050
* Return: 1 if @d matches, 0 otherwise
5151
*/
52-
int nvme_subsys_filter(const struct dirent *d);
52+
int nvme_filter_subsys(const struct dirent *d);
5353

5454
/**
5555
* nvme_scan_subsystems() - Scan for subsystems

libnvme/src/nvme/ioctl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static int nvme_verify_chr(struct nvme_transport_handle *hdl)
3737
return 0;
3838
}
3939

40-
int nvme_subsystem_reset(struct nvme_transport_handle *hdl)
40+
int nvme_reset_subsystem(struct nvme_transport_handle *hdl)
4141
{
4242
int ret;
4343

@@ -51,7 +51,7 @@ int nvme_subsystem_reset(struct nvme_transport_handle *hdl)
5151
return ret;
5252
}
5353

54-
int nvme_ctrl_reset(struct nvme_transport_handle *hdl)
54+
int nvme_reset_ctrl(struct nvme_transport_handle *hdl)
5555
{
5656
int ret;
5757

@@ -65,7 +65,7 @@ int nvme_ctrl_reset(struct nvme_transport_handle *hdl)
6565
return ret;
6666
}
6767

68-
int nvme_ns_rescan(struct nvme_transport_handle *hdl)
68+
int nvme_rescan_ns(struct nvme_transport_handle *hdl)
6969
{
7070
int ret;
7171

0 commit comments

Comments
 (0)