Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758803Ab1CCVDM (ORCPT ); Thu, 3 Mar 2011 16:03:12 -0500 Received: from smtp1.linux-foundation.org ([140.211.169.13]:59218 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758665Ab1CCVDL (ORCPT ); Thu, 3 Mar 2011 16:03:11 -0500 MIME-Version: 1.0 In-Reply-To: <87tyfk7x0c.fsf@devron.myhome.or.jp> References: <20110303032454.GI22723@ZenIV.linux.org.uk> <20110303060352.GK22723@ZenIV.linux.org.uk> <87tyfk7x0c.fsf@devron.myhome.or.jp> From: Linus Torvalds Date: Thu, 3 Mar 2011 13:02:50 -0800 Message-ID: Subject: Re: [RFC] st_nlink after rmdir() and rename() To: OGAWA Hirofumi Cc: Al Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1535 Lines: 38 On Thu, Mar 3, 2011 at 12:46 PM, OGAWA Hirofumi wrote: > > But, some commands see i_nlink (IIRC, it's checking i_nlink == 2, to > know empty dir or not). Actually, that would be a serious bug in the application. The traditional rule of thumb is that a directory with i_nlink==1 has a "I'm not counting at all". For example, I think that's the rule that 'find' uses to decide if a directory can have subdirectories (and when it could try to stop scanning early): i_nlink == 1 means that yes, it _can_ have subdirectories, we just don't know how many. So checking i_nlink==2 is actually a user-level bug. > So we have to simulate some levels. I guess you > are not saying we don't need to care it at all though. I'm saying that it should just work to set i_nlink=1 and not do anything at all. Ever. It's a valid model for directory counts. Seriously - that's what isofs does, for example. It does mean that 'find' for certain cases gets bit more expensive, but on the other hand, other operations are a lot _less_ expensive. We might well try that as a FAT mount option, to let people decide whether they really do want the "scan directories all the time" or only the "let 'find' scan directories when it needs to" behavior. Linus -- 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/