zonefs: Fix management of open zones
authorDamien Le Moal <damien.lemoal@opensource.wdc.com>
Tue, 12 Apr 2022 08:41:37 +0000 (17:41 +0900)
committerDamien Le Moal <damien.lemoal@opensource.wdc.com>
Wed, 20 Apr 2022 23:39:20 +0000 (08:39 +0900)
commit1da18a296f5ba4f99429e62a7cf4fdbefa598902
tree510ac1b4156e62453275655bfb3a657b28c31605
parent694852ead287a3433126e7ebda397b242dc99624
zonefs: Fix management of open zones

The mount option "explicit_open" manages the device open zone
resources to ensure that if an application opens a sequential file for
writing, the file zone can always be written by explicitly opening
the zone and accounting for that state with the s_open_zones counter.

However, if some zones are already open when mounting, the device open
zone resource usage status will be larger than the initial s_open_zones
value of 0. Ensure that this inconsistency does not happen by closing
any sequential zone that is open when mounting.

Furthermore, with ZNS drives, closing an explicitly open zone that has
not been written will change the zone state to "closed", that is, the
zone will remain in an active state. Since this can then cause failures
of explicit open operations on other zones if the drive active zone
resources are exceeded, we need to make sure that the zone is not
active anymore by resetting it instead of closing it. To address this,
zonefs_zone_mgmt() is modified to change a REQ_OP_ZONE_CLOSE request
into a REQ_OP_ZONE_RESET for sequential zones that have not been
written.

Fixes: b5c00e975779 ("zonefs: open/close zone on file open/close")
Cc: <stable@vger.kernel.org>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Hans Holmberg <hans.holmberg@wdc.com>
fs/zonefs/super.c