• Damien Le Moal's avatar
    zonefs: Dynamically create file inodes when needed · d207794a
    Damien Le Moal authored
    Allocating and initializing all inodes and dentries for all files
    results in a very large memory usage with high capacity zoned block
    devices. For instance, with a 26 TB SMR HDD with over 96000 zones,
    mounting the disk with zonefs results in about 130 MB of memory used,
    the vast majority of this space being used for vfs inodes and dentries.
    
    However, since a user will rarely access all zones at the same time,
    dynamically creating file inodes and dentries on demand, similarly to
    regular file systems, can significantly reduce memory usage.
    
    This patch modifies mount processing to not create the inodes and
    dentries for zone files. Instead, the directory inode operation
    zonefs_lookup() and directory file operation zonefs_readdir() are
    introduced to allocate and initialize inodes on-demand using the helper
    functions zonefs_get_dir_inode() and zonefs_get_zgroup_inode().
    
    Implementation of these functions is simple, relying on the static
    nature of zonefs directories and files. Directory inodes are linked to
    the volume zone groups (struct zonefs_zone_group) they represent by
    using the directory inode i_private field. This simplifies the
    implementation of the lookup and readdir operations.
    
    Unreferenced zone file inodes can be evicted from the inode cache at any
    time. In such case, the only inode information that cannot be recreated
    from the zone information that is saved in the zone group data
    structures attached to the volume super block is the inode uid, gid and
    access rights. These values may have been changed by the user. To keep
    these attributes for the life time of the mount, as before, the inode
    mode, uid and gid are saved in the inode zone information and the saved
    values are used to initialize regular file inodes when an inode lookup
    happens. The zone information mode, uid and gid are initialized in
    zonefs_init_zgroup() using the default values.
    
    With these changes, the static minimal memory usage of a zonefs volume
    is mostly reduced to the array of zone information for each zone group.
    For the 26 TB SMR hard-disk mentioned above, the memory usage after
    mount becomes about 5.4 MB, a reduction by a factor of 24 from the
    initial 130 MB memory use.
    Co-developed-by: default avatarJorgen Hansen <Jorgen.Hansen@wdc.com>
    Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
    Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
    d207794a
super.c 35.9 KB