zbd: fixup ->zone_size_log2 if zone size is not power of 2
PATCH 1/1 zbd: fixup ->zone_size_log2 if zone size is not power of 2
Code like this doesn't work if log2 is 0xffffffff.
if (f->zbd_info->zone_size_log2 > 0)
zone_idx = offset >> f->zbd_info->zone_size_log2;
else
zone_idx = offset / f->zbd_info->zone_size;Other than that everything else works!
Signed-off-by Alexey Dobriyan (SK hynix) <[email protected]>
---
zbd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
zbd.c +2 -2
@@ -393,7 +393,7 @@ static int init_zone_info(struct thread_data *td, struct fio_file *f) f->zbd_info = zbd_info; f->zbd_info->zone_size = zone_size; f->zbd_info->zone_size_log2 =is_power_of_2 (zone_size) ? -ilog2 (zone_size) :-1 ; +ilog2 (zone_size) :0 ; f->zbd_info->nr_zones = nr_zones;pthread_mutexattr_destroy (&attr);return 0 ;
@@ -510,7 +510,7 @@ static int parse_zone_info(struct thread_data *td, struct fio_file *f) f->zbd_info = zbd_info; f->zbd_info->zone_size = zone_size; f->zbd_info->zone_size_log2 =is_power_of_2 (zone_size) ? -ilog2 (zone_size) :-1 ; +ilog2 (zone_size) :0 ; f->zbd_info->nr_zones = nr_zones; zbd_info =NULL ; ret =0 ;
Quoted 10 lines · Alexey Dobriyan
Code like this doesn't work if log2 is
0xffffffff.if (f->zbd_info->zone_size_log2 > 0) zone_idx = offset >> f->zbd_info->zone_size_log2; else zone_idx = offset / f->zbd_info->zone_size;Other than that everything else works!
Signed-off-by Alexey Dobriyan (SK hynix) <[email protected]>
Looks good.
Reviewed-by Damien Le Moal <[email protected]>
Quoted 26 lines
---
zbd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)zbd.c +2
-2@@ -393,7 +393,7 @@ static int init_zone_info(struct thread_data *td, struct fio_file *f) f->zbd_info = zbd_info; f->zbd_info->zone_size = zone_size; f->zbd_info->zone_size_log2 =is_power_of_2 (zone_size) ? -ilog2 (zone_size) :-1 ; +ilog2 (zone_size) :0 ; f->zbd_info->nr_zones = nr_zones;pthread_mutexattr_destroy (&attr);return 0 ;@@ -510,7 +510,7 @@ static int parse_zone_info(struct thread_data *td, struct fio_file *f) f->zbd_info = zbd_info; f->zbd_info->zone_size = zone_size; f->zbd_info->zone_size_log2 =is_power_of_2 (zone_size) ? -ilog2 (zone_size) :-1 ; +ilog2 (zone_size) :0 ; f->zbd_info->nr_zones = nr_zones; zbd_info =NULL ; ret =0 ;
Signature · 2 lines
Damien Le Moal Western Digital Research
Jens Axboe
AppliedQuoted 8 lines · Alexey Dobriyan
Code like this doesn't work if log2 is
0xffffffff.if (f->zbd_info->zone_size_log2 > 0) zone_idx = offset >> f->zbd_info->zone_size_log2; else zone_idx = offset / f->zbd_info->zone_size;Other than that everything else works!
Applied, thanks.
Signature · 1 line
Jens Axboe