public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Christoph Hellwig <hch@lst.de>,
	Johannes Thumshirn <jthumshirn@suse.de>,
	Sagi Grimberg <sagi@grimberg.me>,
	Linux Kernel Mailinglist <linux-kernel@vger.kernel.org>,
	Linux NVMe Mailinglist <linux-nvme@lists.infradead.org>,
	Keith Busch <keith.busch@intel.com>,
	Hannes Reinecke <hare@suse.de>, Max Gurtovoy <maxg@mellanox.com>
Subject: Re: [PATCH v6 00/10] Implement NVMe Namespace Descriptor Identification
Date: Wed, 21 Jun 2017 19:06:12 -0500	[thread overview]
Message-ID: <87fuesnax7.fsf@xmission.com> (raw)
In-Reply-To: <CA+55aFxJ0bpRFsnZFe6sh2i4jxNdYmDi_6RZx2CQQdmQ_HU3wQ@mail.gmail.com> (Linus Torvalds's message of "Fri, 16 Jun 2017 22:28:28 +0900")

Linus Torvalds <torvalds@linux-foundation.org> writes:

> On Fri, Jun 16, 2017 at 6:58 PM, Christoph Hellwig <hch@lst.de> 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

      reply	other threads:[~2017-06-22  0:13 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-07  9:45 [PATCH v6 00/10] Implement NVMe Namespace Descriptor Identification Johannes Thumshirn
2017-06-07  9:45 ` [PATCH v6 01/10] scatterlist: add sg_zeroout_area() helper Johannes Thumshirn
2017-06-07  9:49   ` Sagi Grimberg
2017-06-08  7:41   ` Christoph Hellwig
2017-06-08  7:46     ` Johannes Thumshirn
2017-06-07  9:45 ` [PATCH v6 02/10] nvmet: use NVME_IDENTIFY_DATA_SIZE Johannes Thumshirn
2017-06-08  7:42   ` Christoph Hellwig
2017-06-07  9:45 ` [PATCH v6 03/10] nvme: introduce NVMe Namespace Identification Descriptor structures Johannes Thumshirn
2017-06-08  7:42   ` Christoph Hellwig
2017-06-07  9:45 ` [PATCH v6 04/10] nvme: rename uuid to nguid in nvme_ns Johannes Thumshirn
2017-06-07  9:45 ` [PATCH v6 05/10] nvmet: implement namespace identify descriptor list Johannes Thumshirn
2017-06-07  9:50   ` Sagi Grimberg
2017-06-08  7:44   ` Christoph Hellwig
2017-06-08  7:49     ` Johannes Thumshirn
2017-06-08  7:52       ` Christoph Hellwig
2017-06-08  7:55         ` Johannes Thumshirn
2017-06-08  7:57           ` Christoph Hellwig
     [not found]         ` <MWHPR04MB10088151BCB7D7A209A739E686CD0@MWHPR04MB1008.namprd04.prod.outlook.com>
2017-06-12 16:19           ` Christoph Hellwig
2017-06-07  9:45 ` [PATCH v6 06/10] nvmet: add uuid field to nvme_ns and populate via configfs Johannes Thumshirn
2017-06-08  7:44   ` Christoph Hellwig
2017-06-07  9:45 ` [PATCH v6 07/10] nvme: get list of namespace descriptors Johannes Thumshirn
2017-06-08  7:46   ` Christoph Hellwig
2017-06-07  9:45 ` [PATCH v6 08/10] nvme: provide UUID value to userspace Johannes Thumshirn
2017-06-07  9:45 ` [PATCH v6 09/10] nvmet: allow overriding the NVMe VS via configfs Johannes Thumshirn
2017-06-08  7:47   ` Christoph Hellwig
2017-06-15 16:31 ` [PATCH v6 00/10] Implement NVMe Namespace Descriptor Identification Christoph Hellwig
2017-06-16  8:20   ` Johannes Thumshirn
2017-06-16  9:40     ` Christoph Hellwig
2017-06-16  9:48       ` Johannes Thumshirn
2017-06-16  9:58         ` Christoph Hellwig
2017-06-16  9:59           ` Johannes Thumshirn
2017-06-16 13:28           ` Linus Torvalds
2017-06-22  0:06             ` Eric W. Biederman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fuesnax7.fsf@xmission.com \
    --to=ebiederm@xmission.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=jthumshirn@suse.de \
    --cc=keith.busch@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=maxg@mellanox.com \
    --cc=sagi@grimberg.me \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox