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: Liu Xiaodong <xiaodong.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6524
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: <dongx.yi@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Liu Xiaodong 2021-02-23 05:29:46 -05:00 committed by Tomasz Zawadzki
parent 579a678a51
commit 4f2f8e8d44

View File

@ -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_TRIM
rc = ioctl(ctx->nbd->dev_fd, NBD_SET_FLAGS, NBD_FLAG_SEND_TRIM);
if (rc == -1) {
SPDK_ERRLOG("ioctl(NBD_SET_FLAGS) failed: %s\n", spdk_strerror(errno));
rc = -errno;
goto err;
}
#ifdef NBD_FLAG_SEND_FLUSH
nbd_flags |= NBD_FLAG_SEND_FLUSH;
#endif
#ifdef 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, 0x%lx) failed: %s\n", nbd_flags, spdk_strerror(errno));
rc = -errno;
goto err;
}
}
rc = pthread_create(&tid, NULL, nbd_start_kernel, (void *)(intptr_t)ctx->nbd->dev_fd);
if (rc != 0) {