xref: /linux/drivers/md/dm-vdo/io-submitter.h (revision 79790b6818e96c58fe2bffee1b418c16e64e7b80)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright 2023 Red Hat
4  */
5 
6 #ifndef VDO_IO_SUBMITTER_H
7 #define VDO_IO_SUBMITTER_H
8 
9 #include <linux/bio.h>
10 
11 #include "types.h"
12 
13 struct io_submitter;
14 
15 int vdo_make_io_submitter(unsigned int thread_count, unsigned int rotation_interval,
16 			  unsigned int max_requests_active, struct vdo *vdo,
17 			  struct io_submitter **io_submitter);
18 
19 void vdo_cleanup_io_submitter(struct io_submitter *io_submitter);
20 
21 void vdo_free_io_submitter(struct io_submitter *io_submitter);
22 
23 void vdo_submit_vio(struct vdo_completion *completion);
24 
25 void vdo_submit_data_vio(struct data_vio *data_vio);
26 
27 void __submit_metadata_vio(struct vio *vio, physical_block_number_t physical,
28 			   bio_end_io_t callback, vdo_action_fn error_handler,
29 			   blk_opf_t operation, char *data);
30 
vdo_submit_metadata_vio(struct vio * vio,physical_block_number_t physical,bio_end_io_t callback,vdo_action_fn error_handler,blk_opf_t operation)31 static inline void vdo_submit_metadata_vio(struct vio *vio, physical_block_number_t physical,
32 					   bio_end_io_t callback, vdo_action_fn error_handler,
33 					   blk_opf_t operation)
34 {
35 	__submit_metadata_vio(vio, physical, callback, error_handler,
36 			      operation, vio->data);
37 }
38 
vdo_submit_flush_vio(struct vio * vio,bio_end_io_t callback,vdo_action_fn error_handler)39 static inline void vdo_submit_flush_vio(struct vio *vio, bio_end_io_t callback,
40 					vdo_action_fn error_handler)
41 {
42 	/* FIXME: Can we just use REQ_OP_FLUSH? */
43 	__submit_metadata_vio(vio, 0, callback, error_handler,
44 			      REQ_OP_WRITE | REQ_PREFLUSH, NULL);
45 }
46 
47 #endif /* VDO_IO_SUBMITTER_H */
48