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

[PATCH v2 2/3] object-file: don't special-case missing source file in collision check

From
Patrick Steinhardt <ps@pks.im>
Date
Jan 6, 2025, 09:24 UTC
Message-ID
<20250106-b4-pks-object-file-racy-collision-check-v2-2-8b3984ecbb18@pks.im>
In-Reply-To
<20250106-b4-pks-object-file-racy-collision-check-v2-0-8b3984ecbb18@pks.im>

In 0ad3d65652 (object-file: fix race in object collision check, 2024-12-30) we have started to ignore ENOENT when opening either the source or destination file of the collision check. This was done to handle races more gracefully in case either of the potentially-colliding disappears.

The fix is overly broad though: while the destination file may indeed vanish racily, this shouldn't ever happen for the source file, which is a temporary object file (either loose or in packfile format) that we have just created. So if any concurrent process would have removed that temporary file it would indicate an actual issue.

Stop treating ENOENT specially for the source file so that we always bubble up this error.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 object-file.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/object-file.c b/object-file.c
index e1989236ca87e565dea4d003f57882f257889ecf..acfda5e303659195109c94f5b54b8a081fe92c59 100644
--- a/object-file.c
+++ b/object-file.c
@@ -1978,8 +1978,7 @@ static int check_collision(const char *source, const char *dest)
 
 	fd_source = open(source, O_RDONLY);
 	if (fd_source < 0) {
-		if (errno != ENOENT)
-			ret = error_errno(_("unable to open %s"), source);
+		ret = error_errno(_("unable to open %s"), source);
 		goto out;
 	}
 
-- 
2.48.0.rc1.245.gb3e6e7acbc.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 15 of 16 in “object-file: retry linking file into place when occluding file vanishes”
  1. 0/2 object-file: retry linking file into place when occluding file vanishesPatrick Steinhardt, Jan 3, 2025
  2. 1/2 object-file: rename variables in `check_collision()`Patrick Steinhardt, Jan 3, 2025
  3. Jeff KingJan 3, 2025
  4. 2/2 object-file: retry linking file into place when occluding file vanishesPatrick Steinhardt, Jan 3, 2025
  5. Junio C HamanoJan 3, 2025
  6. Jeff KingJan 3, 2025
  7. Jeff KingJan 3, 2025
  8. Junio C HamanoJan 3, 2025
  9. Patrick SteinhardtJan 6, 2025
  10. Jeff KingJan 7, 2025
  11. Junio C HamanoJan 3, 2025
  12. Patrick SteinhardtJan 6, 2025
  13. 0/3 object-file: retry linking file into place when occluding file vanishesPatrick Steinhardt, Jan 6, 2025
  14. 1/3 object-file: rename variables in `check_collision()`Patrick Steinhardt, Jan 6, 2025
  15. 2/3 object-file: don't special-case missing source file in collision checkPatrick Steinhardt, Jan 6, 2025
  16. 3/3 object-file: retry linking file into place when occluding file vanishesPatrick Steinhardt, Jan 6, 2025

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.