git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Duy Nguyen <pclouds@gmail.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] dir.c: avoid stat() in valid_cached_dir()
Date: Tue, 2 Jan 2018 07:02:13 +0700	[thread overview]
Message-ID: <CACsJy8CvYcLm7YGYenea=58EVesLMBiOh3eWMWWSr8LLDsGmPQ@mail.gmail.com> (raw)
In-Reply-To: <87h8sar5sl.fsf@evledraar.gmail.com>

On Fri, Dec 29, 2017 at 2:50 AM, Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
>
> On Thu, Dec 28 2017, Nguyễn Thái Ngọc Duy jotted:
>
>> stat() may follow a symlink and return stat data of the link's target
>> instead of the link itself. We are concerned about the link itself.
>>
>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>> ---
>>  I noticed this while looking at the untracked cache bug [1] but
>>  because it's not directly related to that bug, I'm submitting it
>>  separately here.
>>
>>  [1] https://public-inbox.org/git/CACsJy8AmbKSp0mDLRaDCWn45veeNc03B-Gq8r8PQPrDt9bM_EA@mail.gmail.com/
>
> I'm slowly trying to piece together a re-submission of this whole
> series, if this is a bug and not just an optimziation shouldn't there be
> some test case that demonstrates this bug?

It's kind of hard to demonstrate the bug. I think when path->buf is a
symlink, we most likely find that its target's stat data does not
match our cached one, which means we ignore the cache and fall back to
slow path. This is performance issue, not correctness (though we could
still catch it by verying test-dump-untracked-cache, I guess; I could
try writing a test case for this if you want). The less unlikely case
is, link target stat data matches the cached version and we
incorrectly go fast path, ignoring real data on disk. A test for this
may involve manipulating stat data, which may be not portable.
-- 
Duy

      reply	other threads:[~2018-01-02  0:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-28  0:28 [PATCH] dir.c: avoid stat() in valid_cached_dir() Nguyễn Thái Ngọc Duy
2017-12-28 19:05 ` Junio C Hamano
2017-12-28 19:10   ` Junio C Hamano
2018-01-01 23:57     ` Duy Nguyen
2018-01-03 20:49       ` [PATCH v2 0/5] untracked cache bug fixes Ævar Arnfjörð Bjarmason
2018-01-03 20:49       ` [PATCH v2 1/5] status: add a failing test showing a core.untrackedCache bug Ævar Arnfjörð Bjarmason
2018-01-03 20:49       ` [PATCH v2 2/5] dir.c: avoid stat() in valid_cached_dir() Ævar Arnfjörð Bjarmason
2018-01-03 20:49       ` [PATCH v2 3/5] dir.c: fix missing dir invalidation in untracked code Ævar Arnfjörð Bjarmason
2018-01-03 20:49       ` [PATCH v2 4/5] update-index doc: note a fixed bug in the untracked cache Ævar Arnfjörð Bjarmason
2018-01-03 20:49       ` [PATCH v2 5/5] dir.c: stop ignoring opendir() error in open_cached_dir() Ævar Arnfjörð Bjarmason
2018-01-07 12:44         ` Duy Nguyen
2017-12-28 19:50 ` [PATCH] dir.c: avoid stat() in valid_cached_dir() Ævar Arnfjörð Bjarmason
2018-01-02  0:02   ` Duy Nguyen [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='CACsJy8CvYcLm7YGYenea=58EVesLMBiOh3eWMWWSr8LLDsGmPQ@mail.gmail.com' \
    --to=pclouds@gmail.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).