All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] zbd: avoid Coverity defect report
@ 2023-06-09 23:59 Shin'ichiro Kawasaki
  2023-06-10  0:05 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Shin'ichiro Kawasaki @ 2023-06-09 23:59 UTC (permalink / raw)
  To: fio, Vincent Fu
  Cc: Jens Axboe, Damien Le Moal, Dmitry Fomichev, Niklas Cassel,
	Shin'ichiro Kawasaki

Coverity reported a defect related to the local variable "in_flight":

    Using an unreliable value of "in_flight" inside the second locked
    section. If the data that "in_flight" depends on was changed by
    another thread, this use might be incorrect.

The variable "in_flight" is thread local and other threads can not
change its value. Then the report should be false-positive. Just to
suppress the report, change reference timing of the valuable.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
 zbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/zbd.c b/zbd.c
index 9455140a..7fcf1ec4 100644
--- a/zbd.c
+++ b/zbd.c
@@ -1547,11 +1547,11 @@ retry:
 		dprint(FD_ZBD,
 		       "%s(%s): wait zone write and retry write target zone selection\n",
 		       __func__, f->file_name);
+		should_retry = in_flight;
 		pthread_mutex_unlock(&zbdi->mutex);
 		zone_unlock(z);
 		io_u_quiesce(td);
 		zone_lock(td, f, z);
-		should_retry = in_flight;
 		goto retry;
 	}
 
-- 
2.40.1


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

* Re: [PATCH] zbd: avoid Coverity defect report
  2023-06-09 23:59 [PATCH] zbd: avoid Coverity defect report Shin'ichiro Kawasaki
@ 2023-06-10  0:05 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2023-06-10  0:05 UTC (permalink / raw)
  To: fio, Vincent Fu, Shin'ichiro Kawasaki
  Cc: Damien Le Moal, Dmitry Fomichev, Niklas Cassel


On Sat, 10 Jun 2023 08:59:14 +0900, Shin'ichiro Kawasaki wrote:
> Coverity reported a defect related to the local variable "in_flight":
> 
>     Using an unreliable value of "in_flight" inside the second locked
>     section. If the data that "in_flight" depends on was changed by
>     another thread, this use might be incorrect.
> 
> The variable "in_flight" is thread local and other threads can not
> change its value. Then the report should be false-positive. Just to
> suppress the report, change reference timing of the valuable.
> 
> [...]

Applied, thanks!

[1/1] zbd: avoid Coverity defect report
      commit: 62ac66490f5077e5fca1bd5b49165147cafc5a0d

Best regards,
-- 
Jens Axboe




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

end of thread, other threads:[~2023-06-10  0:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-09 23:59 [PATCH] zbd: avoid Coverity defect report Shin'ichiro Kawasaki
2023-06-10  0:05 ` 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.