reftable: fix tests being broken by NFS' delete-after-close semantics

It was reported that the reftable unit tests in t0032 fail with the
following assertion when running on top of NFS:

    running test_reftable_stack_compaction_concurrent_clean
    reftable/stack_test.c: 1063: failed assertion count_dir_entries(dir) == 2
    Aborted

Setting a breakpoint immediately before the assertion in fact shows the
following list of files:

    ./stack_test-1027.QJBpnd
    ./stack_test-1027.QJBpnd/0x000000000001-0x000000000003-dad7ac80.ref
    ./stack_test-1027.QJBpnd/.nfs000000000001729f00001e11
    ./stack_test-1027.QJBpnd/tables.list

Note the weird ".nfs*" file? This file is maintained by NFS clients in
order to emulate delete-after-last-close semantics that we rely on in
the reftable code [1]. Instead of unlinking the file right away and
keeping it open in the client, the NFS client will rename it to ".nfs*"
and then delete that temporary file when the last reference to it gets
dropped. Quoting the NFS FAQ:

    > D2. What is a "silly rename"? Why do these .nfsXXXXX files keep
    > showing up?
    >
    > A. Unix applications often open a scratch file and then unlink it.
    > They do this so that the file is not visible in the file system name
    > space to any other applications, and so that the system will
    > automatically clean up (delete) the file when the application exits.
    > This is known as "delete on last close", and is a tradition among
    > Unix applications.
    >
    > Because of the design of the NFS protocol, there is no way for a
    > file to be deleted from the name space but still remain in use by an
    > application. Thus NFS clients have to emulate this using what
    > already exists in the protocol. If an open file is unlinked, an NFS
    > client renames it to a special name that looks like ".nfsXXXXX".
    > This "hides" the file while it remains in use. This is known as a
    > "silly rename." Note that NFS servers have nothing to do with this
    > behavior.

This of course throws off the assertion that we got exactly two files in
that directory.

The test in question triggers this behaviour by holding two open file
descriptors to the "tables.list" file. One of the references is because
we are about to append to the stack, whereas the other reference is
because we want to compact it. As the compaction has just finished we
already rewrote "tables.list" to point to the new contents, but the
other file descriptor pointing to the old version is still open. Thus we
trigger the delete-after-last-close emulation.

Furthermore, it was reported that this behaviour only triggers with
4f36b8597c (reftable/stack: fix race in up-to-date check, 2024-01-18).
This is expected as well because it is the first point in time where we
actually keep the "tables.list" file descriptor open for the stat cache.

Fix this bug by skipping over any files that start with a leading dot
when counting files. While we could explicitly check for a prefix of
".nfs", other network file systems like SMB for example do the same
trickery but with a ".smb" prefix. In any case though, this loosening of
the assertion should be fine given that the reftable library would never
write files with leading dots by itself.

[1]: https://nfs.sourceforge.net/#faq_d2

Reported-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 file changed
tree: 124dc5f73d06b1d009dc6c3852a424f8f8abb7c0
  1. .github/
  2. block-sha1/
  3. builtin/
  4. ci/
  5. compat/
  6. contrib/
  7. Documentation/
  8. ewah/
  9. git-gui/
  10. gitk-git/
  11. gitweb/
  12. mergetools/
  13. negotiator/
  14. oss-fuzz/
  15. perl/
  16. po/
  17. refs/
  18. reftable/
  19. sha1/
  20. sha1dc/
  21. sha256/
  22. t/
  23. templates/
  24. trace2/
  25. xdiff/
  26. .cirrus.yml
  27. .clang-format
  28. .editorconfig
  29. .gitattributes
  30. .gitignore
  31. .gitlab-ci.yml
  32. .gitmodules
  33. .mailmap
  34. .tsan-suppressions
  35. abspath.c
  36. abspath.h
  37. aclocal.m4
  38. add-interactive.c
  39. add-interactive.h
  40. add-patch.c
  41. advice.c
  42. advice.h
  43. alias.c
  44. alias.h
  45. alloc.c
  46. alloc.h
  47. apply.c
  48. apply.h
  49. archive-tar.c
  50. archive-zip.c
  51. archive.c
  52. archive.h
  53. attr.c
  54. attr.h
  55. banned.h
  56. base85.c
  57. base85.h
  58. bisect.c
  59. bisect.h
  60. blame.c
  61. blame.h
  62. blob.c
  63. blob.h
  64. bloom.c
  65. bloom.h
  66. branch.c
  67. branch.h
  68. builtin.h
  69. bulk-checkin.c
  70. bulk-checkin.h
  71. bundle-uri.c
  72. bundle-uri.h
  73. bundle.c
  74. bundle.h
  75. cache-tree.c
  76. cache-tree.h
  77. cbtree.c
  78. cbtree.h
  79. chdir-notify.c
  80. chdir-notify.h
  81. check-builtins.sh
  82. checkout.c
  83. checkout.h
  84. chunk-format.c
  85. chunk-format.h
  86. CODE_OF_CONDUCT.md
  87. color.c
  88. color.h
  89. column.c
  90. column.h
  91. combine-diff.c
  92. command-list.txt
  93. commit-graph.c
  94. commit-graph.h
  95. commit-reach.c
  96. commit-reach.h
  97. commit-slab-decl.h
  98. commit-slab-impl.h
  99. commit-slab.h
  100. commit.c
  101. commit.h
  102. common-main.c
  103. config.c
  104. config.h
  105. config.mak.dev
  106. config.mak.in
  107. config.mak.uname
  108. configure.ac
  109. connect.c
  110. connect.h
  111. connected.c
  112. connected.h
  113. convert.c
  114. convert.h
  115. copy.c
  116. copy.h
  117. COPYING
  118. credential.c
  119. credential.h
  120. csum-file.c
  121. csum-file.h
  122. ctype.c
  123. daemon.c
  124. date.c
  125. date.h
  126. decorate.c
  127. decorate.h
  128. delta-islands.c
  129. delta-islands.h
  130. delta.h
  131. detect-compiler
  132. diagnose.c
  133. diagnose.h
  134. diff-delta.c
  135. diff-lib.c
  136. diff-merges.c
  137. diff-merges.h
  138. diff-no-index.c
  139. diff.c
  140. diff.h
  141. diffcore-break.c
  142. diffcore-delta.c
  143. diffcore-order.c
  144. diffcore-pickaxe.c
  145. diffcore-rename.c
  146. diffcore-rotate.c
  147. diffcore.h
  148. dir-iterator.c
  149. dir-iterator.h
  150. dir.c
  151. dir.h
  152. editor.c
  153. editor.h
  154. entry.c
  155. entry.h
  156. environment.c
  157. environment.h
  158. exec-cmd.c
  159. exec-cmd.h
  160. fetch-negotiator.c
  161. fetch-negotiator.h
  162. fetch-pack.c
  163. fetch-pack.h
  164. fmt-merge-msg.c
  165. fmt-merge-msg.h
  166. fsck.c
  167. fsck.h
  168. fsmonitor--daemon.h
  169. fsmonitor-ipc.c
  170. fsmonitor-ipc.h
  171. fsmonitor-ll.h
  172. fsmonitor-path-utils.h
  173. fsmonitor-settings.c
  174. fsmonitor-settings.h
  175. fsmonitor.c
  176. fsmonitor.h
  177. generate-cmdlist.sh
  178. generate-configlist.sh
  179. generate-hooklist.sh
  180. gettext.c
  181. gettext.h
  182. git-archimport.perl
  183. git-compat-util.h
  184. git-curl-compat.h
  185. git-cvsexportcommit.perl
  186. git-cvsimport.perl
  187. git-cvsserver.perl
  188. git-difftool--helper.sh
  189. git-filter-branch.sh
  190. git-instaweb.sh
  191. git-merge-octopus.sh
  192. git-merge-one-file.sh
  193. git-merge-resolve.sh
  194. git-mergetool--lib.sh
  195. git-mergetool.sh
  196. git-p4.py
  197. git-quiltimport.sh
  198. git-request-pull.sh
  199. git-send-email.perl
  200. git-sh-i18n.sh
  201. git-sh-setup.sh
  202. git-submodule.sh
  203. git-svn.perl
  204. GIT-VERSION-GEN
  205. git-web--browse.sh
  206. git-zlib.c
  207. git-zlib.h
  208. git.c
  209. git.rc
  210. gpg-interface.c
  211. gpg-interface.h
  212. graph.c
  213. graph.h
  214. grep.c
  215. grep.h
  216. hash-ll.h
  217. hash-lookup.c
  218. hash-lookup.h
  219. hash.h
  220. hashmap.c
  221. hashmap.h
  222. help.c
  223. help.h
  224. hex-ll.c
  225. hex-ll.h
  226. hex.c
  227. hex.h
  228. hook.c
  229. hook.h
  230. http-backend.c
  231. http-fetch.c
  232. http-push.c
  233. http-walker.c
  234. http.c
  235. http.h
  236. ident.c
  237. ident.h
  238. imap-send.c
  239. INSTALL
  240. iterator.h
  241. json-writer.c
  242. json-writer.h
  243. khash.h
  244. kwset.c
  245. kwset.h
  246. levenshtein.c
  247. levenshtein.h
  248. LGPL-2.1
  249. line-log.c
  250. line-log.h
  251. line-range.c
  252. line-range.h
  253. linear-assignment.c
  254. linear-assignment.h
  255. list-objects-filter-options.c
  256. list-objects-filter-options.h
  257. list-objects-filter.c
  258. list-objects-filter.h
  259. list-objects.c
  260. list-objects.h
  261. list.h
  262. lockfile.c
  263. lockfile.h
  264. log-tree.c
  265. log-tree.h
  266. ls-refs.c
  267. ls-refs.h
  268. mailinfo.c
  269. mailinfo.h
  270. mailmap.c
  271. mailmap.h
  272. Makefile
  273. match-trees.c
  274. match-trees.h
  275. mem-pool.c
  276. mem-pool.h
  277. merge-blobs.c
  278. merge-blobs.h
  279. merge-ll.c
  280. merge-ll.h
  281. merge-ort-wrappers.c
  282. merge-ort-wrappers.h
  283. merge-ort.c
  284. merge-ort.h
  285. merge-recursive.c
  286. merge-recursive.h
  287. merge.c
  288. merge.h
  289. mergesort.h
  290. midx.c
  291. midx.h
  292. name-hash.c
  293. name-hash.h
  294. notes-cache.c
  295. notes-cache.h
  296. notes-merge.c
  297. notes-merge.h
  298. notes-utils.c
  299. notes-utils.h
  300. notes.c
  301. notes.h
  302. object-file.c
  303. object-file.h
  304. object-name.c
  305. object-name.h
  306. object-store-ll.h
  307. object-store.h
  308. object.c
  309. object.h
  310. oid-array.c
  311. oid-array.h
  312. oidmap.c
  313. oidmap.h
  314. oidset.c
  315. oidset.h
  316. oidtree.c
  317. oidtree.h
  318. pack-bitmap-write.c
  319. pack-bitmap.c
  320. pack-bitmap.h
  321. pack-check.c
  322. pack-mtimes.c
  323. pack-mtimes.h
  324. pack-objects.c
  325. pack-objects.h
  326. pack-revindex.c
  327. pack-revindex.h
  328. pack-write.c
  329. pack.h
  330. packfile.c
  331. packfile.h
  332. pager.c
  333. pager.h
  334. parallel-checkout.c
  335. parallel-checkout.h
  336. parse-options-cb.c
  337. parse-options.c
  338. parse-options.h
  339. parse.c
  340. parse.h
  341. patch-delta.c
  342. patch-ids.c
  343. patch-ids.h
  344. path.c
  345. path.h
  346. pathspec.c
  347. pathspec.h
  348. pkt-line.c
  349. pkt-line.h
  350. preload-index.c
  351. preload-index.h
  352. pretty.c
  353. pretty.h
  354. prio-queue.c
  355. prio-queue.h
  356. progress.c
  357. progress.h
  358. promisor-remote.c
  359. promisor-remote.h
  360. prompt.c
  361. prompt.h
  362. protocol-caps.c
  363. protocol-caps.h
  364. protocol.c
  365. protocol.h
  366. prune-packed.c
  367. prune-packed.h
  368. quote.c
  369. quote.h
  370. range-diff.c
  371. range-diff.h
  372. reachable.c
  373. reachable.h
  374. read-cache-ll.h
  375. read-cache.c
  376. read-cache.h
  377. README.md
  378. rebase-interactive.c
  379. rebase-interactive.h
  380. rebase.c
  381. rebase.h
  382. ref-filter.c
  383. ref-filter.h
  384. reflog-walk.c
  385. reflog-walk.h
  386. reflog.c
  387. reflog.h
  388. refs.c
  389. refs.h
  390. refspec.c
  391. refspec.h
  392. remote-curl.c
  393. remote.c
  394. remote.h
  395. replace-object.c
  396. replace-object.h
  397. repo-settings.c
  398. repository.c
  399. repository.h
  400. rerere.c
  401. rerere.h
  402. reset.c
  403. reset.h
  404. resolve-undo.c
  405. resolve-undo.h
  406. revision.c
  407. revision.h
  408. run-command.c
  409. run-command.h
  410. sane-ctype.h
  411. scalar.c
  412. SECURITY.md
  413. send-pack.c
  414. send-pack.h
  415. sequencer.c
  416. sequencer.h
  417. serve.c
  418. serve.h
  419. server-info.c
  420. server-info.h
  421. setup.c
  422. setup.h
  423. sh-i18n--envsubst.c
  424. sha1dc_git.c
  425. sha1dc_git.h
  426. shallow.c
  427. shallow.h
  428. shared.mak
  429. shell.c
  430. shortlog.h
  431. sideband.c
  432. sideband.h
  433. sigchain.c
  434. sigchain.h
  435. simple-ipc.h
  436. sparse-index.c
  437. sparse-index.h
  438. split-index.c
  439. split-index.h
  440. stable-qsort.c
  441. statinfo.c
  442. statinfo.h
  443. strbuf.c
  444. strbuf.h
  445. streaming.c
  446. streaming.h
  447. string-list.c
  448. string-list.h
  449. strmap.c
  450. strmap.h
  451. strvec.c
  452. strvec.h
  453. sub-process.c
  454. sub-process.h
  455. submodule-config.c
  456. submodule-config.h
  457. submodule.c
  458. submodule.h
  459. symlinks.c
  460. symlinks.h
  461. tag.c
  462. tag.h
  463. tar.h
  464. tempfile.c
  465. tempfile.h
  466. thread-utils.c
  467. thread-utils.h
  468. tmp-objdir.c
  469. tmp-objdir.h
  470. trace.c
  471. trace.h
  472. trace2.c
  473. trace2.h
  474. trailer.c
  475. trailer.h
  476. transport-helper.c
  477. transport-internal.h
  478. transport.c
  479. transport.h
  480. tree-diff.c
  481. tree-walk.c
  482. tree-walk.h
  483. tree.c
  484. tree.h
  485. unicode-width.h
  486. unimplemented.sh
  487. unix-socket.c
  488. unix-socket.h
  489. unix-stream-server.c
  490. unix-stream-server.h
  491. unpack-trees.c
  492. unpack-trees.h
  493. upload-pack.c
  494. upload-pack.h
  495. url.c
  496. url.h
  497. urlmatch.c
  498. urlmatch.h
  499. usage.c
  500. userdiff.c
  501. userdiff.h
  502. utf8.c
  503. utf8.h
  504. varint.c
  505. varint.h
  506. version.c
  507. version.h
  508. versioncmp.c
  509. versioncmp.h
  510. walker.c
  511. walker.h
  512. wildmatch.c
  513. wildmatch.h
  514. worktree.c
  515. worktree.h
  516. wrap-for-bin.sh
  517. wrapper.c
  518. wrapper.h
  519. write-or-die.c
  520. write-or-die.h
  521. ws.c
  522. ws.h
  523. wt-status.c
  524. wt-status.h
  525. xdiff-interface.c
  526. xdiff-interface.h
README.md

Build status

Git - fast, scalable, distributed revision control system

Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.

Git is an Open Source project covered by the GNU General Public License version 2 (some parts of it are under different licenses, compatible with the GPLv2). It was originally written by Linus Torvalds with help of a group of hackers around the net.

Please read the file INSTALL for installation instructions.

Many Git online resources are accessible from https://git-scm.com/ including full documentation and Git related tools.

See Documentation/gittutorial.txt to get started, then see Documentation/giteveryday.txt for a useful minimum set of commands, and Documentation/git-<commandname>.txt for documentation of each command. If git has been correctly installed, then the tutorial can also be read with man gittutorial or git help tutorial, and the documentation of each command with man git-<commandname> or git help <commandname>.

CVS users may also want to read Documentation/gitcvs-migration.txt (man gitcvs-migration or git help cvs-migration if git is installed).

The user discussion and development of Git take place on the Git mailing list -- everyone is welcome to post bug reports, feature requests, comments and patches to git@vger.kernel.org (read Documentation/SubmittingPatches for instructions on patch submission and Documentation/CodingGuidelines).

Those wishing to help with error message, usage and informational message string translations (localization l10) should see po/README.md (a po file is a Portable Object file that holds the translations).

To subscribe to the list, send an email to git+subscribe@vger.kernel.org (see https://subspace.kernel.org/subscribing.html for details). The mailing list archives are available at https://lore.kernel.org/git/, https://marc.info/?l=git and other archival sites.

Issues which are security relevant should be disclosed privately to the Git Security mailing list git-security@googlegroups.com.

The maintainer frequently sends the “What's cooking” reports that list the current status of various development topics to the mailing list. The discussion following them give a good reference for project status, development direction and remaining tasks.

The name “git” was given by Linus Torvalds when he wrote the very first version. He described the tool as “the stupid content tracker” and the name as (depending on your mood):

  • random three-letter combination that is pronounceable, and not actually used by any common UNIX command. The fact that it is a mispronunciation of “get” may or may not be relevant.
  • stupid. contemptible and despicable. simple. Take your pick from the dictionary of slang.
  • “global information tracker”: you're in a good mood, and it actually works for you. Angels sing, and a light suddenly fills the room.
  • “goddamn idiotic truckload of sh*t”: when it breaks