blkdev: avoid migration stalls for blkdev pages
authorJan Kara <>
Fri, 28 Dec 2018 08:39:16 +0000 (00:39 -0800)
committerLinus Torvalds <>
Fri, 28 Dec 2018 20:11:51 +0000 (12:11 -0800)
Currently, block device pages don't provide a ->migratepage callback and
thus fallback_migrate_page() is used for them.  This handler cannot deal
with dirty pages in async mode and also with the case a buffer head is in
the LRU buffer head cache (as it has elevated b_count).  Thus such page
can block memory offlining.

Fix the problem by using buffer_migrate_page_norefs() for migrating block
device pages.  That function takes care of dropping bh LRU in case
migration would fail due to elevated buffer refcount to avoid stalls and
can also migrate dirty pages without writing them.

Signed-off-by: Jan Kara <>
Acked-by: Mel Gorman <>
Cc: Michal Hocko <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>

index a80b4f0ee7c4f172d19b4df1c8c330e4c0738557..de2135178e621a42dee21c7873258658ea62bf37 100644 (file)
@@ -1966,6 +1966,7 @@ static const struct address_space_operations def_blk_aops = {
        .writepages     = blkdev_writepages,
        .releasepage    = blkdev_releasepage,
        .direct_IO      = blkdev_direct_IO,
+       .migratepage    = buffer_migrate_page_norefs,
        .is_dirty_writeback = buffer_check_dirty_writeback,