From: Frank Ch. Eigler Date: Fri, 30 May 2008 15:25:27 GMT Subject: Re: reducing prune sync()s Message-ID: <20080530152527.GF4032@redhat.com> In-Reply-To: Hi - On Thu, May 29, 2008 at 05:27:35PM -0700, Linus Torvalds wrote: > [...] > > Or perhaps having the blanket sync be replaced a > > list of fsync()s for only the relevant git repository files? > [...] > Soemthing like this *may* work. THIS IS TOTALLY UNTESTED. And when I say > "TOTALLY UNTESTED", I mean it. Zero testing. None. Nada. Zilch. Testing is > for people who are actually interested in the feature (hint, hint). The patch does add an fsync or two into the mix, a "git gc" or "git repack -a" still goes through the "git-repack" shell script, which still did its "sync". How about this patch, which adds a "git-fsync" builtin for the shell scripts? Added to yours, it replaces all the syncs with fsync's, and tests fine in the same environment originally reported. (Lots of dirty data for another filesystem does not block the fsyncs.) diff --git a/.gitignore b/.gitignore index 4ff2fec..708c5ac 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ git-for-each-ref git-format-patch git-fsck git-fsck-objects +git-fsync git-gc git-get-tar-commit-id git-grep diff --git a/Makefile b/Makefile index 865e2bf..2148196 100644 --- a/Makefile +++ b/Makefile @@ -500,6 +500,7 @@ BUILTIN_OBJS += builtin-fetch.o BUILTIN_OBJS += builtin-fmt-merge-msg.o BUILTIN_OBJS += builtin-for-each-ref.o BUILTIN_OBJS += builtin-fsck.o +BUILTIN_OBJS += builtin-fsync.o BUILTIN_OBJS += builtin-gc.o BUILTIN_OBJS += builtin-grep.o BUILTIN_OBJS += builtin-init-db.o diff --git a/builtin-fsync.c b/builtin-fsync.c new file mode 100644 index 0000000..8c4c7f7 --- /dev/null +++ b/builtin-fsync.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2008 Frank Ch. Eigler + */ +#include "cache.h" +#include "commit.h" +#include "tar.h" +#include "builtin.h" +#include "quote.h" + +static const char fsync_usage[] = +"git-fsync ...\n"; + +int cmd_fsync(int argc, const char **argv, const char *prefix) +{ + int i; + for (i=1; i