test/bdev/nbd: allow building with old kernels
Older kernels do not support flush or trim operations; add #ifdefs to allow the NBD test code to work on those kernels. Fixes build on older distributions (e.g. CentOS 6). Change-Id: Iae06f96b7db9a3bf4a494e2b2c2c15b37e6c1293 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-on: https://review.gerrithub.io/367132 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
0d7e2b6416
commit
dbbde9991d
@ -232,14 +232,18 @@ process_request(struct nbd_disk *nbd)
|
|||||||
case NBD_CMD_DISC:
|
case NBD_CMD_DISC:
|
||||||
nbd_shutdown();
|
nbd_shutdown();
|
||||||
return;
|
return;
|
||||||
|
#ifdef NBD_FLAG_SEND_FLUSH
|
||||||
case NBD_CMD_FLUSH:
|
case NBD_CMD_FLUSH:
|
||||||
io->type = SPDK_BDEV_IO_TYPE_FLUSH;
|
io->type = SPDK_BDEV_IO_TYPE_FLUSH;
|
||||||
nbd_submit_bdev_io(nbd->bdev, nbd->ch, io);
|
nbd_submit_bdev_io(nbd->bdev, nbd->ch, io);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef NBD_FLAG_SEND_TRIM
|
||||||
case NBD_CMD_TRIM:
|
case NBD_CMD_TRIM:
|
||||||
io->type = SPDK_BDEV_IO_TYPE_UNMAP;
|
io->type = SPDK_BDEV_IO_TYPE_UNMAP;
|
||||||
nbd_submit_bdev_io(nbd->bdev, nbd->ch, io);
|
nbd_submit_bdev_io(nbd->bdev, nbd->ch, io);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,11 +324,13 @@ nbd_start_kernel(int nbd_fd, int *sp)
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NBD_FLAG_SEND_TRIM
|
||||||
rc = ioctl(nbd_fd, NBD_SET_FLAGS, NBD_FLAG_SEND_TRIM);
|
rc = ioctl(nbd_fd, NBD_SET_FLAGS, NBD_FLAG_SEND_TRIM);
|
||||||
if (rc == -1) {
|
if (rc == -1) {
|
||||||
SPDK_ERRLOG("ioctl(NBD_SET_FLAGS) failed: %s\n", strerror(errno));
|
SPDK_ERRLOG("ioctl(NBD_SET_FLAGS) failed: %s\n", strerror(errno));
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This will block in the kernel until the client disconnects. */
|
/* This will block in the kernel until the client disconnects. */
|
||||||
ioctl(nbd_fd, NBD_DO_IT);
|
ioctl(nbd_fd, NBD_DO_IT);
|
||||||
|
Loading…
Reference in New Issue
Block a user