{"thread":{"id":"25477","subject":"[BUG] git repack fails if .git/objects/pack is on a separate partition","startedAt":"2010-10-19T06:28:26Z","lastAt":"2010-10-19T16:33:49Z","messageCount":7,"participants":["Marat Radchenko","Thomas Rast","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"153766","messageId":"1287469706023-5649732.post@n2.nabble.com","threadId":"25477","inReplyTo":null,"subject":"[BUG] git repack fails if .git/objects/pack is on a separate partition","fromName":"Marat Radchenko","fromEmail":"marat@slonopotamus.org","sentAt":"2010-10-19T06:28:26Z","receivedAt":"2010-10-19T06:28:26Z","isPatch":false,"sender":{"key":"marat@slonopotamus.org","avatar":"https://avatars.githubusercontent.com/u/92637?v=4"},"body":"\nConsole log:\n\nCounting objects: 5137063, done.\nDelta compression using up to 4 threads.\nCompressing objects: 100% (892984/892984), done.\nfatal: unable to rename temporary pack file: Invalid cross-device link\nerror: failed to run repack\n\nReason:\nwrite_pack_file in builtin/pack-objects.c first writes tmp file in\n\"pack/tmp_pack_XXXXXX\". \n\nThen, it tries to rename it to \"%s-%s.pack\":\n\nsnprintf(tmpname, sizeof(tmpname), \"%s-%s.pack\",\n                                 base_name, sha1_to_hex(sha1));\n...\nif (rename(pack_tmp_name, tmpname))\n                                die_errno(\"unable to rename temporary pack\nfile\");\n\nand happily fails because that crosses device boundary. Same problem with\nindex file. Suggested fix: do those renames inside pack directory or avoid\nthem at all.\n-- \nView this message in context: http://git.661346.n2.nabble.com/BUG-git-repack-fails-if-git-objects-pack-is-on-a-separate-partition-tp5649732p5649732.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"153768","messageId":"201010190859.43098.trast@student.ethz.ch","threadId":"25477","inReplyTo":"1287469706023-5649732.post@n2.nabble.com","subject":"Re: [BUG] git repack fails if .git/objects/pack is on a separate partition","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-10-19T06:59:42Z","receivedAt":"2010-10-19T06:59:42Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Marat Radchenko wrote:\n> fatal: unable to rename temporary pack file: Invalid cross-device link\n> error: failed to run repack\n> \n> Reason:\n> write_pack_file in builtin/pack-objects.c first writes tmp file in\n> \"pack/tmp_pack_XXXXXX\". \n\nWhat's your git version?  Since 8b4eb6b (Do not perform\ncross-directory renames when creating packs, 2008-09-22), which was\nfirst released in 1.6.0.3 and 1.6.1, it should only create and rename\nfiles within the pack/ subdirectory.  Which is what you are implying\nin the above snippet, but this should never result in a cross-device\nrename, so maybe I'm missing something.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"153769","messageId":"1287473363910-5649843.post@n2.nabble.com","threadId":"25477","inReplyTo":"201010190859.43098.trast@student.ethz.ch","subject":"Re: [BUG] git repack fails if .git/objects/pack is on a separate partition","fromName":"Marat Radchenko","fromEmail":"marat@slonopotamus.org","sentAt":"2010-10-19T07:29:23Z","receivedAt":"2010-10-19T07:29:23Z","isPatch":false,"sender":{"key":"marat@slonopotamus.org","avatar":"https://avatars.githubusercontent.com/u/92637?v=4"},"body":"\n\n\n> What's your git version?\n> \n1.7.3.1\n\n\n\n> It should only create and rename\n> files within the pack/ subdirectory.\n> \nIt should, yep, but it doesn't.\n\n\nWhich is what you are implying\n> in the above snippet, but this should never result in a cross-device\n> rename, so maybe I'm missing something.\n> \nThat rename call attempts to put file in _current_ directory.\n\nProof:\nmkdir foo && touch foo/bar && strace mv foo/bar baz 2>&1 | grep rename\noutputs rename(\"foo/bar\", \"baz\")\n\n\n-- \nView this message in context: http://git.661346.n2.nabble.com/BUG-git-repack-fails-if-git-objects-pack-is-on-a-separate-partition-tp5649732p5649843.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"153770","messageId":"1287474040065-5649864.post@n2.nabble.com","threadId":"25477","inReplyTo":"1287473363910-5649843.post@n2.nabble.com","subject":"Re: [BUG] git repack fails if .git/objects/pack is on a separate partition","fromName":"Marat Radchenko","fromEmail":"marat@slonopotamus.org","sentAt":"2010-10-19T07:40:40Z","receivedAt":"2010-10-19T07:40:40Z","isPatch":false,"sender":{"key":"marat@slonopotamus.org","avatar":"https://avatars.githubusercontent.com/u/92637?v=4"},"body":"\nTestcase:\n\n# tell it where is other partition\nOTHER_PARTITION=/path/to/other/partition/\n\n# init repo\nmkdir foo && cd foo && git init\n\n# put some stuff and run gc to create packfile\ncp /etc/fstab . && git add fstab && git commit -m \"initial\" && git gc\n\n# move pack dir to other partition and install symlink\nmv .git/objects/pack $OTHER_PARTITION && ln -s $OTHER_PARTITION/pack\n.git/objects/pack\n\n# run gc (it fails)\nstrace -f git gc 2>&1 | grep rename\n\n[pid  3792] rename(\".git/packed-refs.lock\", \".git/packed-refs\") = 0\n[pid  3793] rename(\".git/logs/refs/heads/master.lock\",\n\".git/logs/refs/heads/master\") = 0\n[pid  3793] rename(\".git/logs/HEAD.lock\", \".git/logs/HEAD\") = 0\n[pid  3808] rename(\".git/objects/pack/tmp_pack_8ZhS92\",\n\"/home/marat/foo/.git/objects/.tmp-3795-pack-da13ceb9f70c2762595a7a2932411db339bdab46.pack\")\n= -1 EXDEV (Invalid cross-device link)\n[pid  3808] write(2, \"fatal: unable to rename temporar\"..., 71fatal: unable\nto rename temporary pack file: Invalid cross-device link\n\nSo you see, it tries to move packfile from .git/objects/pack to .git/objects\n-- \nView this message in context: http://git.661346.n2.nabble.com/BUG-git-repack-fails-if-git-objects-pack-is-on-a-separate-partition-tp5649732p5649864.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"153776","messageId":"cbdf4787ddaccd7105ab1661529a98257d61179b.1287481801.git.trast@student.ethz.ch","threadId":"25477","inReplyTo":"1287474040065-5649864.post@n2.nabble.com","subject":"[PATCH] repack: place temporary packs under .git/objects/pack/","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-10-19T09:50:43Z","receivedAt":"2010-10-19T09:50:43Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"git-pack-objects is already careful to start out its temporary packs\nunder .git/objects/pack/ (cf. 8b4eb6b, Do not perform cross-directory\nrenames when creating packs, 2008-09-22), but git-repack did not\nrespond in kind so the effort was lost when the filesystem boundary is\nexactly at that directory.\n\nLet git-repack pass a path under .git/objects/pack/ as the base for\nits temporary packs.\n\nThis means we might need the $PACKDIR sooner (before the pack-objects\ninvocation), so move the mkdir up just to be safe.\n\nAlso note that the only use of *.pack is in the find invocation way\nbefore the pack-objects call, so the temporary packs will not suddenly\nshow up in any wildcards because of the directory change.\n\nReported-by: Marat Radchenko <marat@slonopotamus.org>\nSigned-off-by: Thomas Rast <trast@student.ethz.ch>\n---\n git-repack.sh |    5 +++--\n 1 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/git-repack.sh b/git-repack.sh\nindex 769baaf..624feec 100755\n--- a/git-repack.sh\n+++ b/git-repack.sh\n@@ -52,7 +52,7 @@ true)\n esac\n \n PACKDIR=\"$GIT_OBJECT_DIRECTORY/pack\"\n-PACKTMP=\"$GIT_OBJECT_DIRECTORY/.tmp-$$-pack\"\n+PACKTMP=\"$PACKDIR/.tmp-$$-pack\"\n rm -f \"$PACKTMP\"-*\n trap 'rm -f \"$PACKTMP\"-*' 0 1 2 3 15\n \n@@ -82,6 +82,8 @@ case \",$all_into_one,\" in\n \t;;\n esac\n \n+mkdir -p \"$PACKDIR\" || exit\n+\n args=\"$args $local ${GIT_QUIET:+-q} $no_reuse$extra\"\n names=$(git pack-objects --keep-true-parents --honor-pack-keep --non-empty --all --reflog $args </dev/null \"$PACKTMP\") ||\n \texit 1\n@@ -90,7 +92,6 @@ if [ -z \"$names\" ]; then\n fi\n \n # Ok we have prepared all new packfiles.\n-mkdir -p \"$PACKDIR\" || exit\n \n # First see if there are packs of the same name and if so\n # if we can move them out of the way (this can happen if we\n-- \n1.7.3.1.271.ged4d2\n"},{"id":"153780","messageId":"1287483456222-5650273.post@n2.nabble.com","threadId":"25477","inReplyTo":"cbdf4787ddaccd7105ab1661529a98257d61179b.1287481801.git.trast@student.ethz.ch","subject":"Re: [PATCH] repack: place temporary packs under .git/objects/pack/","fromName":"Marat Radchenko","fromEmail":"marat@slonopotamus.org","sentAt":"2010-10-19T10:17:36Z","receivedAt":"2010-10-19T10:17:36Z","isPatch":true,"sender":{"key":"marat@slonopotamus.org","avatar":"https://avatars.githubusercontent.com/u/92637?v=4"},"body":"\nEither i'm doing something wrong or given patch doesn't fix testcase [1] i\ngave before. Tested by applying patch to git master and running\n<git_master>/git --exec-path=<git_master> gc\n\n[1]\nhttp://git.661346.n2.nabble.com/BUG-git-repack-fails-if-git-objects-pack-is-on-a-separate-partition-tp5649732p5649864.html\n-- \nView this message in context: http://git.661346.n2.nabble.com/BUG-git-repack-fails-if-git-objects-pack-is-on-a-separate-partition-tp5649732p5650273.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"153796","messageId":"7vocaq16s2.fsf@alter.siamese.dyndns.org","threadId":"25477","inReplyTo":"cbdf4787ddaccd7105ab1661529a98257d61179b.1287481801.git.trast@student.ethz.ch","subject":"Re: [PATCH] repack: place temporary packs under .git/objects/pack/","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-10-19T16:33:49Z","receivedAt":"2010-10-19T16:33:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thomas Rast <trast@student.ethz.ch> writes:\n\n> git-pack-objects is already careful to start out its temporary packs\n> under .git/objects/pack/ (cf. 8b4eb6b, Do not perform cross-directory\n> renames when creating packs, 2008-09-22), but git-repack did not\n> respond in kind so the effort was lost when the filesystem boundary is\n> exactly at that directory.\n>\n> Let git-repack pass a path under .git/objects/pack/ as the base for\n> its temporary packs.\n>\n> This means we might need the $PACKDIR sooner (before the pack-objects\n> invocation), so move the mkdir up just to be safe.\n>\n> Also note that the only use of *.pack is in the find invocation way\n> before the pack-objects call, so the temporary packs will not suddenly\n> show up in any wildcards because of the directory change.\n\nLooks good; thanks.\n"}]}