]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | /*- |
2 | * BSD LICENSE | |
3 | * | |
4 | * Copyright (c) Intel Corporation. | |
5 | * All rights reserved. | |
6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | |
10 | * | |
11 | * * Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | |
13 | * * Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in | |
15 | * the documentation and/or other materials provided with the | |
16 | * distribution. | |
17 | * * Neither the name of Intel Corporation nor the names of its | |
18 | * contributors may be used to endorse or promote products derived | |
19 | * from this software without specific prior written permission. | |
20 | * | |
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | |
33 | ||
34 | #ifndef SPDK_VBDEV_LVOL_H | |
35 | #define SPDK_VBDEV_LVOL_H | |
36 | ||
37 | #include "spdk/lvol.h" | |
38 | #include "spdk/bdev_module.h" | |
39 | ||
40 | #include "spdk_internal/lvolstore.h" | |
41 | ||
42 | struct lvol_store_bdev { | |
43 | struct spdk_lvol_store *lvs; | |
44 | struct spdk_bdev *bdev; | |
45 | struct spdk_lvs_req *req; | |
46 | ||
47 | TAILQ_ENTRY(lvol_store_bdev) lvol_stores; | |
48 | }; | |
49 | ||
50 | int vbdev_lvs_create(struct spdk_bdev *base_bdev, const char *name, uint32_t cluster_sz, | |
9f95a23c | 51 | enum lvs_clear_method clear_method, spdk_lvs_op_with_handle_complete cb_fn, void *cb_arg); |
11fdf7f2 TL |
52 | void vbdev_lvs_destruct(struct spdk_lvol_store *lvs, spdk_lvs_op_complete cb_fn, void *cb_arg); |
53 | void vbdev_lvs_unload(struct spdk_lvol_store *lvs, spdk_lvs_op_complete cb_fn, void *cb_arg); | |
54 | ||
55 | int vbdev_lvol_create(struct spdk_lvol_store *lvs, const char *name, uint64_t sz, | |
9f95a23c TL |
56 | bool thin_provisioned, enum lvol_clear_method clear_method, |
57 | spdk_lvol_op_with_handle_complete cb_fn, | |
58 | void *cb_arg); | |
11fdf7f2 TL |
59 | |
60 | void vbdev_lvol_create_snapshot(struct spdk_lvol *lvol, const char *snapshot_name, | |
61 | spdk_lvol_op_with_handle_complete cb_fn, void *cb_arg); | |
62 | ||
63 | void vbdev_lvol_create_clone(struct spdk_lvol *lvol, const char *clone_name, | |
64 | spdk_lvol_op_with_handle_complete cb_fn, void *cb_arg); | |
65 | ||
66 | /** | |
67 | * \brief Change size of lvol | |
68 | * \param lvol Handle to lvol | |
69 | * \param sz Size of lvol to change | |
70 | * \param cb_fn Completion callback | |
71 | * \param cb_arg Completion callback custom arguments | |
72 | * \return error | |
73 | */ | |
74 | void vbdev_lvol_resize(struct spdk_lvol *lvol, uint64_t sz, spdk_lvol_op_complete cb_fn, | |
75 | void *cb_arg); | |
76 | ||
9f95a23c TL |
77 | /** |
78 | * \brief Mark lvol as read only | |
79 | * \param lvol Handle to lvol | |
80 | * \param cb_fn Completion callback | |
81 | * \param cb_arg Completion callback custom arguments | |
82 | */ | |
83 | void vbdev_lvol_set_read_only(struct spdk_lvol *lvol, spdk_lvol_op_complete cb_fn, void *cb_arg); | |
84 | ||
11fdf7f2 TL |
85 | void vbdev_lvol_rename(struct spdk_lvol *lvol, const char *new_lvol_name, |
86 | spdk_lvol_op_complete cb_fn, void *cb_arg); | |
87 | ||
88 | /** | |
89 | * Destroy a logical volume | |
90 | * \param lvol Handle to lvol | |
91 | * \param cb_fn Completion callback | |
92 | * \param cb_arg Completion callback custom arguments | |
93 | */ | |
94 | void vbdev_lvol_destroy(struct spdk_lvol *lvol, spdk_lvol_op_complete cb_fn, void *cb_arg); | |
95 | ||
96 | /** | |
97 | * \brief Renames given lvolstore. | |
98 | * | |
99 | * \param lvs Pointer to lvolstore | |
100 | * \param new_name New name of lvs | |
101 | * \param cb_fn Completion callback | |
102 | * \param cb_arg Completion callback custom arguments | |
103 | */ | |
104 | void vbdev_lvs_rename(struct spdk_lvol_store *lvs, const char *new_lvs_name, | |
105 | spdk_lvs_op_complete cb_fn, void *cb_arg); | |
106 | ||
107 | /** | |
108 | * \brief Search for handle lvolstore | |
109 | * \param uuid_str UUID of lvolstore | |
110 | * \return Handle to spdk_lvol_store or NULL if not found. | |
111 | */ | |
112 | struct spdk_lvol_store *vbdev_get_lvol_store_by_uuid(const char *uuid_str); | |
113 | ||
114 | /** | |
115 | * \brief Search for handle to lvolstore | |
116 | * \param name name of lvolstore | |
117 | * \return Handle to spdk_lvol_store or NULL if not found. | |
118 | */ | |
119 | struct spdk_lvol_store *vbdev_get_lvol_store_by_name(const char *name); | |
120 | ||
121 | /** | |
122 | * \brief Search for handle to lvol_store_bdev | |
123 | * \param lvs handle to lvolstore | |
124 | * \return Handle to lvol_store_bdev or NULL if not found. | |
125 | */ | |
126 | struct lvol_store_bdev *vbdev_get_lvs_bdev_by_lvs(struct spdk_lvol_store *lvs); | |
127 | ||
128 | struct spdk_lvol *vbdev_lvol_get_from_bdev(struct spdk_bdev *bdev); | |
129 | ||
130 | #endif /* SPDK_VBDEV_LVOL_H */ |