NFSv4 client's BUG?

Wei Yongjun yjwei at cn.fujitsu.com
Tue Jul 1 06:07:33 EDT 2008


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