From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752090AbdFVAN1 (ORCPT ); Wed, 21 Jun 2017 20:13:27 -0400 Received: from out02.mta.xmission.com ([166.70.13.232]:45851 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751641AbdFVANZ (ORCPT ); Wed, 21 Jun 2017 20:13:25 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Linus Torvalds Cc: Christoph Hellwig , Johannes Thumshirn , Sagi Grimberg , Linux Kernel Mailinglist , Linux NVMe Mailinglist , Keith Busch , Hannes Reinecke , Max Gurtovoy References: <20170607094536.32419-1-jthumshirn@suse.de> <20170615163141.GA27307@lst.de> <20170616094056.GA12465@lst.de> <905ed2e6-1c1c-f3a3-5391-66e42fb61861@suse.de> <20170616095837.GA14217@lst.de> Date: Wed, 21 Jun 2017 19:06:12 -0500 In-Reply-To: (Linus Torvalds's message of "Fri, 16 Jun 2017 22:28:28 +0900") Message-ID: <87fuesnax7.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1dNpkI-0006Cq-AE;;;mid=<87fuesnax7.fsf@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=67.3.213.87;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1/psSyq3ROvy+PfHaJitPCLGfP4MYGfM9k= X-SA-Exim-Connect-IP: 67.3.213.87 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.7 XMSubLong Long Subject * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa02 1397; Body=1 Fuz1=1 Fuz2=1] X-Spam-DCC: XMission; sa02 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Linus Torvalds X-Spam-Relay-Country: X-Spam-Timing: total 5566 ms - load_scoreonly_sql: 0.07 (0.0%), signal_user_changed: 3.3 (0.1%), b_tie_ro: 2.2 (0.0%), parse: 1.43 (0.0%), extract_message_metadata: 33 (0.6%), get_uri_detail_list: 3.8 (0.1%), tests_pri_-1000: 16 (0.3%), tests_pri_-950: 2.2 (0.0%), tests_pri_-900: 1.80 (0.0%), tests_pri_-400: 37 (0.7%), check_bayes: 34 (0.6%), b_tokenize: 13 (0.2%), b_tok_get_all: 9 (0.2%), b_comp_prob: 5 (0.1%), b_tok_touch_all: 3.1 (0.1%), b_finish: 0.85 (0.0%), tests_pri_0: 595 (10.7%), check_dkim_signature: 1.02 (0.0%), check_dkim_adsp: 4.7 (0.1%), tests_pri_500: 4871 (87.5%), poll_dns_idle: 4862 (87.4%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH v6 00/10] Implement NVMe Namespace Descriptor Identification X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Linus Torvalds writes: > On Fri, Jun 16, 2017 at 6:58 PM, Christoph Hellwig wrote: >> On Fri, Jun 16, 2017 at 11:48:32AM +0200, Johannes Thumshirn wrote: >>> > >>> > Yeah, it's actually there, but for some reason find on sysfs >>> > behaves strange: >>> > >>> > root@testvm:~# find /sys -name uuid >>> > root@testvm:~# cat /sys/class/nvme/nvme2/nvme2n1/uuid >>> > 6665a65b-f42f-469b-800e-a047238649eb >>> >>> Wasn't there something that find on sysfs isn't reliable? >> >> Looks like it. Which is a pitty. > > Hmm. The *traditional* reason for this particular 'find' oddity is > that find has an optimization which will look at the nlink count of a > directory to decide how many subdirectories it can have. > > So when 'find' then traverses the directory tree, once it has found > all the subdirectories it expects, it will stop traversing any further > subdirectories. > > The reason for this is that it can then avoid doing the 'lstat()' on > each directory entry to even figure out what kind of file it is (ie > directory vs regular file etc). I forget the exact rules, but it > basically depends on nlink being "2+umber of subdirectories". I wonder > if the sysfs code gets this wrong for some cases. > > All the directories I have on the laptop I'm on right now get it > right, but maybe nvme triggers something. > > You can check with some silly shell scripts, and do things like > > stat -c %h /sys/class/nvme > > and then compare that to the number of subdirectories (the link count > should be 2 higher - the parent entry and the '.' entry). > > The traditional *fix* for this is to just set "nlink" to 1 for a > directory, which tells 'find' to not use this optimization. That's > what filesystems like VFAT do, that don't count subdirectories. But > sysfs should get the directory count right. > > I can't imagine any other reason why 'find' would screw up. Definitely worth looking at. There is only one code path for that in kernfs/sysfs so I don't think you can mess that up. I suspect find is getting confused by something more subtle. Perhaps a symlink. /sys/class/nvme/ ought to be be filled with symlinks to other locations in sysfs. Which could be part of the challenge. Perhaps find /sys/ behaves differently than find /sys.. It might be worth running "find /sys | grep uuid" and see if your file turns up. After the work I did cleaning up sysfs to support network namespaces find really ought to work properly on sysfs. inotify is likely to have problems but find should work. Eric