Skip to content
  • Jan Kara's avatar
    fs: fix performance regression in clean_bdev_aliases() · c10f778d
    Jan Kara authored
    Commit e64855c6 ("fs: Add helper to clean bdev aliases under a bh
    and use it") added a wrapper for clean_bdev_aliases() that invalidates
    bdev aliases underlying a single buffer head.
    
    However this has caused a performance regression for bonnie++ benchmark
    on ext4 filesystem when delayed allocation is turned off (ext3 mode) -
    average of 3 runs:
    
      Hmean SeqOut Char  164787.55 (  0.00%) 107189.06 (-34.95%)
      Hmean SeqOut Block 219883.89 (  0.00%) 168870.32 (-23.20%)
    
    The reason for this regression is that clean_bdev_aliases() is slower
    when called for a single block because pagevec_lookup() it uses will end
    up iterating through the radix tree until it finds a page (which may
    take a while) but we are only interested whether there's a page at a
    particular index.
    
    Fix the problem by using pagevec_lookup_range() instead which avoids the
    needless iteration.
    
    Fixes: e64855c6 ("fs: Add helper to clean bdev aliases under a bh and use it")
    Link: http://lkml.kernel.org/r/20170726114704.7626-5-jack@suse.cz
    
    
    Signed-off-by: default avatarJan Kara <jack@suse.cz>
    Cc: Jens Axboe <axboe@fb.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    c10f778d