linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Waiman Long <waiman.long@hp.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	Scott J Norton <scott.norton@hp.com>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	"Chandramouleeswaran, Aswin" <aswin@hp.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] dcache: Translating dentry into pathname without taking rename_lock
Date: Wed, 4 Sep 2013 19:48:14 -0700	[thread overview]
Message-ID: <CA+55aFyURmAMo1Hso1_2zzcNEfcqOLUyhLGrBhvtMXWMJHVMfg@mail.gmail.com> (raw)
In-Reply-To: <5227E321.4090008@hp.com>

On Wed, Sep 4, 2013 at 6:49 PM, Waiman Long <waiman.long@hp.com> wrote:
>
> So what I am going to do is to use memchr() to locate a null
> byte within the given length. If one is found, the string must be invalid
> and there is no point in doing the copying. Instead, EINVAL will be returned
> and the code will check the sequence number then. The memchr() function can
> be fast if an architecture-specific version exists.

We don't have an architecture-specific fast version of memchr, because
nobody sane has ever cared about that abomination of a function. Also,
if rename() overwrites the pathname (switching inline names), I guess
a zero could disappear between your memchr and the copy. Although I
think we always have an ending NUL byte for the inline case, so that
should make sure that memchr would find it *eventually*.

But regardless, that's really not what you want to do.

You should do:

 - use the name length as a maximum

 - do a byte-at-a-time copy, stopping at a zero (it's going to be
faster than memchr anyway)

Then, later on, we can do one that does a word-at-a-time using the
CONFIG_DCACHE_WORD_ACCESS magic: we know dentry names are always
word-aligned, and we have an efficient "has_zero()" function for
finding zero bytes in a word.

Really.

            Linus

  parent reply	other threads:[~2013-09-05  2:48 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-04 19:05 [PATCH] dcache: Translating dentry into pathname without taking rename_lock Waiman Long
2013-09-04 19:11 ` Al Viro
2013-09-04 19:33   ` Waiman Long
2013-09-04 19:43     ` Al Viro
2013-09-05  1:55       ` Waiman Long
2013-09-05  2:42         ` Al Viro
     [not found]   ` <CA+55aFwW+hWwQd8+NgukSidHbf2bnd6QO0yKK9NAgX+9rt0cOQ@mail.gmail.com>
     [not found]     ` <5227E321.4090008@hp.com>
2013-09-05  2:48       ` Linus Torvalds [this message]
2013-09-05  4:20         ` Al Viro
2013-09-04 19:26 ` Waiman Long
2013-09-04 20:40   ` John Stoffel
2013-09-05  2:04     ` Waiman Long
2013-09-05 13:29       ` John Stoffel
2013-09-05 17:28         ` Waiman Long
2013-09-04 21:31 ` Linus Torvalds
2013-09-05  2:17   ` Waiman Long
  -- strict thread matches above, loose matches on Subject: below --
2013-09-05  4:30 George Spelvin
2013-09-05 17:06 ` Waiman Long

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=CA+55aFyURmAMo1Hso1_2zzcNEfcqOLUyhLGrBhvtMXWMJHVMfg@mail.gmail.com \
    --to=torvalds@linux-foundation.org \
    --cc=aswin@hp.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=scott.norton@hp.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=waiman.long@hp.com \
    /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;
as well as URLs for NNTP newsgroup(s).