diff --git a/README.rst b/README.rst index 480600b0..72d586c6 100644 --- a/README.rst +++ b/README.rst @@ -305,7 +305,7 @@ by MIT license. The library functions (all code in lib/ directory and include/ublksrv.h) are covered by dual licensed LGPL and MIT, see COPYING.LGPL and LICENSE. -qcow2 target code is covered by GPL-2.0, see COPYING. +qcow2 and nbd target code is covered by GPL-2.0, see COPYING. All other source code are covered by dual licensed GPL and MIT, see COPYING and LICENSE. diff --git a/include/ublk_cmd.h b/include/ublk_cmd.h index a5da4d20..c0c8f44a 100644 --- a/include/ublk_cmd.h +++ b/include/ublk_cmd.h @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) or MIT */ #ifndef USER_BLK_DRV_CMD_INC_H #define USER_BLK_DRV_CMD_INC_H diff --git a/include/ublksrv_tgt_endian.h b/include/ublksrv_tgt_endian.h index 03d98e6e..df061726 100644 --- a/include/ublksrv_tgt_endian.h +++ b/include/ublksrv_tgt_endian.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 +// SPDX-License-Identifier: MIT or GPL-2.0-only #ifndef UBLK_TGT_ENDIAN_H #define UBLK_TGT_ENDIAN_H @@ -6,136 +6,23 @@ /* ublksrv target code private header, not for libublksrv user */ -static inline uint16_t bswap16(uint16_t x) -{ - return bswap_16(x); -} -static inline uint32_t bswap32(uint32_t x) -{ - return bswap_32(x); -} -static inline uint64_t bswap64(uint64_t x) -{ - return bswap_64(x); -} - -static inline void bswap16s(uint16_t *s) -{ - *s = bswap16(*s); -} - -static inline void bswap32s(uint32_t *s) -{ - *s = bswap32(*s); -} - -static inline void bswap64s(uint64_t *s) -{ - *s = bswap64(*s); -} - -#ifndef glue -#define xglue(x, y) x ## y -#define glue(x, y) xglue(x, y) -#endif - -#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ -#define be_bswap(v, size) (v) -#define le_bswap(v, size) glue(bswap, size)(v) -#define be_bswaps(v, size) -#define le_bswaps(p, size) do { *p = glue(bswap, size)(*p); } while(0) -#else -#define le_bswap(v, size) (v) -#define be_bswap(v, size) glue(bswap, size)(v) -#define le_bswaps(v, size) -#define be_bswaps(p, size) do { *p = glue(bswap, size)(*p); } while(0) -#endif - -/** - * Endianness conversion functions between host cpu and specified endianness. - * (We list the complete set of prototypes produced by the macros below - * to assist people who search the headers to find their definitions.) - * - * uint16_t le16_to_cpu(uint16_t v); - * uint32_t le32_to_cpu(uint32_t v); - * uint64_t le64_to_cpu(uint64_t v); - * uint16_t be16_to_cpu(uint16_t v); - * uint32_t be32_to_cpu(uint32_t v); - * uint64_t be64_to_cpu(uint64_t v); - * - * Convert the value @v from the specified format to the native - * endianness of the host CPU by byteswapping if necessary, and - * return the converted value. - * - * uint16_t cpu_to_le16(uint16_t v); - * uint32_t cpu_to_le32(uint32_t v); - * uint64_t cpu_to_le64(uint64_t v); - * uint16_t cpu_to_be16(uint16_t v); - * uint32_t cpu_to_be32(uint32_t v); - * uint64_t cpu_to_be64(uint64_t v); - * - * Convert the value @v from the native endianness of the host CPU to - * the specified format by byteswapping if necessary, and return - * the converted value. - * - * void le16_to_cpus(uint16_t *v); - * void le32_to_cpus(uint32_t *v); - * void le64_to_cpus(uint64_t *v); - * void be16_to_cpus(uint16_t *v); - * void be32_to_cpus(uint32_t *v); - * void be64_to_cpus(uint64_t *v); - * - * Do an in-place conversion of the value pointed to by @v from the - * specified format to the native endianness of the host CPU. - * - * void cpu_to_le16s(uint16_t *v); - * void cpu_to_le32s(uint32_t *v); - * void cpu_to_le64s(uint64_t *v); - * void cpu_to_be16s(uint16_t *v); - * void cpu_to_be32s(uint32_t *v); - * void cpu_to_be64s(uint64_t *v); - * - * Do an in-place conversion of the value pointed to by @v from the - * native endianness of the host CPU to the specified format. - * - * Both X_to_cpu() and cpu_to_X() perform the same operation; you - * should use whichever one is better documenting of the function your - * code is performing. - * - * Do not use these functions for conversion of values which are in guest - * memory, since the data may not be sufficiently aligned for the host CPU's - * load and store instructions. Instead you should use the ld*_p() and - * st*_p() functions, which perform loads and stores of data of any - * required size and endianness and handle possible misalignment. - */ - -#define CPU_CONVERT(endian, size, type)\ +#define HOST_CONVERT(endian, size, type)\ static inline type endian ## size ## _to_cpu(type v)\ {\ - return glue(endian, _bswap)(v, size);\ + return endian ## size ## toh(v); \ }\ \ static inline type cpu_to_ ## endian ## size(type v)\ {\ - return glue(endian, _bswap)(v, size);\ + return hto ## endian ## size(v); \ }\ -\ -static inline void endian ## size ## _to_cpus(type *p)\ -{\ - glue(endian, _bswaps)(p, size);\ -}\ -\ -static inline void cpu_to_ ## endian ## size ## s(type *p)\ -{\ - glue(endian, _bswaps)(p, size);\ -} -CPU_CONVERT(be, 16, uint16_t) -CPU_CONVERT(be, 32, uint32_t) -CPU_CONVERT(be, 64, uint64_t) +HOST_CONVERT(be, 16, uint16_t) +HOST_CONVERT(be, 32, uint32_t) +HOST_CONVERT(be, 64, uint64_t) -CPU_CONVERT(le, 16, uint16_t) -CPU_CONVERT(le, 32, uint32_t) -CPU_CONVERT(le, 64, uint64_t) +HOST_CONVERT(le, 16, uint16_t) +HOST_CONVERT(le, 32, uint32_t) +HOST_CONVERT(le, 64, uint64_t) #endif diff --git a/tests/common/nbd_common b/tests/common/nbd_common index ab4eda5e..aabccc9d 100755 --- a/tests/common/nbd_common +++ b/tests/common/nbd_common @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: MIT or GPL-2.0 export NBDSRV=127.0.0.1 export NBD_SIZE=2G diff --git a/tests/common/qcow2_common b/tests/common/qcow2_common index 9c4b3405..a0cc1469 100755 --- a/tests/common/qcow2_common +++ b/tests/common/qcow2_common @@ -1,5 +1,5 @@ -# SPDX-License-Identifier: GPL-2.0 #!/bin/bash +# SPDX-License-Identifier: MIT or GPL-2.0-only export QCOW2_IMG_SZ=2G diff --git a/tests/debug/test_dev b/tests/debug/test_dev index b1ed84d1..b5c0ba66 100755 --- a/tests/debug/test_dev +++ b/tests/debug/test_dev @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: MIT or GPL-2.0-only # #usage: # export UBLK_DBG_DEV=/dev/vdc; make test T=debug/test_dev diff --git a/tests/nbd/001 b/tests/nbd/001 index 6768f6a1..c1e6a474 100755 --- a/tests/nbd/001 +++ b/tests/nbd/001 @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: MIT or GPL-2.0 . common/fio_common . common/nbd_common diff --git a/tests/nbd/002 b/tests/nbd/002 index aab42991..3bf2943a 100755 --- a/tests/nbd/002 +++ b/tests/nbd/002 @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: MIT or GPL-2.0 . common/fio_common . common/nbd_common diff --git a/tests/nbd/003 b/tests/nbd/003 index 338187b0..f35412ac 100755 --- a/tests/nbd/003 +++ b/tests/nbd/003 @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: MIT or GPL-2.0 . common/fio_common . common/nbd_common diff --git a/tests/nbd/021 b/tests/nbd/021 index 2921bf90..af49106e 100755 --- a/tests/nbd/021 +++ b/tests/nbd/021 @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: MIT or GPL-2.0 . common/fio_common . common/nbd_common diff --git a/tests/nbd/022 b/tests/nbd/022 index 8ddd038b..72d88ee7 100755 --- a/tests/nbd/022 +++ b/tests/nbd/022 @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: MIT or GPL-2.0 . common/fio_common . common/nbd_common diff --git a/tests/nbd/023 b/tests/nbd/023 index e37a0108..eef0bd8c 100755 --- a/tests/nbd/023 +++ b/tests/nbd/023 @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: MIT or GPL-2.0 . common/fio_common . common/nbd_common diff --git a/tests/nbd/041 b/tests/nbd/041 index 5c49536a..70c56538 100755 --- a/tests/nbd/041 +++ b/tests/nbd/041 @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: MIT or GPL-2.0 . common/fio_common . common/nbd_common diff --git a/tests/nbd/042 b/tests/nbd/042 index b5f673bb..c3d1c326 100755 --- a/tests/nbd/042 +++ b/tests/nbd/042 @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: MIT or GPL-2.0 . common/fio_common . common/nbd_common diff --git a/tests/nbd/043 b/tests/nbd/043 index e463774e..46085546 100755 --- a/tests/nbd/043 +++ b/tests/nbd/043 @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: MIT or GPL-2.0 . common/fio_common . common/nbd_common diff --git a/tests/qcow2/001 b/tests/qcow2/001 index 7367dc3a..4cb16785 100755 --- a/tests/qcow2/001 +++ b/tests/qcow2/001 @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: MIT or GPL-2.0 . common/fio_common . common/qcow2_common diff --git a/tests/qcow2/002 b/tests/qcow2/002 index 0e67a478..789702d9 100755 --- a/tests/qcow2/002 +++ b/tests/qcow2/002 @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: MIT or GPL-2.0 . common/fio_common . common/qcow2_common diff --git a/tests/qcow2/021 b/tests/qcow2/021 index d820fcf9..a61daa2d 100755 --- a/tests/qcow2/021 +++ b/tests/qcow2/021 @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: MIT or GPL-2.0 . common/fio_common . common/qcow2_common diff --git a/tests/qcow2/022 b/tests/qcow2/022 index 972a9851..16e3c404 100755 --- a/tests/qcow2/022 +++ b/tests/qcow2/022 @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: MIT or GPL-2.0 . common/fio_common . common/qcow2_common diff --git a/tests/qcow2/040 b/tests/qcow2/040 index b7c879dc..81e0ca44 100755 --- a/tests/qcow2/040 +++ b/tests/qcow2/040 @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: MIT or GPL-2.0 . common/fio_common . common/qcow2_common diff --git a/tests/qcow2/041 b/tests/qcow2/041 index 3edc08a9..ec8a2aeb 100755 --- a/tests/qcow2/041 +++ b/tests/qcow2/041 @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: MIT or GPL-2.0 . common/fio_common . common/qcow2_common diff --git a/tests/qcow2/big_size_fs_io b/tests/qcow2/big_size_fs_io index 7c736c02..aa344719 100755 --- a/tests/qcow2/big_size_fs_io +++ b/tests/qcow2/big_size_fs_io @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: MIT or GPL-2.0-only . common/fio_common . common/qcow2_common diff --git a/tests/qcow2/big_size_io b/tests/qcow2/big_size_io index 0fca12ac..e30fbe65 100755 --- a/tests/qcow2/big_size_io +++ b/tests/qcow2/big_size_io @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: MIT or GPL-2.0-only . common/fio_common . common/qcow2_common diff --git a/utils/genver.sh b/utils/genver.sh index 50479df3..acdf5351 100755 --- a/utils/genver.sh +++ b/utils/genver.sh @@ -1,5 +1,5 @@ #!/bin/sh -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: MIT or GPL-2.0-only GITDESC=$(git describe --dirty|sed -e 's/^v//' 2>/dev/null) diff --git a/utils/nop.c b/utils/nop.c deleted file mode 100644 index 55156831..00000000 --- a/utils/nop.c +++ /dev/null @@ -1,65 +0,0 @@ -/* SPDX-License-Identifier: MIT */ -#include -#include -#include -#include -#include -#include -#include - -/* gcc -g -o nop nop.c -luring */ - -/* test nop over uring and see io_uring is working */ -static int test_nop() -{ - struct io_uring _ring; - struct io_uring *ring = &_ring; - struct io_uring_params p = { }; - int ret, i; - struct io_uring_cqe *cqe; - struct io_uring_sqe *sqe; - - p.flags = IORING_SETUP_SQE128; - ret = io_uring_queue_init_params(64, ring, &p); - if (ret < 0) { - fprintf(stderr, "ring can't be setup %d\n", ret); - goto err; - } - - ret = -EINVAL; - sqe = io_uring_get_sqe(ring); - if (!sqe) { - fprintf(stderr, "get sqe failed ret %d\n", ret); - return ret; - } - - io_uring_prep_nop(sqe); - sqe->user_data = 1; - ret = io_uring_submit(ring); - if (ret <= 0) { - fprintf(stderr, "sqe submit failed: %d\n", ret); - goto err; - } - - ret = io_uring_wait_cqe(ring, &cqe); - if (ret < 0) { - fprintf(stderr, "wait completion %d\n", ret); - goto err; - } - if (!cqe->user_data) { - fprintf(stderr, "Unexpected 0 user_data\n"); - goto err; - } - io_uring_cqe_seen(ring, cqe); - fprintf(stdout, "nop over uring run successfully\n"); -err: - io_uring_queue_exit(ring); - return ret; -} - -int main(int argc, char *argv[]) -{ - test_nop(); - - return 0; -} diff --git a/utils/ublk_chown_docker.sh b/utils/ublk_chown_docker.sh index a0e7841c..68a2fd7a 100755 --- a/utils/ublk_chown_docker.sh +++ b/utils/ublk_chown_docker.sh @@ -1,5 +1,5 @@ #!/bin/bash -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: MIT or GPL-2.0-only ublk_docker_add() {