Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756683AbdDRSwK (ORCPT ); Tue, 18 Apr 2017 14:52:10 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:32831 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754079AbdDRSwE (ORCPT ); Tue, 18 Apr 2017 14:52:04 -0400 Subject: Re: [PATCH 2/4] fs/block_dev: always invalidate cleancache in invalidate_bdev() To: Andrey Ryabinin , Alexander Viro , linux-fsdevel@vger.kernel.org References: <20170414140753.16108-1-aryabinin@virtuozzo.com> <20170414140753.16108-3-aryabinin@virtuozzo.com> Cc: Konrad Rzeszutek Wilk , Eric Van Hensbergen , Ron Minnich , Latchesar Ionkov , Steve French , Matthew Wilcox , Ross Zwisler , Trond Myklebust , Anna Schumaker , Andrew Morton , Jan Kara , Jens Axboe , Johannes Weiner , Alexey Kuznetsov , Christoph Hellwig , v9fs-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org From: Nikolay Borisov Message-ID: <705067e3-eb15-ce2a-cfc8-d048dfc8be4f@gmail.com> Date: Tue, 18 Apr 2017 21:51:59 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170414140753.16108-3-aryabinin@virtuozzo.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1396 Lines: 41 On 14.04.2017 17:07, Andrey Ryabinin wrote: > invalidate_bdev() calls cleancache_invalidate_inode() iff ->nrpages != 0 > which doen't make any sense. > Make invalidate_bdev() always invalidate cleancache data. > > Fixes: c515e1fd361c ("mm/fs: add hooks to support cleancache") > Signed-off-by: Andrey Ryabinin > --- > fs/block_dev.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/fs/block_dev.c b/fs/block_dev.c > index e405d8e..7af4787 100644 > --- a/fs/block_dev.c > +++ b/fs/block_dev.c > @@ -103,12 +103,11 @@ void invalidate_bdev(struct block_device *bdev) > { > struct address_space *mapping = bdev->bd_inode->i_mapping; > > - if (mapping->nrpages == 0) > - return; > - > - invalidate_bh_lrus(); > - lru_add_drain_all(); /* make sure all lru add caches are flushed */ > - invalidate_mapping_pages(mapping, 0, -1); > + if (mapping->nrpages) { > + invalidate_bh_lrus(); > + lru_add_drain_all(); /* make sure all lru add caches are flushed */ > + invalidate_mapping_pages(mapping, 0, -1); > + } How is this different than the current code? You will only invalidate the mapping iff ->nrpages > 0 ( I assume it can't go down below 0) ? Perhaps just remove the if altogether? > /* 99% of the time, we don't need to flush the cleancache on the bdev. > * But, for the strange corners, lets be cautious > */ >