Block Device Module Interface. More...
Macros | |
#define | SPDK_BDEV_CLAIM_NAME_LEN 32 |
#define | SPDK_BDEV_RESET_IO_DRAIN_RECOMMENDED_VALUE 5 |
#define | SPDK_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. | |
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. | |
typedef void(* | spdk_bdev_part_base_free_fn) (void *ctx) |
typedef int(* | spdk_bdev_io_fn) (void *ctx, struct spdk_bdev_io *bdev_io) |
typedef void(* | spdk_bdev_for_each_io_cb) (void *ctx, int rc) |
typedef void(* | spdk_bdev_get_current_qd_cb) (struct spdk_bdev *bdev, uint64_t current_qd, void *cb_arg, int rc) |
typedef void(* | spdk_bdev_quiesce_cb) (void *ctx, int status) |
Enumerations | |
enum | spdk_bdev_claim_type { SPDK_BDEV_CLAIM_NONE = 0 , SPDK_BDEV_CLAIM_EXCL_WRITE , SPDK_BDEV_CLAIM_READ_MANY_WRITE_ONE , SPDK_BDEV_CLAIM_READ_MANY_WRITE_NONE , SPDK_BDEV_CLAIM_READ_MANY_WRITE_SHARED } |
Claim types. More... | |
enum | spdk_bdev_io_status { SPDK_BDEV_IO_STATUS_AIO_ERROR = -8 , SPDK_BDEV_IO_STATUS_ABORTED = -7 , 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 , SPDK_MIN_BDEV_IO_STATUS = SPDK_BDEV_IO_STATUS_AIO_ERROR } |
bdev I/O completion status | |
enum | spdk_bdev_reset_stat_mode { SPDK_BDEV_RESET_STAT_ALL , SPDK_BDEV_RESET_STAT_MAXMIN } |
Functions | |
SPDK_STATIC_ASSERT (sizeof(struct spdk_bdev_claim_opts)==48, "Incorrect size") | |
const char * | spdk_bdev_claim_get_name (enum spdk_bdev_claim_type claim_type) |
Retrieve the name of the bdev module claim type. | |
void | spdk_bdev_claim_opts_init (struct spdk_bdev_claim_opts *opts, size_t size) |
Initialize bdev module claim options structure. | |
int | spdk_bdev_module_claim_bdev_desc (struct spdk_bdev_desc *desc, enum spdk_bdev_claim_type type, struct spdk_bdev_claim_opts *opts, struct spdk_bdev_module *module) |
Claim the bdev referenced by the open descriptor. | |
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 claim to a bdev. | |
void | spdk_bdev_module_release_bdev (struct spdk_bdev *bdev) |
Called to release a write claim on a block device. | |
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. | |
void | spdk_bdev_unregister (struct spdk_bdev *bdev, spdk_bdev_unregister_cb cb_fn, void *cb_arg) |
Start unregistering a bdev. | |
int | spdk_bdev_unregister_by_name (const char *bdev_name, struct spdk_bdev_module *module, spdk_bdev_unregister_cb cb_fn, void *cb_arg) |
Start unregistering a bdev. | |
void | spdk_bdev_destruct_done (struct spdk_bdev *bdev, int bdeverrno) |
Notify the bdev layer that an asynchronous destruct operation is complete. | |
void | spdk_bdev_module_examine_done (struct spdk_bdev_module *module) |
Indicate to the bdev layer that the module is done examining a bdev. | |
void | spdk_bdev_module_init_done (struct spdk_bdev_module *module) |
Indicate to the bdev layer that the module is done initializing. | |
void | spdk_bdev_module_fini_done (void) |
Indicate that the module finish has completed. | |
void | spdk_bdev_module_fini_start_done (void) |
Indicate that the module fini start has completed. | |
int | spdk_bdev_alias_add (struct spdk_bdev *bdev, const char *alias) |
Add alias to block device names list. | |
int | spdk_bdev_alias_del (struct spdk_bdev *bdev, const char *alias) |
Removes name from block device names list. | |
void | spdk_bdev_alias_del_all (struct spdk_bdev *bdev) |
Removes all alias from block device alias list. | |
const struct spdk_bdev_aliases_list * | spdk_bdev_get_aliases (const struct spdk_bdev *bdev) |
Get pointer to block device aliases list. | |
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. | |
void | spdk_bdev_io_get_aux_buf (struct spdk_bdev_io *bdev_io, spdk_bdev_io_get_aux_buf_cb cb) |
Allocate an auxiliary buffer for given bdev_io. | |
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() . | |
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. | |
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. | |
void | spdk_bdev_io_complete (struct spdk_bdev_io *bdev_io, enum spdk_bdev_io_status status) |
Complete a bdev_io. | |
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. | |
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. | |
void | spdk_bdev_io_complete_aio_status (struct spdk_bdev_io *bdev_io, int aio_result) |
Complete a bdev_io with AIO errno. | |
void | spdk_bdev_io_complete_base_io_status (struct spdk_bdev_io *bdev_io, const struct spdk_bdev_io *base_io) |
Complete a bdev_io copying a status from another bdev_io. | |
struct spdk_thread * | spdk_bdev_io_get_thread (struct spdk_bdev_io *bdev_io) |
Get a thread that given bdev_io was submitted on. | |
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. | |
uint64_t | spdk_bdev_io_get_submit_tsc (struct spdk_bdev_io *bdev_io) |
Get the submit_tsc of a bdev I/O. | |
int | spdk_bdev_notify_blockcnt_change (struct spdk_bdev *bdev, uint64_t size) |
Resize for a bdev. | |
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. | |
void | spdk_bdev_module_list_add (struct spdk_bdev_module *bdev_module) |
Add the given module to the list of registered modules. | |
struct spdk_bdev_module * | spdk_bdev_module_list_find (const char *name) |
Find registered module with name pointed by name . | |
static struct spdk_bdev_io * | spdk_bdev_io_from_ctx (void *ctx) |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
int | spdk_bdev_part_free (struct spdk_bdev_part *part) |
Free an spdk_bdev_part context. | |
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. | |
int | spdk_bdev_part_base_construct_ext (const char *bdev_name, 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, struct spdk_bdev_part_base **base) |
Construct a new spdk_bdev_part_base on top of the provided bdev. | |
SPDK_STATIC_ASSERT (sizeof(struct spdk_bdev_part_construct_opts)==24, "Incorrect size") | |
void | spdk_bdev_part_construct_opts_init (struct spdk_bdev_part_construct_opts *opts, uint64_t size) |
Initialize options that will be passed to spdk_bdev_part_construct_ext(). | |
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. | |
int | spdk_bdev_part_construct_ext (struct spdk_bdev_part *part, struct spdk_bdev_part_base *base, char *name, uint64_t offset_blocks, uint64_t num_blocks, char *product_name, const struct spdk_bdev_part_construct_opts *opts) |
Create a logical spdk_bdev_part on top of a base with a non-NULL bdev UUID. | |
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. | |
int | spdk_bdev_part_submit_request_ext (struct spdk_bdev_part_channel *ch, struct spdk_bdev_io *bdev_io, spdk_bdev_io_completion_cb cb) |
Forwards I/O from an spdk_bdev_part to the underlying base bdev. | |
struct spdk_bdev * | spdk_bdev_part_get_bdev (struct spdk_bdev_part *part) |
Return a pointer to this part's spdk_bdev. | |
struct spdk_bdev_part_base * | spdk_bdev_part_get_base (struct spdk_bdev_part *part) |
Return a pointer to this part's base. | |
struct spdk_bdev * | spdk_bdev_part_get_base_bdev (struct spdk_bdev_part *part) |
Return a pointer to this part's base bdev. | |
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. | |
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. | |
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. | |
void | spdk_bdev_for_each_bdev_io (struct spdk_bdev *bdev, void *ctx, spdk_bdev_io_fn fn, spdk_bdev_for_each_io_cb cb) |
Call the provided function on the appropriate thread for each bdev_io submitted to the provided bdev. | |
void | spdk_bdev_get_current_qd (struct spdk_bdev *bdev, spdk_bdev_get_current_qd_cb cb_fn, void *cb_arg) |
Measure and return the queue depth from a bdev. | |
void | spdk_bdev_add_io_stat (struct spdk_bdev_io_stat *total, struct spdk_bdev_io_stat *add) |
Add I/O statistics. | |
void | spdk_bdev_dump_io_stat_json (struct spdk_bdev_io_stat *stat, struct spdk_json_write_ctx *w) |
Output bdev I/O statistics information to a JSON stream. | |
void | spdk_bdev_reset_io_stat (struct spdk_bdev_io_stat *stat, enum spdk_bdev_reset_stat_mode mode) |
Reset I/O statistics structure. | |
int | spdk_bdev_quiesce (struct spdk_bdev *bdev, struct spdk_bdev_module *module, spdk_bdev_quiesce_cb cb_fn, void *cb_arg) |
Quiesce a bdev. | |
int | spdk_bdev_unquiesce (struct spdk_bdev *bdev, struct spdk_bdev_module *module, spdk_bdev_quiesce_cb cb_fn, void *cb_arg) |
Unquiesce a previously quiesced bdev. | |
int | spdk_bdev_quiesce_range (struct spdk_bdev *bdev, struct spdk_bdev_module *module, uint64_t offset, uint64_t length, spdk_bdev_quiesce_cb cb_fn, void *cb_arg) |
Quiesce a bdev LBA range. | |
int | spdk_bdev_unquiesce_range (struct spdk_bdev *bdev, struct spdk_bdev_module *module, uint64_t offset, uint64_t length, spdk_bdev_quiesce_cb cb_fn, void *cb_arg) |
Unquiesce a previously quiesced bdev LBA range. | |
Block Device Module Interface.
For information on how to write a bdev module, see Writing a Custom Block Device Module.
#define SPDK_BDEV_MODULE_REGISTER | ( | name, | |
module ) |
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.
ch | The I/O channel the bdev I/O was handled on. |
bdev_io | The bdev I/O |
aux_buf | Pointer to the allocated buffer. NULL if there was a failure such as the size of the buffer to allocate is greater than the permitted maximum. |
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.
ch | The I/O channel the bdev I/O was handled on. |
bdev_io | The bdev I/O |
success | True 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. |
enum spdk_bdev_claim_type |
Claim types.
Enumerator | |
---|---|
SPDK_BDEV_CLAIM_EXCL_WRITE | Exclusive writer, with allowances for legacy behavior. This matches the behavior of |
SPDK_BDEV_CLAIM_READ_MANY_WRITE_ONE | The descriptor passed with this claim request is the only writer. Other claimless readers are allowed. |
SPDK_BDEV_CLAIM_READ_MANY_WRITE_NONE | Any number of readers, no writers. Readers without a claim are allowed. |
SPDK_BDEV_CLAIM_READ_MANY_WRITE_SHARED | Any number of writers with matching shared_claim_key. After the first writer establishes a claim, future aspiring writers should open read-only and pass the read-only descriptor. If the shared claim is granted to the aspiring writer, the descriptor will be upgraded to read-write. |
void spdk_bdev_add_io_stat | ( | struct spdk_bdev_io_stat * | total, |
struct spdk_bdev_io_stat * | add ) |
Add I/O statistics.
total | The aggregated I/O statistics. |
add | The I/O statistics to be added. |
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.
bdev | Block device to query. |
alias | Alias to be added to list. |
int spdk_bdev_alias_del | ( | struct spdk_bdev * | bdev, |
const char * | alias ) |
Removes name from block device names list.
bdev | Block device to query. |
alias | Alias to be deleted from list. |
void spdk_bdev_alias_del_all | ( | struct spdk_bdev * | bdev | ) |
Removes all alias from block device alias list.
bdev | Block device to operate. |
const char * spdk_bdev_claim_get_name | ( | enum spdk_bdev_claim_type | claim_type | ) |
Retrieve the name of the bdev module claim type.
The mapping between claim types and their names is:
SPDK_BDEV_CLAIM_NONE "not_claimed" SPDK_BDEV_CLAIM_EXCL_WRITE "exclusive_write" SPDK_BDEV_CLAIM_READ_MANY_WRITE_ONE "read_many_write_one" SPDK_BDEV_CLAIM_READ_MANY_WRITE_NONE "read_many_write_none" SPDK_BDEV_CLAIM_READ_MANY_WRITE_SHARED "read_many_write_shared"
Any other value will return "invalid_claim".
claim_type | The claim type. |
void spdk_bdev_claim_opts_init | ( | struct spdk_bdev_claim_opts * | opts, |
size_t | size ) |
Initialize bdev module claim options structure.
opts | The structure to initialize. |
size | The size of *opts. |
void spdk_bdev_destruct_done | ( | struct spdk_bdev * | bdev, |
int | bdeverrno ) |
Notify the bdev layer that an asynchronous destruct operation is complete.
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.
bdev | Block device that was destroyed. |
bdeverrno | Error code returned from bdev's destruct callback. |
void spdk_bdev_dump_io_stat_json | ( | struct spdk_bdev_io_stat * | stat, |
struct spdk_json_write_ctx * | w ) |
Output bdev I/O statistics information to a JSON stream.
stat | The bdev I/O statistics to output. |
w | JSON write context. |
void spdk_bdev_for_each_bdev_io | ( | struct spdk_bdev * | bdev, |
void * | ctx, | ||
spdk_bdev_io_fn | fn, | ||
spdk_bdev_for_each_io_cb | cb ) |
Call the provided function on the appropriate thread for each bdev_io submitted to the provided bdev.
Note: This function should be used only in the bdev module and it should be ensured that the bdev is not unregistered while executing the function. Both fn and cb are required to specify.
bdev | Block device to query. |
ctx | Context passed to the function for each bdev_io and the completion callback function. |
fn | Called on the appropriate thread for each bdev_io submitted to the bdev. |
cb | Called when this operation completes. |
const struct spdk_bdev_aliases_list * spdk_bdev_get_aliases | ( | const struct spdk_bdev * | bdev | ) |
Get pointer to block device aliases list.
bdev | Block device to query. |
void spdk_bdev_get_current_qd | ( | struct spdk_bdev * | bdev, |
spdk_bdev_get_current_qd_cb | cb_fn, | ||
void * | cb_arg ) |
Measure and return the queue depth from a bdev.
Note: spdk_bdev_get_qd() works only when the user enables queue depth sampling, while this new function works even when queue depth sampling is disabled. The returned queue depth may not be exact, for example, some additional I/Os may have been submitted or completed during the for_each_channel operation. This function should be used only in the bdev module and it should be ensured that the dev is not unregistered while executing the function. cb_fn is required to specify.
bdev | Block device to query. |
cb_fn | Callback function to be called with queue depth measured for a bdev. |
cb_arg | Argument to pass to callback function. |
void spdk_bdev_io_complete | ( | struct spdk_bdev_io * | bdev_io, |
enum spdk_bdev_io_status | status ) |
Complete a bdev_io.
bdev_io | I/O to complete. |
status | The I/O completion status. |
void spdk_bdev_io_complete_aio_status | ( | struct spdk_bdev_io * | bdev_io, |
int | aio_result ) |
Complete a bdev_io with AIO errno.
bdev_io | I/O to complete. |
aio_result | Negative errno returned from AIO. |
void spdk_bdev_io_complete_base_io_status | ( | struct spdk_bdev_io * | bdev_io, |
const struct spdk_bdev_io * | base_io ) |
Complete a bdev_io copying a status from another bdev_io.
bdev_io | I/O to complete. |
base_io | I/O from which to copy the 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.
bdev_io | I/O to complete. |
cdw0 | NVMe Completion Queue DW0 value (set to 0 if not applicable) |
sct | NVMe Status Code Type. |
sc | NVMe Status Code. |
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.
bdev_io | I/O to complete. |
sc | SCSI Status Code. |
sk | SCSI Sense Key. |
asc | SCSI Additional Sense Code. |
ascq | SCSI Additional Sense Code Qualifier. |
void spdk_bdev_io_get_aux_buf | ( | struct spdk_bdev_io * | bdev_io, |
spdk_bdev_io_get_aux_buf_cb | cb ) |
Allocate an auxiliary 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.
bdev_io | I/O to allocate buffer for. |
cb | callback to be called when the buffer is allocated |
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. This function must be called from the thread issuing bdev_io
.
bdev_io | I/O to allocate buffer for. |
cb | callback to be called when the buffer is allocated or the bdev_io has an SGL assigned already. |
len | size 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 . |
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.
bdev_io | I/O |
uint64_t spdk_bdev_io_get_submit_tsc | ( | struct spdk_bdev_io * | bdev_io | ) |
Get the submit_tsc of a bdev I/O.
bdev_io | The bdev I/O to get the submit_tsc. |
struct spdk_thread * spdk_bdev_io_get_thread | ( | struct spdk_bdev_io * | bdev_io | ) |
Get a thread that given bdev_io was submitted on.
bdev_io | I/O |
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()
.
bdev_io | bdev_io specified when the aux_buf was allocated. |
aux_buf | auxiliary buffer to free |
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 alignment purposes.
bdev_io | I/O to set the buffer on. |
buf | The buffer to set as the active data buffer. |
len | The length of the buffer. |
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.
bdev_io | I/O to set the buffer on. |
md_buf | The buffer to set as the active metadata buffer. |
len | The length of the metadata buffer. |
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 claim to a bdev.
Also upgrades that bdev's descriptor to have write access if desc is not NULL.
bdev | Block device to be claimed. |
desc | Descriptor for the above block device or NULL. |
module | Bdev module attempting to claim bdev. |
int spdk_bdev_module_claim_bdev_desc | ( | struct spdk_bdev_desc * | desc, |
enum spdk_bdev_claim_type | type, | ||
struct spdk_bdev_claim_opts * | opts, | ||
struct spdk_bdev_module * | module ) |
Claim the bdev referenced by the open descriptor.
The claim is released as the descriptor is closed.
desc | An open bdev descriptor. Some claim types may upgrade this from read-only to read-write. |
type | The type of claim to establish. |
opts | NULL or options required by the particular claim type. |
module | The bdev module making this claim. |
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 during examine_config function or asynchronously in response to the module's examine_disk function being called.
module | Pointer to the module completing the examination. |
void spdk_bdev_module_fini_done | ( | void | ) |
Indicate that the module finish has completed.
To be called in response to the module_fini, only if async_fini is set.
void spdk_bdev_module_fini_start_done | ( | void | ) |
Indicate that the module fini start has completed.
To be called in response to the fini_start, only if async_fini_start is set. May be called during fini_start or asynchronously.
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 once after an asynchronous operation required for module initialization is completed. If module->async_init is false, the module must not call this function.
module | Pointer to the module completing the initialization. |
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.
bdev_module | Module to be added. |
struct spdk_bdev_module * spdk_bdev_module_list_find | ( | const char * | name | ) |
Find registered module with name pointed by name
.
name | name of module to be searched for. |
name
exist void spdk_bdev_module_release_bdev | ( | struct spdk_bdev * | bdev | ) |
Called to release a write claim on a block device.
bdev | Block device to be released. |
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.
bdev | Block device to change. |
size | New size of bdev. |
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.
bdev | Block device |
int spdk_bdev_part_base_construct_ext | ( | const char * | bdev_name, |
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, | ||
struct spdk_bdev_part_base ** | base ) |
Construct a new spdk_bdev_part_base on top of the provided bdev.
bdev_name | Name of the bdev upon which this base will be built. |
remove_cb | Function to be called upon hotremove of the bdev. |
module | The module to which this bdev base belongs. |
fn_table | Function table for communicating with the bdev backend. |
tailq | The head of the list of all spdk_bdev_part structures registered to this base's module. |
free_fn | User provided function to free base related context upon bdev removal or shutdown. |
ctx | Module specific context for this bdev part base. |
channel_size | Channel size in bytes. |
ch_create_cb | Called after a new channel is allocated. |
ch_destroy_cb | Called upon channel deletion. |
base | output parameter for the part object when operation is successful. |
void spdk_bdev_part_base_free | ( | struct spdk_bdev_part_base * | base | ) |
Free the base corresponding to one or more spdk_bdev_part.
base | The base to free. |
struct spdk_bdev * spdk_bdev_part_base_get_bdev | ( | struct spdk_bdev_part_base * | part_base | ) |
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.
part_base | A pointer to an spdk_bdev_part_base object. |
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.
part_base | A pointer to an spdk_bdev_part_base object. |
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.
part_base | A pointer to an spdk_bdev_part_base object. |
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.
part_base | A pointer to an spdk_bdev_part_base object. |
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.
part_base | The part base object built on top of an spdk_bdev |
tailq | The list of spdk_bdev_part bdevs associated with this base bdev. |
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.
part | The part object allocated by the user. |
base | The base from which to create the part. |
name | The name of the new spdk_bdev_part. |
offset_blocks | The offset into the base bdev at which this part begins. |
num_blocks | The number of blocks that this part will span. |
product_name | Unique name for this type of block device. |
int spdk_bdev_part_construct_ext | ( | struct spdk_bdev_part * | part, |
struct spdk_bdev_part_base * | base, | ||
char * | name, | ||
uint64_t | offset_blocks, | ||
uint64_t | num_blocks, | ||
char * | product_name, | ||
const struct spdk_bdev_part_construct_opts * | opts ) |
Create a logical spdk_bdev_part on top of a base with a non-NULL bdev UUID.
part | The part object allocated by the user. |
base | The base from which to create the part. |
name | The name of the new spdk_bdev_part. |
offset_blocks | The offset into the base bdev at which this part begins. |
num_blocks | The number of blocks that this part will span. |
product_name | Unique name for this type of block device. |
opts | Additional options. |
void spdk_bdev_part_construct_opts_init | ( | struct spdk_bdev_part_construct_opts * | opts, |
uint64_t | size ) |
Initialize options that will be passed to spdk_bdev_part_construct_ext().
opts | Options structure to initialize |
size | Size of opts structure. |
int spdk_bdev_part_free | ( | struct spdk_bdev_part * | part | ) |
Free an spdk_bdev_part context.
part | The part to free. |
struct spdk_bdev_part_base * spdk_bdev_part_get_base | ( | struct spdk_bdev_part * | part | ) |
Return a pointer to this part's base.
part | An spdk_bdev_part object. |
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.
part | An spdk_bdev_part object. |
struct spdk_bdev * spdk_bdev_part_get_bdev | ( | struct spdk_bdev_part * | part | ) |
Return a pointer to this part's spdk_bdev.
part | An spdk_bdev_part object. |
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.
part | An spdk_bdev_part object. |
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.
ch | The I/O channel associated with the spdk_bdev_part. |
bdev_io | The I/O to be submitted to the underlying bdev. |
int spdk_bdev_part_submit_request_ext | ( | struct spdk_bdev_part_channel * | ch, |
struct spdk_bdev_io * | bdev_io, | ||
spdk_bdev_io_completion_cb | cb ) |
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.
This function enables user to specify a completion callback. It is required that the completion callback calls spdk_bdev_io_complete() for the forwarded I/O.
ch | The I/O channel associated with the spdk_bdev_part. |
bdev_io | The I/O to be submitted to the underlying bdev. |
cb | Called when the forwarded I/O completes. |
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.
bdev | Block device |
events | Array of media events |
num_events | Size of the events array |
int spdk_bdev_quiesce | ( | struct spdk_bdev * | bdev, |
struct spdk_bdev_module * | module, | ||
spdk_bdev_quiesce_cb | cb_fn, | ||
void * | cb_arg ) |
Quiesce a bdev.
All I/O submitted after this function is called will be queued until the bdev is unquiesced. A callback will be called when all outstanding I/O on this bdev submitted before calling this function have completed.
Only the module that registered the bdev may call this function.
bdev | Block device. |
module | The module that registered the bdev. |
cb_fn | Callback function to be called when the bdev is quiesced. Optional. |
cb_arg | Argument to be supplied to cb_fn. |
int spdk_bdev_quiesce_range | ( | struct spdk_bdev * | bdev, |
struct spdk_bdev_module * | module, | ||
uint64_t | offset, | ||
uint64_t | length, | ||
spdk_bdev_quiesce_cb | cb_fn, | ||
void * | cb_arg ) |
Quiesce a bdev LBA range.
Same as spdk_bdev_quiesce() but limited to the specified LBA range.
bdev | Block device. |
module | The module that registered the bdev. |
offset | The offset of the start of the range, in blocks, from the start of the block device. |
length | The length of the range, in blocks. |
cb_fn | Callback function to be called when the range is quiesced. Optional. |
cb_arg | Argument to be supplied to cb_fn. |
int spdk_bdev_register | ( | struct spdk_bdev * | bdev | ) |
Register a new bdev.
This function must be called from the SPDK app thread.
bdev | Block device to register. |
void spdk_bdev_reset_io_stat | ( | struct spdk_bdev_io_stat * | stat, |
enum spdk_bdev_reset_stat_mode | mode ) |
Reset I/O statistics structure.
stat | The I/O statistics to reset. |
mode | The mode to reset I/O statistics. |
int spdk_bdev_unquiesce | ( | struct spdk_bdev * | bdev, |
struct spdk_bdev_module * | module, | ||
spdk_bdev_quiesce_cb | cb_fn, | ||
void * | cb_arg ) |
Unquiesce a previously quiesced bdev.
All I/O queued after the bdev was quiesced will be submitted.
Only the module that registered the bdev may call this function.
bdev | Block device. |
module | The module that registered the bdev. |
cb_fn | Callback function to be called when the bdev is unquiesced. Optional. |
cb_arg | Argument to be supplied to cb_fn. |
int spdk_bdev_unquiesce_range | ( | struct spdk_bdev * | bdev, |
struct spdk_bdev_module * | module, | ||
uint64_t | offset, | ||
uint64_t | length, | ||
spdk_bdev_quiesce_cb | cb_fn, | ||
void * | cb_arg ) |
Unquiesce a previously quiesced bdev LBA range.
Same as spdk_bdev_unquiesce() but limited to the specified LBA range. The specified range must match exactly a previously quiesced LBA range.
bdev | Block device. |
module | The module that registered the bdev. |
offset | The offset of the start of the range, in blocks, from the start of the block device. |
length | The length of the range, in blocks. |
cb_fn | Callback function to be called when the range is unquiesced. Optional. |
cb_arg | Argument to be supplied to cb_fn. |
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 of the hotremoval to request the upper layers to 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.
The cb_fn will be called from the context of the same spdk_thread that called spdk_bdev_unregister.
Note: spdk_bdev_unregister() can be unsafe unless the bdev is not opened before and closed after unregistration. It is recommended to use spdk_bdev_unregister_by_name().
bdev | Block device to unregister. |
cb_fn | Callback function to be called when the unregister is complete. |
cb_arg | Argument to be supplied to cb_fn |
int spdk_bdev_unregister_by_name | ( | const char * | bdev_name, |
struct spdk_bdev_module * | module, | ||
spdk_bdev_unregister_cb | cb_fn, | ||
void * | cb_arg ) |
Start unregistering a bdev.
This will notify each currently open descriptor on this bdev of the hotremoval to request the upper layer to 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.
The cb_fn will be called from the context of the same spdk_thread that called spdk_bdev_unregister.
bdev_name | Block device name to unregister. |
module | Module by which the block device was registered. |
cb_fn | Callback function to be called when the unregister is complete. |
cb_arg | Argument to be supplied to cb_fn |
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.
bdev_io | I/O containing status codes to translate. |
sc | SCSI Status Code will be stored here. |
sk | SCSI Sense Key will be stored here. |
asc | SCSI Additional Sense Code will be stored here. |
ascq | SCSI Additional Sense Code Qualifier will be stored here. |