summaryrefslogtreecommitdiff
path: root/zbd.c
diff options
context:
space:
mode:
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>2021-10-13 15:09:00 +0900
committerJens Axboe <axboe@kernel.dk>2021-10-17 07:00:36 -0600
commit07fc3f57d106e58e0bcfff1a46ec8b4266770388 (patch)
tree4f7c2f70334f6489ef3c2e2aa07a5e9d094cae2c /zbd.c
parentee5e3436012aad0d2a06c7638dad39f01ee44c1e (diff)
downloadfio-07fc3f57d106e58e0bcfff1a46ec8b4266770388.tar.gz
fio-07fc3f57d106e58e0bcfff1a46ec8b4266770388.tar.bz2
zbd: Fix type of local variable min_bs
In zbd.c, thread option min_bs[] is referred and stored in the local variable min_bs. Elements of min_bs[] have type unsigned long long, but the local variable min_bs has type uint32_t. When an element of min_bs[] has value larger than UINT32_MAX, it overflows on assignment to min_bs. To avoid the overflow, fix type of the local variable min_bs from uint32_t to uint64_t. Use uint64_t rather than unsigned long long to be more specific about data size and consistency in zbd.c. The variable is passed to the helper function zbd_find_zone(), then fix the type of the argument of the function also. Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com> Reviewed-by: Niklas Cassel <niklas.cassel@wdc.com> Link: https://lore.kernel.org/r/20211013060903.166543-3-shinichiro.kawasaki@wdc.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'zbd.c')
-rw-r--r--zbd.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/zbd.c b/zbd.c
index f175d490..c18998c4 100644
--- a/zbd.c
+++ b/zbd.c
@@ -968,7 +968,7 @@ static int zbd_reset_zones(struct thread_data *td, struct fio_file *f,
struct fio_zone_info *const ze)
{
struct fio_zone_info *z;
- const uint32_t min_bs = td->o.min_bs[DDIR_WRITE];
+ const uint64_t min_bs = td->o.min_bs[DDIR_WRITE];
int res = 0;
assert(min_bs);
@@ -1141,7 +1141,7 @@ static bool is_zone_open(const struct thread_data *td, const struct fio_file *f,
static bool zbd_open_zone(struct thread_data *td, const struct fio_file *f,
uint32_t zone_idx)
{
- const uint32_t min_bs = td->o.min_bs[DDIR_WRITE];
+ const uint64_t min_bs = td->o.min_bs[DDIR_WRITE];
struct zoned_block_device_info *zbdi = f->zbd_info;
struct fio_zone_info *z = get_zone(f, zone_idx);
bool res = true;
@@ -1224,7 +1224,7 @@ static bool any_io_in_flight(void)
static struct fio_zone_info *zbd_convert_to_open_zone(struct thread_data *td,
struct io_u *io_u)
{
- const uint32_t min_bs = td->o.min_bs[io_u->ddir];
+ const uint64_t min_bs = td->o.min_bs[io_u->ddir];
struct fio_file *f = io_u->file;
struct zoned_block_device_info *zbdi = f->zbd_info;
struct fio_zone_info *z;
@@ -1427,7 +1427,7 @@ static struct fio_zone_info *zbd_replay_write_order(struct thread_data *td,
struct fio_zone_info *z)
{
const struct fio_file *f = io_u->file;
- const uint32_t min_bs = td->o.min_bs[DDIR_WRITE];
+ const uint64_t min_bs = td->o.min_bs[DDIR_WRITE];
if (!zbd_open_zone(td, f, zbd_zone_nr(f, z))) {
zone_unlock(z);
@@ -1436,7 +1436,7 @@ static struct fio_zone_info *zbd_replay_write_order(struct thread_data *td,
}
if (z->verify_block * min_bs >= z->capacity) {
- log_err("%s: %d * %d >= %"PRIu64"\n", f->file_name, z->verify_block,
+ log_err("%s: %d * %"PRIu64" >= %"PRIu64"\n", f->file_name, z->verify_block,
min_bs, z->capacity);
/*
* If the assertion below fails during a test run, adding
@@ -1463,7 +1463,7 @@ static struct fio_zone_info *zbd_replay_write_order(struct thread_data *td,
* pointer, hold the mutex for the zone.
*/
static struct fio_zone_info *
-zbd_find_zone(struct thread_data *td, struct io_u *io_u, uint32_t min_bytes,
+zbd_find_zone(struct thread_data *td, struct io_u *io_u, uint64_t min_bytes,
struct fio_zone_info *zb, struct fio_zone_info *zl)
{
struct fio_file *f = io_u->file;
@@ -1495,7 +1495,7 @@ zbd_find_zone(struct thread_data *td, struct io_u *io_u, uint32_t min_bytes,
zone_unlock(z2);
}
}
- dprint(FD_ZBD, "%s: no zone has %d bytes of readable data\n",
+ dprint(FD_ZBD, "%s: no zone has %"PRIu64" bytes of readable data\n",
f->file_name, min_bytes);
return NULL;
}
@@ -1754,7 +1754,7 @@ enum io_u_action zbd_adjust_block(struct thread_data *td, struct io_u *io_u)
uint32_t zone_idx_b;
struct fio_zone_info *zb, *zl, *orig_zb;
uint32_t orig_len = io_u->buflen;
- uint32_t min_bs = td->o.min_bs[io_u->ddir];
+ uint64_t min_bs = td->o.min_bs[io_u->ddir];
uint64_t new_len;
int64_t range;
@@ -1780,7 +1780,7 @@ enum io_u_action zbd_adjust_block(struct thread_data *td, struct io_u *io_u)
if (io_u->offset + min_bs > (zb + 1)->start) {
dprint(FD_IO,
- "%s: off=%llu + min_bs=%u > next zone %"PRIu64"\n",
+ "%s: off=%llu + min_bs=%"PRIu64" > next zone %"PRIu64"\n",
f->file_name, io_u->offset,
min_bs, (zb + 1)->start);
io_u->offset = zb->start + (zb + 1)->start - io_u->offset;
@@ -1911,7 +1911,7 @@ enum io_u_action zbd_adjust_block(struct thread_data *td, struct io_u *io_u)
if (zb->capacity < min_bs) {
td_verror(td, EINVAL, "ZCAP is less min_bs");
- log_err("zone capacity %"PRIu64" smaller than minimum block size %d\n",
+ log_err("zone capacity %"PRIu64" smaller than minimum block size %"PRIu64"\n",
zb->capacity, min_bs);
goto eof;
}
@@ -1942,7 +1942,7 @@ enum io_u_action zbd_adjust_block(struct thread_data *td, struct io_u *io_u)
goto accept;
}
td_verror(td, EIO, "zone remainder too small");
- log_err("zone remainder %lld smaller than min block size %d\n",
+ log_err("zone remainder %lld smaller than min block size %"PRIu64"\n",
(zbd_zone_capacity_end(zb) - io_u->offset), min_bs);
goto eof;
case DDIR_TRIM: