Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2018-06-22 12:55:04 +0200
committerJiri Kosina <jkosina@suse.cz>2018-06-22 12:55:04 +0200
commitd8ce4d6f552da6a9422bf10d0b48a2838fa113c5 (patch)
treee2d8fae64e962159290ef33aee5c6dd31ed2b4fe
parent40b427535158c5c2d5cd75148bc1b0e95fd3d291 (diff)
parentcd291d18075c3cdc971516cf9d5de5d6287022b8 (diff)
Merge remote-tracking branch 'origin/users/vbabka/SLE15/for-next' into SLE15
Pull mm/swap fix from Vlastimil Babka suse-commit: 3ef33e7efb5f98ba21555251b9c259d1cd0069d4
-rw-r--r--include/linux/swap.h1
-rw-r--r--mm/swap_state.c3
-rw-r--r--mm/swapfile.c5
3 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 40a26fe9e4f9..d2438fb86d38 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -440,6 +440,7 @@ extern int page_swapcount(struct page *);
extern int __swp_swapcount(swp_entry_t entry);
extern int swp_swapcount(swp_entry_t entry);
extern struct swap_info_struct *page_swap_info(struct page *);
+extern struct swap_info_struct *swp_swap_info(swp_entry_t entry);
extern bool reuse_swap_page(struct page *, int *);
extern int try_to_free_swap(struct page *);
struct backing_dev_info;
diff --git a/mm/swap_state.c b/mm/swap_state.c
index 48032506f697..95344cf9a8f6 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -500,6 +500,7 @@ struct page *swapin_readahead(swp_entry_t entry, gfp_t gfp_mask,
unsigned long offset = entry_offset;
unsigned long start_offset, end_offset;
unsigned long mask;
+ struct swap_info_struct *si = swp_swap_info(entry);
struct blk_plug plug;
mask = swapin_nr_pages(offset) - 1;
@@ -511,6 +512,8 @@ struct page *swapin_readahead(swp_entry_t entry, gfp_t gfp_mask,
end_offset = offset | mask;
if (!start_offset) /* First page is swap header. */
start_offset++;
+ if (end_offset >= si->max)
+ end_offset = si->max - 1;
blk_start_plug(&plug);
for (offset = start_offset; offset <= end_offset ; offset++) {
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 13f3d4c5c560..ad50a270fbf1 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -3065,6 +3065,11 @@ int swapcache_prepare(swp_entry_t entry)
return __swap_duplicate(entry, SWAP_HAS_CACHE);
}
+struct swap_info_struct *swp_swap_info(swp_entry_t entry)
+{
+ return swap_info[swp_type(entry)];
+}
+
struct swap_info_struct *page_swap_info(struct page *page)
{
swp_entry_t swap = { .val = page_private(page) };