]> git.proxmox.com Git - mirror_qemu.git/blame - include/sysemu/block-backend-io.h
block: rename blk_io_plug_call() API to defer_call()
[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);
6d43eaa3
SL
49BlockAIOCB *blk_aio_zone_report(BlockBackend *blk, int64_t offset,
50 unsigned int *nr_zones,
51 BlockZoneDescriptor *zones,
52 BlockCompletionFunc *cb, void *opaque);
53BlockAIOCB *blk_aio_zone_mgmt(BlockBackend *blk, BlockZoneOp op,
54 int64_t offset, int64_t len,
55 BlockCompletionFunc *cb, void *opaque);
4751d09a
SL
56BlockAIOCB *blk_aio_zone_append(BlockBackend *blk, int64_t *offset,
57 QEMUIOVector *qiov, BdrvRequestFlags flags,
58 BlockCompletionFunc *cb, void *opaque);
a2c4c3b1
EGE
59BlockAIOCB *blk_aio_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes,
60 BlockCompletionFunc *cb, void *opaque);
61void blk_aio_cancel_async(BlockAIOCB *acb);
62BlockAIOCB *blk_aio_ioctl(BlockBackend *blk, unsigned long int req, void *buf,
63 BlockCompletionFunc *cb, void *opaque);
64
65void blk_inc_in_flight(BlockBackend *blk);
66void blk_dec_in_flight(BlockBackend *blk);
1e97be91 67
c73ff92c
EGE
68bool coroutine_fn GRAPH_RDLOCK blk_co_is_inserted(BlockBackend *blk);
69bool co_wrapper_mixed_bdrv_rdlock blk_is_inserted(BlockBackend *blk);
1e97be91 70
c73ff92c
EGE
71bool coroutine_fn GRAPH_RDLOCK blk_co_is_available(BlockBackend *blk);
72bool co_wrapper_mixed_bdrv_rdlock blk_is_available(BlockBackend *blk);
2c75261c
EGE
73
74void coroutine_fn blk_co_lock_medium(BlockBackend *blk, bool locked);
75void co_wrapper blk_lock_medium(BlockBackend *blk, bool locked);
2531b390
EGE
76
77void coroutine_fn blk_co_eject(BlockBackend *blk, bool eject_flag);
78void co_wrapper blk_eject(BlockBackend *blk, bool eject_flag);
c86422c5
EGE
79
80int64_t coroutine_fn blk_co_getlength(BlockBackend *blk);
81int64_t co_wrapper_mixed blk_getlength(BlockBackend *blk);
82
d8fbf9aa
KW
83void coroutine_fn blk_co_get_geometry(BlockBackend *blk,
84 uint64_t *nb_sectors_ptr);
81f730d4 85void blk_get_geometry(BlockBackend *blk, uint64_t *nb_sectors_ptr);
c86422c5
EGE
86
87int64_t coroutine_fn blk_co_nb_sectors(BlockBackend *blk);
81f730d4 88int64_t blk_nb_sectors(BlockBackend *blk);
c86422c5 89
a2c4c3b1
EGE
90void *blk_try_blockalign(BlockBackend *blk, size_t size);
91void *blk_blockalign(BlockBackend *blk, size_t size);
92bool blk_is_writable(BlockBackend *blk);
93bool blk_enable_write_cache(BlockBackend *blk);
94BlockdevOnError blk_get_on_error(BlockBackend *blk, bool is_read);
95BlockErrorAction blk_get_error_action(BlockBackend *blk, bool is_read,
96 int error);
97void blk_error_action(BlockBackend *blk, BlockErrorAction action,
98 bool is_read, int error);
99void blk_iostatus_set_err(BlockBackend *blk, int error);
100int blk_get_max_iov(BlockBackend *blk);
101int blk_get_max_hw_iov(BlockBackend *blk);
a2c4c3b1 102
ccee48aa
SH
103void defer_call_begin(void);
104void defer_call_end(void);
105void defer_call(void (*fn)(void *), void *opaque);
09d9fc97 106
a2c4c3b1
EGE
107AioContext *blk_get_aio_context(BlockBackend *blk);
108BlockAcctStats *blk_get_stats(BlockBackend *blk);
109void *blk_aio_get(const AIOCBInfo *aiocb_info, BlockBackend *blk,
110 BlockCompletionFunc *cb, void *opaque);
111BlockAIOCB *blk_abort_aio_request(BlockBackend *blk,
112 BlockCompletionFunc *cb,
113 void *opaque, int ret);
114
115uint32_t blk_get_request_alignment(BlockBackend *blk);
116uint32_t blk_get_max_transfer(BlockBackend *blk);
117uint64_t blk_get_max_hw_transfer(BlockBackend *blk);
118
119int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in,
120 BlockBackend *blk_out, int64_t off_out,
121 int64_t bytes, BdrvRequestFlags read_flags,
122 BdrvRequestFlags write_flags);
123
ff7e261b
EGE
124int coroutine_fn blk_co_block_status_above(BlockBackend *blk,
125 BlockDriverState *base,
126 int64_t offset, int64_t bytes,
127 int64_t *pnum, int64_t *map,
128 BlockDriverState **file);
129int coroutine_fn blk_co_is_allocated_above(BlockBackend *blk,
130 BlockDriverState *base,
131 bool include_base, int64_t offset,
132 int64_t bytes, int64_t *pnum);
a2c4c3b1
EGE
133
134/*
135 * "I/O or GS" API functions. These functions can run without
136 * the BQL, but only in one specific iothread/main loop.
137 *
138 * See include/block/block-io.h for more information about
139 * the "I/O or GS" API.
140 */
141
1bd54201
EGE
142int co_wrapper_mixed blk_pread(BlockBackend *blk, int64_t offset,
143 int64_t bytes, void *buf,
144 BdrvRequestFlags flags);
6f675c93
AF
145int coroutine_fn blk_co_pread(BlockBackend *blk, int64_t offset, int64_t bytes,
146 void *buf, BdrvRequestFlags flags);
147
1bd54201
EGE
148int co_wrapper_mixed blk_preadv(BlockBackend *blk, int64_t offset,
149 int64_t bytes, QEMUIOVector *qiov,
150 BdrvRequestFlags flags);
6f675c93
AF
151int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset,
152 int64_t bytes, QEMUIOVector *qiov,
153 BdrvRequestFlags flags);
154
1bd54201
EGE
155int co_wrapper_mixed blk_preadv_part(BlockBackend *blk, int64_t offset,
156 int64_t bytes, QEMUIOVector *qiov,
157 size_t qiov_offset,
158 BdrvRequestFlags flags);
d1d3fc3d
AF
159int coroutine_fn blk_co_preadv_part(BlockBackend *blk, int64_t offset,
160 int64_t bytes, QEMUIOVector *qiov,
161 size_t qiov_offset, BdrvRequestFlags flags);
6f675c93 162
1bd54201
EGE
163int co_wrapper_mixed blk_pwrite(BlockBackend *blk, int64_t offset,
164 int64_t bytes, const void *buf,
165 BdrvRequestFlags flags);
6f675c93
AF
166int coroutine_fn blk_co_pwrite(BlockBackend *blk, int64_t offset, int64_t bytes,
167 const void *buf, BdrvRequestFlags flags);
168
1bd54201
EGE
169int co_wrapper_mixed blk_pwritev(BlockBackend *blk, int64_t offset,
170 int64_t bytes, QEMUIOVector *qiov,
171 BdrvRequestFlags flags);
6f675c93
AF
172int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset,
173 int64_t bytes, QEMUIOVector *qiov,
174 BdrvRequestFlags flags);
175
1bd54201
EGE
176int co_wrapper_mixed blk_pwritev_part(BlockBackend *blk, int64_t offset,
177 int64_t bytes, QEMUIOVector *qiov,
178 size_t qiov_offset,
179 BdrvRequestFlags flags);
a2c4c3b1
EGE
180int coroutine_fn blk_co_pwritev_part(BlockBackend *blk, int64_t offset,
181 int64_t bytes,
182 QEMUIOVector *qiov, size_t qiov_offset,
183 BdrvRequestFlags flags);
a2c4c3b1 184
1bd54201
EGE
185int co_wrapper_mixed blk_pwrite_compressed(BlockBackend *blk,
186 int64_t offset, int64_t bytes,
187 const void *buf);
6f675c93
AF
188int coroutine_fn blk_co_pwrite_compressed(BlockBackend *blk, int64_t offset,
189 int64_t bytes, const void *buf);
a2c4c3b1 190
1bd54201
EGE
191int co_wrapper_mixed blk_pwrite_zeroes(BlockBackend *blk, int64_t offset,
192 int64_t bytes,
193 BdrvRequestFlags flags);
6f675c93
AF
194int coroutine_fn blk_co_pwrite_zeroes(BlockBackend *blk, int64_t offset,
195 int64_t bytes, BdrvRequestFlags flags);
6d43eaa3
SL
196
197int coroutine_fn blk_co_zone_report(BlockBackend *blk, int64_t offset,
198 unsigned int *nr_zones,
199 BlockZoneDescriptor *zones);
200int co_wrapper_mixed blk_zone_report(BlockBackend *blk, int64_t offset,
201 unsigned int *nr_zones,
202 BlockZoneDescriptor *zones);
203int coroutine_fn blk_co_zone_mgmt(BlockBackend *blk, BlockZoneOp op,
204 int64_t offset, int64_t len);
205int co_wrapper_mixed blk_zone_mgmt(BlockBackend *blk, BlockZoneOp op,
206 int64_t offset, int64_t len);
4751d09a
SL
207int coroutine_fn blk_co_zone_append(BlockBackend *blk, int64_t *offset,
208 QEMUIOVector *qiov,
209 BdrvRequestFlags flags);
210int co_wrapper_mixed blk_zone_append(BlockBackend *blk, int64_t *offset,
211 QEMUIOVector *qiov,
212 BdrvRequestFlags flags);
a2c4c3b1 213
1bd54201
EGE
214int co_wrapper_mixed blk_pdiscard(BlockBackend *blk, int64_t offset,
215 int64_t bytes);
a2c4c3b1
EGE
216int coroutine_fn blk_co_pdiscard(BlockBackend *blk, int64_t offset,
217 int64_t bytes);
218
1bd54201 219int co_wrapper_mixed blk_flush(BlockBackend *blk);
a2c4c3b1 220int coroutine_fn blk_co_flush(BlockBackend *blk);
a2c4c3b1 221
1bd54201
EGE
222int co_wrapper_mixed blk_ioctl(BlockBackend *blk, unsigned long int req,
223 void *buf);
df02da00
AF
224int coroutine_fn blk_co_ioctl(BlockBackend *blk, unsigned long int req,
225 void *buf);
a2c4c3b1 226
1bd54201
EGE
227int co_wrapper_mixed blk_truncate(BlockBackend *blk, int64_t offset,
228 bool exact, PreallocMode prealloc,
229 BdrvRequestFlags flags, Error **errp);
015ed252
AF
230int coroutine_fn blk_co_truncate(BlockBackend *blk, int64_t offset, bool exact,
231 PreallocMode prealloc, BdrvRequestFlags flags,
232 Error **errp);
a2c4c3b1
EGE
233
234#endif /* BLOCK_BACKEND_IO_H */