[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/32] block/file-posix: Do not force-cap *pnum
From: |
Hanna Reitz |
Subject: |
[PULL 05/32] block/file-posix: Do not force-cap *pnum |
Date: |
Wed, 15 Sep 2021 19:52:51 +0200 |
bdrv_co_block_status() does it for us, we do not need to do it here.
The advantage of not capping *pnum is that bdrv_co_block_status() can
cache larger data regions than requested by its caller.
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20210812084148.14458-5-hreitz@redhat.com>
---
block/file-posix.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/block/file-posix.c b/block/file-posix.c
index cb9bffe047..9f35e5631a 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -2744,7 +2744,8 @@ static int find_allocation(BlockDriverState *bs, off_t
start,
* the specified offset) that are known to be in the same
* allocated/unallocated state.
*
- * 'bytes' is the max value 'pnum' should be set to.
+ * 'bytes' is a soft cap for 'pnum'. If the information is free, 'pnum' may
+ * well exceed it.
*/
static int coroutine_fn raw_co_block_status(BlockDriverState *bs,
bool want_zero,
@@ -2782,7 +2783,7 @@ static int coroutine_fn
raw_co_block_status(BlockDriverState *bs,
} else if (data == offset) {
/* On a data extent, compute bytes to the end of the extent,
* possibly including a partial sector at EOF. */
- *pnum = MIN(bytes, hole - offset);
+ *pnum = hole - offset;
/*
* We are not allowed to return partial sectors, though, so
@@ -2801,7 +2802,7 @@ static int coroutine_fn
raw_co_block_status(BlockDriverState *bs,
} else {
/* On a hole, compute bytes to the beginning of the next extent. */
assert(hole == offset);
- *pnum = MIN(bytes, data - offset);
+ *pnum = data - offset;
ret = BDRV_BLOCK_ZERO;
}
*map = offset;
--
2.31.1
- [PULL 00/32] Block patches, Hanna Reitz, 2021/09/15
- [PULL 02/32] block: Drop BDS comment regarding bdrv_append(), Hanna Reitz, 2021/09/15
- [PULL 01/32] gluster: Align block-status tail, Hanna Reitz, 2021/09/15
- [PULL 04/32] block: Clarify that @bytes is no limit on *pnum, Hanna Reitz, 2021/09/15
- [PULL 05/32] block/file-posix: Do not force-cap *pnum,
Hanna Reitz <=
- [PULL 03/32] block: block-status cache for data regions, Hanna Reitz, 2021/09/15
- [PULL 06/32] block/gluster: Do not force-cap *pnum, Hanna Reitz, 2021/09/15
- [PULL 07/32] block/iscsi: Do not force-cap *pnum, Hanna Reitz, 2021/09/15
- [PULL 09/32] iotests: Fix use-{list,dict}-literal warnings, Hanna Reitz, 2021/09/15
- [PULL 13/32] mirror-top-perms: Fix AbnormalShutdown path, Hanna Reitz, 2021/09/15
- [PULL 08/32] iotests: Fix unspecified-encoding pylint warnings, Hanna Reitz, 2021/09/15
- [PULL 15/32] block/mirror: fix NULL pointer dereference in mirror_wait_on_conflicts(), Hanna Reitz, 2021/09/15
- [PULL 10/32] iotests/297: Drop 169 and 199 from the skip list, Hanna Reitz, 2021/09/15
- [PULL 14/32] iotests/297: Cover tests/, Hanna Reitz, 2021/09/15
- [PULL 17/32] block: bdrv_inactivate_recurse(): check for permissions and fix crash, Hanna Reitz, 2021/09/15