lkml.org 
[lkml]   [1998]   [Dec]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectNFS client write out corrupted file? (with test case)
From
> I wonder if anyone can reproduce the bug I encountered and better nail down
> where the bug is.
>
> I have a x86 2.1.130 kernel acting as a client to a Solaris 2.5.1 NFS
> server. The NFS read and write size are set to 8K. I've also tried 4K write
> size but it makes no difference. I've also gone back to 2.1.129 and
> 2.1.131ac11, same result.
>
> The symptom is when I compile a large source tree (C++ source but I don't
> think it matters), one or more of the object files contain junk. Local
> compilation works fine which makes me suspect the NFS client
> code. Compiling on another machine with 2.0.36 kernel and the same NFS
> server is fine as well.

Base on the strace output of a gas run that generates a corrupted file, I
wrote the attached test program to repeat the same sequence of lseek and
write. I'm able to reproduce the error with the Solaris 2.5.1 server.

Compare the hex dump of the correct and the corrupted file, I find that
the only region that is different is 0004d00-0004fff. The data in this
region seems to be shifted by 3 bytes! This corresponds to the first part of
the 1520 bytes written in the last write system call.

The bad news is I can only reproduce this bug on one file system on the NFS
server but not another one. In fact, I cannot reproduce the error on other
NFS file server. It looks like a timing dependent bug.

Hope this information is helpful.

Regards,
Sai-Lai


Here is the test program:
------------------------------
/* gcc -O bug bug.c */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <assert.h>

int
main(int argc, char** argv)
{
int fd;
unsigned char* buf;
int i;


buf = (char*) malloc(4096);
for (i=0; i<4096; i++) {
buf[i] = i % 256;
}

if ((fd = open("dump",O_CREAT|O_RDWR)) < 0) {
fprintf(stderr, "Cannot open file\n");
return 1;
}

assert(lseek(fd,24144,SEEK_SET) == 24144);

assert(write(fd,buf,4096) == 4096);

assert(write(fd,buf, 1024) == 1024);

assert(lseek(fd, 52, SEEK_SET) == 52);

assert(write(fd,buf,4096) == 4096);

assert(write(fd,buf,4096) == 4096);

assert(write(fd,buf,4096) == 4096);

assert(write(fd,buf, 592) == 592);

assert(lseek(fd, 12960, SEEK_SET) == 12960);

assert(write(fd,buf, 3126) == 3126);

assert(lseek(fd, 16088, SEEK_SET) == 16088);

assert(write(fd,buf, 10) == 10);

assert(lseek(fd, 16100, SEEK_SET) == 16100);

assert(write(fd,buf, 10) == 10);

assert(lseek(fd, 16112, SEEK_SET) == 16112);

assert(write(fd,buf, 10) == 10);

assert(lseek(fd, 16124, SEEK_SET) == 16124);

assert(write(fd,buf,10) == 10);

assert(lseek(fd, 16136, SEEK_SET) == 16136);

assert(write(fd,buf, 22) == 22);

assert(lseek(fd, 16160, SEEK_SET) == 16160);

assert(write(fd,buf, 54) == 54);

assert(lseek(fd, 16216, SEEK_SET) == 16216);

assert(write(fd,buf, 22) == 22);

assert(lseek(fd, 16240, SEEK_SET) == 16240);

assert(write(fd,buf, 65) == 65);

assert(lseek(fd, 16308, SEEK_SET) == 16308);

assert(write(fd,buf, 50) == 50);

assert(lseek(fd, 16360, SEEK_SET) == 16360);

assert(write(fd,buf, 2095) == 2095);

assert(lseek(fd, 29264, SEEK_SET) == 29264);

assert(write(fd,buf, 4096) == 4096);

assert(write(fd,buf, 2648) == 2648);

assert(lseek(fd, 21232, SEEK_SET) == 21232);

assert(write(fd,buf, 2912) == 2912);

assert(lseek(fd, 18455, SEEK_SET) == 18455);

assert(write(fd,buf, 1257) == 1257);

assert(lseek(fd, 0, SEEK_SET) == 0);

assert(write(fd,buf, 52) == 52);

assert(lseek(fd, 19712, SEEK_SET) == 19712);

assert(write(fd,buf, 1520) == 1520);

close(fd);

return 0;

}
------------------------------------------
Here is the hexdump of the region where the corrupted file differs from
the correct one:

> 0004d00 0000 0000 0201 0403 0605 0807 0a09 0c0b
> 0004d10 0e0d 100f 1211 1413 1615 1817 1a19 1c1b
> 0004d20 1e1d 201f 2221 2423 2625 2827 2a29 2c2b
> 0004d30 2e2d 302f 3231 3433 3635 3837 3a39 3c3b
> 0004d40 3e3d 403f 4241 4443 4645 4847 4a49 4c4b
> 0004d50 4e4d 504f 5251 5453 5655 5857 5a59 5c5b
> 0004d60 5e5d 605f 6261 6463 6665 6867 6a69 6c6b
> 0004d70 6e6d 706f 7271 7473 7675 7877 7a79 7c7b
> 0004d80 7e7d 807f 8281 8483 8685 8887 8a89 8c8b
> 0004d90 8e8d 908f 9291 9493 9695 9897 9a99 9c9b
> 0004da0 9e9d a09f a2a1 a4a3 a6a5 a8a7 aaa9 acab
> 0004db0 aead b0af b2b1 b4b3 b6b5 b8b7 bab9 bcbb
> 0004dc0 bebd c0bf c2c1 c4c3 c6c5 c8c7 cac9 cccb
> 0004dd0 cecd d0cf d2d1 d4d3 d6d5 d8d7 dad9 dcdb
> 0004de0 dedd e0df e2e1 e4e3 e6e5 e8e7 eae9 eceb
> 0004df0 eeed f0ef f2f1 f4f3 f6f5 f8f7 faf9 fcfb
> 0004e00 fefd 00ff 0201 0403 0605 0807 0a09 0c0b
> 0004e10 0e0d 100f 1211 1413 1615 1817 1a19 1c1b
> 0004e20 1e1d 201f 2221 2423 2625 2827 2a29 2c2b
> 0004e30 2e2d 302f 3231 3433 3635 3837 3a39 3c3b
> 0004e40 3e3d 403f 4241 4443 4645 4847 4a49 4c4b
> 0004e50 4e4d 504f 5251 5453 5655 5857 5a59 5c5b
> 0004e60 5e5d 605f 6261 6463 6665 6867 6a69 6c6b
> 0004e70 6e6d 706f 7271 7473 7675 7877 7a79 7c7b
> 0004e80 7e7d 807f 8281 8483 8685 8887 8a89 8c8b
> 0004e90 8e8d 908f 9291 9493 9695 9897 9a99 9c9b
> 0004ea0 9e9d a09f a2a1 a4a3 a6a5 a8a7 aaa9 acab
> 0004eb0 aead b0af b2b1 b4b3 b6b5 b8b7 bab9 bcbb
> 0004ec0 bebd c0bf c2c1 c4c3 c6c5 c8c7 cac9 cccb
> 0004ed0 cecd d0cf d2d1 d4d3 d6d5 d8d7 dad9 dcdb
> 0004ee0 dedd e0df e2e1 e4e3 e6e5 e8e7 eae9 eceb
> 0004ef0 eeed f0ef f2f1 f4f3 f6f5 f8f7 faf9 fcfb
> 0004f00 fefd 00ff 0201 0403 0605 0807 0a09 0c0b
> 0004f10 0e0d 100f 1211 1413 1615 1817 1a19 1c1b
> 0004f20 1e1d 201f 2221 2423 2625 2827 2a29 2c2b
> 0004f30 2e2d 302f 3231 3433 3635 3837 3a39 3c3b
> 0004f40 3e3d 403f 4241 4443 4645 4847 4a49 4c4b
> 0004f50 4e4d 504f 5251 5453 5655 5857 5a59 5c5b
> 0004f60 5e5d 605f 6261 6463 6665 6867 6a69 6c6b
> 0004f70 6e6d 706f 7271 7473 7675 7877 7a79 7c7b
> 0004f80 7e7d 807f 8281 8483 8685 8887 8a89 8c8b
> 0004f90 8e8d 908f 9291 9493 9695 9897 9a99 9c9b
> 0004fa0 9e9d a09f a2a1 a4a3 a6a5 a8a7 aaa9 acab
> 0004fb0 aead b0af b2b1 b4b3 b6b5 b8b7 bab9 bcbb
> 0004fc0 bebd c0bf c2c1 c4c3 c6c5 c8c7 cac9 cccb
> 0004fd0 cecd d0cf d2d1 d4d3 d6d5 d8d7 dad9 dcdb
> 0004fe0 dedd e0df e2e1 e4e3 e6e5 e8e7 eae9 eceb
> 0004ff0 eeed f0ef f2f1 f4f3 f6f5 f8f7 faf9 fcfb

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:46    [W:0.043 / U:0.312 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site