Hi Hanna, Hanna Czenczek <hre...@redhat.com> 于2023年8月24日周四 23:53写道: > > Hi, > > As presented in [1] there is a bug in the zone code in raw_co_prw(), > specifically we don’t check whether there actually is zone information > before running code that assumes there is (and thus we run into a > division by zero). This has now also been reported in [2].
Thanks for catching the bugs and your work. > > I believe the solution [1] is incomplete, though, which is why I’m > sending this separate series: I don’t think checking bs->wps and/or > bs->bl.zone_size to determine whether there is zone information is > right; for example, we do not have raw_refresh_zoned_limits() clear > those values if on a refresh, zone information were to disappear. > > It is also weird that we separate checking bs->wps and bs->bl.zone_size > at all; raw_refresh_zoned_limits() seems to intend to ensure that either > we have information with non-NULL bs->wps and non-zero bs->bl.zone_size, > or we don’t. > > I think we should have a single flag that tells whether we have valid > information or not, and it looks to me like bs->bl.zoned != BLK_Z_NONE > is the condition that fits best. The former way only checks zone information when it is being used to avoid divide-by-zero or nullptr errors. Putting the error path with non-zoned model implies a zoned device must have non-zero zone size and allocated write pointers. Given that no other parts are changing the zone_size to 0 and free wps, It does simplify the code path. Thanks, Sam