Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8109302imu; Tue, 4 Dec 2018 03:09:34 -0800 (PST) X-Google-Smtp-Source: AFSGD/WBM79FzwDEr9vEK3R8OCQDnAi9LiRmjFQ2fGeGeAMM7IIVWDunjw+R404T8u962T2DVrlL X-Received: by 2002:a62:e30d:: with SMTP id g13mr19438198pfh.151.1543921774369; Tue, 04 Dec 2018 03:09:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543921774; cv=none; d=google.com; s=arc-20160816; b=NjuZrwgMRdQasx9wudzGPOsfLRjRZI7oWGQUvkxmvOHGgbUQKfATTi/TSSse2ZvxVX KZOSuatgn2oqGWoVfK2FT2pw5lqQyarhLt2cYNK5MTeHMdzk2OCFa2AuWkej3Yvtp3sJ oUPBTtv53wmhEOiJV3mXhD+KTskppsBsM/hJccO1G16+/aThAVCK3a8mdj764rybdyE+ MIuZiZNR7Lxr6IYDh4Sm4x7ix8BkFiPocc5Hg/kiH6XLs8r5wrXoDbgE65enr3I7AqQx c07w36Uh/D+gTRhx/PEVE9RYNW6qrW9ZgKk8CTMn5pJ8tvzZjIggn284Sb6vNR2ryaK/ NHIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cj6dyab25pqcc+PAgRFlvGGk6XMNDWoox78YOHj8iEU=; b=xzpRfeakqPea3VSO2YZTQzxO4TMNS6B4Ei8J9X/W1zqrdTIuaxpa2OZw7xjffN7wjn WtEKKA2VCzVbnKGeksc/5cssMdqhkJgWp+wFPbNT6+PPrpICvIvH7V41MrPhjE7yIVgJ EvPTsEzbhc8ZltRIfMzKVTsw9Aoz4nbkZehUZ20cjoji+K4QJpHFq0CuX3Z9lGHUYnMS uX4v5ls1oFj40BXV0ItJp+irqrQTqvM6qOCxACttUmf3+ax8wAwoTeVIT4Gd1pys2thH CcxrL3UoQtKfF/bJ6Hb2agizDBkcET/hIgQyYmRSCOFWKpMmSJoq83nuSGo/017Up6zz CKvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=donV88g6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h16si15120347pgj.203.2018.12.04.03.09.19; Tue, 04 Dec 2018 03:09:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=donV88g6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728157AbeLDLHZ (ORCPT + 99 others); Tue, 4 Dec 2018 06:07:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:56428 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728158AbeLDLHW (ORCPT ); Tue, 4 Dec 2018 06:07:22 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EC40E2087F; Tue, 4 Dec 2018 11:07:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543921642; bh=bFC3Q9wrrG9t8poEfXcWROtmQy+yrMLxmoETs1V5Gvg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=donV88g6dYzcsFjd+/1eRK8E2X1Su60EOv2TnQ5QeS1QtxDrUwYP+8KbqHOhO//WK di7rxEO0NNxG1i6anu9DdXpJV3TjTQIH332PSIHbYYhUBr79O75nSJAr2YpCvtAEkX Ga2845G8QBvGB/lEUhrJ3UBWibd27W3SbdZpOtJU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yu Zhao , Matthew Wilcox , Hugh Dickins , Andrew Morton , Linus Torvalds Subject: [PATCH 4.14 143/146] mm: use swp_offset as key in shmem_replace_page() Date: Tue, 4 Dec 2018 11:50:29 +0100 Message-Id: <20181204103732.575115034@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181204103726.750894136@linuxfoundation.org> References: <20181204103726.750894136@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yu Zhao commit c1cb20d43728aa9b5393bd8d489bc85c142949b2 upstream. We changed the key of swap cache tree from swp_entry_t.val to swp_offset. We need to do so in shmem_replace_page() as well. Hugh said: "shmem_replace_page() has been wrong since the day I wrote it: good enough to work on swap "type" 0, which is all most people ever use (especially those few who need shmem_replace_page() at all), but broken once there are any non-0 swp_type bits set in the higher order bits" Link: http://lkml.kernel.org/r/20181121215442.138545-1-yuzhao@google.com Fixes: f6ab1f7f6b2d ("mm, swap: use offset of swap entry as key of swap cache") Signed-off-by: Yu Zhao Reviewed-by: Matthew Wilcox Acked-by: Hugh Dickins Cc: [4.9+] Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/shmem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1532,11 +1532,13 @@ static int shmem_replace_page(struct pag { 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); /* @@ -1555,7 +1557,7 @@ static int shmem_replace_page(struct pag __SetPageLocked(newpage); __SetPageSwapBacked(newpage); SetPageUptodate(newpage); - set_page_private(newpage, swap_index); + set_page_private(newpage, entry.val); SetPageSwapCache(newpage); /*