OSDN Git Service

zonefs: open/close zone on file open/close
authorJohannes Thumshirn <johannes.thumshirn@wdc.com>
Fri, 11 Sep 2020 08:56:50 +0000 (17:56 +0900)
committerDamien Le Moal <damien.lemoal@wdc.com>
Tue, 15 Sep 2020 09:32:52 +0000 (18:32 +0900)
commitb5c00e975779c3d9e6d530c5481309257d5e4220
treee13c460c1a1f9c84369c798e88d56e093870e505
parent48d546a8dad4c09745d464e12b95f21c773bff39
zonefs: open/close zone on file open/close

NVMe Zoned Namespace introduced the concept of active zones, which are
zones in the implicit open, explicit open or closed condition. Drives may
have a limit on the number of zones that can be simultaneously active.
This potential limitation translate into a risk for applications to see
write IO errors due to this limit if the zone of a file being written to is
not already active when a write request is issued.

To avoid these potential errors, the zone of a file can explicitly be made
active using an open zone command when the file is open for the first
time. If the zone open command succeeds, the application is then
guaranteed that write requests can be processed. This indirect management
of active zones relies on the maximum number of open zones of a drive,
which is always lower or equal to the maximum number of active zones.

On the first open of a sequential zone file, send a REQ_OP_ZONE_OPEN
command to the block device. Conversely, on the last release of a zone
file and send a REQ_OP_ZONE_CLOSE to the device if the zone is not full or
empty.

As truncating a zone file to 0 or max can deactivate a zone as well, we
need to serialize against truncates and also be careful not to close a
zone as the file may still be open for writing, e.g. the user called
ftruncate(). If the zone file is not open and a process does a truncate(),
then no close operation is needed.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
fs/zonefs/super.c
fs/zonefs/zonefs.h