block.c (1a30b0f5d76f842576de2ab9a29ab9e8a7c9eb09) block.c (de335638a399b614d510b978b5c6d1b237e0ac79)
1/*
2 * QEMU System Emulator block driver
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 * Copyright (c) 2020 Virtuozzo International GmbH.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal

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

5745 return ret;
5746}
5747
5748/**
5749 * Implementation of BlockDriver.bdrv_co_get_allocated_file_size() that
5750 * sums the size of all data-bearing children. (This excludes backing
5751 * children.)
5752 */
1/*
2 * QEMU System Emulator block driver
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 * Copyright (c) 2020 Virtuozzo International GmbH.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal

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

5745 return ret;
5746}
5747
5748/**
5749 * Implementation of BlockDriver.bdrv_co_get_allocated_file_size() that
5750 * sums the size of all data-bearing children. (This excludes backing
5751 * children.)
5752 */
5753static int64_t coroutine_fn bdrv_sum_allocated_file_size(BlockDriverState *bs)
5753static int64_t coroutine_fn GRAPH_RDLOCK
5754bdrv_sum_allocated_file_size(BlockDriverState *bs)
5754{
5755 BdrvChild *child;
5756 int64_t child_size, sum = 0;
5757
5758 QLIST_FOREACH(child, &bs->children, next) {
5759 if (child->role & (BDRV_CHILD_DATA | BDRV_CHILD_METADATA |
5760 BDRV_CHILD_FILTERED))
5761 {

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

5773/**
5774 * Length of a allocated file in bytes. Sparse files are counted by actual
5775 * allocated space. Return < 0 if error or unknown.
5776 */
5777int64_t coroutine_fn bdrv_co_get_allocated_file_size(BlockDriverState *bs)
5778{
5779 BlockDriver *drv = bs->drv;
5780 IO_CODE();
5755{
5756 BdrvChild *child;
5757 int64_t child_size, sum = 0;
5758
5759 QLIST_FOREACH(child, &bs->children, next) {
5760 if (child->role & (BDRV_CHILD_DATA | BDRV_CHILD_METADATA |
5761 BDRV_CHILD_FILTERED))
5762 {

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

5774/**
5775 * Length of a allocated file in bytes. Sparse files are counted by actual
5776 * allocated space. Return < 0 if error or unknown.
5777 */
5778int64_t coroutine_fn bdrv_co_get_allocated_file_size(BlockDriverState *bs)
5779{
5780 BlockDriver *drv = bs->drv;
5781 IO_CODE();
5782 assert_bdrv_graph_readable();
5781
5782 if (!drv) {
5783 return -ENOMEDIUM;
5784 }
5785 if (drv->bdrv_co_get_allocated_file_size) {
5786 return drv->bdrv_co_get_allocated_file_size(bs);
5787 }
5788

--- 2476 unchanged lines hidden ---
5783
5784 if (!drv) {
5785 return -ENOMEDIUM;
5786 }
5787 if (drv->bdrv_co_get_allocated_file_size) {
5788 return drv->bdrv_co_get_allocated_file_size(bs);
5789 }
5790

--- 2476 unchanged lines hidden ---