Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libnvme/src/libnvme.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extern "C" {
#include <nvme/lib-types.h>
#include <nvme/lib.h>
#include <nvme/linux.h>
#include <nvme/mem.h>
#include <nvme/nvme-cmds.h>
#include <nvme/nvme-types.h>
#include <nvme/tree.h>
Expand Down
51 changes: 28 additions & 23 deletions libnvme/src/libnvme.ld
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@

LIBNVME_3 {
global:
libnvme_alloc;
libnvme_alloc_huge;
libnvme_clear_etdas;
libnvme_close;
libnvme_create_global_ctx;
libnvme_create_raw_secret;
libnvme_ctrl_first_ns;
libnvme_ctrl_first_path;
libnvme_ctrl_get_command_error_count;
libnvme_ctrl_get_phy_slot;
libnvme_ctrl_get_reconnect_count;
libnvme_ctrl_get_reset_count;
libnvme_ctrl_get_src_addr;
libnvme_ctrl_get_state;
libnvme_ctrl_get_subsysnqn;
libnvme_ctrl_get_subsystem;
libnvme_ctrl_get_transport_handle;
libnvme_ctrl_get_command_error_count;
libnvme_ctrl_get_reset_count;
libnvme_ctrl_get_reconnect_count;
libnvme_ctrl_identify;
libnvme_ctrl_match_config;
libnvme_ctrl_next_ns;
Expand All @@ -35,9 +37,11 @@ LIBNVME_3 {
libnvme_find_uuid;
libnvme_first_host;
libnvme_first_subsystem;
libnvme_free;
libnvme_free_ctrl;
libnvme_free_global_ctx;
libnvme_free_host;
libnvme_free_huge;
libnvme_free_nbft;
libnvme_free_ns;
libnvme_free_subsystem;
Expand Down Expand Up @@ -84,7 +88,6 @@ LIBNVME_3 {
libnvme_insert_tls_key_versioned;
libnvme_lookup_key;
libnvme_lookup_keyring;
libnvme_scan_ns_head_paths;
libnvme_mi_admin_xfer;
libnvme_mi_aem_disable;
libnvme_mi_aem_enable;
Expand Down Expand Up @@ -121,43 +124,46 @@ LIBNVME_3 {
libnvme_next_host;
libnvme_next_subsystem;
libnvme_ns_compare;
libnvme_ns_copy_uuid;
libnvme_ns_flush;
libnvme_ns_get_command_error_count;
libnvme_ns_get_command_retry_count;
libnvme_ns_get_csi;
libnvme_ns_get_ctrl;
libnvme_ns_get_eui64;
libnvme_ns_get_fail_no_available_path_count;
libnvme_ns_get_firmware;
libnvme_ns_get_generic_name;
libnvme_ns_get_inflights;
libnvme_ns_get_io_ticks;
libnvme_ns_get_model;
libnvme_ns_get_nguid;
libnvme_ns_get_read_ios;
libnvme_ns_get_read_sectors;
libnvme_ns_get_read_ticks;
libnvme_ns_get_requeue_no_usable_path_count;
libnvme_ns_get_serial;
libnvme_ns_get_subsystem;
libnvme_ns_copy_uuid;
libnvme_ns_reset_stat;
libnvme_ns_update_stat;
libnvme_ns_get_stat_interval;
libnvme_ns_get_read_ios;
libnvme_ns_get_subsystem;
libnvme_ns_get_write_ios;
libnvme_ns_get_read_ticks;
libnvme_ns_get_write_ticks;
libnvme_ns_get_read_sectors;
libnvme_ns_get_write_sectors;
libnvme_ns_get_inflights;
libnvme_ns_get_io_ticks;
libnvme_ns_get_command_retry_count;
libnvme_ns_get_command_error_count;
libnvme_ns_get_requeue_no_usable_path_count;
libnvme_ns_get_fail_no_available_path_count;
libnvme_ns_get_write_ticks;
libnvme_ns_identify;
libnvme_ns_read;
libnvme_ns_reset_stat;
libnvme_ns_update_stat;
libnvme_ns_verify;
libnvme_ns_write;
libnvme_ns_write_uncorrectable;
libnvme_ns_write_zeros;
libnvme_open;
libnvme_path_get_ana_state;
libnvme_path_get_command_error_count;
libnvme_path_get_command_retry_count;
libnvme_path_get_ctrl;
libnvme_path_get_inflights;
libnvme_path_get_io_ticks;
libnvme_path_get_multipath_failover_count;
libnvme_path_get_ns;
libnvme_path_get_numa_nodes;
libnvme_path_get_queue_depth;
Expand All @@ -170,15 +176,13 @@ LIBNVME_3 {
libnvme_path_get_write_ticks;
libnvme_path_reset_stat;
libnvme_path_update_stat;
libnvme_path_get_command_retry_count;
libnvme_path_get_command_error_count;
libnvme_path_get_multipath_failover_count;
libnvme_random_uuid;
libnvme_read_config;
libnvme_read_hostid;
libnvme_read_hostnqn;
libnvme_read_key;
libnvme_read_nbft;
libnvme_realloc;
libnvme_refresh_topology;
libnvme_rescan_ctrl;
libnvme_rescan_ns;
Expand All @@ -190,6 +194,7 @@ LIBNVME_3 {
libnvme_scan_ctrl_namespaces;
libnvme_scan_ctrls;
libnvme_scan_namespace;
libnvme_scan_ns_head_paths;
libnvme_scan_subsystem_namespaces;
libnvme_scan_subsystems;
libnvme_scan_tls_keys;
Expand All @@ -205,9 +210,7 @@ LIBNVME_3 {
libnvme_status_to_string;
libnvme_strerror;
libnvme_submit_admin_passthru;
libnvme_wait_admin_passthru;
libnvme_submit_io_passthru;
libnvme_wait_io_passthru;
libnvme_subsystem_first_ctrl;
libnvme_subsystem_first_ns;
libnvme_subsystem_get_host;
Expand All @@ -231,6 +234,8 @@ LIBNVME_3 {
libnvme_update_key;
libnvme_uuid_from_string;
libnvme_uuid_to_string;
libnvme_wait_admin_passthru;
libnvme_wait_io_passthru;
local:
*;
};
6 changes: 5 additions & 1 deletion libnvme/src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#
sources = []
if host_system == 'windows'
sources += []
sources += [
'nvme/mem-win.c',
]
else
sources += [
'nvme/accessors.c',
Expand All @@ -18,6 +20,7 @@ else
'nvme/lib.c',
'nvme/linux.c',
'nvme/log.c',
'nvme/mem-linux.c',
'nvme/nvme-cmds.c',
'nvme/sysfs.c',
'nvme/tree.c',
Expand All @@ -32,6 +35,7 @@ headers = [
'nvme/lib-types.h',
'nvme/lib.h',
'nvme/linux.h',
'nvme/mem.h',
'nvme/nvme-cmds.h',
'nvme/nvme-types.h',
'nvme/tree.h',
Expand Down
8 changes: 8 additions & 0 deletions libnvme/src/nvme/cleanup.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include <stdlib.h>

#include <nvme/mem.h>

#define __cleanup(fn) __attribute__((cleanup(fn)))

#define DECLARE_CLEANUP_FUNC(name, type) \
Expand All @@ -22,4 +24,10 @@ static inline void freep(void *p)
}
#define __cleanup_free __cleanup(freep)

static inline void libnvme_freep(void *p)
{
libnvme_free(*(void **)p);
}
#define __cleanup_libnvme_free __cleanup(libnvme_freep)

#endif
18 changes: 9 additions & 9 deletions libnvme/src/nvme/fabrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,7 @@ static int nvme_discovery_log(libnvme_ctrl_t ctrl,
hdl = libnvme_ctrl_get_transport_handle(ctrl);
struct libnvme_passthru_cmd cmd;

log = __libnvme_alloc(sizeof(*log));
log = libnvme_alloc(sizeof(*log));
if (!log) {
libnvme_msg(ctx, LIBNVME_LOG_ERR,
"could not allocate memory for discovery log header\n");
Expand All @@ -1426,9 +1426,9 @@ static int nvme_discovery_log(libnvme_ctrl_t ctrl,
if (numrec == 0)
break;

free(log);
libnvme_free(log);
entries_size = sizeof(*log->entries) * numrec;
log = __libnvme_alloc(sizeof(*log) + entries_size);
log = libnvme_alloc(sizeof(*log) + entries_size);
if (!log) {
libnvme_msg(ctx, LIBNVME_LOG_ERR,
"could not alloc memory for discovery log page\n");
Expand Down Expand Up @@ -1483,7 +1483,7 @@ static int nvme_discovery_log(libnvme_ctrl_t ctrl,
}

out_free_log:
free(log);
libnvme_free(log);
return err;
}

Expand Down Expand Up @@ -1772,10 +1772,10 @@ static const char *dctype_str[] = {
*/
static int nvme_fetch_cntrltype_dctype_from_id(libnvme_ctrl_t c)
{
__cleanup_free struct nvme_id_ctrl *id = NULL;
__cleanup_libnvme_free struct nvme_id_ctrl *id = NULL;
int ret;

id = __libnvme_alloc(sizeof(*id));
id = libnvme_alloc(sizeof(*id));
if (!id)
return -ENOMEM;

Expand Down Expand Up @@ -2247,7 +2247,7 @@ static int nvmf_create_discovery_ctrl(struct libnvme_global_ctx *ctx,
struct libnvmf_context *fctx, libnvme_host_t h,
struct libnvme_ctrl **ctrl)
{
__cleanup_free struct nvme_id_ctrl *id = NULL;
__cleanup_libnvme_free struct nvme_id_ctrl *id = NULL;
struct libnvme_ctrl *c;
int ret;

Expand All @@ -2260,7 +2260,7 @@ static int nvmf_create_discovery_ctrl(struct libnvme_global_ctx *ctx,
return 0;
}

id = __libnvme_alloc(sizeof(*id));
id = libnvme_alloc(sizeof(*id));
if (!id) {
libnvme_free_ctrl(c);
return -ENOMEM;
Expand Down Expand Up @@ -2827,7 +2827,7 @@ static int nbft_discovery(struct libnvme_global_ctx *ctx,
fctx->cfg.keep_alive_tmo = tmo;
}

free(log);
libnvme_free(log);
return 0;
}

Expand Down
Loading
Loading