From patchwork Thu Aug 13 21:23:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 7011031 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 74B289F373 for ; Thu, 13 Aug 2015 21:29:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8ACC420544 for ; Thu, 13 Aug 2015 21:29:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 855CC205C1 for ; Thu, 13 Aug 2015 21:29:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754248AbbHMV3M (ORCPT ); Thu, 13 Aug 2015 17:29:12 -0400 Received: from mail.linux-iscsi.org ([67.23.28.174]:36985 "EHLO linux-iscsi.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752592AbbHMV3K (ORCPT ); Thu, 13 Aug 2015 17:29:10 -0400 Received: from linux-iscsi.org (localhost [127.0.0.1]) by linux-iscsi.org (Postfix) with ESMTP id EDBB022DA56; Thu, 13 Aug 2015 21:23:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=linux-iscsi.org; s=default.private; t=1439501038; bh=2SbvizowCakjOOrXfmcbdZZRU2nhw3j k80lroWa/5FY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To: References; b=Prk6jtLd+due5JQ60693SuvEpklGFTZ/Tgbj6qXsGHHGGLzGMsVs 9MI+ZgeF9Gyn1Rai1zGVY/yNK2wUPeCZpF/+RT8+KHWOl88ztOhNO52mTwtoqoiMzX/ YeyOIbQPp/r34jsaPJQlZrppwEt0KT1461u66M+ADEGh7ACrkRvg= From: "Nicholas A. Bellinger" To: stable Cc: Greg-KH , Al Viro , Miklos Szeredi , linux-fsdevel Subject: [PATCH-v3.14.y 6/8] don't remove from shrink list in select_collect() Date: Thu, 13 Aug 2015 21:23:44 +0000 Message-Id: <1439501026-19955-7-git-send-email-nab@linux-iscsi.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1439501026-19955-1-git-send-email-nab@linux-iscsi.org> References: <1439501026-19955-1-git-send-email-nab@linux-iscsi.org> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Al Viro commit fe91522a7ba82ca1a51b07e19954b3825e4aaa22 upstream. If we find something already on a shrink list, just increment data->found and do nothing else. Loops in shrink_dcache_parent() and check_submounts_and_drop() will do the right thing - everything we did put into our list will be evicted and if there had been nothing, but data->found got non-zero, well, we have somebody else shrinking those guys; just try again. Signed-off-by: Al Viro --- fs/dcache.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 099308a..03e8107 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1231,34 +1231,23 @@ static enum d_walk_ret select_collect(void *_data, struct dentry *dentry) if (data->start == dentry) goto out; - /* - * move only zero ref count dentries to the dispose list. - * - * Those which are presently on the shrink list, being processed - * by shrink_dentry_list(), shouldn't be moved. Otherwise the - * loop in shrink_dcache_parent() might not make any progress - * and loop forever. - */ - if (dentry->d_lockref.count) { - dentry_lru_del(dentry); - } else if (!(dentry->d_flags & DCACHE_SHRINK_LIST)) { - /* - * We can't use d_lru_shrink_move() because we - * need to get the global LRU lock and do the - * LRU accounting. - */ - d_lru_del(dentry); - d_shrink_add(dentry, &data->dispose); + if (dentry->d_flags & DCACHE_SHRINK_LIST) { data->found++; - ret = D_WALK_NORETRY; + } else { + if (dentry->d_flags & DCACHE_LRU_LIST) + d_lru_del(dentry); + if (!dentry->d_lockref.count) { + d_shrink_add(dentry, &data->dispose); + data->found++; + } } /* * We can return to the caller if we have found some (this * ensures forward progress). We'll be coming back to find * the rest. */ - if (data->found && need_resched()) - ret = D_WALK_QUIT; + if (!list_empty(&data->dispose)) + ret = need_resched() ? D_WALK_QUIT : D_WALK_NORETRY; out: return ret; }