Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751661AbaJCKz5 (ORCPT ); Fri, 3 Oct 2014 06:55:57 -0400 Received: from mail-lb0-f171.google.com ([209.85.217.171]:63234 "EHLO mail-lb0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750852AbaJCKzx (ORCPT ); Fri, 3 Oct 2014 06:55:53 -0400 MIME-Version: 1.0 In-Reply-To: <1412263501-6572-3-git-send-email-nicolas.dichtel@6wind.com> References: <20131003.150947.2179820478039260398.davem@davemloft.net> <1412263501-6572-1-git-send-email-nicolas.dichtel@6wind.com> <1412263501-6572-3-git-send-email-nicolas.dichtel@6wind.com> Date: Fri, 3 Oct 2014 13:55:51 +0300 Message-ID: Subject: Re: [RFC PATCH linux 2/2] fs/proc: use a hash table for the directory entries From: Alexey Dobriyan To: Nicolas Dichtel Cc: netdev , Linux Kernel , David Miller , "Eric W. Biederman" , Andrew Morton , rui.xiang@huawei.com, Al Viro , Oleg Nesterov , Cyrill Gorcunov , kirill.shutemov@linux.intel.com, Grant Likely , "Theodore Ts'o" , Thierry Herbelot Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 2, 2014 at 6:25 PM, Nicolas Dichtel wrote: > --- a/fs/proc/generic.c > +++ b/fs/proc/generic.c > @@ -81,10 +81,13 @@ static int __xlate_proc_name(const char *name, struct proc_dir_entry **ret, > + if (!S_ISDIR(de->mode)) > + return -EINVAL; There are way too many S_ISDIR checks. In lookup and readdir, it is guaranteed that PDE is directory. I'd say all of them aren't needed because non-directories have ->subdir = NULL and directories have ->subdir != NULL which transforms into hashtable or rbtree or whatever, so you only need to guarantee only directories appear where they are expected and fearlessly use your new data structure traversing directories. Alexey -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/