• Johannes Thumshirn's avatar
    zonefs: open/close zone on file open/close · b5c00e97
    Johannes Thumshirn authored
    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: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
    Reviewed-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
    Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
    b5c00e97
zonefs.h 5 KB