From ec73f5807cd6e6f6d55e716cde80637a1019d67d Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Thu, 24 Oct 2013 14:01:47 -0400 Subject: sha1_file: export `git_open_noatime` The `git_open_noatime` helper can be of general interest for other consumers of git's different on-disk formats. Signed-off-by: Vicent Marti Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- sha1_file.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sha1_file.c') diff --git a/sha1_file.c b/sha1_file.c index f80bbe4674..4714bd8671 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -239,8 +239,6 @@ char *sha1_pack_index_name(const unsigned char *sha1) struct alternate_object_database *alt_odb_list; static struct alternate_object_database **alt_odb_tail; -static int git_open_noatime(const char *name); - /* * Prepare alternate object database registry. * @@ -1357,7 +1355,7 @@ int check_sha1_signature(const unsigned char *sha1, void *map, return hashcmp(sha1, real_sha1) ? -1 : 0; } -static int git_open_noatime(const char *name) +int git_open_noatime(const char *name) { static int sha1_file_open_flag = O_NOATIME; -- cgit v1.2.3 From d3d3e4c490c83daeba61ac1f2be5da2396f7411c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sat, 21 Dec 2013 09:00:34 -0500 Subject: count-objects: recognize .bitmap in garbage-checking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Count-objects will report any "garbage" files in the packs directory, including files whose extensions it does not know (case 1), and files whose matching ".pack" file is missing (case 2). Without having learned about ".bitmap" files, the current code reports all such files as garbage (case 1), even if their pack exists. Instead, they should be treated as case 2. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- sha1_file.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sha1_file.c') diff --git a/sha1_file.c b/sha1_file.c index 4714bd8671..129496250c 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1194,6 +1194,7 @@ static void prepare_packed_git_one(char *objdir, int local) if (has_extension(de->d_name, ".idx") || has_extension(de->d_name, ".pack") || + has_extension(de->d_name, ".bitmap") || has_extension(de->d_name, ".keep")) string_list_append(&garbage, path); else -- cgit v1.2.3 From 1a6d8b91489ad4a7b7d267b46a3e838b004157f1 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 15 Jan 2014 06:17:48 -0500 Subject: do not discard revindex when re-preparing packfiles When an object lookup fails, we re-read the objects/pack directory to pick up any new packfiles that may have been created since our last read. We also discard any pack revindex structs we've allocated. The discarding is a problem for the pack-bitmap code, which keeps a pointer to the revindex for the bitmapped pack. After the discard, the pointer is invalid, and we may read free()d memory. Other revindex users do not keep a bare pointer to the revindex; instead, they always access it through revindex_for_pack(), which lazily builds the revindex. So one solution is to teach the pack-bitmap code a similar trick. It would be slightly less efficient, but probably not all that noticeable. However, it turns out this discarding is not actually necessary. When we call reprepare_packed_git, we do not throw away our old pack list. We keep the existing entries, and only add in new ones. So there is no safety problem; we will still have the pack struct that matches each revindex. The packfile itself may go away, of course, but we are already prepared to handle that, and it may happen outside of reprepare_packed_git anyway. Throwing away the revindex may save some RAM if the pack never gets reused (about 12 bytes per object). But it also wastes some CPU time (to regenerate the index) if the pack does get reused. It's hard to say which is more valuable, but in either case, it happens very rarely (only when we race with a simultaneous repack). Just leaving the revindex in place is simple and safe both for current and future code. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- sha1_file.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sha1_file.c') diff --git a/sha1_file.c b/sha1_file.c index 129496250c..36d55c05f7 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1279,7 +1279,6 @@ void prepare_packed_git(void) void reprepare_packed_git(void) { - discard_revindex(); prepare_packed_git_run_once = 0; prepare_packed_git(); } -- cgit v1.2.3