xref: /spdk/module/bdev/compress/vbdev_compress.h (revision 8afdeef3becfe9409cc9e7372bd0bc10e8b7d46d)
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 cb_fn Function to call after creation.
59  * \param cb_arg Argument to pass to cb_fn.
60  * \return 0 on success, other on failure.
61  */
62 int create_compress_bdev(const char *bdev_name, const char *pm_path, uint32_t lb_size,
63 			 bdev_compress_create_cb cb_fn, void *cb_arg);
64 
65 /**
66  * Delete compress bdev.
67  *
68  * \param bdev_name Bdev on which compression bdev will be deleted.
69  * \param cb_fn Function to call after deletion.
70  * \param cb_arg Argument to pass to cb_fn.
71  */
72 void bdev_compress_delete(const char *bdev_name, spdk_delete_compress_complete cb_fn,
73 			  void *cb_arg);
74 
75 #endif /* SPDK_VBDEV_COMPRESS_H */
76