Revision 3d1807ac
b/block/raw-posix.c | ||
---|---|---|
133 | 133 |
int use_aio; |
134 | 134 |
void *aio_ctx; |
135 | 135 |
#endif |
136 |
uint8_t *aligned_buf; |
|
137 |
unsigned aligned_buf_size; |
|
138 | 136 |
#ifdef CONFIG_XFS |
139 | 137 |
bool is_xfs : 1; |
140 | 138 |
#endif |
... | ... | |
259 | 257 |
return ret; |
260 | 258 |
} |
261 | 259 |
s->fd = fd; |
262 |
s->aligned_buf = NULL; |
|
263 |
|
|
264 |
if ((bdrv_flags & BDRV_O_NOCACHE)) { |
|
265 |
/* |
|
266 |
* Allocate a buffer for read/modify/write cycles. Chose the size |
|
267 |
* pessimistically as we don't know the block size yet. |
|
268 |
*/ |
|
269 |
s->aligned_buf_size = 32 * MAX_BLOCKSIZE; |
|
270 |
s->aligned_buf = qemu_memalign(MAX_BLOCKSIZE, s->aligned_buf_size); |
|
271 |
if (s->aligned_buf == NULL) { |
|
272 |
goto out_close; |
|
273 |
} |
|
274 |
} |
|
275 | 260 |
|
276 | 261 |
/* We're falling back to POSIX AIO in some cases so init always */ |
277 | 262 |
if (paio_init() < 0) { |
278 |
goto out_free_buf;
|
|
263 |
goto out_close;
|
|
279 | 264 |
} |
280 | 265 |
|
281 | 266 |
#ifdef CONFIG_LINUX_AIO |
... | ... | |
292 | 277 |
|
293 | 278 |
return 0; |
294 | 279 |
|
295 |
out_free_buf: |
|
296 |
qemu_vfree(s->aligned_buf); |
|
297 | 280 |
out_close: |
298 | 281 |
qemu_close(fd); |
299 | 282 |
return -errno; |
... | ... | |
402 | 385 |
if (s->fd >= 0) { |
403 | 386 |
qemu_close(s->fd); |
404 | 387 |
s->fd = -1; |
405 |
if (s->aligned_buf != NULL) |
|
406 |
qemu_vfree(s->aligned_buf); |
|
407 | 388 |
} |
408 | 389 |
} |
409 | 390 |
|
Also available in: Unified diff