Skip to content

Commit 06f0325

Browse files
Vladimir Sementsov-Ogievskiyebblake
authored andcommitted
block-backend: convert blk_foo wrappers to use int64_t bytes parameter
Convert blk_pdiscard, blk_pwrite_compressed, blk_pwrite_zeroes. These are just wrappers for functions with int64_t argument, so allow passing int64_t as well. Parameter type becomes wider so all callers should be OK with it. Note that requests exceeding INT_MAX are still restricted by blk_check_byte_request(). Note also that we don't (and are not going to) convert blk_pwrite and blk_pread: these functions return number of bytes on success, so to update them, we should change return type to int64_t as well, which will lead to investigating and updating all callers which is too much. So, blk_pread and blk_pwrite remain unchanged. Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]> Message-Id: <[email protected]> Reviewed-by: Eric Blake <[email protected]> [eblake: grammar tweaks] Signed-off-by: Eric Blake <[email protected]>
1 parent 16d36e2 commit 06f0325

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

block/block-backend.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,7 @@ typedef struct BlkRwCo {
13301330
} BlkRwCo;
13311331

13321332
int blk_pwrite_zeroes(BlockBackend *blk, int64_t offset,
1333-
int bytes, BdrvRequestFlags flags)
1333+
int64_t bytes, BdrvRequestFlags flags)
13341334
{
13351335
return blk_pwritev_part(blk, offset, bytes, NULL, 0,
13361336
flags | BDRV_REQ_ZERO_WRITE);
@@ -1637,7 +1637,7 @@ int coroutine_fn blk_co_pdiscard(BlockBackend *blk, int64_t offset,
16371637
return ret;
16381638
}
16391639

1640-
int blk_pdiscard(BlockBackend *blk, int64_t offset, int bytes)
1640+
int blk_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes)
16411641
{
16421642
int ret;
16431643

@@ -2186,10 +2186,10 @@ int coroutine_fn blk_co_pwrite_zeroes(BlockBackend *blk, int64_t offset,
21862186
}
21872187

21882188
int blk_pwrite_compressed(BlockBackend *blk, int64_t offset, const void *buf,
2189-
int count)
2189+
int64_t bytes)
21902190
{
2191-
QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, count);
2192-
return blk_pwritev_part(blk, offset, count, &qiov, 0,
2191+
QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, bytes);
2192+
return blk_pwritev_part(blk, offset, bytes, &qiov, 0,
21932193
BDRV_REQ_WRITE_COMPRESSED);
21942194
}
21952195

include/sysemu/block-backend.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static inline int coroutine_fn blk_co_pwrite(BlockBackend *blk, int64_t offset,
155155
}
156156

157157
int blk_pwrite_zeroes(BlockBackend *blk, int64_t offset,
158-
int bytes, BdrvRequestFlags flags);
158+
int64_t bytes, BdrvRequestFlags flags);
159159
BlockAIOCB *blk_aio_pwrite_zeroes(BlockBackend *blk, int64_t offset,
160160
int bytes, BdrvRequestFlags flags,
161161
BlockCompletionFunc *cb, void *opaque);
@@ -246,10 +246,10 @@ void *blk_aio_get(const AIOCBInfo *aiocb_info, BlockBackend *blk,
246246
int coroutine_fn blk_co_pwrite_zeroes(BlockBackend *blk, int64_t offset,
247247
int64_t bytes, BdrvRequestFlags flags);
248248
int blk_pwrite_compressed(BlockBackend *blk, int64_t offset, const void *buf,
249-
int bytes);
249+
int64_t bytes);
250250
int blk_truncate(BlockBackend *blk, int64_t offset, bool exact,
251251
PreallocMode prealloc, BdrvRequestFlags flags, Error **errp);
252-
int blk_pdiscard(BlockBackend *blk, int64_t offset, int bytes);
252+
int blk_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes);
253253
int blk_save_vmstate(BlockBackend *blk, const uint8_t *buf,
254254
int64_t pos, int size);
255255
int blk_load_vmstate(BlockBackend *blk, uint8_t *buf, int64_t pos, int size);

0 commit comments

Comments
 (0)