Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8610773imu; Thu, 15 Nov 2018 14:32:10 -0800 (PST) X-Google-Smtp-Source: AJdET5fEdDCisShCZ46ELejF/ymW4RORDmUjiPjFpZZ/ng/sqMHI7ip5ItHXnxPvcPU7lD3eYlwi X-Received: by 2002:a17:902:4381:: with SMTP id j1-v6mr7963607pld.59.1542321130637; Thu, 15 Nov 2018 14:32:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542321130; cv=none; d=google.com; s=arc-20160816; b=gSyxOdUX5eTZrSsYkv8orxJ4G3pH9NHp9pXUDDMGmgqjYaZV5st3jQSjvj1QO1O7HW 0wIaXBCQ/m9cly3H+JE5FjwcTfFSjGG6j+O073BfNojIZ0ncKrqsm65iPjJu3i5F/1Zu ySnYStU5AvkFUq73kAvd9BVyv2ynqkrjswoK6xOPSOWmXiVNVZ1Gw5uv27dyIG1carn1 GhZmRe+DNn3D6d/CJHsEzkdcY8lRbld0kdnzmwG/F2L+I6T1D6I1IkniOFkI9j0E2/s8 6l7yRSkTBPdYjgtF4+e4NH6wG7OjnuJ7ByKxv61g4o8SIQrXx672WKRE/Pf//qsPrIR1 l+Mw== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=787MBcCRVZ0FwK0UbuBTunnO0RHL61fFg1ZB5hIbuDs=; b=HgMiqIZU0lCSXguWjmo0DFTxxe+rLvOrqOTkvrJZtjlaTdByxuOMYSRak/9FnYRdrl CCpx2BkTkeL/k449LNT2P5Av2o4+iWZ0XZ5tTEfBNQRxYkVvl1zpuXoRNAhI9XRYdXVp UDRHXNKBFoo7wQiNrOAjQwpRgXeR8Q37ZoV230Mkn1wYc49mDoaD0xApwWpXilYlwno9 87cuYn8N7PWlQh5xguJjnTLj8lO8F0QSeY6A4+4MGgj8lGePkAaNc/JyKeKU17SNwKid KKZfvstBUmON6gv7q53Anzh43OBkrhcmG4PeI5PjfVQsKmcxPdt4w63w4kbk3iULbwpg KGSw== ARC-Authentication-Results: i=1; mx.google.com; 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 o22-v6si28743956pll.345.2018.11.15.14.31.55; Thu, 15 Nov 2018 14:32:10 -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; 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 S1726910AbeKPIkr (ORCPT + 99 others); Fri, 16 Nov 2018 03:40:47 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:42714 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725916AbeKPIkr (ORCPT ); Fri, 16 Nov 2018 03:40:47 -0500 Received: from akpm3.svl.corp.google.com (unknown [104.133.8.65]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A03C9949; Thu, 15 Nov 2018 22:31:04 +0000 (UTC) Date: Thu, 15 Nov 2018 14:31:03 -0800 From: Andrew Morton To: Pavel Tikhomirov Cc: Vasily Averin , Andrey Ryabinin , Konstantin Khorenko , Johannes Weiner , Mel Gorman , Jan Kara , Matthew Wilcox , Andi Kleen , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: cleancache: fix corruption on missed inode invalidation Message-Id: <20181115143103.c6fa8fec343bb706b91f6c6c@linux-foundation.org> In-Reply-To: <20181112095734.17979-1-ptikhomirov@virtuozzo.com> References: <20181112095734.17979-1-ptikhomirov@virtuozzo.com> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 12 Nov 2018 12:57:34 +0300 Pavel Tikhomirov wrote: > If all pages are deleted from the mapping by memory reclaim and also > moved to the cleancache: > > __delete_from_page_cache > (no shadow case) > unaccount_page_cache_page > cleancache_put_page > page_cache_delete > mapping->nrpages -= nr > (nrpages becomes 0) > > We don't clean the cleancache for an inode after final file truncation > (removal). > > truncate_inode_pages_final > check (nrpages || nrexceptional) is false > no truncate_inode_pages > no cleancache_invalidate_inode(mapping) > > These way when reading the new file created with same inode we may get > these trash leftover pages from cleancache and see wrong data instead of > the contents of the new file. > > Fix it by always doing truncate_inode_pages which is already ready for > nrpages == 0 && nrexceptional == 0 case and just invalidates inode. > Data corruption sounds serious. Shouldn't we backport this into -stable kernels?