lib/nbd:export bdev flush and trim ability
Fix mkfs fail when using lvol as backend of nbd.Predefined NBD_FLAG_SEND_FLUSH and NBD_FLAG_SEND_TRIM are defined by default, so the operations of trim and flush are supported,but in fact lvol doesn't support trim and flush operations.Therefore add judgement for NBD_FLAG_SEND_FLUSH and NBD_FLAG_SEND_TRIM to check. Signed-off-by: Xinrui Mao <xinrui.mao@intel.com> Change-Id: I3d21034d12a038c8fc694d3383028103239ea6bd Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14099 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
7a4cb7bc1c
commit
c3f628f141
@ -935,11 +935,16 @@ nbd_start_complete(struct spdk_nbd_start_ctx *ctx)
|
||||
#endif
|
||||
|
||||
#ifdef NBD_FLAG_SEND_FLUSH
|
||||
nbd_flags |= NBD_FLAG_SEND_FLUSH;
|
||||
if (spdk_bdev_io_type_supported(ctx->nbd->bdev, SPDK_BDEV_IO_TYPE_FLUSH)) {
|
||||
nbd_flags |= NBD_FLAG_SEND_FLUSH;
|
||||
}
|
||||
#endif
|
||||
#ifdef NBD_FLAG_SEND_TRIM
|
||||
nbd_flags |= NBD_FLAG_SEND_TRIM;
|
||||
if (spdk_bdev_io_type_supported(ctx->nbd->bdev, SPDK_BDEV_IO_TYPE_UNMAP)) {
|
||||
nbd_flags |= NBD_FLAG_SEND_TRIM;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (nbd_flags) {
|
||||
rc = ioctl(ctx->nbd->dev_fd, NBD_SET_FLAGS, nbd_flags);
|
||||
if (rc == -1) {
|
||||
|
@ -228,6 +228,7 @@ function nbd_function_test() {
|
||||
|
||||
nbd_rpc_start_stop_verify $rpc_server "${bdev_list[*]}"
|
||||
nbd_rpc_data_verify $rpc_server "${bdev_list[*]}" "${nbd_list[*]}"
|
||||
nbd_with_lvol_verify $rpc_server "${nbd_list[*]}"
|
||||
|
||||
killprocess $nbd_pid
|
||||
trap - SIGINT SIGTERM EXIT
|
||||
|
@ -121,3 +121,21 @@ function nbd_rpc_start_stop_verify() {
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function nbd_with_lvol_verify() {
|
||||
local rpc_server=$1
|
||||
local nbd_list=($2)
|
||||
|
||||
$rootdir/scripts/rpc.py -s $rpc_server bdev_malloc_create -b malloc_lvol_verify 16 512
|
||||
$rootdir/scripts/rpc.py -s $rpc_server bdev_lvol_create_lvstore malloc_lvol_verify lvs
|
||||
$rootdir/scripts/rpc.py -s $rpc_server bdev_lvol_create lvol 4 -l lvs
|
||||
$rootdir/scripts/rpc.py -s $rpc_server nbd_start_disk lvs/lvol "${nbd_list[0]}"
|
||||
|
||||
mkfs_ret=$(mkfs.ext4 ${nbd_list[0]})
|
||||
nbd_stop_disks $rpc_server "${nbd_list[0]}"
|
||||
if [ $mkfs_ret -ne 0 ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user