Commit 81db062c authored by Changpeng Liu's avatar Changpeng Liu Committed by Daniel Verkamp
Browse files

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: default avatarChangpeng Liu <changpeng.liu@intel.com>
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 16c75b8a
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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);

/**
+6 −0
Original line number Diff line number Diff line
@@ -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 {
+2 −2
Original line number Diff line number Diff line
@@ -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;
	}