@matheusbsbs / matheus-bagliano / commits / c8b296450e
Fork 0

Fix checkout of large files to network shares on Windows XP

Bigger writes to network drives on Windows XP fail. Cap them at 31MB to allow them to succeed. Callers need to be prepared for write() calls that do less work than requested anyway. On local drives, write() calls are translated to WriteFile() calls with a cap of 64KB on Windows XP and 256KB on Vista. Thus a cap of 31MB won't affect the number of WriteFile() calls which do the actual work. There's still room for some other version of Windows to use a chunk size of 1MB without increasing the number of system calls. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed May 20, 2010 at 20:57 UTC c8b296450e5148c576697ea4709072b7855aacd5
3 files changed +29 -3
compat/mingw.c
+17
@@ -140,6 +140,23 @@ int mingw_open (const char *filename, int oflags, ...)
140 return fd;
141 }
142
143 +#undef write
144 +ssize_t mingw_write(int fd, const void *buf, size_t count)
145 +{
146 + /*
147 + * While write() calls to a file on a local disk are translated
148 + * into WriteFile() calls with a maximum size of 64KB on Windows
149 + * XP and 256KB on Vista, no such cap is placed on writes to
150 + * files over the network on Windows XP. Unfortunately, there
151 + * seems to be a limit of 32MB-28KB on X64 and 64MB-32KB on x86;
152 + * bigger writes fail on Windows XP.
153 + * So we cap to a nice 31MB here to avoid write failures over
154 + * the net without changing the number of WriteFile() calls in
155 + * the local case.
156 + */
157 + return write(fd, buf, min(count, 31 * 1024 * 1024));
158 +}
159 +
160 #undef fopen
161 FILE *mingw_fopen (const char *filename, const char *otype)
162 {
compat/mingw.h
+3
@@ -170,6 +170,9 @@ int link(const char *oldpath, const char *newpath);
170 int mingw_open (const char *filename, int oflags, ...);
171 #define open mingw_open
172
173 +ssize_t mingw_write(int fd, const void *buf, size_t count);
174 +#define write mingw_write
175 +
176 FILE *mingw_fopen (const char *filename, const char *otype);
177 #define fopen mingw_fopen
178
t/t5705-clone-2gb.sh
+9 -3
@@ -12,7 +12,7 @@ test_expect_success 'setup' '
12
13 git config pack.compression 0 &&
14 git config pack.depth 0 &&
15 - blobsize=$((20*1024*1024)) &&
15 + blobsize=$((100*1024*1024)) &&
16 blobcount=$((2*1024*1024*1024/$blobsize+1)) &&
17 i=1 &&
18 (while test $i -le $blobcount
@@ -36,9 +36,15 @@ test_expect_success 'setup' '
36
37 '
38
39 -test_expect_success 'clone' '
39 +test_expect_success 'clone - bare' '
40
41 - git clone --bare --no-hardlinks . clone
41 + git clone --bare --no-hardlinks . clone-bare
42 +
43 +'
44 +
45 +test_expect_success 'clone - with worktree, file:// protocol' '
46 +
47 + git clone file://. clone-wt
48
49 '
50