• D
    zonefs: fix zone report size in __zonefs_io_error() · 5bd8c6e6
    Damien Le Moal 提交于
    stable inclusion
    from stable-v5.10.157
    commit 0964b77bab5445307177bc6d969d2b57f744ed33
    category: bugfix
    bugzilla: https://gitee.com/openeuler/kernel/issues/I7MU59
    
    Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=0964b77bab5445307177bc6d969d2b57f744ed33
    
    --------------------------------
    
    [ Upstream commit 7dd12d65 ]
    
    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: NJohannes Thumshirn <johannes.thumshirn@wdc.com>
    Signed-off-by: NDamien Le Moal <damien.lemoal@opensource.wdc.com>
    Signed-off-by: NSasha Levin <sashal@kernel.org>
    Signed-off-by: Nsanglipeng <sanglipeng1@jd.com>
    5bd8c6e6
super.c 48.9 KB