コード例 #1
0
ファイル: blockdev_malloc.c プロジェクト: gongchuang/spdk
static int
blockdev_malloc_reset(struct malloc_disk *mdisk, struct copy_task *copy_req)
{
	spdk_bdev_io_complete(spdk_bdev_io_from_ctx(copy_req), SPDK_BDEV_IO_STATUS_SUCCESS);

	return 0;
}
コード例 #2
0
ファイル: blockdev_aio.c プロジェクト: chennqqi/spdk
static void
blockdev_aio_poll(void *arg)
{
	struct blockdev_aio_io_channel *ch = arg;
	int nr, i;
	enum spdk_bdev_io_status status;
	struct blockdev_aio_task *aio_task;
	struct timespec timeout;

	timeout.tv_sec = 0;
	timeout.tv_nsec = 0;

	nr = io_getevents(ch->io_ctx, 1, ch->queue_depth,
			  ch->events, &timeout);

	if (nr < 0) {
		SPDK_ERRLOG("%s: io_getevents returned %d\n", __func__, nr);
		return;
	}

	for (i = 0; i < nr; i++) {
		aio_task = ch->events[i].data;
		if (ch->events[i].res != aio_task->len) {
			status = SPDK_BDEV_IO_STATUS_FAILED;
		} else {
			status = SPDK_BDEV_IO_STATUS_SUCCESS;
		}

		spdk_bdev_io_complete(spdk_bdev_io_from_ctx(aio_task), status);
	}
}
コード例 #3
0
ファイル: blockdev_aio.c プロジェクト: chennqqi/spdk
static int64_t
blockdev_aio_writev(struct file_disk *fdisk, struct spdk_io_channel *ch,
		    struct blockdev_aio_task *aio_task,
		    struct iovec *iov, int iovcnt, size_t len, uint64_t offset)
{
	struct iocb *iocb = &aio_task->iocb;
	struct blockdev_aio_io_channel *aio_ch = spdk_io_channel_get_ctx(ch);
	int rc;

	io_prep_pwritev(iocb, fdisk->fd, iov, iovcnt, offset);
	iocb->data = aio_task;
	aio_task->len = len;

	SPDK_TRACELOG(SPDK_TRACE_AIO, "write %d iovs size %lu from off: %#lx\n",
		      iovcnt, len, offset);

	rc = io_submit(aio_ch->io_ctx, 1, &iocb);
	if (rc < 0) {
		spdk_bdev_io_complete(spdk_bdev_io_from_ctx(aio_task), SPDK_BDEV_IO_STATUS_FAILED);
		SPDK_ERRLOG("%s: io_submit returned %d\n", __func__, rc);
		return -1;
	}

	return len;
}
コード例 #4
0
ファイル: blockdev_malloc.c プロジェクト: gongchuang/spdk
static int64_t
blockdev_malloc_flush(struct malloc_disk *mdisk, struct copy_task *copy_req,
		      uint64_t offset, uint64_t nbytes)
{
	spdk_bdev_io_complete(spdk_bdev_io_from_ctx(copy_req), SPDK_BDEV_IO_STATUS_SUCCESS);

	return 0;
}
コード例 #5
0
ファイル: blockdev_aio.c プロジェクト: chennqqi/spdk
static void
blockdev_aio_flush(struct file_disk *fdisk, struct blockdev_aio_task *aio_task,
		   uint64_t offset, uint64_t nbytes)
{
	int rc = fsync(fdisk->fd);

	spdk_bdev_io_complete(spdk_bdev_io_from_ctx(aio_task),
			      rc == 0 ? SPDK_BDEV_IO_STATUS_SUCCESS : SPDK_BDEV_IO_STATUS_FAILED);
}
コード例 #6
0
ファイル: blockdev_malloc.c プロジェクト: gongchuang/spdk
static void
malloc_done(void *ref, int status)
{
	struct copy_task *cp_task = (struct copy_task *)ref;
	enum spdk_bdev_io_status bdev_status;

	if (status != 0) {
		bdev_status = SPDK_BDEV_IO_STATUS_FAILED;
	} else {
		bdev_status = SPDK_BDEV_IO_STATUS_SUCCESS;
	}
	spdk_bdev_io_complete(spdk_bdev_io_from_ctx(cp_task), bdev_status);
}
コード例 #7
0
ファイル: blockdev_malloc.c プロジェクト: gongchuang/spdk
static int _blockdev_malloc_submit_request(struct spdk_bdev_io *bdev_io)
{
	switch (bdev_io->type) {
	case SPDK_BDEV_IO_TYPE_READ:
		if (bdev_io->u.read.buf == NULL) {
			bdev_io->u.read.buf = ((struct malloc_disk *)bdev_io->ctx)->malloc_buf +
					      bdev_io->u.read.offset;
			spdk_bdev_io_complete(spdk_bdev_io_from_ctx(bdev_io->driver_ctx),
					      SPDK_BDEV_IO_STATUS_SUCCESS);
			return 0;
		}

		return blockdev_malloc_read((struct malloc_disk *)bdev_io->ctx,
					    bdev_io->ch,
					    (struct copy_task *)bdev_io->driver_ctx,
					    bdev_io->u.read.buf,
					    bdev_io->u.read.nbytes,
					    bdev_io->u.read.offset);

	case SPDK_BDEV_IO_TYPE_WRITE:
		return blockdev_malloc_writev((struct malloc_disk *)bdev_io->ctx,
					      bdev_io->ch,
					      (struct copy_task *)bdev_io->driver_ctx,
					      bdev_io->u.write.iovs,
					      bdev_io->u.write.iovcnt,
					      bdev_io->u.write.len,
					      bdev_io->u.write.offset);

	case SPDK_BDEV_IO_TYPE_RESET:
		return blockdev_malloc_reset((struct malloc_disk *)bdev_io->ctx,
					     (struct copy_task *)bdev_io->driver_ctx);

	case SPDK_BDEV_IO_TYPE_FLUSH:
		return blockdev_malloc_flush((struct malloc_disk *)bdev_io->ctx,
					     (struct copy_task *)bdev_io->driver_ctx,
					     bdev_io->u.flush.offset,
					     bdev_io->u.flush.length);

	case SPDK_BDEV_IO_TYPE_UNMAP:
		return blockdev_malloc_unmap((struct malloc_disk *)bdev_io->ctx,
					     bdev_io->ch,
					     (struct copy_task *)bdev_io->driver_ctx,
					     bdev_io->u.unmap.unmap_bdesc,
					     bdev_io->u.unmap.bdesc_count);
	default:
		return -1;
	}
	return 0;
}
コード例 #8
0
ファイル: blockdev_malloc.c プロジェクト: gongchuang/spdk
static void blockdev_malloc_submit_request(struct spdk_bdev_io *bdev_io)
{
	if (_blockdev_malloc_submit_request(bdev_io) < 0) {
		spdk_bdev_io_complete(bdev_io, SPDK_BDEV_IO_STATUS_FAILED);
	}
}
コード例 #9
0
ファイル: blockdev_aio.c プロジェクト: chennqqi/spdk
static void
blockdev_aio_reset(struct file_disk *fdisk, struct blockdev_aio_task *aio_task)
{
	spdk_bdev_io_complete(spdk_bdev_io_from_ctx(aio_task), SPDK_BDEV_IO_STATUS_SUCCESS);
}