All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] zbd: use ->min_zone, ->max_zone in more places
@ 2020-08-13 16:36 Alexey Dobriyan
  2020-08-13 22:00 ` Dmitry Fomichev
  2020-08-13 22:06 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Alexey Dobriyan @ 2020-08-13 16:36 UTC (permalink / raw)
  To: axboe; +Cc: fio, damien.lemoal

Check that ->min_zone is less than ->max_zone.
This assert found one bug here.

Use it in more places, now that it was added.

Signed-off-by: Alexey Dobriyan (SK hynix) <adobriyan@gmail.com>
---

 zbd.c |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

--- a/zbd.c
+++ b/zbd.c
@@ -319,6 +319,7 @@ static bool zbd_verify_sizes(void)
 
 			f->min_zone = zbd_zone_idx(f, f->file_offset);
 			f->max_zone = zbd_zone_idx(f, f->file_offset + f->io_size);
+			assert(f->min_zone < f->max_zone);
 		}
 	}
 
@@ -839,9 +840,8 @@ static uint64_t zbd_process_swd(const struct fio_file *f, enum swd_action a)
 	struct fio_zone_info *zb, *ze, *z;
 	uint64_t swd = 0;
 
-	zb = &f->zbd_info->zone_info[zbd_zone_idx(f, f->file_offset)];
-	ze = &f->zbd_info->zone_info[zbd_zone_idx(f, f->file_offset +
-						  f->io_size)];
+	zb = &f->zbd_info->zone_info[f->min_zone];
+	ze = &f->zbd_info->zone_info[f->max_zone];
 	for (z = zb; z < ze; z++) {
 		pthread_mutex_lock(&z->mutex);
 		swd += z->wp - z->start;
@@ -1175,7 +1175,7 @@ zbd_find_zone(struct thread_data *td, struct io_u *io_u,
 	struct fio_file *f = io_u->file;
 	struct fio_zone_info *z1, *z2;
 	const struct fio_zone_info *const zf =
-		&f->zbd_info->zone_info[zbd_zone_idx(f, f->file_offset)];
+		&f->zbd_info->zone_info[f->min_zone];
 
 	/*
 	 * Skip to the next non-empty zone in case of sequential I/O and to
@@ -1482,8 +1482,7 @@ enum io_u_action zbd_adjust_block(struct thread_data *td, struct io_u *io_u)
 		if (range < min_bs ||
 		    ((!td_random(td)) && (io_u->offset + min_bs > zb->wp))) {
 			pthread_mutex_unlock(&zb->mutex);
-			zl = &f->zbd_info->zone_info[zbd_zone_idx(f,
-						f->file_offset + f->io_size)];
+			zl = &f->zbd_info->zone_info[f->max_zone];
 			zb = zbd_find_zone(td, io_u, zb, zl);
 			if (!zb) {
 				dprint(FD_ZBD,


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] zbd: use ->min_zone, ->max_zone in more places
  2020-08-13 16:36 [PATCH] zbd: use ->min_zone, ->max_zone in more places Alexey Dobriyan
@ 2020-08-13 22:00 ` Dmitry Fomichev
  2020-08-13 22:06 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Fomichev @ 2020-08-13 22:00 UTC (permalink / raw)
  To: Alexey Dobriyan, axboe; +Cc: fio, Damien Le Moal


> -----Original Message-----
> From: fio-owner@vger.kernel.org <fio-owner@vger.kernel.org> On Behalf
> Of Alexey Dobriyan
> Sent: Thursday, August 13, 2020 12:37 PM
> To: axboe@kernel.dk
> Cc: fio@vger.kernel.org; Damien Le Moal <Damien.LeMoal@wdc.com>
> Subject: [PATCH] zbd: use ->min_zone, ->max_zone in more places
> 
> Check that ->min_zone is less than ->max_zone.
> This assert found one bug here.
> 
> Use it in more places, now that it was added.
> 
> Signed-off-by: Alexey Dobriyan (SK hynix) <adobriyan@gmail.com>
> ---

Works fine for me. Nice cleanup!

Reviewed-by: Dmitry Fomichev <dmitry.fomichev@wdc.com>

> 
>  zbd.c |   11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> --- a/zbd.c
> +++ b/zbd.c
> @@ -319,6 +319,7 @@ static bool zbd_verify_sizes(void)
> 
>  			f->min_zone = zbd_zone_idx(f, f->file_offset);
>  			f->max_zone = zbd_zone_idx(f, f->file_offset + f-
> >io_size);
> +			assert(f->min_zone < f->max_zone);
>  		}
>  	}
> 
> @@ -839,9 +840,8 @@ static uint64_t zbd_process_swd(const struct fio_file
> *f, enum swd_action a)
>  	struct fio_zone_info *zb, *ze, *z;
>  	uint64_t swd = 0;
> 
> -	zb = &f->zbd_info->zone_info[zbd_zone_idx(f, f->file_offset)];
> -	ze = &f->zbd_info->zone_info[zbd_zone_idx(f, f->file_offset +
> -						  f->io_size)];
> +	zb = &f->zbd_info->zone_info[f->min_zone];
> +	ze = &f->zbd_info->zone_info[f->max_zone];
>  	for (z = zb; z < ze; z++) {
>  		pthread_mutex_lock(&z->mutex);
>  		swd += z->wp - z->start;
> @@ -1175,7 +1175,7 @@ zbd_find_zone(struct thread_data *td, struct io_u
> *io_u,
>  	struct fio_file *f = io_u->file;
>  	struct fio_zone_info *z1, *z2;
>  	const struct fio_zone_info *const zf =
> -		&f->zbd_info->zone_info[zbd_zone_idx(f, f->file_offset)];
> +		&f->zbd_info->zone_info[f->min_zone];
> 
>  	/*
>  	 * Skip to the next non-empty zone in case of sequential I/O and to
> @@ -1482,8 +1482,7 @@ enum io_u_action zbd_adjust_block(struct
> thread_data *td, struct io_u *io_u)
>  		if (range < min_bs ||
>  		    ((!td_random(td)) && (io_u->offset + min_bs > zb->wp))) {
>  			pthread_mutex_unlock(&zb->mutex);
> -			zl = &f->zbd_info->zone_info[zbd_zone_idx(f,
> -						f->file_offset + f->io_size)];
> +			zl = &f->zbd_info->zone_info[f->max_zone];
>  			zb = zbd_find_zone(td, io_u, zb, zl);
>  			if (!zb) {
>  				dprint(FD_ZBD,

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] zbd: use ->min_zone, ->max_zone in more places
  2020-08-13 16:36 [PATCH] zbd: use ->min_zone, ->max_zone in more places Alexey Dobriyan
  2020-08-13 22:00 ` Dmitry Fomichev
@ 2020-08-13 22:06 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2020-08-13 22:06 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: fio, damien.lemoal

On 8/13/20 10:36 AM, Alexey Dobriyan wrote:
> Check that ->min_zone is less than ->max_zone.
> This assert found one bug here.
> 
> Use it in more places, now that it was added.

Applied, thanks.

-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-13 22:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-13 16:36 [PATCH] zbd: use ->min_zone, ->max_zone in more places Alexey Dobriyan
2020-08-13 22:00 ` Dmitry Fomichev
2020-08-13 22:06 ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.