Fix index preloading for racy dirty case

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




In the threaded index preloading case, we must be sure to always use the 
CE_MATCH_RACY_IS_DIRTY flag when calling ie_match_stat(), in order to make 
sure that we only ever look at the stat() data, and don't try to do 
anything fancy.

Because most of git internals are not thread-safe, and must not be called 
in parallel.

Otherwise, what happens is that if the timestamps indicate that an entry 
_might_ be dirty, we might start actually comparing filesystem data with 
the object database. And we mustn't do that, because that would involve
looking up and creating the object structure, and that whole code sequence 
with read_sha1_file() where we look up and add objects to the hashes is 
definitely not thread-safe.

Nor do we want to add locking, because the whole point of the preload was 
to be simple and not affect anything else. With CE_MATCH_RACY_IS_DIRTY, we 
get what we wanted, and we'll just leave the hard cases well alone, to be 
done later in the much simpler serial case.

Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
---

On Mon, 17 Nov 2008, Linus Torvalds wrote:
> 
> Oh, damn. I had forgotten that check_fs() doesn't just do a "lstat()" any 
> more. You're right.

Never mind the "any more". I don't think it ever did.

But I do think that this is trivially fixed, and I should have thought 
about it. And while I didn't reproduce your SIGSEGV, I think this trivial 
patch should fix it.

Sorry about the mindfart.

 preload-index.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/preload-index.c b/preload-index.c
index 3ce42e0..a6a6bdb 100644
--- a/preload-index.c
+++ b/preload-index.c
@@ -43,7 +43,7 @@ static void *preload_thread(void *_data)
 			continue;
 		if (lstat(ce->name, &st))
 			continue;
-		if (ie_match_stat(index, ce, &st, 0))
+		if (ie_match_stat(index, ce, &st, CE_MATCH_RACY_IS_DIRTY))
 			continue;
 		ce_mark_uptodate(ce);
 	} while (--nr > 0);
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux