xref: /spdk/module/bdev/lvol/vbdev_lvol.h (revision da231290b273ae555f25c4eb12a7f34efee0d29a)
1 /*   SPDX-License-Identifier: BSD-3-Clause
2  *   Copyright (c) Intel Corporation.
3  *   All rights reserved.
4  */
5 
6 #ifndef SPDK_VBDEV_LVOL_H
7 #define SPDK_VBDEV_LVOL_H
8 
9 #include "spdk/lvol.h"
10 #include "spdk/bdev_module.h"
11 
12 #include "spdk_internal/lvolstore.h"
13 
14 struct lvol_store_bdev {
15 	struct spdk_lvol_store	*lvs;
16 	struct spdk_bdev	*bdev;
17 	struct spdk_lvs_req	*req;
18 
19 	TAILQ_ENTRY(lvol_store_bdev)	lvol_stores;
20 };
21 
22 struct lvol_bdev {
23 	struct spdk_bdev	bdev;
24 	struct spdk_lvol	*lvol;
25 	struct lvol_store_bdev	*lvs_bdev;
26 };
27 
28 int vbdev_lvs_create(const char *base_bdev_name, const char *name, uint32_t cluster_sz,
29 		     enum lvs_clear_method clear_method, uint32_t num_md_pages_per_cluster_ratio,
30 		     spdk_lvs_op_with_handle_complete cb_fn, void *cb_arg);
31 void vbdev_lvs_destruct(struct spdk_lvol_store *lvs, spdk_lvs_op_complete cb_fn, void *cb_arg);
32 void vbdev_lvs_unload(struct spdk_lvol_store *lvs, spdk_lvs_op_complete cb_fn, void *cb_arg);
33 
34 int vbdev_lvol_create(struct spdk_lvol_store *lvs, const char *name, uint64_t sz,
35 		      bool thin_provisioned, enum lvol_clear_method clear_method,
36 		      spdk_lvol_op_with_handle_complete cb_fn,
37 		      void *cb_arg);
38 
39 void vbdev_lvol_create_snapshot(struct spdk_lvol *lvol, const char *snapshot_name,
40 				spdk_lvol_op_with_handle_complete cb_fn, void *cb_arg);
41 
42 void vbdev_lvol_create_clone(struct spdk_lvol *lvol, const char *clone_name,
43 			     spdk_lvol_op_with_handle_complete cb_fn, void *cb_arg);
44 
45 /**
46  * \brief Change size of lvol
47  * \param lvol Handle to lvol
48  * \param sz Size of lvol to change
49  * \param cb_fn Completion callback
50  * \param cb_arg Completion callback custom arguments
51  * \return error
52  */
53 void vbdev_lvol_resize(struct spdk_lvol *lvol, uint64_t sz, spdk_lvol_op_complete cb_fn,
54 		       void *cb_arg);
55 
56 /**
57  * \brief Mark lvol as read only
58  * \param lvol Handle to lvol
59  * \param cb_fn Completion callback
60  * \param cb_arg Completion callback custom arguments
61  */
62 void vbdev_lvol_set_read_only(struct spdk_lvol *lvol, spdk_lvol_op_complete cb_fn, void *cb_arg);
63 
64 void vbdev_lvol_rename(struct spdk_lvol *lvol, const char *new_lvol_name,
65 		       spdk_lvol_op_complete cb_fn, void *cb_arg);
66 
67 /**
68  * Destroy a logical volume
69  * \param lvol Handle to lvol
70  * \param cb_fn Completion callback
71  * \param cb_arg Completion callback custom arguments
72  */
73 void vbdev_lvol_destroy(struct spdk_lvol *lvol, spdk_lvol_op_complete cb_fn, void *cb_arg);
74 
75 /**
76  * \brief Renames given lvolstore.
77  *
78  * \param lvs Pointer to lvolstore
79  * \param new_name New name of lvs
80  * \param cb_fn Completion callback
81  * \param cb_arg Completion callback custom arguments
82  */
83 void vbdev_lvs_rename(struct spdk_lvol_store *lvs, const char *new_lvs_name,
84 		      spdk_lvs_op_complete cb_fn, void *cb_arg);
85 
86 /**
87  * \brief Search for handle lvolstore
88  * \param uuid_str UUID of lvolstore
89  * \return Handle to spdk_lvol_store or NULL if not found.
90  */
91 struct spdk_lvol_store *vbdev_get_lvol_store_by_uuid(const char *uuid_str);
92 
93 /**
94  * \brief Search for handle to lvolstore
95  * \param name name of lvolstore
96  * \return Handle to spdk_lvol_store or NULL if not found.
97  */
98 struct spdk_lvol_store *vbdev_get_lvol_store_by_name(const char *name);
99 
100 /**
101  * \brief Search for handle to lvol_store_bdev
102  * \param lvs handle to lvolstore
103  * \return Handle to lvol_store_bdev or NULL if not found.
104  */
105 struct lvol_store_bdev *vbdev_get_lvs_bdev_by_lvs(struct spdk_lvol_store *lvs);
106 
107 struct spdk_lvol *vbdev_lvol_get_from_bdev(struct spdk_bdev *bdev);
108 
109 /**
110  * \brief Grow given lvolstore.
111  *
112  * \param lvs Pointer to lvolstore
113  * \param cb_fn Completion callback
114  * \param cb_arg Completion callback custom arguments
115  */
116 void vbdev_lvs_grow(struct spdk_lvol_store *lvs,
117 		    spdk_lvs_op_complete cb_fn, void *cb_arg);
118 
119 #endif /* SPDK_VBDEV_LVOL_H */
120