Lines Matching refs:bs

83 static int preallocate_drop_resize(BlockDriverState *bs, Error **errp);
140 static int preallocate_open(BlockDriverState *bs, QDict *options, int flags, in preallocate_open() argument
143 BDRVPreallocateState *s = bs->opaque; in preallocate_open()
153 s->drop_resize_bh = qemu_bh_new(preallocate_drop_resize_bh, bs); in preallocate_open()
155 ret = bdrv_open_file_child(NULL, options, "file", bs, errp); in preallocate_open()
162 if (!preallocate_absorb_opts(&s->opts, options, bs->file->bs, errp)) { in preallocate_open()
166 bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED | in preallocate_open()
167 (BDRV_REQ_FUA & bs->file->bs->supported_write_flags); in preallocate_open()
169 bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED | in preallocate_open()
171 bs->file->bs->supported_zero_flags); in preallocate_open()
177 preallocate_truncate_to_real_size(BlockDriverState *bs, Error **errp) in preallocate_truncate_to_real_size() argument
179 BDRVPreallocateState *s = bs->opaque; in preallocate_truncate_to_real_size()
183 s->file_end = bdrv_getlength(bs->file->bs); in preallocate_truncate_to_real_size()
191 ret = bdrv_truncate(bs->file, s->data_end, true, PREALLOC_MODE_OFF, 0, in preallocate_truncate_to_real_size()
204 static void preallocate_close(BlockDriverState *bs) in preallocate_close() argument
206 BDRVPreallocateState *s = bs->opaque; in preallocate_close()
215 preallocate_truncate_to_real_size(bs, NULL); in preallocate_close()
238 reopen_state->bs->file->bs, errp)) { in preallocate_reopen_prepare()
249 ret = preallocate_drop_resize(reopen_state->bs, errp); in preallocate_reopen_prepare()
263 BDRVPreallocateState *s = state->bs->opaque; in preallocate_reopen_commit()
278 preallocate_co_preadv_part(BlockDriverState *bs, int64_t offset, int64_t bytes, in preallocate_co_preadv_part() argument
282 return bdrv_co_preadv_part(bs->file, offset, bytes, qiov, qiov_offset, in preallocate_co_preadv_part()
287 preallocate_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes) in preallocate_co_pdiscard() argument
289 return bdrv_co_pdiscard(bs->file, offset, bytes); in preallocate_co_pdiscard()
297 static bool GRAPH_RDLOCK has_prealloc_perms(BlockDriverState *bs) in has_prealloc_perms() argument
299 BDRVPreallocateState *s = bs->opaque; in has_prealloc_perms()
301 if (can_write_resize(bs->file->perm)) { in has_prealloc_perms()
302 assert(!(bs->file->shared_perm & BLK_PERM_WRITE)); in has_prealloc_perms()
303 assert(!(bs->file->shared_perm & BLK_PERM_RESIZE)); in has_prealloc_perms()
322 handle_write(BlockDriverState *bs, int64_t offset, int64_t bytes, in handle_write() argument
325 BDRVPreallocateState *s = bs->opaque; in handle_write()
329 uint32_t file_align = bs->file->bs->bl.request_alignment; in handle_write()
334 if (!has_prealloc_perms(bs)) { in handle_write()
340 s->data_end = bdrv_co_getlength(bs->file->bs); in handle_write()
362 s->file_end = bdrv_co_getlength(bs->file->bs); in handle_write()
387 bs->file, prealloc_start, prealloc_end - prealloc_start, in handle_write()
399 preallocate_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, in preallocate_co_pwrite_zeroes() argument
404 if (handle_write(bs, offset, bytes, want_merge_zero)) { in preallocate_co_pwrite_zeroes()
408 return bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags); in preallocate_co_pwrite_zeroes()
412 preallocate_co_pwritev_part(BlockDriverState *bs, int64_t offset, int64_t bytes, in preallocate_co_pwritev_part() argument
416 handle_write(bs, offset, bytes, false); in preallocate_co_pwritev_part()
418 return bdrv_co_pwritev_part(bs->file, offset, bytes, qiov, qiov_offset, in preallocate_co_pwritev_part()
423 preallocate_co_truncate(BlockDriverState *bs, int64_t offset, in preallocate_co_truncate() argument
428 BDRVPreallocateState *s = bs->opaque; in preallocate_co_truncate()
433 s->file_end = bdrv_co_getlength(bs->file->bs); in preallocate_co_truncate()
462 ret = bdrv_co_truncate(bs->file, s->data_end, true, in preallocate_co_truncate()
477 ret = bdrv_co_truncate(bs->file, offset, exact, prealloc, flags, errp); in preallocate_co_truncate()
483 if (has_prealloc_perms(bs)) { in preallocate_co_truncate()
489 static int coroutine_fn GRAPH_RDLOCK preallocate_co_flush(BlockDriverState *bs) in preallocate_co_flush() argument
491 return bdrv_co_flush(bs->file->bs); in preallocate_co_flush()
495 preallocate_co_getlength(BlockDriverState *bs) in preallocate_co_getlength() argument
498 BDRVPreallocateState *s = bs->opaque; in preallocate_co_getlength()
504 ret = bdrv_co_getlength(bs->file->bs); in preallocate_co_getlength()
506 if (has_prealloc_perms(bs)) { in preallocate_co_getlength()
514 preallocate_drop_resize(BlockDriverState *bs, Error **errp) in preallocate_drop_resize() argument
516 BDRVPreallocateState *s = bs->opaque; in preallocate_drop_resize()
527 ret = preallocate_truncate_to_real_size(bs, errp); in preallocate_drop_resize()
540 bdrv_child_refresh_perms(bs, bs->file, NULL); in preallocate_drop_resize()
558 preallocate_set_perm(BlockDriverState *bs, uint64_t perm, uint64_t shared) in preallocate_set_perm() argument
560 BDRVPreallocateState *s = bs->opaque; in preallocate_set_perm()
566 bs->file->bs->total_sectors * BDRV_SECTOR_SIZE; in preallocate_set_perm()
573 static void preallocate_child_perm(BlockDriverState *bs, BdrvChild *c, in preallocate_child_perm() argument
577 BDRVPreallocateState *s = bs->opaque; in preallocate_child_perm()
579 bdrv_default_perms(bs, c, role, reopen_queue, perm, shared, nperm, nshared); in preallocate_child_perm()