NFSv4 client's BUG?
Wei Yongjun
yjwei at cn.fujitsu.com
Tue Jul 1 21:55:16 EDT 2008
J. Bruce Fields wrote:
> On Wed, Jul 02, 2008 at 08:39:16AM +0800, Wei Yongjun wrote:
>
>> Ellard, Daniel wrote:
>>
>>> You're never closing filedes[i], and eventually you're running out of
>>> file descriptors.
>>>
>>> Add
>>>
>>> close(filedes[i]);
>>>
>>> After
>>>
>>> write(filedes[i], "...
>>>
>>>
>> This is not the problem. Because I used ulimit -n 5000 to let program
>> can open 5000 files.
>> The "fopen: Input/output error" may happend when I just open 40 files,
>> it is random.
>>
>
> What's the server? Could you watch the traffic in wireshark and see
> whether the server is returning an error on the failing open?
>
I have tcpdump the packets, there is no error return by the server.
> --b.
>
>
>>
>>> -----Original Message-----
>>> From: Wei Yongjun [mailto:yjwei at cn.fujitsu.com]
>>> Sent: Tuesday, July 01, 2008 6:08 AM
>>> To: nfsv4 at linux-nfs.org
>>> Subject: NFSv4 client's BUG?
>>>
>>> I have the following test program, but when it run, fopen may return
>>> EIO, is this a bug of NFSv4 client?
>>> NFSv4 client is 2.6.26-rc6.
>>>
>>> -------------------------tstfopen.c-------------------------------------
>>>
>>> #include <stdio.h>
>>> #include <error.h>
>>> #include <stdlib.h>
>>> #include <string.h>
>>>
>>> char * fname;
>>> #define TEMPLATE "HighInodeXXXXXX"
>>> int main(int argc, char *argv[]) {
>>> FILE *fp;
>>> char filename[4096];
>>> int filedes[4096];
>>> int i;
>>>
>>> if (argc != 2) {
>>> printf("Usage: %s filename\n", argv[0]);
>>> exit(1);
>>> }
>>>
>>> fname = argv[1];
>>>
>>> for (i = 0; i < 4096; i++) {
>>> if (i % 100 == 0)
>>> printf("i = %d\n", i);
>>>
>>> strcpy(filename, TEMPLATE);
>>> if ((filedes[i] = mkstemp(filename)) == -1) {
>>> perror("mkstemp");
>>> exit(0);
>>> }
>>>
>>> if ((fp = fopen(fname, "w+")) == NULL) {
>>> perror("fopen");
>>> exit(0);
>>> }
>>>
>>> if (fprintf(fp, "this is a test %d\n", i) == 0) {
>>> perror("fprintf");
>>> exit(0);
>>> }
>>>
>>> fclose(fp);
>>> write(filedes[i], "abcdef!!!\n",23);
>>> }
>>>
>>> return 0;
>>> }
>>>
>>>
>>> ---------------------------tstmain.sh------------------------------
>>> umount /mnt
>>> killall /root/tstfopen
>>>
>>> ulimit -n 5000
>>>
>>> mount -t nfs4 NFS4SERVER:/ /mnt
>>>
>>> cd /mnt
>>>
>>> /root/tstfopen debug_file &
>>>
>>> CNT=1
>>> while [ $CNT -lt 1000 ];
>>> do
>>> cat debug_file
>>> TSTR=`cat debug_file`
>>> if [ "$TSTR" = "$LTSTR" ]; then
>>> break
>>> fi
>>> LTSTR=$TSTR
>>> sleep 1
>>> CNT=$((CNT+1))
>>> done
>>>
>>> rm -rf /mnt/*
>>>
>>> cd -
>>>
>>> umount /mnt
>>> -----------------------------------end----------------------------
>>>
>>>
>>> Usage:
>>> #cd /root
>>> #gcc tstfopen.c -o tstfopen
>>> #sh tstmain.sh
>>>
>>> The output may be like this:
>>> i = 0
>>> this is a test 0
>>> this is a test 63
>>> ...
>>> i = 1400
>>> this is a test 1410
>>> this is a test 1415
>>> this is a test 1438
>>> fopen: Input/output error
>>>
>>>
More information about the NFSv4
mailing list