xref: /spdk/lib/ftl/mngt/ftl_mngt.h (revision 106ad3793f953d7353e5a5a1fa67fa6a82d13747)
1293cdc48SArtur Paszkiewicz /*   SPDX-License-Identifier: BSD-3-Clause
2a6dbe372Spaul luse  *   Copyright (C) 2022 Intel Corporation.
3293cdc48SArtur Paszkiewicz  *   All rights reserved.
4293cdc48SArtur Paszkiewicz  */
5293cdc48SArtur Paszkiewicz 
6293cdc48SArtur Paszkiewicz #ifndef FTL_MNGT_H
7293cdc48SArtur Paszkiewicz #define FTL_MNGT_H
8293cdc48SArtur Paszkiewicz 
9293cdc48SArtur Paszkiewicz #include "spdk/stdinc.h"
10293cdc48SArtur Paszkiewicz #include "spdk/ftl.h"
11293cdc48SArtur Paszkiewicz 
12293cdc48SArtur Paszkiewicz struct spdk_ftl_dev;
13293cdc48SArtur Paszkiewicz struct ftl_mngt_process;
14293cdc48SArtur Paszkiewicz 
15293cdc48SArtur Paszkiewicz /**
16293cdc48SArtur Paszkiewicz  * The FTL management callback function
17293cdc48SArtur Paszkiewicz  *
18293cdc48SArtur Paszkiewicz  * @param dev FTL device
19293cdc48SArtur Paszkiewicz  * @param mngt FTL management handle
20293cdc48SArtur Paszkiewicz  */
21293cdc48SArtur Paszkiewicz typedef void (*ftl_mngt_fn)(struct spdk_ftl_dev *dev, struct ftl_mngt_process *mngt);
22293cdc48SArtur Paszkiewicz 
23293cdc48SArtur Paszkiewicz /**
249452abe6SMateusz Kozlowski  * The FTL management init function
259452abe6SMateusz Kozlowski  *
269452abe6SMateusz Kozlowski  * @param dev FTL device
279452abe6SMateusz Kozlowski  * @param mngt FTL management handle
289452abe6SMateusz Kozlowski  * @param init_ctx The initialization context
299452abe6SMateusz Kozlowski  *
309452abe6SMateusz Kozlowski  * @return Initialization status
319452abe6SMateusz Kozlowski  * @retval 0 initialization successful, the process can be executed
329452abe6SMateusz Kozlowski  * @retval non-zero an error occurred during initialization, fail the process
339452abe6SMateusz Kozlowski  */
349452abe6SMateusz Kozlowski typedef int (*ftl_mngt_init_fn)(struct spdk_ftl_dev *dev, struct ftl_mngt_process *mngt,
359452abe6SMateusz Kozlowski 				void *init_ctx);
369452abe6SMateusz Kozlowski 
379452abe6SMateusz Kozlowski /**
38b71eebd8SArtur Paszkiewicz  * The FTL management process completion callback function
39b71eebd8SArtur Paszkiewicz  *
40b71eebd8SArtur Paszkiewicz  * @param dev FTL device
41b71eebd8SArtur Paszkiewicz  * @param ctx Caller context
42b71eebd8SArtur Paszkiewicz  * @param status The operation result of the management process
43b71eebd8SArtur Paszkiewicz  */
44b71eebd8SArtur Paszkiewicz typedef void (*ftl_mngt_completion)(struct spdk_ftl_dev *dev, void *ctx, int status);
45b71eebd8SArtur Paszkiewicz 
46b71eebd8SArtur Paszkiewicz /**
473f912cf0SMichal Berger  * The FTL management step descriptor
48293cdc48SArtur Paszkiewicz  */
49293cdc48SArtur Paszkiewicz struct ftl_mngt_step_desc {
50293cdc48SArtur Paszkiewicz 	/**
51293cdc48SArtur Paszkiewicz 	 * Name of the step
52293cdc48SArtur Paszkiewicz 	 */
53293cdc48SArtur Paszkiewicz 	const char *name;
54293cdc48SArtur Paszkiewicz 
55293cdc48SArtur Paszkiewicz 	/**
56293cdc48SArtur Paszkiewicz 	 * Size of the step argument (context)
57293cdc48SArtur Paszkiewicz 	 *
58293cdc48SArtur Paszkiewicz 	 * The step context will be allocated before execution of step's
59293cdc48SArtur Paszkiewicz 	 * callback.
60293cdc48SArtur Paszkiewicz 	 *
61293cdc48SArtur Paszkiewicz 	 * @note The context can be reallocated (freed and newly allocated
62293cdc48SArtur Paszkiewicz 	 * when calling ftl_mngt_alloc_step_ctx). The main usage is the ability
63293cdc48SArtur Paszkiewicz 	 * to set this value to 0 and only allocate as needed if the step is
64293cdc48SArtur Paszkiewicz 	 * going to be extremely similar - eg. recovery from shared memory and
65293cdc48SArtur Paszkiewicz 	 * disk - in case of shm all the data is already available in memory, while
66293cdc48SArtur Paszkiewicz 	 * recovery from disk needs extra context to be able to synchronize IO. This
67293cdc48SArtur Paszkiewicz 	 * allows for saving a little bit of time on alloc/dealloc in the cases where
68293cdc48SArtur Paszkiewicz 	 * execution time may be critical.
69293cdc48SArtur Paszkiewicz 	 * @note It doesn't work like realloc
70293cdc48SArtur Paszkiewicz 	 * @note The context can be retrieved within callback when calling
71293cdc48SArtur Paszkiewicz 	 * ftl_mngt_get_step_ctx
72293cdc48SArtur Paszkiewicz 	 */
73293cdc48SArtur Paszkiewicz 	size_t ctx_size;
74293cdc48SArtur Paszkiewicz 
75293cdc48SArtur Paszkiewicz 	/**
76293cdc48SArtur Paszkiewicz 	 * Step callback function
77293cdc48SArtur Paszkiewicz 	 */
78293cdc48SArtur Paszkiewicz 	ftl_mngt_fn action;
79293cdc48SArtur Paszkiewicz 
80293cdc48SArtur Paszkiewicz 	/**
81293cdc48SArtur Paszkiewicz 	 * It the step requires cleanup this is right place to put your handler.
82293cdc48SArtur Paszkiewicz 	 * When a FTL management process fails cleanup callbacks are executed
83293cdc48SArtur Paszkiewicz 	 * in rollback procedure. Cleanup functions are executed in reverse
84293cdc48SArtur Paszkiewicz 	 * order to actions already called.
85293cdc48SArtur Paszkiewicz 	 */
86293cdc48SArtur Paszkiewicz 	ftl_mngt_fn cleanup;
87293cdc48SArtur Paszkiewicz };
88293cdc48SArtur Paszkiewicz 
89293cdc48SArtur Paszkiewicz /**
90293cdc48SArtur Paszkiewicz  * The FTL management process descriptor
91293cdc48SArtur Paszkiewicz  */
92293cdc48SArtur Paszkiewicz struct ftl_mngt_process_desc {
93293cdc48SArtur Paszkiewicz 	/**
94293cdc48SArtur Paszkiewicz 	 * The name of the process
95293cdc48SArtur Paszkiewicz 	 */
96293cdc48SArtur Paszkiewicz 	const char *name;
97293cdc48SArtur Paszkiewicz 
98293cdc48SArtur Paszkiewicz 	/**
99293cdc48SArtur Paszkiewicz 	 * Size of the process argument (context)
100293cdc48SArtur Paszkiewicz 	 *
101293cdc48SArtur Paszkiewicz 	 * The process context will be allocated before execution of the first
102293cdc48SArtur Paszkiewicz 	 * step
103293cdc48SArtur Paszkiewicz 	 *
104293cdc48SArtur Paszkiewicz 	 * @note To get context of the process within FTL management callback,
105293cdc48SArtur Paszkiewicz 	 * execute ftl_mngt_get_process_ctx
106293cdc48SArtur Paszkiewicz 	 */
107293cdc48SArtur Paszkiewicz 	size_t ctx_size;
108293cdc48SArtur Paszkiewicz 
109293cdc48SArtur Paszkiewicz 	/**
110293cdc48SArtur Paszkiewicz 	 * Pointer to the additional error handler when the process fails
111293cdc48SArtur Paszkiewicz 	 */
112293cdc48SArtur Paszkiewicz 	ftl_mngt_fn error_handler;
113293cdc48SArtur Paszkiewicz 
114293cdc48SArtur Paszkiewicz 	/**
1159452abe6SMateusz Kozlowski 	 * The initialization handler is invoked when the management process is
1169452abe6SMateusz Kozlowski 	 * being created before the execution of the process
1179452abe6SMateusz Kozlowski 	 */
1189452abe6SMateusz Kozlowski 	ftl_mngt_init_fn init_handler;
1199452abe6SMateusz Kozlowski 
1209452abe6SMateusz Kozlowski 	/**
1215d89ebb7SMateusz Kozlowski 	 * When the process wants to cleanup, for example free resources which
1225d89ebb7SMateusz Kozlowski 	 * were allocated in init_handler, the deinit_handler can be provided
1235d89ebb7SMateusz Kozlowski 	 */
1245d89ebb7SMateusz Kozlowski 	ftl_mngt_fn deinit_handler;
1255d89ebb7SMateusz Kozlowski 
1265d89ebb7SMateusz Kozlowski 	/**
127293cdc48SArtur Paszkiewicz 	 * The FTL process steps
128293cdc48SArtur Paszkiewicz 	 *
129293cdc48SArtur Paszkiewicz 	 * The process context will be allocated before execution of the first
130293cdc48SArtur Paszkiewicz 	 * step
131293cdc48SArtur Paszkiewicz 	 *
132293cdc48SArtur Paszkiewicz 	 * @note The step array terminator shall end with action equals NULL
133293cdc48SArtur Paszkiewicz 	 */
134293cdc48SArtur Paszkiewicz 	struct ftl_mngt_step_desc steps[];
135293cdc48SArtur Paszkiewicz };
136293cdc48SArtur Paszkiewicz 
137293cdc48SArtur Paszkiewicz /**
138293cdc48SArtur Paszkiewicz  * @brief Executes the FTL management process defined by the process descriptor
139293cdc48SArtur Paszkiewicz  *
140293cdc48SArtur Paszkiewicz  * In case of an error all already executed steps will have their rollback functions
141293cdc48SArtur Paszkiewicz  * called in reverse order.
142293cdc48SArtur Paszkiewicz  *
143293cdc48SArtur Paszkiewicz  * @param dev FTL device
144293cdc48SArtur Paszkiewicz  * @param process The descriptor of process to be executed
145293cdc48SArtur Paszkiewicz  * @param cb Caller callback
146293cdc48SArtur Paszkiewicz  * @param cb_ctx Caller context
147293cdc48SArtur Paszkiewicz  *
148293cdc48SArtur Paszkiewicz  * @return Result of invoking the operation
149293cdc48SArtur Paszkiewicz  * @retval 0 - The FTL management process has been started
150293cdc48SArtur Paszkiewicz  * @retval Non-zero An error occurred when starting The FTL management process
151293cdc48SArtur Paszkiewicz  */
152293cdc48SArtur Paszkiewicz int ftl_mngt_process_execute(struct spdk_ftl_dev *dev,
153293cdc48SArtur Paszkiewicz 			     const struct ftl_mngt_process_desc *process,
154b71eebd8SArtur Paszkiewicz 			     ftl_mngt_completion cb, void *cb_ctx);
155293cdc48SArtur Paszkiewicz 
156293cdc48SArtur Paszkiewicz /**
157293cdc48SArtur Paszkiewicz  * @brief Executes rollback on the FTL management process defined by the process
158293cdc48SArtur Paszkiewicz  * descriptor
159293cdc48SArtur Paszkiewicz  *
160293cdc48SArtur Paszkiewicz  * All cleanup function from steps will be executed in reversed order
161293cdc48SArtur Paszkiewicz  *
162293cdc48SArtur Paszkiewicz  * @param dev FTL device
163293cdc48SArtur Paszkiewicz  * @param process The descriptor of process to be rollback
164293cdc48SArtur Paszkiewicz  * @param cb Caller callback
165293cdc48SArtur Paszkiewicz  * @param cb_ctx Caller context
166293cdc48SArtur Paszkiewicz  *
167293cdc48SArtur Paszkiewicz  * @return Result of invoking the rollback operation
168293cdc48SArtur Paszkiewicz  * @retval 0 - Rollback of the FTL management process has been started
169293cdc48SArtur Paszkiewicz  * @retval Non-zero An error occurred when starting the rollback
170293cdc48SArtur Paszkiewicz  */
171293cdc48SArtur Paszkiewicz int ftl_mngt_process_rollback(struct spdk_ftl_dev *dev,
172293cdc48SArtur Paszkiewicz 			      const struct ftl_mngt_process_desc *process,
173b71eebd8SArtur Paszkiewicz 			      ftl_mngt_completion cb, void *cb_ctx);
174293cdc48SArtur Paszkiewicz 
175293cdc48SArtur Paszkiewicz /*
176293cdc48SArtur Paszkiewicz  * FTL management API for steps
177293cdc48SArtur Paszkiewicz  */
178293cdc48SArtur Paszkiewicz 
179293cdc48SArtur Paszkiewicz /**
180293cdc48SArtur Paszkiewicz  * @brief Gets FTL device
181293cdc48SArtur Paszkiewicz  *
182293cdc48SArtur Paszkiewicz  * @param mngt FTL management handle
183293cdc48SArtur Paszkiewicz  *
184293cdc48SArtur Paszkiewicz  * @note This function can be invoked within step handler only
185293cdc48SArtur Paszkiewicz  *
186293cdc48SArtur Paszkiewicz  * @return FTL device
187293cdc48SArtur Paszkiewicz  */
188293cdc48SArtur Paszkiewicz struct spdk_ftl_dev *ftl_mngt_get_dev(struct ftl_mngt_process *mngt);
189293cdc48SArtur Paszkiewicz 
190293cdc48SArtur Paszkiewicz /**
191293cdc48SArtur Paszkiewicz  * @brief Allocates a context for the management step
192293cdc48SArtur Paszkiewicz  *
193293cdc48SArtur Paszkiewicz  * @param mngt FTL management handle
194293cdc48SArtur Paszkiewicz  * @param size Size of the step context
195293cdc48SArtur Paszkiewicz  *
196293cdc48SArtur Paszkiewicz  * @note This function can be invoked within ftl_mngt_fn callback only
197293cdc48SArtur Paszkiewicz  *
198293cdc48SArtur Paszkiewicz  * @return Operation result
199293cdc48SArtur Paszkiewicz  * @retval 0 Operation successful
200293cdc48SArtur Paszkiewicz  * @retval Non-zero Operation failure
201293cdc48SArtur Paszkiewicz  */
202293cdc48SArtur Paszkiewicz int ftl_mngt_alloc_step_ctx(struct ftl_mngt_process *mngt, size_t size);
203293cdc48SArtur Paszkiewicz 
204293cdc48SArtur Paszkiewicz /**
205293cdc48SArtur Paszkiewicz  * @brief Gets the management step context
206293cdc48SArtur Paszkiewicz  *
207293cdc48SArtur Paszkiewicz  * @param mngt FTL management handle
208293cdc48SArtur Paszkiewicz  *
209293cdc48SArtur Paszkiewicz  * @note This function can be invoked within ftl_mngt_fn callback only
210293cdc48SArtur Paszkiewicz  *
211293cdc48SArtur Paszkiewicz  * @return Context of the step containing pointer to buffer and its size
212293cdc48SArtur Paszkiewicz  */
213293cdc48SArtur Paszkiewicz void *ftl_mngt_get_step_ctx(struct ftl_mngt_process *mngt);
214293cdc48SArtur Paszkiewicz 
215293cdc48SArtur Paszkiewicz /**
216293cdc48SArtur Paszkiewicz  * @brief Gets the management process context
217293cdc48SArtur Paszkiewicz  *
218293cdc48SArtur Paszkiewicz  * @param mngt FTL management handle
219293cdc48SArtur Paszkiewicz  *
220293cdc48SArtur Paszkiewicz  * @note This function can be invoked within ftl_mngt_fn callback only
221293cdc48SArtur Paszkiewicz  *
222293cdc48SArtur Paszkiewicz  * @return Context of the process containing pointer to buffer and its size
223293cdc48SArtur Paszkiewicz  */
224293cdc48SArtur Paszkiewicz void *ftl_mngt_get_process_ctx(struct ftl_mngt_process *mngt);
225293cdc48SArtur Paszkiewicz 
226293cdc48SArtur Paszkiewicz /**
227293cdc48SArtur Paszkiewicz  * @brief Gets the caller context
228293cdc48SArtur Paszkiewicz  *
229293cdc48SArtur Paszkiewicz  * @param mngt FTL management handle
230293cdc48SArtur Paszkiewicz  *
231293cdc48SArtur Paszkiewicz  * @note This function can be invoked within ftl_mngt_fn callback only
232293cdc48SArtur Paszkiewicz  *
233293cdc48SArtur Paszkiewicz  * @return Pointer to the caller context
234293cdc48SArtur Paszkiewicz  */
235293cdc48SArtur Paszkiewicz void *ftl_mngt_get_caller_ctx(struct ftl_mngt_process *mngt);
236293cdc48SArtur Paszkiewicz 
237293cdc48SArtur Paszkiewicz /**
238293cdc48SArtur Paszkiewicz  * @brief Finishes the management process immediately
239293cdc48SArtur Paszkiewicz  *
240293cdc48SArtur Paszkiewicz  * @note This function can be invoked within ftl_mngt_fn callback only
241293cdc48SArtur Paszkiewicz  *
242293cdc48SArtur Paszkiewicz  * @param mngt FTL management handle of process to be finished
243293cdc48SArtur Paszkiewicz  */
244293cdc48SArtur Paszkiewicz void ftl_mngt_finish(struct ftl_mngt_process *mngt);
245293cdc48SArtur Paszkiewicz 
246293cdc48SArtur Paszkiewicz /**
247293cdc48SArtur Paszkiewicz  * @brief Completes the step currently in progress and jump to a next one
248293cdc48SArtur Paszkiewicz  *
249293cdc48SArtur Paszkiewicz  * If no more steps to be executed then the management process is finished and
250293cdc48SArtur Paszkiewicz  * caller callback is invoked
251293cdc48SArtur Paszkiewicz  *
252293cdc48SArtur Paszkiewicz  * @note This function can be invoked within ftl_mngt_fn callback only
253293cdc48SArtur Paszkiewicz  *
254293cdc48SArtur Paszkiewicz  * @param mngt FTL management handle
255293cdc48SArtur Paszkiewicz  */
256293cdc48SArtur Paszkiewicz void ftl_mngt_next_step(struct ftl_mngt_process *mngt);
257293cdc48SArtur Paszkiewicz 
258293cdc48SArtur Paszkiewicz /**
259293cdc48SArtur Paszkiewicz  * @brief Skips the step currently in progress and jump to a next one
260293cdc48SArtur Paszkiewicz  *
261293cdc48SArtur Paszkiewicz  * @note This function can be invoked within ftl_mngt_fn callback only
262293cdc48SArtur Paszkiewicz  *
263293cdc48SArtur Paszkiewicz  * @param mngt FTL management handle
264293cdc48SArtur Paszkiewicz  */
265293cdc48SArtur Paszkiewicz void ftl_mngt_skip_step(struct ftl_mngt_process *mngt);
266293cdc48SArtur Paszkiewicz 
267293cdc48SArtur Paszkiewicz /**
268293cdc48SArtur Paszkiewicz  * @brief Continue the step currently in progress
269293cdc48SArtur Paszkiewicz  *
270293cdc48SArtur Paszkiewicz  * This causes invoking the same step handler in next iteration of the
271293cdc48SArtur Paszkiewicz  * management process. This mechanism can be used by a job when polling for
272293cdc48SArtur Paszkiewicz  * something.
273293cdc48SArtur Paszkiewicz  *
274293cdc48SArtur Paszkiewicz  * @note This function can be invoked within ftl_mngt_fn callback only
275293cdc48SArtur Paszkiewicz  *
276293cdc48SArtur Paszkiewicz  * @param mngt FTL management handle
277293cdc48SArtur Paszkiewicz  */
278293cdc48SArtur Paszkiewicz void ftl_mngt_continue_step(struct ftl_mngt_process *mngt);
279293cdc48SArtur Paszkiewicz 
280293cdc48SArtur Paszkiewicz /**
281293cdc48SArtur Paszkiewicz  * @brief Fail the step currently in progress.
282293cdc48SArtur Paszkiewicz  *
283293cdc48SArtur Paszkiewicz  * It stops executing all steps and starts the rollback procedure (calling
284293cdc48SArtur Paszkiewicz  * the cleanup functions of all already executed steps).
285293cdc48SArtur Paszkiewicz  * If executed from a cleanup function, it will stop executing and the following
286293cdc48SArtur Paszkiewicz  * cleanup functions (if any) will be executed.
287293cdc48SArtur Paszkiewicz  *
288293cdc48SArtur Paszkiewicz  * @param mngt FTL management handle
289293cdc48SArtur Paszkiewicz  */
290293cdc48SArtur Paszkiewicz void ftl_mngt_fail_step(struct ftl_mngt_process *mngt);
291293cdc48SArtur Paszkiewicz 
292293cdc48SArtur Paszkiewicz /**
293293cdc48SArtur Paszkiewicz  * @brief Calls another management process
294293cdc48SArtur Paszkiewicz  *
295293cdc48SArtur Paszkiewicz  * Ends the current step and executes specified process and finally continues
296293cdc48SArtur Paszkiewicz  * executing the the remaining steps
297293cdc48SArtur Paszkiewicz  *
298293cdc48SArtur Paszkiewicz  * @param mngt The management handle
299293cdc48SArtur Paszkiewicz  * @param process The management process to be called
3009452abe6SMateusz Kozlowski  * @param init_ctx Process initialization context
3019452abe6SMateusz Kozlowski  *
3029452abe6SMateusz Kozlowski  * @note If the initialization procedure is required then both init_ctx and
3039452abe6SMateusz Kozlowski  * init_handler in the process descriptor must be provided.
304293cdc48SArtur Paszkiewicz  */
305293cdc48SArtur Paszkiewicz void ftl_mngt_call_process(struct ftl_mngt_process *mngt,
3069452abe6SMateusz Kozlowski 			   const struct ftl_mngt_process_desc *process,
3079452abe6SMateusz Kozlowski 			   void *init_ctx);
308293cdc48SArtur Paszkiewicz 
309293cdc48SArtur Paszkiewicz /**
310293cdc48SArtur Paszkiewicz  * @brief Calls rollback steps of another management process
311293cdc48SArtur Paszkiewicz  *
312293cdc48SArtur Paszkiewicz  * Ends the current step and executes rollback steps of specified process
313293cdc48SArtur Paszkiewicz  * and finally continues executing the remaining steps in the original process
314293cdc48SArtur Paszkiewicz  *
315293cdc48SArtur Paszkiewicz  * @param mngt The management handle
316293cdc48SArtur Paszkiewicz  * @param process The management process to be called to execute rollback
317293cdc48SArtur Paszkiewicz  */
318293cdc48SArtur Paszkiewicz void ftl_mngt_call_process_rollback(struct ftl_mngt_process *mngt,
319293cdc48SArtur Paszkiewicz 				    const struct ftl_mngt_process_desc *process);
320293cdc48SArtur Paszkiewicz 
321e49ccfc8SArtur Paszkiewicz /*
322e49ccfc8SArtur Paszkiewicz  * The specific management functions
323e49ccfc8SArtur Paszkiewicz  */
324e49ccfc8SArtur Paszkiewicz /**
325e49ccfc8SArtur Paszkiewicz  * @brief Starts up a FTL instance
326e49ccfc8SArtur Paszkiewicz  *
327e49ccfc8SArtur Paszkiewicz  * @param dev FTL device
328e49ccfc8SArtur Paszkiewicz  * @param cb Caller callback
329e49ccfc8SArtur Paszkiewicz  * @param cb_cntx Caller context
330e49ccfc8SArtur Paszkiewicz  *
331e49ccfc8SArtur Paszkiewicz  * @return Operation result
332e49ccfc8SArtur Paszkiewicz  * @retval 0 The operation successful has started
333e49ccfc8SArtur Paszkiewicz  * @retval Non-zero Startup failure
334e49ccfc8SArtur Paszkiewicz  */
335e49ccfc8SArtur Paszkiewicz int ftl_mngt_call_dev_startup(struct spdk_ftl_dev *dev, ftl_mngt_completion cb, void *cb_cntx);
336e49ccfc8SArtur Paszkiewicz 
3372c7c8b6cSKozlowski Mateusz /*
3382c7c8b6cSKozlowski Mateusz  * The specific management functions
3392c7c8b6cSKozlowski Mateusz  */
3402c7c8b6cSKozlowski Mateusz /**
341*106ad379SMateusz Kozlowski  * @brief Issue trim on FTL instance
3422c7c8b6cSKozlowski Mateusz  *
3432c7c8b6cSKozlowski Mateusz  * @param dev FTL device
3442c7c8b6cSKozlowski Mateusz  * @param cb Caller callback
3452c7c8b6cSKozlowski Mateusz  * @param cb_cntx Caller context
3462c7c8b6cSKozlowski Mateusz  *
3472c7c8b6cSKozlowski Mateusz  * @return Operation result
3482c7c8b6cSKozlowski Mateusz  * @retval 0 The operation successful has started
3492c7c8b6cSKozlowski Mateusz  * @retval Non-zero Startup failure
3502c7c8b6cSKozlowski Mateusz  */
351*106ad379SMateusz Kozlowski int ftl_mngt_trim(struct spdk_ftl_dev *dev, uint64_t lba, uint64_t num_blocks, spdk_ftl_fn cb,
3522c7c8b6cSKozlowski Mateusz 		  void *cb_cntx);
3532c7c8b6cSKozlowski Mateusz 
354e49ccfc8SArtur Paszkiewicz /**
355e49ccfc8SArtur Paszkiewicz  * @brief Shuts down a FTL instance
356e49ccfc8SArtur Paszkiewicz  *
357e49ccfc8SArtur Paszkiewicz  * @param dev FTL device
358e49ccfc8SArtur Paszkiewicz  * @param cb Caller callback
359e49ccfc8SArtur Paszkiewicz  * @param cb_cntx Caller context
360e49ccfc8SArtur Paszkiewicz  *
361e49ccfc8SArtur Paszkiewicz  * @return Operation result
362e49ccfc8SArtur Paszkiewicz  * @retval 0 The operation successful has started
363e49ccfc8SArtur Paszkiewicz  * @retval Non-zero Shutdown failure
364e49ccfc8SArtur Paszkiewicz  */
365e49ccfc8SArtur Paszkiewicz int ftl_mngt_call_dev_shutdown(struct spdk_ftl_dev *dev, ftl_mngt_completion cb, void *cb_cntx);
366e49ccfc8SArtur Paszkiewicz 
367293cdc48SArtur Paszkiewicz #endif /* LIB_FTL_FTL_MNGT_H */
368