git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH/RFC 1/4] Optimised, faster, more effective symlink/directory detection

From
KBKjetil Barvik <barvik@broadpark.no>
Date
Jan 6, 2009, 13:45 UTC
Message-ID
<86mye4k0ob.fsf@broadpark.no>
In-Reply-To
<7v3afwizi7.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
 <snipp>
Show 24 quoted lines
> If everything is working correctly, I do not think you will ever have a
> situation where you check "A/B" here and get ENOTDIR back.  lstat("A/B")
> would yield ENOTDIR if "A" is not a directory, but:
>
>  (1) If you did test "A" in the earlier round in the loop, you would have
>      already found it is not a directory and would have exited the loop
>      with LSTAT_ERR.  You cannot test "A/B" in such a case;
>
>  (2) If you did not test "A" in the loop, that has to be because you had a
>      cached information for it, and the caching logic would have returned
>      early if "A" was a non-directory without entering the loop; in other
>      words, you would test "A/B" here without testing "A" in the loop only
>      when the cache says "A" was a directory.  You cannot get ENOTDIR in
>      such a case.
>
> In any case, my main puzzlement still stands.  I think ENOTDIR case should
> behave differently from ENOENT case.
>
> And I think it is an indication of a grave error, either this code is
> racing with an external process that is actively mucking with the work
> tree to make your cached information unusable, or somebody forgot to call
> clear_lstat_cache().
>
> Hmm?
  I have looked at this once more, and I have to admit that what you
  have said is correct.  Sorry for being confusing!  I will update the
  patch by removing the 'errno == ENOTDIR' part from the if-test.
  -- kjetil
Previous: Kjetil BarvikNext: Kjetil Barvik
Message 6 of 12 in “git checkout: optimise away lots of lstat() calls”
  1. 0/4 git checkout: optimise away lots of lstat() callsKjetil Barvik, Jan 5, 2009
  2. 1/4 Optimised, faster, more effective symlink/directory detectionKjetil Barvik, Jan 5, 2009
  3. Junio C HamanoJan 6, 2009
  4. Junio C HamanoJan 6, 2009
  5. Kjetil BarvikJan 6, 2009
  6. Kjetil BarvikJan 6, 2009
  7. Kjetil BarvikJan 6, 2009
  8. 2/4 Use 'lstat_cache()' instead of 'has_symlink_leading_path()'Kjetil Barvik, Jan 5, 2009
  9. Junio C HamanoJan 6, 2009
  10. Kjetil BarvikJan 6, 2009
  11. 3/4 create_directories() inside entry.c: only check each directory once!Kjetil Barvik, Jan 5, 2009
  12. 4/4 remove the old 'has_symlink_leading_path()' functionKjetil Barvik, Jan 5, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.