bug-coreutils
[Top][All Lists]
Advanced

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

dd truncates reads of large block sizes to 2GiB


From: Kent Vander Velden
Subject: dd truncates reads of large block sizes to 2GiB
Date: Wed, 24 Dec 2008 18:16:56 -0600

When a large block size is specified with dd (coreutils 6.12), the read is
truncated at 2GiB (on a x64 Linux 2.6.25 system.) The following examples
show attempts to write 6GiB. The first example attempts to write three 2 GiB
blocks, while the second example attempts to write a single 6 GiB block.
While the first succeeds, the latter only writes 2 GiB. The third example
shows the results from a patched version of dd. A patch is included below
the system information. I tried to follow the example of iwrite() when
patching iread().

Thank you,

Kent A. Vander Velden


/raid|Wed6:04pm 0} ~/coreutils-6.12/src/dd if=/dev/zero of=rrr bs=2G count=3
0+3 records in
0+3 records out
6442438656 bytes (6.4 GB) copied, 14.1874 s, 454 MB/s

/raid|Wed6:05pm 0} ~/coreutils-6.12/src/dd if=/dev/zero of=rrr bs=6G count=1
0+1 records in
0+1 records out
2147479552 bytes (2.1 GB) copied, 4.65884 s, 461 MB/s

/raid|Wed5:58pm 0} ~/coreutils-6.12/src/dd.new if=/dev/zero of=rrr bs=6G
count=1
1+0 records in
1+0 records out
6442450944 bytes (6.4 GB) copied, 320.646 s, 20.1 MB/s

src|Wed5:56pm 0} uname -a
Linux linux-1 2.6.25.18-0.2-default #1 SMP 2008-10-21 16:30:26 +0200 x86_64
x86_64 x86_64 GNU/Linux

src|Wed6:01pm 0} gcc -v
Using built-in specs.
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --with-local-prefix=/usr/local
--infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64
--libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,obj-c++,java,ada
--enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.3
--enable-ssp --disable-libssp
--with-bugurl=http://bugs.opensuse.org/--with-pkgversion='SUSE Linux'
--disable-libgcj --with-slibdir=/lib64
--with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-allocator=new
--disable-libstdcxx-pch --program-suffix=-4.3
--enable-version-specific-runtime-libs --enable-linux-futex
--without-system-libunwind --with-cpu=generic --build=x86_64-suse-linux
Thread model: posix
gcc version 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036]
(SUSE Linux)

src|Wed6:08pm 0} diff dd.c dd_new.c
758c758,760
<   for (;;)
---
>   size_t total_read = 0;
>
>   while (total_read < size)
762,764c764,775
<       nread = read (fd, buf, size);
<       if (! (nread < 0 && errno == EINTR))
<     return nread;
---
>       nread = read (fd, buf + total_read, size - total_read);
>       if (nread < 0)
>         {
>           if (errno != EINTR)
>             break;
>         }
>       else if (nread == 0)
>         {
>           break;
>         }
>       else
>        total_read += nread;
765a777,778
>
>   return total_read;


reply via email to

[Prev in Thread] Current Thread [Next in Thread]