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 typedef void (*bdev_compress_create_cb)(void *ctx, int status); 18 19 /** 20 * Get the first compression bdev. 21 * 22 * \return the first compression bdev. 23 */ 24 struct vbdev_compress *compress_bdev_first(void); 25 26 /** 27 * Get the next compression bdev. 28 * 29 * \param prev previous compression bdev. 30 * \return the next compression bdev. 31 */ 32 struct vbdev_compress *compress_bdev_next(struct vbdev_compress *prev); 33 34 /** 35 * Test to see if a compression bdev orphan exists. 36 * 37 * \param name The name of the compression bdev. 38 * \return true if found, false if not. 39 */ 40 bool compress_has_orphan(const char *name); 41 42 /** 43 * Get the name of a compression bdev. 44 * 45 * \param comp_bdev The compression bdev. 46 * \return the name of the compression bdev. 47 */ 48 const char *compress_get_name(const struct vbdev_compress *comp_bdev); 49 50 typedef void (*spdk_delete_compress_complete)(void *cb_arg, int bdeverrno); 51 52 /** 53 * Create new compression bdev. 54 * 55 * \param bdev_name Bdev on which compression bdev will be created. 56 * \param pm_path Path to persistent memory. 57 * \param lb_size Logical block size for the compressed volume in bytes. Must be 4K or 512. 58 * \param comp_algo compression algorithm for the compressed volume. 59 * \param comp_level compression algorithm level for the compressed volume. 60 * \param cb_fn Function to call after creation. 61 * \param cb_arg Argument to pass to cb_fn. 62 * \return 0 on success, other on failure. 63 */ 64 int create_compress_bdev(const char *bdev_name, const char *pm_path, uint32_t lb_size, 65 uint8_t comp_algo, uint32_t comp_level, 66 bdev_compress_create_cb cb_fn, void *cb_arg); 67 68 /** 69 * Delete compress bdev. 70 * 71 * \param bdev_name Bdev on which compression bdev will be deleted. 72 * \param cb_fn Function to call after deletion. 73 * \param cb_arg Argument to pass to cb_fn. 74 */ 75 void bdev_compress_delete(const char *bdev_name, spdk_delete_compress_complete cb_fn, 76 void *cb_arg); 77 78 #endif /* SPDK_VBDEV_COMPRESS_H */ 79