git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 4/5] fsck: three levels of validation
Date: Fri, 30 Jan 2009 03:05:16 -0800	[thread overview]
Message-ID: <1233313517-24208-5-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1233313517-24208-4-git-send-email-gitster@pobox.com>

Traditionally, "git fsck" only checked loose objects and "git fsck --full"
checked both loose and packed objects fully.

This introduces a new medium level of validation that checks loose objects
and runs the quicker packfile validation introduced earlier (in other
words, the individual objects in packfiles are not validated, but we still
make sure that the packfiles themselves are sound and individual objects
pass their own CRC checks when the pack has version 2 idx file), and makes
this new mode the default.  The original "loose objects only" mode can be
asked with --quick option.

In my private git project repository (almost fully packed but with may
dangling objects) on my AMD 64X2:

    $ /usr/bin/time ./git-fsck --quick
    0.18user 0.02system 0:00.20elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
    0inputs+0outputs (0major+3205minor)pagefaults 0swaps

    $ /usr/bin/time ./git-fsck
    68.61user 0.43system 1:09.06elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
    0inputs+0outputs (0major+116707minor)pagefaults 0swaps

    $ /usr/bin/time ./git-fsck --full
    90.36user 0.61system 1:31.00elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
    0inputs+0outputs (0major+169641minor)pagefaults 0swaps

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin-fsck.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/builtin-fsck.c b/builtin-fsck.c
index 8dc7881..72bf33b 100644
--- a/builtin-fsck.c
+++ b/builtin-fsck.c
@@ -20,6 +20,7 @@ static int show_tags;
 static int show_unreachable;
 static int include_reflogs = 1;
 static int check_full;
+static int check_quick;
 static int check_strict;
 static int keep_cache_objects;
 static unsigned char head_sha1[20];
@@ -576,7 +577,8 @@ static struct option fsck_opts[] = {
 	OPT_BOOLEAN(0, "root", &show_root, "report root nodes"),
 	OPT_BOOLEAN(0, "cache", &keep_cache_objects, "make index objects head nodes"),
 	OPT_BOOLEAN(0, "reflogs", &include_reflogs, "make reflogs head nodes (default)"),
-	OPT_BOOLEAN(0, "full", &check_full, "also consider alternate objects"),
+	OPT_BOOLEAN(0, "full", &check_full, "fully check packs"),
+	OPT_BOOLEAN(0, "quick", &check_quick, "only check loose objects"),
 	OPT_BOOLEAN(0, "strict", &check_strict, "enable more strict checking"),
 	OPT_BOOLEAN(0, "lost-found", &write_lost_and_found,
 				"write dangling objects in .git/lost-found"),
@@ -587,10 +589,14 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
 {
 	int i, heads;
 	struct alternate_object_database *alt;
+	unsigned verify_pack_flag;
 
 	errors_found = 0;
 
 	argc = parse_options(argc, argv, fsck_opts, fsck_usage, 0);
+	if (check_full && check_quick)
+		die("--full and --quick?  which one do you want?");
+
 	if (write_lost_and_found) {
 		check_full = 1;
 		include_reflogs = 0;
@@ -608,13 +614,14 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
 		fsck_object_dir(namebuf);
 	}
 
-	if (check_full) {
+	if (!check_quick) {
 		struct packed_git *p;
 
+		verify_pack_flag = check_full ? 0 : VERIFY_PACK_QUICK;
 		prepare_packed_git();
 		for (p = packed_git; p; p = p->next)
 			/* verify gives error messages itself */
-			verify_pack(p, 0);
+			verify_pack(p, verify_pack_flag);
 
 		for (p = packed_git; p; p = p->next) {
 			uint32_t j, num;
-- 
1.6.1.2.312.g5be3c

  reply	other threads:[~2009-01-30 11:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-30 11:05 [PATCH 0/5] fsck updates Junio C Hamano
2009-01-30 11:05 ` [PATCH 1/5] pack-check.c: minor formatting fix to match coding style Junio C Hamano
2009-01-30 11:05   ` [PATCH 2/5] verify_pack(): allow a quicker verification for a pack with version 2 idx Junio C Hamano
2009-01-30 11:05     ` [PATCH 3/5] verify-pack: add --quick Junio C Hamano
2009-01-30 11:05       ` Junio C Hamano [this message]
2009-01-30 11:05         ` [PATCH 5/5] [squash] fsck: revert --quick to the default and introduce --medium Junio C Hamano
2009-01-30 11:37           ` Kjetil Barvik
2009-01-31 21:45   ` [PATCH 1/5] pack-check.c: minor formatting fix to match coding style Nanako Shiraishi
2009-01-31 22:00     ` Marius Storm-Olsen
2009-02-01  0:52       ` Nanako Shiraishi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1233313517-24208-5-git-send-email-gitster@pobox.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).