Commit 4f2f8e8d authored by Liu Xiaodong's avatar Liu Xiaodong Committed by Tomasz Zawadzki
Browse files

nbd: set NBD_FLAG_SEND_FLUSH



SPDK nbd supports NBD_CMD_FLUSH, so set NBD_FLAG_SEND_FLUSH
to inform kernel about this flush ability.

Change-Id: Iaccb98da07e6fa184a798d792dd062f3d4013ade
Signed-off-by: default avatarLiu Xiaodong <xiaodong.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6524


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatar <dongx.yi@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 579a678a
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -917,6 +917,7 @@ nbd_start_complete(struct spdk_nbd_start_ctx *ctx)
	int		rc;
	pthread_t	tid;
	int		flag;
	unsigned long	nbd_flags = 0;

	rc = ioctl(ctx->nbd->dev_fd, NBD_SET_BLKSIZE, spdk_bdev_get_block_size(ctx->nbd->bdev));
	if (rc == -1) {
@@ -943,14 +944,20 @@ nbd_start_complete(struct spdk_nbd_start_ctx *ctx)
	SPDK_NOTICELOG("ioctl(NBD_SET_TIMEOUT) is not supported.\n");
#endif

#ifdef NBD_FLAG_SEND_FLUSH
	nbd_flags |= NBD_FLAG_SEND_FLUSH;
#endif
#ifdef NBD_FLAG_SEND_TRIM
	rc = ioctl(ctx->nbd->dev_fd, NBD_SET_FLAGS, NBD_FLAG_SEND_TRIM);
	nbd_flags |= NBD_FLAG_SEND_TRIM;
#endif
	if (nbd_flags) {
		rc = ioctl(ctx->nbd->dev_fd, NBD_SET_FLAGS, nbd_flags);
		if (rc == -1) {
		SPDK_ERRLOG("ioctl(NBD_SET_FLAGS) failed: %s\n", spdk_strerror(errno));
			SPDK_ERRLOG("ioctl(NBD_SET_FLAGS, 0x%lx) failed: %s\n", nbd_flags, spdk_strerror(errno));
			rc = -errno;
			goto err;
		}
#endif
	}

	rc = pthread_create(&tid, NULL, nbd_start_kernel, (void *)(intptr_t)ctx->nbd->dev_fd);
	if (rc != 0) {