1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright (C) 2018 Intel Corporation. 3 * All rights reserved. 4 * Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 5 */ 6 7 #ifndef SPDK_VBDEV_COMPRESS_H 8 #define SPDK_VBDEV_COMPRESS_H 9 10 #include "spdk/stdinc.h" 11 12 #include "spdk/bdev.h" 13 14 #define LB_SIZE_4K 0x1000UL 15 #define LB_SIZE_512B 0x200UL 16 17 /** 18 * Get the first compression bdev. 19 * 20 * \return the first compression bdev. 21 */ 22 struct vbdev_compress *compress_bdev_first(void); 23 24 /** 25 * Get the next compression bdev. 26 * 27 * \param prev previous compression bdev. 28 * \return the next compression bdev. 29 */ 30 struct vbdev_compress *compress_bdev_next(struct vbdev_compress *prev); 31 32 /** 33 * Test to see if a compression bdev orphan exists. 34 * 35 * \param name The name of the compression bdev. 36 * \return true if found, false if not. 37 */ 38 bool compress_has_orphan(const char *name); 39 40 /** 41 * Get the name of a compression bdev. 42 * 43 * \param comp_bdev The compression bdev. 44 * \return the name of the compression bdev. 45 */ 46 const char *compress_get_name(const struct vbdev_compress *comp_bdev); 47 48 typedef void (*spdk_delete_compress_complete)(void *cb_arg, int bdeverrno); 49 50 /** 51 * Create new compression bdev. 52 * 53 * \param bdev_name Bdev on which compression bdev will be created. 54 * \param pm_path Path to persistent memory. 55 * \param lb_size Logical block size for the compressed volume in bytes. Must be 4K or 512. 56 * \return 0 on success, other on failure. 57 */ 58 int create_compress_bdev(const char *bdev_name, const char *pm_path, uint32_t lb_size); 59 60 /** 61 * Delete compress bdev. 62 * 63 * \param bdev_name Bdev on which compression bdev will be deleted. 64 * \param cb_fn Function to call after deletion. 65 * \param cb_arg Argument to pass to cb_fn. 66 */ 67 void bdev_compress_delete(const char *bdev_name, spdk_delete_compress_complete cb_fn, 68 void *cb_arg); 69 70 #endif /* SPDK_VBDEV_COMPRESS_H */ 71