Re: [PATCH v2 0/7] zbd: clean up code and fix bugs for open zones accounting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[...]
> 
> Vincent gets these too, but pasting it here for Shin'ichiro:
> 
> Please find the latest report on new defect(s) introduced to axboe/fio found with Coverity Scan.
> 
> 1 new defect(s) introduced to axboe/fio found with Coverity Scan.
> 1 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.
> 
> New defect(s) Reported-by: Coverity Scan
> Showing 1 of 1 defect(s)
> 
> 
> ** CID 462265:    (ATOMICITY)
> /zbd.c: 1554 in zbd_convert_to_write_zone()
> /zbd.c: 1554 in zbd_convert_to_write_zone()
> 
> 
> ________________________________________________________________________________________________________
> *** CID 462265:    (ATOMICITY)
> /zbd.c: 1554 in zbd_convert_to_write_zone()
> 1548     		       "%s(%s): wait zone write and retry write target zone selection\n",
> 1549     		       __func__, f->file_name);
> 1550     		pthread_mutex_unlock(&zbdi->mutex);
> 1551     		zone_unlock(z);
> 1552     		io_u_quiesce(td);
> 1553     		zone_lock(td, f, z);
> >>>     CID 462265:    (ATOMICITY)
> >>>     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.
> 1554     		should_retry = in_flight;
> 1555     		goto retry;
> 1556     	}
> 1557     
> 1558     	pthread_mutex_unlock(&zbdi->mutex);
> 1559     
> /zbd.c: 1554 in zbd_convert_to_write_zone()
> 1548     		       "%s(%s): wait zone write and retry write target zone selection\n",
> 1549     		       __func__, f->file_name);
> 1550     		pthread_mutex_unlock(&zbdi->mutex);
> 1551     		zone_unlock(z);
> 1552     		io_u_quiesce(td);
> 1553     		zone_lock(td, f, z);
> >>>     CID 462265:    (ATOMICITY)
> >>>     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.
> 1554     		should_retry = in_flight;
> 1555     		goto retry;
> 1556     	}
> 1557     
> 1558     	pthread_mutex_unlock(&zbdi->mutex);
> 1559     

Thanks for the notice. I think the defect report is false-positive. The
variable in_flight is on the stack and thread local, so no other thread
can change it across the zone_unlock() and zone_lock().

I guess and hope the following patch will suppress the report. May I ask Vincent
or Jens to confirm it? If its formal patch helps, please let me know.

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;
 	}
 




[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux