{"thread":{"id":"24056","subject":"Misterious warning about file system boundaries","startedAt":"2010-06-09T20:21:13Z","lastAt":"2010-06-12T04:24:10Z","messageCount":9,"participants":["Michael J Gruber","Andreas Ericsson","Erik Faye-Lund","Ævar Arnfjörð Bjarmason","Jeff King","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"143370","messageId":"4C0FF7B9.8040007@drmicha.warpmail.net","threadId":"24056","inReplyTo":null,"subject":"Misterious warning about file system boundaries","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-06-09T20:21:13Z","receivedAt":"2010-06-09T20:21:13Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Heya,\n\nnow what is going on here? After upgrading to current next I get\n\nwarning: working tree spans across filesystems but\nGIT_DISCOVERY_ACROSS_FILESYSTEM is not set.\n\nin several repos, such as my local git.git repo. That is certainly on a\nsingle file system only (ext4 over lvm over luks, all on one partition,\nFedora 13). I also get this for another repo, but not for every repo. It\ngoes away when I set the var and comes back when I don't set it, of course.\n\nAlthough I haven't bisected this should be due to\n52b98a7 (write-index: check and warn when worktree crosses a filesystem\nboundary, 2010-04-04).\n\nHow does the code detect a file system boundary, and where could it go\nwrong?\n\nMichael\n"},{"id":"143401","messageId":"4C109C4F.1030809@op5.se","threadId":"24056","inReplyTo":"4C0FF7B9.8040007@drmicha.warpmail.net","subject":"Re: Misterious warning about file system boundaries","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2010-06-10T08:03:27Z","receivedAt":"2010-06-10T08:03:27Z","isPatch":false,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"On 06/09/2010 10:21 PM, Michael J Gruber wrote:\n> Heya,\n> \n> now what is going on here? After upgrading to current next I get\n> \n> warning: working tree spans across filesystems but\n> GIT_DISCOVERY_ACROSS_FILESYSTEM is not set.\n> \n> in several repos, such as my local git.git repo. That is certainly on a\n> single file system only (ext4 over lvm over luks, all on one partition,\n> Fedora 13). I also get this for another repo, but not for every repo. It\n> goes away when I set the var and comes back when I don't set it, of course.\n> \n> Although I haven't bisected this should be due to\n> 52b98a7 (write-index: check and warn when worktree crosses a filesystem\n> boundary, 2010-04-04).\n> \n> How does the code detect a file system boundary, and where could it go\n> wrong?\n> \n\nAccording to the patch, it checks if the device id recorded from stat(2)\nis the same for all files and, if not, warns about it.\n\nIt seems that your interpretation of \"one partition\" differs from that\nreported by the kernel. Why that is so, I have no idea.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n\nConsidering the successes of the wars on alcohol, poverty, drugs and\nterror, I think we should give some serious thought to declaring war\non peace.\n"},{"id":"143405","messageId":"4C10AAC4.90405@drmicha.warpmail.net","threadId":"24056","inReplyTo":"4C109C4F.1030809@op5.se","subject":"Re: Misterious warning about file system boundaries [It's a bug, not a mystery.]","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-06-10T09:05:08Z","receivedAt":"2010-06-10T09:05:08Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Andreas Ericsson venit, vidit, dixit 10.06.2010 10:03:\n> On 06/09/2010 10:21 PM, Michael J Gruber wrote:\n>> Heya,\n>>\n>> now what is going on here? After upgrading to current next I get\n>>\n>> warning: working tree spans across filesystems but\n>> GIT_DISCOVERY_ACROSS_FILESYSTEM is not set.\n>>\n>> in several repos, such as my local git.git repo. That is certainly on a\n>> single file system only (ext4 over lvm over luks, all on one partition,\n>> Fedora 13). I also get this for another repo, but not for every repo. It\n>> goes away when I set the var and comes back when I don't set it, of course.\n>>\n>> Although I haven't bisected this should be due to\n>> 52b98a7 (write-index: check and warn when worktree crosses a filesystem\n>> boundary, 2010-04-04).\n>>\n>> How does the code detect a file system boundary, and where could it go\n>> wrong?\n>>\n> \n> According to the patch, it checks if the device id recorded from stat(2)\n> is the same for all files and, if not, warns about it.\n> \n> It seems that your interpretation of \"one partition\" differs from that\n> reported by the kernel. Why that is so, I have no idea.\n> \n\nI'm sorry, but \"my interpretation\"? WTF? This is all on\n/home/mjg/src/git which has no bind mounts whatsoever.\n\nI actually mixed up my / and /home situation above, /home is even\nsimpler: single ext3 over luks dm device over single \"real\" partition.\nAll of this (except for single ext3 part.) should not matter, of course.\n\nI bisected it just be sure, and it boils down to 9780e62 which is the\ncommit merging 52b98a7 to next.\n\ngit ls-files|xargs stat -c \"%d %D\" |sort|uniq\n\ngives\n\n64772 fd04\n\nwhich is, in particular, 1 device only. Now, here comes funny. After\nchanging write_index() to print the two ce_dev's which differ, i.e.\nprintf(\"%d %d\\n\", ce->ce_dev, cache[first_valid_ent]->ce_dev);\n I have:\n\n./git-status -s|sort|uniq -c\nwarning: working tree spans across filesystems but\nGIT_DISCOVERY_ACROSS_FILESYSTEM is not set.\n    150 64770 64772\n    662 64771 64772\n      1  M read-cache.c\n\nWTF???\n\ngit reset --hard doesn't help this.\n\nrm .git/index && git reset does help.\n\nSo, it seems that nowadays not even \"reset --hard\" refreshes the index\ncompletely. After a reboot your device IDs may change, of course, and\nfiles on the same file system will have different ce_dev values in the\nindex depending on when their index entry was refreshed last.\n\nI really don't know how to fix this (other than by refreshing stat info\nin write_index() before warning). Debugging it was quite an exercise\nalready.\n\nAlso, having git reset --index do the equivalent of \"rm .git/index &&\ngit reset\" might be good to have.\n\nI'm keeping the bad index, btw, so that I can test a possible future fix.\n\nMichael\n"},{"id":"143412","messageId":"AANLkTimwhDGNTMiOaW8_AGGd4PvFtyILEikePdC4zGDo@mail.gmail.com","threadId":"24056","inReplyTo":"4C10AAC4.90405@drmicha.warpmail.net","subject":"Re: Misterious warning about file system boundaries [It's a bug, not a mystery.]","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2010-06-10T09:39:00Z","receivedAt":"2010-06-10T09:39:00Z","isPatch":false,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Thu, Jun 10, 2010 at 11:05 AM, Michael J Gruber\n<git@drmicha.warpmail.net> wrote:\n> Andreas Ericsson venit, vidit, dixit 10.06.2010 10:03:\n>> On 06/09/2010 10:21 PM, Michael J Gruber wrote:\n>>> Heya,\n>>>\n>>> now what is going on here? After upgrading to current next I get\n>>>\n>>> warning: working tree spans across filesystems but\n>>> GIT_DISCOVERY_ACROSS_FILESYSTEM is not set.\n>>>\n>>> in several repos, such as my local git.git repo. That is certainly on a\n>>> single file system only (ext4 over lvm over luks, all on one partition,\n>>> Fedora 13). I also get this for another repo, but not for every repo. It\n>>> goes away when I set the var and comes back when I don't set it, of course.\n>>>\n>>> Although I haven't bisected this should be due to\n>>> 52b98a7 (write-index: check and warn when worktree crosses a filesystem\n>>> boundary, 2010-04-04).\n>>>\n>>> How does the code detect a file system boundary, and where could it go\n>>> wrong?\n>>>\n>>\n>> According to the patch, it checks if the device id recorded from stat(2)\n>> is the same for all files and, if not, warns about it.\n>>\n>> It seems that your interpretation of \"one partition\" differs from that\n>> reported by the kernel. Why that is so, I have no idea.\n>>\n>\n> I'm sorry, but \"my interpretation\"? WTF? This is all on\n> /home/mjg/src/git which has no bind mounts whatsoever.\n>\n> I actually mixed up my / and /home situation above, /home is even\n> simpler: single ext3 over luks dm device over single \"real\" partition.\n> All of this (except for single ext3 part.) should not matter, of course.\n>\n> I bisected it just be sure, and it boils down to 9780e62 which is the\n> commit merging 52b98a7 to next.\n>\n> git ls-files|xargs stat -c \"%d %D\" |sort|uniq\n>\n> gives\n>\n> 64772 fd04\n>\n> which is, in particular, 1 device only. Now, here comes funny. After\n> changing write_index() to print the two ce_dev's which differ, i.e.\n> printf(\"%d %d\\n\", ce->ce_dev, cache[first_valid_ent]->ce_dev);\n>  I have:\n>\n> ./git-status -s|sort|uniq -c\n> warning: working tree spans across filesystems but\n> GIT_DISCOVERY_ACROSS_FILESYSTEM is not set.\n>    150 64770 64772\n>    662 64771 64772\n>      1  M read-cache.c\n>\n> WTF???\n>\n> git reset --hard doesn't help this.\n>\n> rm .git/index && git reset does help.\n>\n<snip>\n>\n> Also, having git reset --index do the equivalent of \"rm .git/index &&\n> git reset\" might be good to have.\n>\n\nDoesn't \"git update-index --refresh\" do the trick?\n\n-- \nErik \"kusma\" Faye-Lund\n"},{"id":"143413","messageId":"4C10C02E.50502@drmicha.warpmail.net","threadId":"24056","inReplyTo":"AANLkTimwhDGNTMiOaW8_AGGd4PvFtyILEikePdC4zGDo@mail.gmail.com","subject":"Re: Misterious warning about file system boundaries [It's a bug, not a mystery.]","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-06-10T10:36:30Z","receivedAt":"2010-06-10T10:36:30Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Erik Faye-Lund venit, vidit, dixit 10.06.2010 11:39:\n> On Thu, Jun 10, 2010 at 11:05 AM, Michael J Gruber\n> <git@drmicha.warpmail.net> wrote:\n>> Andreas Ericsson venit, vidit, dixit 10.06.2010 10:03:\n>>> On 06/09/2010 10:21 PM, Michael J Gruber wrote:\n>>>> Heya,\n>>>>\n>>>> now what is going on here? After upgrading to current next I get\n>>>>\n>>>> warning: working tree spans across filesystems but\n>>>> GIT_DISCOVERY_ACROSS_FILESYSTEM is not set.\n>>>>\n>>>> in several repos, such as my local git.git repo. That is certainly on a\n>>>> single file system only (ext4 over lvm over luks, all on one partition,\n>>>> Fedora 13). I also get this for another repo, but not for every repo. It\n>>>> goes away when I set the var and comes back when I don't set it, of course.\n>>>>\n>>>> Although I haven't bisected this should be due to\n>>>> 52b98a7 (write-index: check and warn when worktree crosses a filesystem\n>>>> boundary, 2010-04-04).\n>>>>\n>>>> How does the code detect a file system boundary, and where could it go\n>>>> wrong?\n>>>>\n>>>\n>>> According to the patch, it checks if the device id recorded from stat(2)\n>>> is the same for all files and, if not, warns about it.\n>>>\n>>> It seems that your interpretation of \"one partition\" differs from that\n>>> reported by the kernel. Why that is so, I have no idea.\n>>>\n>>\n>> I'm sorry, but \"my interpretation\"? WTF? This is all on\n>> /home/mjg/src/git which has no bind mounts whatsoever.\n>>\n>> I actually mixed up my / and /home situation above, /home is even\n>> simpler: single ext3 over luks dm device over single \"real\" partition.\n>> All of this (except for single ext3 part.) should not matter, of course.\n>>\n>> I bisected it just be sure, and it boils down to 9780e62 which is the\n>> commit merging 52b98a7 to next.\n>>\n>> git ls-files|xargs stat -c \"%d %D\" |sort|uniq\n>>\n>> gives\n>>\n>> 64772 fd04\n>>\n>> which is, in particular, 1 device only. Now, here comes funny. After\n>> changing write_index() to print the two ce_dev's which differ, i.e.\n>> printf(\"%d %d\\n\", ce->ce_dev, cache[first_valid_ent]->ce_dev);\n>>  I have:\n>>\n>> ./git-status -s|sort|uniq -c\n>> warning: working tree spans across filesystems but\n>> GIT_DISCOVERY_ACROSS_FILESYSTEM is not set.\n>>    150 64770 64772\n>>    662 64771 64772\n>>      1  M read-cache.c\n>>\n>> WTF???\n>>\n>> git reset --hard doesn't help this.\n>>\n>> rm .git/index && git reset does help.\n>>\n> <snip>\n>>\n>> Also, having git reset --index do the equivalent of \"rm .git/index &&\n>> git reset\" might be good to have.\n>>\n> \n> Doesn't \"git update-index --refresh\" do the trick?\n> \n\nNo.\n\nAnd neither does --really-refresh.\n\nI guess we need --I-really-mean-it-refresh.\n\nIn fact, not even after recompiling with USE_STDEV=y that\n--really-refresh helps which stomps me.But what do I know.\n\nMichael\n"},{"id":"143414","messageId":"AANLkTikle0gxLvKkhr-APkt_6QCB0hVu7bIGm0sRcjVK@mail.gmail.com","threadId":"24056","inReplyTo":"4C10C02E.50502@drmicha.warpmail.net","subject":"Re: Misterious warning about file system boundaries [It's a bug, not a mystery.]","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-06-10T10:52:40Z","receivedAt":"2010-06-10T10:52:40Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Thu, Jun 10, 2010 at 10:36, Michael J Gruber\n<git@drmicha.warpmail.net> wrote:\n> I guess we need --I-really-mean-it-refresh.\n>\n> In fact, not even after recompiling with USE_STDEV=y that\n> --really-refresh helps which stomps me.But what do I know.\n\nThe real problem here is the assumption in 52b98a7 that stat's st_dev\nwill stay the same for a given device, clearly that's not the case on\nLinux if you reboot your machine.\n\nIs there some way of working around that?\n"},{"id":"143416","messageId":"20100610110258.GA17290@coredump.intra.peff.net","threadId":"24056","inReplyTo":"AANLkTikle0gxLvKkhr-APkt_6QCB0hVu7bIGm0sRcjVK@mail.gmail.com","subject":"Re: Misterious warning about file system boundaries [It's a bug, not a mystery.]","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-06-10T11:02:58Z","receivedAt":"2010-06-10T11:02:58Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Jun 10, 2010 at 10:52:40AM +0000, Ævar Arnfjörð Bjarmason wrote:\n\n> On Thu, Jun 10, 2010 at 10:36, Michael J Gruber\n> <git@drmicha.warpmail.net> wrote:\n> > I guess we need --I-really-mean-it-refresh.\n> >\n> > In fact, not even after recompiling with USE_STDEV=y that\n> > --really-refresh helps which stomps me.But what do I know.\n> \n> The real problem here is the assumption in 52b98a7 that stat's st_dev\n> will stay the same for a given device, clearly that's not the case on\n> Linux if you reboot your machine.\n> \n> Is there some way of working around that?\n\nWe could simply drop the warning. The real point of the original patch\nwas to stop cross-device traversal in setup_git_directory, which doesn't\ncare about crossing reboots. I believe the index check and warning are\njust there as an early suggestion. When you actually fail to cross the\ndevice boundary looking for .git in the future, it will complain and\nmention GIT_DISCOVERY_ACROSS_FILESYSTEM then.\n\nSince the early-warning suggestion is generating false positives, and I\ndon't think there is a portable and reliable way around it, dropping it\nmakes sense to me.\n\n-Peff\n"},{"id":"143441","messageId":"7v39wvndl0.fsf@alter.siamese.dyndns.org","threadId":"24056","inReplyTo":"20100610110258.GA17290@coredump.intra.peff.net","subject":"Re: Misterious warning about file system boundaries [It's a bug, not a mystery.]","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-06-10T14:53:47Z","receivedAt":"2010-06-10T14:53:47Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> Since the early-warning suggestion is generating false positives, and I\n> don't think there is a portable and reliable way around it, dropping it\n> makes sense to me.\n\nMakes sense.  Let's make it so (I won't have time to do that myself until\nlate this evening, though).\n\nThanks.\n"},{"id":"143547","messageId":"20100612042410.GA20535@coredump.intra.peff.net","threadId":"24056","inReplyTo":"7v39wvndl0.fsf@alter.siamese.dyndns.org","subject":"Re: Misterious warning about file system boundaries [It's a bug, not a mystery.]","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-06-12T04:24:10Z","receivedAt":"2010-06-12T04:24:10Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Jun 10, 2010 at 07:53:47AM -0700, Junio C Hamano wrote:\n\n> Jeff King <peff@peff.net> writes:\n> \n> > Since the early-warning suggestion is generating false positives, and I\n> > don't think there is a portable and reliable way around it, dropping it\n> > makes sense to me.\n> \n> Makes sense.  Let's make it so (I won't have time to do that myself until\n> late this evening, though).\n> \n> Thanks.\n\nHere it is with a nice commit message (though since it is only in next,\nI guess you can just merge the early part and both 52b98a and my revert\nwill be dropped). It's on top of ld/discovery-limit-to-fs, of course.\n\nNote that it would be possible to do a warning in some instances. We\njust can't trust the on-disk index ce_dev information, so if you\nactually refreshed two cross-filesystem entries we could detect that.\nThat is such a minority case that I doubt it is worth caring about,\nthough.\n\n-- >8 --\nSubject: [PATCH] Revert \"write-index: check and warn when worktree crosses a filesystem boundary\"\n\nThis reverts commit 52b98a7d2f12b5d0dd076221d40f8fa93598e11a.\n\nThe goal of that commit was to warn users early when their\nworktree crossed filesystem boundaries. It worked by\ncomparing the st_dev stat information in the index, and\nwarning when we had more than one device.\n\nHowever, the stat information may come from multiple runs,\nand the st_dev field is not necessarily stable. In\nparticular, st_dev will change on Linux across reboots.\nIndex entries from the previous reboot will appear to come\nfrom a different device, triggering a false positive.\n\nSince this message is really only an early warning for\npeople who will be bit by the new\nGIT_DISCOVERY_ACROSS_FILESYSTEM behavior, and because they\nwill get an actual error later on (when we can't find their\ncross-filesystem .git directory), we can just scrap the\nearly warning.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n read-cache.c |   14 --------------\n 1 files changed, 0 insertions(+), 14 deletions(-)\n\ndiff --git a/read-cache.c b/read-cache.c\nindex e381ea5..f1f789b 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -1550,8 +1550,6 @@ int write_index(struct index_state *istate, int newfd)\n \tstruct cache_entry **cache = istate->cache;\n \tint entries = istate->cache_nr;\n \tstruct stat st;\n-\tint first_valid_ent = -1;\n-\tint more_than_one_dev;\n \n \tfor (i = removed = extended = 0; i < entries; i++) {\n \t\tif (cache[i]->ce_flags & CE_REMOVE)\n@@ -1574,7 +1572,6 @@ int write_index(struct index_state *istate, int newfd)\n \tif (ce_write(&c, newfd, &hdr, sizeof(hdr)) < 0)\n \t\treturn -1;\n \n-\tmore_than_one_dev = 0;\n \tfor (i = 0; i < entries; i++) {\n \t\tstruct cache_entry *ce = cache[i];\n \t\tif (ce->ce_flags & CE_REMOVE)\n@@ -1583,19 +1580,8 @@ int write_index(struct index_state *istate, int newfd)\n \t\t\tce_smudge_racily_clean_entry(ce);\n \t\tif (ce_write_entry(&c, newfd, ce) < 0)\n \t\t\treturn -1;\n-\t\tif (ce_uptodate(ce)) {\n-\t\t\tif (first_valid_ent < 0)\n-\t\t\t\tfirst_valid_ent = i;\n-\t\t\telse if (ce->ce_dev != cache[first_valid_ent]->ce_dev)\n-\t\t\t\tmore_than_one_dev = 1;\n-\t\t}\n \t}\n \n-\tif (more_than_one_dev &&\n-\t    !git_env_bool(\"GIT_DISCOVERY_ACROSS_FILESYSTEM\", 0))\n-\t\twarning(\"working tree spans across filesystems but \"\n-\t\t\t\"GIT_DISCOVERY_ACROSS_FILESYSTEM is not set.\");\n-\n \t/* Write extension data here */\n \tif (istate->cache_tree) {\n \t\tstruct strbuf sb = STRBUF_INIT;\n-- \n1.7.1.516.gd5539.dirty\n"}]}