• Alex Zhuravlev's avatar
    ext4: add prefetching for block allocation bitmaps · cfd73237
    Alex Zhuravlev authored
    This should significantly improve bitmap loading, especially for flex
    groups as it tries to load all bitmaps within a flex.group instead of
    one by one synchronously.
    
    Prefetching is done in 8 * flex_bg groups, so it should be 8
    read-ahead reads for a single allocating thread. At the end of
    allocation the thread waits for read-ahead completion and initializes
    buddy information so that read-aheads are not lost in case of memory
    pressure.
    
    At cr=0 the number of prefetching IOs is limited per allocation
    context to prevent a situation when mballoc loads thousands of bitmaps
    looking for a perfect group and ignoring groups with good chunks.
    
    Together with the patch "ext4: limit scanning of uninitialized groups"
    the mount time (which includes few tiny allocations) of a 1PB
    filesystem is reduced significantly:
    
                   0% full    50%-full unpatched    patched
      mount time       33s                9279s       563s
    
    [ Restructured by tytso; removed the state flags in the allocation
      context, so it can be used to lazily prefetch the allocation bitmaps
      immediately after the file system is mounted.  Skip prefetching
      block groups which are uninitialized.  Finally pass in the
      REQ_RAHEAD flag to the block layer while prefetching. ]
    Signed-off-by: default avatarAlex Zhuravlev <bzzz@whamcloud.com>
    Reviewed-by: default avatarAndreas Dilger <adilger@whamcloud.com>
    Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
    cfd73237
mballoc.c 156 KB