Commit a0d7056f authored by Jim Harris's avatar Jim Harris
Browse files

copy: return 0 on success and appropriate errno on failure



This code was still using an old paradigm of returning the
number of bytes associated with a successful submission.
Just return 0 on success instead - if caller needs the
number of bytes for some reason they have the information
to get it.

While here, return an appropriate negated errno where possible -
we especially want ENOMEM returned when an ioat channel runs out
of descriptors.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I5858ccd6cff916b6c80fda7d2c9fce96fb39ef89

Reviewed-on: https://review.gerrithub.io/378858


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 49cf3861
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -50,9 +50,9 @@ int spdk_copy_engine_initialize(void);
int spdk_copy_engine_finish(void);

struct spdk_io_channel *spdk_copy_engine_get_io_channel(void);
int64_t spdk_copy_submit(struct spdk_copy_task *copy_req, struct spdk_io_channel *ch, void *dst,
int spdk_copy_submit(struct spdk_copy_task *copy_req, struct spdk_io_channel *ch, void *dst,
		     void *src, uint64_t nbytes, spdk_copy_completion_cb cb);
int64_t spdk_copy_submit_fill(struct spdk_copy_task *copy_req, struct spdk_io_channel *ch,
int spdk_copy_submit_fill(struct spdk_copy_task *copy_req, struct spdk_io_channel *ch,
			  void *dst, uint8_t fill, uint64_t nbytes, spdk_copy_completion_cb cb);
size_t spdk_copy_task_size(void);

+6 −6
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ int spdk_ioat_detach(struct spdk_ioat_chan *ioat);
 * \param src Source virtual address.
 * \param nbytes Number of bytes to copy.
 */
int64_t spdk_ioat_submit_copy(struct spdk_ioat_chan *chan,
int spdk_ioat_submit_copy(struct spdk_ioat_chan *chan,
			  void *cb_arg, spdk_ioat_req_cb cb_fn,
			  void *dst, const void *src, uint64_t nbytes);

@@ -126,7 +126,7 @@ int64_t spdk_ioat_submit_copy(struct spdk_ioat_chan *chan,
 * \param fill_pattern Repeating eight-byte pattern to use for memory fill.
 * \param nbytes Number of bytes to fill.
 */
int64_t spdk_ioat_submit_fill(struct spdk_ioat_chan *chan,
int spdk_ioat_submit_fill(struct spdk_ioat_chan *chan,
			  void *cb_arg, spdk_ioat_req_cb cb_fn,
			  void *dst, uint64_t fill_pattern, uint64_t nbytes);

+2 −2
Original line number Diff line number Diff line
@@ -45,9 +45,9 @@ struct spdk_copy_task {
};

struct spdk_copy_engine {
	int64_t	(*copy)(void *cb_arg, struct spdk_io_channel *ch, void *dst, void *src,
	int	(*copy)(void *cb_arg, struct spdk_io_channel *ch, void *dst, void *src,
			uint64_t nbytes, spdk_copy_completion_cb cb);
	int64_t	(*fill)(void *cb_arg, struct spdk_io_channel *ch, void *dst, uint8_t fill,
	int	(*fill)(void *cb_arg, struct spdk_io_channel *ch, void *dst, uint8_t fill,
			uint64_t nbytes, spdk_copy_completion_cb cb);
	struct spdk_io_channel *(*get_io_channel)(void);
};
+5 −5
Original line number Diff line number Diff line
@@ -185,8 +185,8 @@ bdev_malloc_readv(struct malloc_disk *mdisk, struct spdk_io_channel *ch,
				       ch, iov[i].iov_base,
				       src, iov[i].iov_len, malloc_done);

		if (res != (int64_t)iov[i].iov_len) {
			malloc_done(__copy_task_from_malloc_task(task), -1);
		if (res != 0) {
			malloc_done(__copy_task_from_malloc_task(task), res);
		}

		src += iov[i].iov_len;
@@ -220,8 +220,8 @@ bdev_malloc_writev(struct malloc_disk *mdisk, struct spdk_io_channel *ch,
				       ch, dst, iov[i].iov_base,
				       iov[i].iov_len, malloc_done);

		if (res != (int64_t)iov[i].iov_len) {
			malloc_done(__copy_task_from_malloc_task(task), -1);
		if (res != 0) {
			malloc_done(__copy_task_from_malloc_task(task), res);
		}

		dst += iov[i].iov_len;
@@ -328,7 +328,7 @@ static int _bdev_malloc_submit_request(struct spdk_io_channel *ch, struct spdk_b

static void bdev_malloc_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_io)
{
	if (_bdev_malloc_submit_request(ch, bdev_io) < 0) {
	if (_bdev_malloc_submit_request(ch, bdev_io) != 0) {
		spdk_bdev_io_complete(bdev_io, SPDK_BDEV_IO_STATUS_FAILED);
	}
}
+6 −6
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ copy_engine_done(void *ref, int status)
	req->cb(req, status);
}

int64_t
int
spdk_copy_submit(struct spdk_copy_task *copy_req, struct spdk_io_channel *ch,
		 void *dst, void *src, uint64_t nbytes, spdk_copy_completion_cb cb)
{
@@ -87,7 +87,7 @@ spdk_copy_submit(struct spdk_copy_task *copy_req, struct spdk_io_channel *ch,
				     copy_engine_done);
}

int64_t
int
spdk_copy_submit_fill(struct spdk_copy_task *copy_req, struct spdk_io_channel *ch,
		      void *dst, uint8_t fill, uint64_t nbytes, spdk_copy_completion_cb cb)
{
@@ -100,7 +100,7 @@ spdk_copy_submit_fill(struct spdk_copy_task *copy_req, struct spdk_io_channel *c
}

/* memcpy default copy engine */
static int64_t
static int
mem_copy_submit(void *cb_arg, struct spdk_io_channel *ch, void *dst, void *src, uint64_t nbytes,
		spdk_copy_completion_cb cb)
{
@@ -111,10 +111,10 @@ mem_copy_submit(void *cb_arg, struct spdk_io_channel *ch, void *dst, void *src,
	copy_req = (struct spdk_copy_task *)((uintptr_t)cb_arg -
					     offsetof(struct spdk_copy_task, offload_ctx));
	cb(copy_req, 0);
	return nbytes;
	return 0;
}

static int64_t
static int
mem_copy_fill(void *cb_arg, struct spdk_io_channel *ch, void *dst, uint8_t fill, uint64_t nbytes,
	      spdk_copy_completion_cb cb)
{
@@ -125,7 +125,7 @@ mem_copy_fill(void *cb_arg, struct spdk_io_channel *ch, void *dst, uint8_t fill,
					     offsetof(struct spdk_copy_task, offload_ctx));
	cb(copy_req, 0);

	return nbytes;
	return 0;
}

static struct spdk_io_channel *mem_get_io_channel(void);
Loading