preallocate.c (fcb7e040f5c69ca1f0678f991ab5354488a9e192) preallocate.c (c86422c5549c0983b4b4525b8f56a1c69dd67aa1)
1/*
2 * preallocate filter driver
3 *
4 * The driver performs preallocate operation: it is injected above
5 * some node, and before each write over EOF it does additional preallocating
6 * write-zeroes request.
7 *
8 * Copyright (c) 2020 Virtuozzo International GmbH.

--- 428 unchanged lines hidden (view full) ---

437 return 0;
438}
439
440static int coroutine_fn preallocate_co_flush(BlockDriverState *bs)
441{
442 return bdrv_co_flush(bs->file->bs);
443}
444
1/*
2 * preallocate filter driver
3 *
4 * The driver performs preallocate operation: it is injected above
5 * some node, and before each write over EOF it does additional preallocating
6 * write-zeroes request.
7 *
8 * Copyright (c) 2020 Virtuozzo International GmbH.

--- 428 unchanged lines hidden (view full) ---

437 return 0;
438}
439
440static int coroutine_fn preallocate_co_flush(BlockDriverState *bs)
441{
442 return bdrv_co_flush(bs->file->bs);
443}
444
445static int64_t preallocate_getlength(BlockDriverState *bs)
445static int64_t coroutine_fn preallocate_co_getlength(BlockDriverState *bs)
446{
447 int64_t ret;
448 BDRVPreallocateState *s = bs->opaque;
449
450 if (s->data_end >= 0) {
451 return s->data_end;
452 }
453
446{
447 int64_t ret;
448 BDRVPreallocateState *s = bs->opaque;
449
450 if (s->data_end >= 0) {
451 return s->data_end;
452 }
453
454 ret = bdrv_getlength(bs->file->bs);
454 ret = bdrv_co_getlength(bs->file->bs);
455
456 if (has_prealloc_perms(bs)) {
457 s->file_end = s->zero_start = s->data_end = ret;
458 }
459
460 return ret;
461}
462

--- 69 unchanged lines hidden (view full) ---

532 *nshared &= ~(BLK_PERM_WRITE | BLK_PERM_RESIZE);
533 }
534}
535
536BlockDriver bdrv_preallocate_filter = {
537 .format_name = "preallocate",
538 .instance_size = sizeof(BDRVPreallocateState),
539
455
456 if (has_prealloc_perms(bs)) {
457 s->file_end = s->zero_start = s->data_end = ret;
458 }
459
460 return ret;
461}
462

--- 69 unchanged lines hidden (view full) ---

532 *nshared &= ~(BLK_PERM_WRITE | BLK_PERM_RESIZE);
533 }
534}
535
536BlockDriver bdrv_preallocate_filter = {
537 .format_name = "preallocate",
538 .instance_size = sizeof(BDRVPreallocateState),
539
540 .bdrv_getlength = preallocate_getlength,
541 .bdrv_open = preallocate_open,
542 .bdrv_close = preallocate_close,
540 .bdrv_co_getlength = preallocate_co_getlength,
541 .bdrv_open = preallocate_open,
542 .bdrv_close = preallocate_close,
543
544 .bdrv_reopen_prepare = preallocate_reopen_prepare,
545 .bdrv_reopen_commit = preallocate_reopen_commit,
546 .bdrv_reopen_abort = preallocate_reopen_abort,
547
548 .bdrv_co_preadv_part = preallocate_co_preadv_part,
549 .bdrv_co_pwritev_part = preallocate_co_pwritev_part,
550 .bdrv_co_pwrite_zeroes = preallocate_co_pwrite_zeroes,

--- 18 unchanged lines hidden ---
543
544 .bdrv_reopen_prepare = preallocate_reopen_prepare,
545 .bdrv_reopen_commit = preallocate_reopen_commit,
546 .bdrv_reopen_abort = preallocate_reopen_abort,
547
548 .bdrv_co_preadv_part = preallocate_co_preadv_part,
549 .bdrv_co_pwritev_part = preallocate_co_pwritev_part,
550 .bdrv_co_pwrite_zeroes = preallocate_co_pwrite_zeroes,

--- 18 unchanged lines hidden ---