Re: [PATCH v3] mm: use swp_offset as key in shmem_replace_page()
From: Hugh Dickins
Date: Wed Nov 21 2018 - 19:36:51 EST
On Wed, 21 Nov 2018, Yu Zhao wrote:
> We changed key of swap cache tree from swp_entry_t.val to
> swp_offset. Need to do so in shmem_replace_page() as well.
>
> Fixes: f6ab1f7f6b2d ("mm, swap: use offset of swap entry as key of swap cache")
> Cc: stable@xxxxxxxxxxxxxxx # v4.9+
> Signed-off-by: Yu Zhao <yuzhao@xxxxxxxxxx>
Acked-by: Hugh Dickins <hughd@xxxxxxxxxx>
Thanks!
> ---
> mm/shmem.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/mm/shmem.c b/mm/shmem.c
> index d44991ea5ed4..42b70978e814 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -1509,11 +1509,13 @@ static int shmem_replace_page(struct page **pagep, gfp_t gfp,
> {
> struct page *oldpage, *newpage;
> struct address_space *swap_mapping;
> + swp_entry_t entry;
> pgoff_t swap_index;
> int error;
>
> oldpage = *pagep;
> - swap_index = page_private(oldpage);
> + entry.val = page_private(oldpage);
> + swap_index = swp_offset(entry);
> swap_mapping = page_mapping(oldpage);
>
> /*
> @@ -1532,7 +1534,7 @@ static int shmem_replace_page(struct page **pagep, gfp_t gfp,
> __SetPageLocked(newpage);
> __SetPageSwapBacked(newpage);
> SetPageUptodate(newpage);
> - set_page_private(newpage, swap_index);
> + set_page_private(newpage, entry.val);
> SetPageSwapCache(newpage);
>
> /*
> --
> 2.19.1.1215.g8438c0b245-goog