bdev_module.h File Reference

Block Device Module Interface. More...

Data Structures

struct  spdk_bdev_module
 Block device module. More...
 
struct  spdk_bdev_module::__bdev_module_internal_fields
 Fields that are used by the internal bdev subsystem. More...
 
struct  spdk_bdev_fn_table
 Function table for a block device backend. More...
 
struct  spdk_bdev_alias
 
struct  spdk_bdev
 
struct  spdk_bdev::__bdev_internal_fields
 Fields that are used internally by the bdev subsystem. More...
 
struct  spdk_bdev_io
 
struct  spdk_bdev_io::__bdev_io_internal_fields
 Fields that are used internally by the bdev subsystem. More...
 
struct  spdk_bdev_part
 
struct  spdk_bdev_part::bdev_part_internal_fields
 Fields that are used internally by part.c These fields should only be accessed from a module using any pertinent get and set methods. More...
 
struct  spdk_bdev_part_channel
 

Macros

#define BDEV_IO_NUM_CHILD_IOV   32
 
#define SPDK_BDEV_MODULE_REGISTER(name, module)
 

Typedefs

typedef void(* spdk_bdev_unregister_cb) (void *cb_arg, int rc)
 
typedef void(* spdk_bdev_io_get_buf_cb) (struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io, bool success)
 Callback when buffer is allocated for the bdev I/O. More...
 
typedef void(* spdk_bdev_io_get_aux_buf_cb) (struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io, void *aux_buf)
 Callback when an auxiliary buffer is allocated for the bdev I/O. More...
 
typedef void(* spdk_bdev_part_base_free_fn) (void *ctx)
 

Enumerations

enum  spdk_bdev_io_status {
  SPDK_BDEV_IO_STATUS_FIRST_FUSED_FAILED = -6, SPDK_BDEV_IO_STATUS_MISCOMPARE = -5, SPDK_BDEV_IO_STATUS_NOMEM = -4, SPDK_BDEV_IO_STATUS_SCSI_ERROR = -3,
  SPDK_BDEV_IO_STATUS_NVME_ERROR = -2, SPDK_BDEV_IO_STATUS_FAILED = -1, SPDK_BDEV_IO_STATUS_PENDING = 0, SPDK_BDEV_IO_STATUS_SUCCESS = 1
}
 bdev I/O completion status
 

Functions

typedef TAILQ_HEAD (, spdk_bdev_io) bdev_io_tailq_t
 
typedef STAILQ_HEAD (, spdk_bdev_io) bdev_io_stailq_t
 
typedef TAILQ_HEAD (, lba_range) lba_range_tailq_t
 
int spdk_bdev_register (struct spdk_bdev *bdev)
 Register a new bdev. More...
 
void spdk_bdev_unregister (struct spdk_bdev *bdev, spdk_bdev_unregister_cb cb_fn, void *cb_arg)
 Start unregistering a bdev. More...
 
void spdk_bdev_destruct_done (struct spdk_bdev *bdev, int bdeverrno)
 Invokes the unregister callback of a bdev backing a virtual bdev. More...
 
int spdk_vbdev_register (struct spdk_bdev *vbdev, struct spdk_bdev **base_bdevs, int base_bdev_count)
 Register a virtual bdev. More...
 
void spdk_bdev_module_examine_done (struct spdk_bdev_module *module)
 Indicate to the bdev layer that the module is done examining a bdev. More...
 
void spdk_bdev_module_init_done (struct spdk_bdev_module *module)
 Indicate to the bdev layer that the module is done initializing. More...
 
void spdk_bdev_module_finish_done (void)
 Indicate to the bdev layer that the module is done cleaning up. More...
 
int spdk_bdev_module_claim_bdev (struct spdk_bdev *bdev, struct spdk_bdev_desc *desc, struct spdk_bdev_module *module)
 Called by a bdev module to lay exclusive write claim to a bdev. More...
 
void spdk_bdev_module_release_bdev (struct spdk_bdev *bdev)
 Called to release a write claim on a block device. More...
 
int spdk_bdev_alias_add (struct spdk_bdev *bdev, const char *alias)
 Add alias to block device names list. More...
 
int spdk_bdev_alias_del (struct spdk_bdev *bdev, const char *alias)
 Removes name from block device names list. More...
 
void spdk_bdev_alias_del_all (struct spdk_bdev *bdev)
 Removes all alias from block device alias list. More...
 
const struct spdk_bdev_aliases_list * spdk_bdev_get_aliases (const struct spdk_bdev *bdev)
 Get pointer to block device aliases list. More...
 
void spdk_bdev_io_get_buf (struct spdk_bdev_io *bdev_io, spdk_bdev_io_get_buf_cb cb, uint64_t len)
 Allocate a buffer for given bdev_io. More...
 
void spdk_bdev_io_get_aux_buf (struct spdk_bdev_io *bdev_io, spdk_bdev_io_get_aux_buf_cb cb)
 Allocate an auxillary buffer for given bdev_io. More...
 
void spdk_bdev_io_put_aux_buf (struct spdk_bdev_io *bdev_io, void *aux_buf)
 Free an auxiliary buffer previously allocated by spdk_bdev_io_get_aux_buf(). More...
 
void spdk_bdev_io_set_buf (struct spdk_bdev_io *bdev_io, void *buf, size_t len)
 Set the given buffer as the data buffer described by this bdev_io. More...
 
void spdk_bdev_io_set_md_buf (struct spdk_bdev_io *bdev_io, void *md_buf, size_t len)
 Set the given buffer as metadata buffer described by this bdev_io. More...
 
void spdk_bdev_io_complete (struct spdk_bdev_io *bdev_io, enum spdk_bdev_io_status status)
 Complete a bdev_io. More...
 
void spdk_bdev_io_complete_nvme_status (struct spdk_bdev_io *bdev_io, uint32_t cdw0, int sct, int sc)
 Complete a bdev_io with an NVMe status code and DW0 completion queue entry. More...
 
void spdk_bdev_io_complete_scsi_status (struct spdk_bdev_io *bdev_io, enum spdk_scsi_status sc, enum spdk_scsi_sense sk, uint8_t asc, uint8_t ascq)
 Complete a bdev_io with a SCSI status code. More...
 
struct spdk_thread * spdk_bdev_io_get_thread (struct spdk_bdev_io *bdev_io)
 Get a thread that given bdev_io was submitted on. More...
 
struct spdk_io_channelspdk_bdev_io_get_io_channel (struct spdk_bdev_io *bdev_io)
 Get the bdev module's I/O channel that the given bdev_io was submitted on. More...
 
int spdk_bdev_notify_blockcnt_change (struct spdk_bdev *bdev, uint64_t size)
 Resize for a bdev. More...
 
void spdk_scsi_nvme_translate (const struct spdk_bdev_io *bdev_io, int *sc, int *sk, int *asc, int *ascq)
 Translates NVMe status codes to SCSI status information. More...
 
void spdk_bdev_module_list_add (struct spdk_bdev_module *bdev_module)
 Add the given module to the list of registered modules. More...
 
struct spdk_bdev_modulespdk_bdev_module_list_find (const char *name)
 Find registered module with name pointed by name. More...
 
static struct spdk_bdev_iospdk_bdev_io_from_ctx (void *ctx)
 
struct spdk_bdevspdk_bdev_part_base_get_bdev (struct spdk_bdev_part_base *part_base)
 Returns a pointer to the spdk_bdev associated with an spdk_bdev_part_base. More...
 
const char * spdk_bdev_part_base_get_bdev_name (struct spdk_bdev_part_base *part_base)
 Returns a spdk_bdev name of the corresponding spdk_bdev_part_base. More...
 
struct spdk_bdev_desc * spdk_bdev_part_base_get_desc (struct spdk_bdev_part_base *part_base)
 Returns a pointer to the spdk_bdev_descriptor associated with an spdk_bdev_part_base. More...
 
struct bdev_part_tailq * spdk_bdev_part_base_get_tailq (struct spdk_bdev_part_base *part_base)
 Returns a pointer to the tailq associated with an spdk_bdev_part_base. More...
 
void * spdk_bdev_part_base_get_ctx (struct spdk_bdev_part_base *part_base)
 Returns a pointer to the module level context associated with an spdk_bdev_part_base. More...
 
typedef TAILQ_HEAD (bdev_part_tailq, spdk_bdev_part) SPDK_BDEV_PART_TAILQ
 
void spdk_bdev_part_base_free (struct spdk_bdev_part_base *base)
 Free the base corresponding to one or more spdk_bdev_part. More...
 
int spdk_bdev_part_free (struct spdk_bdev_part *part)
 Free an spdk_bdev_part context. More...
 
void spdk_bdev_part_base_hotremove (struct spdk_bdev_part_base *part_base, struct bdev_part_tailq *tailq)
 Calls spdk_bdev_unregister on the bdev for each part associated with base_bdev. More...
 
struct spdk_bdev_part_base * spdk_bdev_part_base_construct (struct spdk_bdev *bdev, spdk_bdev_remove_cb_t remove_cb, struct spdk_bdev_module *module, struct spdk_bdev_fn_table *fn_table, struct bdev_part_tailq *tailq, spdk_bdev_part_base_free_fn free_fn, void *ctx, uint32_t channel_size, spdk_io_channel_create_cb ch_create_cb, spdk_io_channel_destroy_cb ch_destroy_cb)
 Construct a new spdk_bdev_part_base on top of the provided bdev. More...
 
int spdk_bdev_part_construct (struct spdk_bdev_part *part, struct spdk_bdev_part_base *base, char *name, uint64_t offset_blocks, uint64_t num_blocks, char *product_name)
 Create a logical spdk_bdev_part on top of a base. More...
 
int spdk_bdev_part_submit_request (struct spdk_bdev_part_channel *ch, struct spdk_bdev_io *bdev_io)
 Forwards I/O from an spdk_bdev_part to the underlying base bdev. More...
 
struct spdk_bdevspdk_bdev_part_get_bdev (struct spdk_bdev_part *part)
 Return a pointer to this part's spdk_bdev. More...
 
struct spdk_bdev_part_base * spdk_bdev_part_get_base (struct spdk_bdev_part *part)
 Return a pointer to this part's base. More...
 
struct spdk_bdevspdk_bdev_part_get_base_bdev (struct spdk_bdev_part *part)
 Return a pointer to this part's base bdev. More...
 
uint64_t spdk_bdev_part_get_offset_blocks (struct spdk_bdev_part *part)
 Return this part's offset from the beginning of the base bdev. More...
 
int spdk_bdev_push_media_events (struct spdk_bdev *bdev, const struct spdk_bdev_media_event *events, size_t num_events)
 Push media management events. More...
 
void spdk_bdev_notify_media_management (struct spdk_bdev *bdev)
 Send SPDK_BDEV_EVENT_MEDIA_MANAGEMENT to all open descriptors that have pending media events. More...
 

Detailed Description

Block Device Module Interface.

For information on how to write a bdev module, see Writing a Custom Block Device Module.

Macro Definition Documentation

◆ SPDK_BDEV_MODULE_REGISTER

#define SPDK_BDEV_MODULE_REGISTER (   name,
  module 
)
Value:
static void __attribute__((constructor)) spdk_bdev_module_register_##name(void) \
{ \
spdk_bdev_module_list_add(module); \
} \

Typedef Documentation

◆ spdk_bdev_io_get_aux_buf_cb

typedef void(* spdk_bdev_io_get_aux_buf_cb) (struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io, void *aux_buf)

Callback when an auxiliary buffer is allocated for the bdev I/O.

Parameters
chThe I/O channel the bdev I/O was handled on.
bdev_ioThe bdev I/O
aux_bufPointer to the allocated buffer. NULL if there was a failuer such as the size of the buffer to allocate is greater than the permitted maximum.

◆ spdk_bdev_io_get_buf_cb

typedef void(* spdk_bdev_io_get_buf_cb) (struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io, bool success)

Callback when buffer is allocated for the bdev I/O.

Parameters
chThe I/O channel the bdev I/O was handled on.
bdev_ioThe bdev I/O
successTrue if buffer is allocated successfully or the bdev I/O has an SGL assigned already, or false if it failed. The possible reason of failure is the size of the buffer to allocate is greater than the permitted maximum.

Function Documentation

◆ spdk_bdev_alias_add()

int spdk_bdev_alias_add ( struct spdk_bdev bdev,
const char *  alias 
)

Add alias to block device names list.

Aliases can be add only to registered bdev.

Parameters
bdevBlock device to query.
aliasAlias to be added to list.
Returns
0 on success
-EEXIST if alias already exists as name or alias on any bdev
-ENOMEM if memory cannot be allocated to store alias
-EINVAL if passed alias is empty

◆ spdk_bdev_alias_del()

int spdk_bdev_alias_del ( struct spdk_bdev bdev,
const char *  alias 
)

Removes name from block device names list.

Parameters
bdevBlock device to query.
aliasAlias to be deleted from list.
Returns
0 on success
-ENOENT if alias does not exists

◆ spdk_bdev_alias_del_all()

void spdk_bdev_alias_del_all ( struct spdk_bdev bdev)

Removes all alias from block device alias list.

Parameters
bdevBlock device to operate.

◆ spdk_bdev_destruct_done()

void spdk_bdev_destruct_done ( struct spdk_bdev bdev,
int  bdeverrno 
)

Invokes the unregister callback of a bdev backing a virtual bdev.

A Bdev with an asynchronous destruct path should return 1 from its destruct function and call this function at the conclusion of that path. Bdevs with synchronous destruct paths should return 0 from their destruct path.

Parameters
bdevBlock device that was destroyed.
bdeverrnoError code returned from bdev's destruct callback.

◆ spdk_bdev_get_aliases()

const struct spdk_bdev_aliases_list* spdk_bdev_get_aliases ( const struct spdk_bdev bdev)

Get pointer to block device aliases list.

Parameters
bdevBlock device to query.
Returns
Pointer to bdev aliases list.

◆ spdk_bdev_io_complete()

void spdk_bdev_io_complete ( struct spdk_bdev_io bdev_io,
enum spdk_bdev_io_status  status 
)

Complete a bdev_io.

Parameters
bdev_ioI/O to complete.
statusThe I/O completion status.

◆ spdk_bdev_io_complete_nvme_status()

void spdk_bdev_io_complete_nvme_status ( struct spdk_bdev_io bdev_io,
uint32_t  cdw0,
int  sct,
int  sc 
)

Complete a bdev_io with an NVMe status code and DW0 completion queue entry.

Parameters
bdev_ioI/O to complete.
cdw0NVMe Completion Queue DW0 value (set to 0 if not applicable)
sctNVMe Status Code Type.
scNVMe Status Code.

◆ spdk_bdev_io_complete_scsi_status()

void spdk_bdev_io_complete_scsi_status ( struct spdk_bdev_io bdev_io,
enum spdk_scsi_status  sc,
enum spdk_scsi_sense  sk,
uint8_t  asc,
uint8_t  ascq 
)

Complete a bdev_io with a SCSI status code.

Parameters
bdev_ioI/O to complete.
scSCSI Status Code.
skSCSI Sense Key.
ascSCSI Additional Sense Code.
ascqSCSI Additional Sense Code Qualifier.

◆ spdk_bdev_io_get_aux_buf()

void spdk_bdev_io_get_aux_buf ( struct spdk_bdev_io bdev_io,
spdk_bdev_io_get_aux_buf_cb  cb 
)

Allocate an auxillary buffer for given bdev_io.

The length of the buffer will be the same size as the bdev_io primary buffer. The buffer must be freed using spdk_bdev_io_put_aux_buf() before completing the associated bdev_io. This call will never fail. In case of lack of memory given callback cb will be deferred until enough memory is freed.

Parameters
bdev_ioI/O to allocate buffer for.
cbcallback to be called when the buffer is allocated

◆ spdk_bdev_io_get_buf()

void spdk_bdev_io_get_buf ( struct spdk_bdev_io bdev_io,
spdk_bdev_io_get_buf_cb  cb,
uint64_t  len 
)

Allocate a buffer for given bdev_io.

Allocation will happen only if the bdev_io has no assigned SGL yet or SGL is not aligned to bdev->required_alignment. If SGL is not aligned, this call will cause copy from SGL to bounce buffer on write path or copy from bounce buffer to SGL before completion callback on read path. The buffer will be freed automatically on spdk_bdev_free_io() call. This call will never fail. In case of lack of memory given callback cb will be deferred until enough memory is freed.

Parameters
bdev_ioI/O to allocate buffer for.
cbcallback to be called when the buffer is allocated or the bdev_io has an SGL assigned already.
lensize of the buffer to allocate. In case the bdev_io doesn't have an SGL assigned this field must be no bigger than SPDK_BDEV_LARGE_BUF_MAX_SIZE.

◆ spdk_bdev_io_get_io_channel()

struct spdk_io_channel* spdk_bdev_io_get_io_channel ( struct spdk_bdev_io bdev_io)

Get the bdev module's I/O channel that the given bdev_io was submitted on.

Parameters
bdev_ioI/O
Returns
the bdev module's I/O channel that the given bdev_io was submitted on.

◆ spdk_bdev_io_get_thread()

struct spdk_thread* spdk_bdev_io_get_thread ( struct spdk_bdev_io bdev_io)

Get a thread that given bdev_io was submitted on.

Parameters
bdev_ioI/O
Returns
thread that submitted the I/O

◆ spdk_bdev_io_put_aux_buf()

void spdk_bdev_io_put_aux_buf ( struct spdk_bdev_io bdev_io,
void *  aux_buf 
)

Free an auxiliary buffer previously allocated by spdk_bdev_io_get_aux_buf().

Parameters
bdev_iobdev_io specified when the aux_buf was allocated.
aux_bufauxiliary buffer to free

◆ spdk_bdev_io_set_buf()

void spdk_bdev_io_set_buf ( struct spdk_bdev_io bdev_io,
void *  buf,
size_t  len 
)

Set the given buffer as the data buffer described by this bdev_io.

The portion of the buffer used may be adjusted for memory alignement purposes.

Parameters
bdev_ioI/O to set the buffer on.
bufThe buffer to set as the active data buffer.
lenThe length of the buffer.

◆ spdk_bdev_io_set_md_buf()

void spdk_bdev_io_set_md_buf ( struct spdk_bdev_io bdev_io,
void *  md_buf,
size_t  len 
)

Set the given buffer as metadata buffer described by this bdev_io.

Parameters
bdev_ioI/O to set the buffer on.
md_bufThe buffer to set as the active metadata buffer.
lenThe length of the metadata buffer.

◆ spdk_bdev_module_claim_bdev()

int spdk_bdev_module_claim_bdev ( struct spdk_bdev bdev,
struct spdk_bdev_desc *  desc,
struct spdk_bdev_module module 
)

Called by a bdev module to lay exclusive write claim to a bdev.

Also upgrades that bdev's descriptor to have write access.

Parameters
bdevBlock device to be claimed.
descDescriptor for the above block device.
moduleBdev module attempting to claim bdev.
Returns
0 on success
-EPERM if the bdev is already claimed by another module.

◆ spdk_bdev_module_examine_done()

void spdk_bdev_module_examine_done ( struct spdk_bdev_module module)

Indicate to the bdev layer that the module is done examining a bdev.

To be called synchronously or asynchronously in response to the module's examine function being called.

Parameters
modulePointer to the module completing the examination.

◆ spdk_bdev_module_finish_done()

void spdk_bdev_module_finish_done ( void  )

Indicate to the bdev layer that the module is done cleaning up.

To be called either synchronously or asynchronously in response to the module_fini function being called.

◆ spdk_bdev_module_init_done()

void spdk_bdev_module_init_done ( struct spdk_bdev_module module)

Indicate to the bdev layer that the module is done initializing.

To be called synchronously or asynchronously in response to the module_init function being called.

Parameters
modulePointer to the module completing the initialization.

◆ spdk_bdev_module_list_add()

void spdk_bdev_module_list_add ( struct spdk_bdev_module bdev_module)

Add the given module to the list of registered modules.

This function should be invoked by referencing the macro SPDK_BDEV_MODULE_REGISTER in the module c file.

Parameters
bdev_moduleModule to be added.

◆ spdk_bdev_module_list_find()

struct spdk_bdev_module* spdk_bdev_module_list_find ( const char *  name)

Find registered module with name pointed by name.

Parameters
namename of module to be searched for.
Returns
pointer to module or NULL if no module with name exist

◆ spdk_bdev_module_release_bdev()

void spdk_bdev_module_release_bdev ( struct spdk_bdev bdev)

Called to release a write claim on a block device.

Parameters
bdevBlock device to be released.

◆ spdk_bdev_notify_blockcnt_change()

int spdk_bdev_notify_blockcnt_change ( struct spdk_bdev bdev,
uint64_t  size 
)

Resize for a bdev.

Change number of blocks for provided block device. It can only be called on a registered bdev.

Parameters
bdevBlock device to change.
sizeNew size of bdev.
Returns
0 on success, negated errno on failure.

◆ spdk_bdev_notify_media_management()

void spdk_bdev_notify_media_management ( struct spdk_bdev bdev)

Send SPDK_BDEV_EVENT_MEDIA_MANAGEMENT to all open descriptors that have pending media events.

Parameters
bdevBlock device

◆ spdk_bdev_part_base_construct()

struct spdk_bdev_part_base* spdk_bdev_part_base_construct ( struct spdk_bdev bdev,
spdk_bdev_remove_cb_t  remove_cb,
struct spdk_bdev_module module,
struct spdk_bdev_fn_table fn_table,
struct bdev_part_tailq *  tailq,
spdk_bdev_part_base_free_fn  free_fn,
void *  ctx,
uint32_t  channel_size,
spdk_io_channel_create_cb  ch_create_cb,
spdk_io_channel_destroy_cb  ch_destroy_cb 
)

Construct a new spdk_bdev_part_base on top of the provided bdev.

Parameters
bdevThe spdk_bdev upon which this base will be built.
remove_cbFunction to be called upon hotremove of the bdev.
moduleThe module to which this bdev base belongs.
fn_tableFunction table for communicating with the bdev backend.
tailqThe head of the list of all spdk_bdev_part structures registered to this base's module.
free_fnUser provided function to free base related context upon bdev removal or shutdown.
ctxModule specific context for this bdev part base.
channel_sizeChannel size in bytes.
ch_create_cbCalled after a new channel is allocated.
ch_destroy_cbCalled upon channel deletion.
Returns
0 on success
-1 if the underlying bdev cannot be opened.

◆ spdk_bdev_part_base_free()

void spdk_bdev_part_base_free ( struct spdk_bdev_part_base *  base)

Free the base corresponding to one or more spdk_bdev_part.

Parameters
baseThe base to free.

◆ spdk_bdev_part_base_get_bdev()

struct spdk_bdev* spdk_bdev_part_base_get_bdev ( struct spdk_bdev_part_base *  part_base)

Returns a pointer to the spdk_bdev associated with an spdk_bdev_part_base.

Parameters
part_baseA pointer to an spdk_bdev_part_base object.
Returns
A pointer to the base's spdk_bdev struct.

◆ spdk_bdev_part_base_get_bdev_name()

const char* spdk_bdev_part_base_get_bdev_name ( struct spdk_bdev_part_base *  part_base)

Returns a spdk_bdev name of the corresponding spdk_bdev_part_base.

Parameters
part_baseA pointer to an spdk_bdev_part_base object.
Returns
A text string representing the name of the base bdev.

◆ spdk_bdev_part_base_get_ctx()

void* spdk_bdev_part_base_get_ctx ( struct spdk_bdev_part_base *  part_base)

Returns a pointer to the module level context associated with an spdk_bdev_part_base.

Parameters
part_baseA pointer to an spdk_bdev_part_base object.
Returns
A pointer to the module level context registered with the base in spdk_bdev_part_base_construct.

◆ spdk_bdev_part_base_get_desc()

struct spdk_bdev_desc* spdk_bdev_part_base_get_desc ( struct spdk_bdev_part_base *  part_base)

Returns a pointer to the spdk_bdev_descriptor associated with an spdk_bdev_part_base.

Parameters
part_baseA pointer to an spdk_bdev_part_base object.
Returns
A pointer to the base's spdk_bdev_desc struct.

◆ spdk_bdev_part_base_get_tailq()

struct bdev_part_tailq* spdk_bdev_part_base_get_tailq ( struct spdk_bdev_part_base *  part_base)

Returns a pointer to the tailq associated with an spdk_bdev_part_base.

Parameters
part_baseA pointer to an spdk_bdev_part_base object.
Returns
The head of a tailq of spdk_bdev_part structs registered to the base's module.

◆ spdk_bdev_part_base_hotremove()

void spdk_bdev_part_base_hotremove ( struct spdk_bdev_part_base *  part_base,
struct bdev_part_tailq *  tailq 
)

Calls spdk_bdev_unregister on the bdev for each part associated with base_bdev.

Parameters
part_baseThe part base object built on top of an spdk_bdev
tailqThe list of spdk_bdev_part bdevs associated with this base bdev.

◆ spdk_bdev_part_construct()

int spdk_bdev_part_construct ( struct spdk_bdev_part part,
struct spdk_bdev_part_base *  base,
char *  name,
uint64_t  offset_blocks,
uint64_t  num_blocks,
char *  product_name 
)

Create a logical spdk_bdev_part on top of a base.

Parameters
partThe part object allocated by the user.
baseThe base from which to create the part.
nameThe name of the new spdk_bdev_part.
offset_blocksThe offset into the base bdev at which this part begins.
num_blocksThe number of blocks that this part will span.
product_nameUnique name for this type of block device.
Returns
0 on success.
-1 if the bases underlying bdev cannot be claimed by the current module.

◆ spdk_bdev_part_free()

int spdk_bdev_part_free ( struct spdk_bdev_part part)

Free an spdk_bdev_part context.

Parameters
partThe part to free.
Returns
1 always. To indicate that the operation is asynchronous.

◆ spdk_bdev_part_get_base()

struct spdk_bdev_part_base* spdk_bdev_part_get_base ( struct spdk_bdev_part part)

Return a pointer to this part's base.

Parameters
partAn spdk_bdev_part object.
Returns
A pointer to this part's spdk_bdev_part_base object.

◆ spdk_bdev_part_get_base_bdev()

struct spdk_bdev* spdk_bdev_part_get_base_bdev ( struct spdk_bdev_part part)

Return a pointer to this part's base bdev.

The return value of this function is equivalent to calling spdk_bdev_part_base_get_bdev on this part's base.

Parameters
partAn spdk_bdev_part object.
Returns
A pointer to the bdev belonging to this part's base.

◆ spdk_bdev_part_get_bdev()

struct spdk_bdev* spdk_bdev_part_get_bdev ( struct spdk_bdev_part part)

Return a pointer to this part's spdk_bdev.

Parameters
partAn spdk_bdev_part object.
Returns
A pointer to this part's spdk_bdev object.

◆ spdk_bdev_part_get_offset_blocks()

uint64_t spdk_bdev_part_get_offset_blocks ( struct spdk_bdev_part part)

Return this part's offset from the beginning of the base bdev.

This function should not be called in the I/O path. Any block translations to I/O will be handled in spdk_bdev_part_submit_request.

Parameters
partAn spdk_bdev_part object.
Returns
the block offset of this part from it's underlying bdev.

◆ spdk_bdev_part_submit_request()

int spdk_bdev_part_submit_request ( struct spdk_bdev_part_channel ch,
struct spdk_bdev_io bdev_io 
)

Forwards I/O from an spdk_bdev_part to the underlying base bdev.

This function will apply the offset_blocks the user provided to spdk_bdev_part_construct to the I/O. The user should not manually apply this offset before submitting any I/O through this function.

Parameters
chThe I/O channel associated with the spdk_bdev_part.
bdev_ioThe I/O to be submitted to the underlying bdev.
Returns
0 on success or non-zero if submit request failed.

◆ spdk_bdev_push_media_events()

int spdk_bdev_push_media_events ( struct spdk_bdev bdev,
const struct spdk_bdev_media_event events,
size_t  num_events 
)

Push media management events.

To send the notification that new events are available, spdk_bdev_notify_media_management needs to be called.

Parameters
bdevBlock device
eventsArray of media events
num_eventsSize of the events array
Returns
number of events pushed or negative errno in case of failure

◆ spdk_bdev_register()

int spdk_bdev_register ( struct spdk_bdev bdev)

Register a new bdev.

Parameters
bdevBlock device to register.
Returns
0 on success.
-EINVAL if the bdev name is NULL.
-EEXIST if a bdev or bdev alias with the same name already exists.

◆ spdk_bdev_unregister()

void spdk_bdev_unregister ( struct spdk_bdev bdev,
spdk_bdev_unregister_cb  cb_fn,
void *  cb_arg 
)

Start unregistering a bdev.

This will notify each currently open descriptor on this bdev about the hotremoval in hopes that the upper layers will stop using this bdev and manually close all the descriptors with spdk_bdev_close(). The actual bdev unregistration may be deferred until all descriptors are closed.

Parameters
bdevBlock device to unregister.
cb_fnCallback function to be called when the unregister is complete.
cb_argArgument to be supplied to cb_fn

◆ spdk_scsi_nvme_translate()

void spdk_scsi_nvme_translate ( const struct spdk_bdev_io bdev_io,
int *  sc,
int *  sk,
int *  asc,
int *  ascq 
)

Translates NVMe status codes to SCSI status information.

The codes are stored in the user supplied integers.

Parameters
bdev_ioI/O containing status codes to translate.
scSCSI Status Code will be stored here.
skSCSI Sense Key will be stored here.
ascSCSI Additional Sense Code will be stored here.
ascqSCSI Additional Sense Code Qualifier will be stored here.

◆ spdk_vbdev_register()

int spdk_vbdev_register ( struct spdk_bdev vbdev,
struct spdk_bdev **  base_bdevs,
int  base_bdev_count 
)

Register a virtual bdev.

This function is deprecated. Users should call spdk_bdev_register instead. The bdev layer currently makes no use of the base_bdevs array, so switching to spdk_bdev_register results in no loss of functionality.

Parameters
vbdevVirtual bdev to register.
base_bdevsArray of bdevs upon which this vbdev is based.
base_bdev_countNumber of bdevs in base_bdevs.
Returns
0 on success
-EINVAL if the bdev name is NULL.
-EEXIST if the bdev already exists.
-ENOMEM if allocation of the base_bdevs array or the base bdevs vbdevs array fails.