nvme: fix wrong type of the deallocate function parameter

According to the specification, the dataset management for deallocate
attribute can support to 256 ranges, so we should use uint16_t
instead of uint8_t as the ranges parameter.

Change-Id: Ibacc00da8b4b9e2b2f3454d382aadf7ad353ff31
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Changpeng Liu 2015-12-24 10:34:38 +08:00 committed by Daniel Verkamp
parent 16c75b8af7
commit 81db062c52
3 changed files with 11 additions and 4 deletions

View File

@ -324,7 +324,8 @@ int nvme_ns_cmd_read(struct nvme_namespace *ns, void *payload,
* \param ns NVMe namespace to submit the deallocation request
* \param payload virtual address pointer to the list of LBA ranges to
* deallocate
* \param num_ranges number of ranges in the list pointed to by payload
* \param num_ranges number of ranges in the list pointed to by payload; must be
* between 1 and \ref NVME_DATASET_MANAGEMENT_MAX_RANGES, inclusive.
* \param cb_fn callback function to invoke when the I/O is completed
* \param cb_arg argument to pass to the callback function
*
@ -335,7 +336,7 @@ int nvme_ns_cmd_read(struct nvme_namespace *ns, void *payload,
* nvme_register_io_thread().
*/
int nvme_ns_cmd_deallocate(struct nvme_namespace *ns, void *payload,
uint8_t num_ranges, nvme_cb_fn_t cb_fn,
uint16_t num_ranges, nvme_cb_fn_t cb_fn,
void *cb_arg);
/**

View File

@ -59,6 +59,12 @@
#define NVME_MAX_IO_QUEUES (1 << 16)
/**
* Indicates the maximum number of range sets that may be specified
* in the dataset mangement command.
*/
#define NVME_DATASET_MANAGEMENT_MAX_RANGES 256
union nvme_cap_lo_register {
uint32_t raw;
struct {

View File

@ -196,12 +196,12 @@ nvme_ns_cmd_write(struct nvme_namespace *ns, void *payload, uint64_t lba,
int
nvme_ns_cmd_deallocate(struct nvme_namespace *ns, void *payload,
uint8_t num_ranges, nvme_cb_fn_t cb_fn, void *cb_arg)
uint16_t num_ranges, nvme_cb_fn_t cb_fn, void *cb_arg)
{
struct nvme_request *req;
struct nvme_command *cmd;
if (num_ranges == 0) {
if (num_ranges == 0 || num_ranges > NVME_DATASET_MANAGEMENT_MAX_RANGES) {
return EINVAL;
}