diff --git a/mm/swap_state.c b/mm/swap_state.c index 0d6a7f268d2e6c1abe6fb550a9e14206b26188ff..23f91c32dfa18f382b9319414bdfdfb259a26d20 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -582,6 +582,13 @@ struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask, if (!mask) goto skip; + /* Test swap type to make sure the dereference is safe */ + if (likely(si->flags & (SWP_BLKDEV | SWP_FILE))) { + struct inode *inode = si->swap_file->f_mapping->host; + if (inode_read_congested(inode)) + goto skip; + } + do_poll = false; /* Read a page_cluster sized and aligned cluster around offset. */ start_offset = offset & ~mask;