]> git.proxmox.com Git - mirror_qemu.git/blame - include/sysemu/block-backend-io.h
block, block-backend: write some hot coroutine wrappers by hand
[mirror_qemu.git] / include / sysemu / block-backend-io.h
CommitLineData
a2c4c3b1
EGE
1/*
2 * QEMU Block backends
3 *
4 * Copyright (C) 2014-2016 Red Hat, Inc.
5 *
6 * Authors:
7 * Markus Armbruster <armbru@redhat.com>,
8 *
9 * This work is licensed under the terms of the GNU LGPL, version 2.1
10 * or later. See the COPYING.LIB file in the top-level directory.
11 */
12
13#ifndef BLOCK_BACKEND_IO_H
14#define BLOCK_BACKEND_IO_H
15
16#include "block-backend-common.h"
e2c1c34f 17#include "block/accounting.h"
a2c4c3b1
EGE
18
19/*
20 * I/O API functions. These functions are thread-safe.
21 *
22 * See include/block/block-io.h for more information about
23 * the I/O API.
24 */
25
26const char *blk_name(const BlockBackend *blk);
27
28BlockDriverState *blk_bs(BlockBackend *blk);
29
30void blk_set_allow_write_beyond_eof(BlockBackend *blk, bool allow);
31void blk_set_allow_aio_context_change(BlockBackend *blk, bool allow);
32void blk_set_disable_request_queuing(BlockBackend *blk, bool disable);
33bool blk_iostatus_is_enabled(const BlockBackend *blk);
34
35char *blk_get_attached_dev_id(BlockBackend *blk);
36
37BlockAIOCB *blk_aio_pwrite_zeroes(BlockBackend *blk, int64_t offset,
38 int64_t bytes, BdrvRequestFlags flags,
39 BlockCompletionFunc *cb, void *opaque);
40
41BlockAIOCB *blk_aio_preadv(BlockBackend *blk, int64_t offset,
42 QEMUIOVector *qiov, BdrvRequestFlags flags,
43 BlockCompletionFunc *cb, void *opaque);
44BlockAIOCB *blk_aio_pwritev(BlockBackend *blk, int64_t offset,
45 QEMUIOVector *qiov, BdrvRequestFlags flags,
46 BlockCompletionFunc *cb, void *opaque);
47BlockAIOCB *blk_aio_flush(BlockBackend *blk,
48 BlockCompletionFunc *cb, void *opaque);
49BlockAIOCB *blk_aio_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes,
50 BlockCompletionFunc *cb, void *opaque);
51void blk_aio_cancel_async(BlockAIOCB *acb);
52BlockAIOCB *blk_aio_ioctl(BlockBackend *blk, unsigned long int req, void *buf,
53 BlockCompletionFunc *cb, void *opaque);
54
55void blk_inc_in_flight(BlockBackend *blk);
56void blk_dec_in_flight(BlockBackend *blk);
1e97be91 57
c73ff92c
EGE
58bool coroutine_fn GRAPH_RDLOCK blk_co_is_inserted(BlockBackend *blk);
59bool co_wrapper_mixed_bdrv_rdlock blk_is_inserted(BlockBackend *blk);
1e97be91 60
c73ff92c
EGE
61bool coroutine_fn GRAPH_RDLOCK blk_co_is_available(BlockBackend *blk);
62bool co_wrapper_mixed_bdrv_rdlock blk_is_available(BlockBackend *blk);
2c75261c
EGE
63
64void coroutine_fn blk_co_lock_medium(BlockBackend *blk, bool locked);
65void co_wrapper blk_lock_medium(BlockBackend *blk, bool locked);
2531b390
EGE
66
67void coroutine_fn blk_co_eject(BlockBackend *blk, bool eject_flag);
68void co_wrapper blk_eject(BlockBackend *blk, bool eject_flag);
c86422c5
EGE
69
70int64_t coroutine_fn blk_co_getlength(BlockBackend *blk);
71int64_t co_wrapper_mixed blk_getlength(BlockBackend *blk);
72
d8fbf9aa
KW
73void coroutine_fn blk_co_get_geometry(BlockBackend *blk,
74 uint64_t *nb_sectors_ptr);
81f730d4 75void blk_get_geometry(BlockBackend *blk, uint64_t *nb_sectors_ptr);
c86422c5
EGE
76
77int64_t coroutine_fn blk_co_nb_sectors(BlockBackend *blk);
81f730d4 78int64_t blk_nb_sectors(BlockBackend *blk);
c86422c5 79
a2c4c3b1
EGE
80void *blk_try_blockalign(BlockBackend *blk, size_t size);
81void *blk_blockalign(BlockBackend *blk, size_t size);
82bool blk_is_writable(BlockBackend *blk);
83bool blk_enable_write_cache(BlockBackend *blk);
84BlockdevOnError blk_get_on_error(BlockBackend *blk, bool is_read);
85BlockErrorAction blk_get_error_action(BlockBackend *blk, bool is_read,
86 int error);
87void blk_error_action(BlockBackend *blk, BlockErrorAction action,
88 bool is_read, int error);
89void blk_iostatus_set_err(BlockBackend *blk, int error);
90int blk_get_max_iov(BlockBackend *blk);
91int blk_get_max_hw_iov(BlockBackend *blk);
a2c4c3b1 92
8f497454
EGE
93void coroutine_fn blk_co_io_plug(BlockBackend *blk);
94void co_wrapper blk_io_plug(BlockBackend *blk);
95
09d9fc97
EGE
96void coroutine_fn blk_co_io_unplug(BlockBackend *blk);
97void co_wrapper blk_io_unplug(BlockBackend *blk);
98
a2c4c3b1
EGE
99AioContext *blk_get_aio_context(BlockBackend *blk);
100BlockAcctStats *blk_get_stats(BlockBackend *blk);
101void *blk_aio_get(const AIOCBInfo *aiocb_info, BlockBackend *blk,
102 BlockCompletionFunc *cb, void *opaque);
103BlockAIOCB *blk_abort_aio_request(BlockBackend *blk,
104 BlockCompletionFunc *cb,
105 void *opaque, int ret);
106
107uint32_t blk_get_request_alignment(BlockBackend *blk);
108uint32_t blk_get_max_transfer(BlockBackend *blk);
109uint64_t blk_get_max_hw_transfer(BlockBackend *blk);
110
111int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in,
112 BlockBackend *blk_out, int64_t off_out,
113 int64_t bytes, BdrvRequestFlags read_flags,
114 BdrvRequestFlags write_flags);
115
ff7e261b
EGE
116int coroutine_fn blk_co_block_status_above(BlockBackend *blk,
117 BlockDriverState *base,
118 int64_t offset, int64_t bytes,
119 int64_t *pnum, int64_t *map,
120 BlockDriverState **file);
121int coroutine_fn blk_co_is_allocated_above(BlockBackend *blk,
122 BlockDriverState *base,
123 bool include_base, int64_t offset,
124 int64_t bytes, int64_t *pnum);
a2c4c3b1
EGE
125
126/*
127 * "I/O or GS" API functions. These functions can run without
128 * the BQL, but only in one specific iothread/main loop.
129 *
130 * See include/block/block-io.h for more information about
131 * the "I/O or GS" API.
132 */
133
1bd54201
EGE
134int co_wrapper_mixed blk_pread(BlockBackend *blk, int64_t offset,
135 int64_t bytes, void *buf,
136 BdrvRequestFlags flags);
6f675c93
AF
137int coroutine_fn blk_co_pread(BlockBackend *blk, int64_t offset, int64_t bytes,
138 void *buf, BdrvRequestFlags flags);
139
1bd54201
EGE
140int co_wrapper_mixed blk_preadv(BlockBackend *blk, int64_t offset,
141 int64_t bytes, QEMUIOVector *qiov,
142 BdrvRequestFlags flags);
6f675c93
AF
143int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset,
144 int64_t bytes, QEMUIOVector *qiov,
145 BdrvRequestFlags flags);
146
1bd54201
EGE
147int co_wrapper_mixed blk_preadv_part(BlockBackend *blk, int64_t offset,
148 int64_t bytes, QEMUIOVector *qiov,
149 size_t qiov_offset,
150 BdrvRequestFlags flags);
d1d3fc3d
AF
151int coroutine_fn blk_co_preadv_part(BlockBackend *blk, int64_t offset,
152 int64_t bytes, QEMUIOVector *qiov,
153 size_t qiov_offset, BdrvRequestFlags flags);
6f675c93 154
1bd54201
EGE
155int co_wrapper_mixed blk_pwrite(BlockBackend *blk, int64_t offset,
156 int64_t bytes, const void *buf,
157 BdrvRequestFlags flags);
6f675c93
AF
158int coroutine_fn blk_co_pwrite(BlockBackend *blk, int64_t offset, int64_t bytes,
159 const void *buf, BdrvRequestFlags flags);
160
1bd54201
EGE
161int co_wrapper_mixed blk_pwritev(BlockBackend *blk, int64_t offset,
162 int64_t bytes, QEMUIOVector *qiov,
163 BdrvRequestFlags flags);
6f675c93
AF
164int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset,
165 int64_t bytes, QEMUIOVector *qiov,
166 BdrvRequestFlags flags);
167
1bd54201
EGE
168int co_wrapper_mixed blk_pwritev_part(BlockBackend *blk, int64_t offset,
169 int64_t bytes, QEMUIOVector *qiov,
170 size_t qiov_offset,
171 BdrvRequestFlags flags);
a2c4c3b1
EGE
172int coroutine_fn blk_co_pwritev_part(BlockBackend *blk, int64_t offset,
173 int64_t bytes,
174 QEMUIOVector *qiov, size_t qiov_offset,
175 BdrvRequestFlags flags);
a2c4c3b1 176
1bd54201
EGE
177int co_wrapper_mixed blk_pwrite_compressed(BlockBackend *blk,
178 int64_t offset, int64_t bytes,
179 const void *buf);
6f675c93
AF
180int coroutine_fn blk_co_pwrite_compressed(BlockBackend *blk, int64_t offset,
181 int64_t bytes, const void *buf);
a2c4c3b1 182
1bd54201
EGE
183int co_wrapper_mixed blk_pwrite_zeroes(BlockBackend *blk, int64_t offset,
184 int64_t bytes,
185 BdrvRequestFlags flags);
6f675c93
AF
186int coroutine_fn blk_co_pwrite_zeroes(BlockBackend *blk, int64_t offset,
187 int64_t bytes, BdrvRequestFlags flags);
a2c4c3b1 188
1bd54201
EGE
189int co_wrapper_mixed blk_pdiscard(BlockBackend *blk, int64_t offset,
190 int64_t bytes);
a2c4c3b1
EGE
191int coroutine_fn blk_co_pdiscard(BlockBackend *blk, int64_t offset,
192 int64_t bytes);
193
1bd54201 194int co_wrapper_mixed blk_flush(BlockBackend *blk);
a2c4c3b1 195int coroutine_fn blk_co_flush(BlockBackend *blk);
a2c4c3b1 196
1bd54201
EGE
197int co_wrapper_mixed blk_ioctl(BlockBackend *blk, unsigned long int req,
198 void *buf);
df02da00
AF
199int coroutine_fn blk_co_ioctl(BlockBackend *blk, unsigned long int req,
200 void *buf);
a2c4c3b1 201
1bd54201
EGE
202int co_wrapper_mixed blk_truncate(BlockBackend *blk, int64_t offset,
203 bool exact, PreallocMode prealloc,
204 BdrvRequestFlags flags, Error **errp);
015ed252
AF
205int coroutine_fn blk_co_truncate(BlockBackend *blk, int64_t offset, bool exact,
206 PreallocMode prealloc, BdrvRequestFlags flags,
207 Error **errp);
a2c4c3b1
EGE
208
209#endif /* BLOCK_BACKEND_IO_H */