diff --git a/include/spdk/bdev_module.h b/include/spdk/bdev_module.h index a8bf5693d..4a3df0480 100644 --- a/include/spdk/bdev_module.h +++ b/include/spdk/bdev_module.h @@ -339,6 +339,21 @@ struct spdk_bdev { */ bool zoned; + /** + * Default size of each zone (in blocks). + */ + uint64_t zone_size; + + /** + * Maximum number of open zones. + */ + uint32_t max_open_zones; + + /** + * Optimal number of open zones. + */ + uint32_t optimal_open_zones; + /** * Pointer to the bdev module that registered this bdev. */ diff --git a/include/spdk/bdev_zone.h b/include/spdk/bdev_zone.h new file mode 100644 index 000000000..5f5fb687c --- /dev/null +++ b/include/spdk/bdev_zone.h @@ -0,0 +1,77 @@ +/*- + * BSD LICENSE + * + * Copyright (c) Intel Corporation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** \file + * Zoned device public interface + */ + +#ifndef SPDK_BDEV_ZONE_H +#define SPDK_BDEV_ZONE_H + +#include "spdk/stdinc.h" + +/** + * \brief SPDK block device. + * + * This is a virtual representation of a block device that is exported by the backend. + */ + +struct spdk_bdev; + +/** + * Get device zone size in logical blocks. + * + * \param bdev Block device to query. + * \return Size of zone for this zoned device in logical blocks. + */ +uint64_t spdk_bdev_get_zone_size(const struct spdk_bdev *bdev); + +/** + * Get device maximum number of open zones. + * + * If this value is 0, there is no limit. + * + * \param bdev Block device to query. + * \return Maximum number of open zones for this zoned device. + */ +uint32_t spdk_bdev_get_max_open_zones(const struct spdk_bdev *bdev); + +/** + * Get device optimal number of open zones. + * + * \param bdev Block device to query. + * \return Optimal number of open zones for this zoned device. + */ +uint32_t spdk_bdev_get_optimal_open_zones(const struct spdk_bdev *bdev); + +#endif /* SPDK_BDEV_ZONE_H */ diff --git a/lib/bdev/Makefile b/lib/bdev/Makefile index 6de952147..e8d2dd9ea 100644 --- a/lib/bdev/Makefile +++ b/lib/bdev/Makefile @@ -38,7 +38,7 @@ ifeq ($(CONFIG_VTUNE),y) CFLAGS += -I$(CONFIG_VTUNE_DIR)/include -I$(CONFIG_VTUNE_DIR)/sdk/src/ittnotify endif -C_SRCS = bdev.c bdev_rpc.c part.c scsi_nvme.c +C_SRCS = bdev.c bdev_rpc.c bdev_zone.c part.c scsi_nvme.c C_SRCS-$(CONFIG_VTUNE) += vtune.c LIBNAME = bdev diff --git a/lib/bdev/bdev_zone.c b/lib/bdev/bdev_zone.c new file mode 100644 index 000000000..a96cf9bb7 --- /dev/null +++ b/lib/bdev/bdev_zone.c @@ -0,0 +1,55 @@ +/*- + * BSD LICENSE + * + * Copyright (c) Intel Corporation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "spdk/stdinc.h" + +#include "spdk/bdev_zone.h" +#include "spdk/bdev_module.h" + +uint64_t +spdk_bdev_get_zone_size(const struct spdk_bdev *bdev) +{ + return bdev->zone_size; +} + +uint32_t +spdk_bdev_get_max_open_zones(const struct spdk_bdev *bdev) +{ + return bdev->max_open_zones; +} + +uint32_t +spdk_bdev_get_optimal_open_zones(const struct spdk_bdev *bdev) +{ + return bdev->optimal_open_zones; +}