1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#ifndef BLOCK_INT_IO_H
25#define BLOCK_INT_IO_H
26
27#include "block_int-common.h"
28
29
30
31
32
33
34
35
36int coroutine_fn bdrv_co_preadv_snapshot(BdrvChild *child,
37 int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset);
38int coroutine_fn bdrv_co_snapshot_block_status(BlockDriverState *bs,
39 bool want_zero, int64_t offset, int64_t bytes, int64_t *pnum,
40 int64_t *map, BlockDriverState **file);
41int coroutine_fn bdrv_co_pdiscard_snapshot(BlockDriverState *bs,
42 int64_t offset, int64_t bytes);
43
44
45int coroutine_fn bdrv_co_preadv(BdrvChild *child,
46 int64_t offset, int64_t bytes, QEMUIOVector *qiov,
47 BdrvRequestFlags flags);
48int coroutine_fn bdrv_co_preadv_part(BdrvChild *child,
49 int64_t offset, int64_t bytes,
50 QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags);
51int coroutine_fn bdrv_co_pwritev(BdrvChild *child,
52 int64_t offset, int64_t bytes, QEMUIOVector *qiov,
53 BdrvRequestFlags flags);
54int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child,
55 int64_t offset, int64_t bytes,
56 QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags);
57
58static inline int coroutine_fn bdrv_co_pread(BdrvChild *child,
59 int64_t offset, int64_t bytes, void *buf, BdrvRequestFlags flags)
60{
61 QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, bytes);
62 IO_CODE();
63
64 return bdrv_co_preadv(child, offset, bytes, &qiov, flags);
65}
66
67static inline int coroutine_fn bdrv_co_pwrite(BdrvChild *child,
68 int64_t offset, int64_t bytes, const void *buf, BdrvRequestFlags flags)
69{
70 QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, bytes);
71 IO_CODE();
72
73 return bdrv_co_pwritev(child, offset, bytes, &qiov, flags);
74}
75
76void coroutine_fn bdrv_make_request_serialising(BdrvTrackedRequest *req,
77 uint64_t align);
78BdrvTrackedRequest *coroutine_fn bdrv_co_get_self_request(BlockDriverState *bs);
79
80BlockDriver *bdrv_probe_all(const uint8_t *buf, int buf_size,
81 const char *filename);
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96void bdrv_wakeup(BlockDriverState *bs);
97
98const char *bdrv_get_parent_name(const BlockDriverState *bs);
99bool blk_dev_has_tray(BlockBackend *blk);
100bool blk_dev_is_tray_open(BlockBackend *blk);
101
102void bdrv_set_dirty(BlockDriverState *bs, int64_t offset, int64_t bytes);
103
104void bdrv_clear_dirty_bitmap(BdrvDirtyBitmap *bitmap, HBitmap **out);
105void bdrv_dirty_bitmap_merge_internal(BdrvDirtyBitmap *dest,
106 const BdrvDirtyBitmap *src,
107 HBitmap **backup, bool lock);
108
109void bdrv_inc_in_flight(BlockDriverState *bs);
110void bdrv_dec_in_flight(BlockDriverState *bs);
111
112int coroutine_fn bdrv_co_copy_range_from(BdrvChild *src, int64_t src_offset,
113 BdrvChild *dst, int64_t dst_offset,
114 int64_t bytes,
115 BdrvRequestFlags read_flags,
116 BdrvRequestFlags write_flags);
117int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, int64_t src_offset,
118 BdrvChild *dst, int64_t dst_offset,
119 int64_t bytes,
120 BdrvRequestFlags read_flags,
121 BdrvRequestFlags write_flags);
122
123int refresh_total_sectors(BlockDriverState *bs, int64_t hint);
124
125BdrvChild *bdrv_cow_child(BlockDriverState *bs);
126BdrvChild *bdrv_filter_child(BlockDriverState *bs);
127BdrvChild *bdrv_filter_or_cow_child(BlockDriverState *bs);
128BdrvChild *bdrv_primary_child(BlockDriverState *bs);
129BlockDriverState *bdrv_skip_filters(BlockDriverState *bs);
130BlockDriverState *bdrv_backing_chain_next(BlockDriverState *bs);
131
132static inline BlockDriverState *bdrv_cow_bs(BlockDriverState *bs)
133{
134 IO_CODE();
135 return child_bs(bdrv_cow_child(bs));
136}
137
138static inline BlockDriverState *bdrv_filter_bs(BlockDriverState *bs)
139{
140 IO_CODE();
141 return child_bs(bdrv_filter_child(bs));
142}
143
144static inline BlockDriverState *bdrv_filter_or_cow_bs(BlockDriverState *bs)
145{
146 IO_CODE();
147 return child_bs(bdrv_filter_or_cow_child(bs));
148}
149
150static inline BlockDriverState *bdrv_primary_bs(BlockDriverState *bs)
151{
152 IO_CODE();
153 return child_bs(bdrv_primary_child(bs));
154}
155
156
157
158
159
160
161
162
163
164
165bool bdrv_bsc_is_data(BlockDriverState *bs, int64_t offset, int64_t *pnum);
166
167
168
169
170
171
172
173
174void bdrv_bsc_invalidate_range(BlockDriverState *bs,
175 int64_t offset, int64_t bytes);
176
177
178
179
180void bdrv_bsc_fill(BlockDriverState *bs, int64_t offset, int64_t bytes);
181
182
183
184
185
186
187
188
189
190
191void bdrv_apply_subtree_drain(BdrvChild *child, BlockDriverState *new_parent);
192void bdrv_unapply_subtree_drain(BdrvChild *child, BlockDriverState *old_parent);
193
194#endif
195