• Damien Le Moal's avatar
    zonefs: fix zone report size in __zonefs_io_error() · 7dd12d65
    Damien Le Moal authored
    When an IO error occurs, the function __zonefs_io_error() is used to
    issue a zone report to obtain the latest zone information from the
    device. This function gets a zone report for all zones used as storage
    for a file, which is always 1 zone except for files representing
    aggregated conventional zones.
    
    The number of zones of a zone report for a file is calculated in
    __zonefs_io_error() by doing a bit-shift of the inode i_zone_size field,
    which is equal to or larger than the device zone size. However, this
    calculation does not take into account that the last zone of a zoned
    device may be smaller than the zone size reported by bdev_zone_sectors()
    (which is used to set the bit shift size). As a result, if an error
    occurs for an IO targetting such last smaller zone, the zone report will
    ask for 0 zones, leading to an invalid zone report.
    
    Fix this by using the fact that all files require a 1 zone report,
    except if the inode i_zone_size field indicates a zone size larger than
    the device zone size. This exception case corresponds to a mount with
    aggregated conventional zones.
    
    A check for this exception is added to the file inode initialization
    during mount. If an invalid setup is detected, emit an error and fail
    the mount (check contributed by Johannes Thumshirn).
    Signed-off-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
    Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
    7dd12d65
super.c 50.6 KB