Description of problem : If an NFS client open a file over NFS, and then this file is modified on the server,when read the file on Client,the contents of file is wrong(Client can't get Server's modify). Version-Release number of selected component (if applicable) : RHEL4U5 (kernel-2.6.9-55.EL) nfs-utils-1.0.6-80.EL4 How reproducible : Use the following C program : ---------------------------------------------------------------- #include <stdio.h> #include <fcntl.h> int main() { int fd, ret; char readbuf[1024]=""; char *sfile = "/mnt/testfile"; printf("test start\n"); if ((fd = open(s, O_CREAT|O_TRUNC|O_RDWR ,0700)) < 0) { printf("can't open file\n"); exit(1); } printf("sleeping,please do echo operation on server.\n"); sleep(60); ret = read(fd, readbuf, 1024); printf("read: %s\n",readbuf); close(fd); printf("test end\n"); } ---------------------------------------------------------------- Reproduce Environment : Server: 192.168.1.2 showmount -e : /tmp * Client: 192.168.1.1 Steps to Reproduce : 1. On Client : mount -t nfs4 192.168.1.2:/ /mnt 2. On Client : run above C program 3. On Server : echo teststring >> /tmp/testfile #Do the echo operation while C program sleeping 4. On Client : See the C program execute result Actual Results : read: (NULL) Expected Results : read: teststring Additional info : I have investigated the problem, and found the cause : In nfsv4 occasions,opening a file with write mode calls the function nfs4_proc_file_open(),and nfs4_proc_file_open() will call nfs_begin_data_update() to declare that a set of operations will update file data on the server. After modifying the file at server side, the Client will call nfs_update_inode () to update file properties, but nfs_begin_data_update() has been called while opening the file, which resulted in nfs_update_inode() to race with nfs_end_data_update() while updating file properties, so i_size of inode cannot be updated correctly (Please refer to nfs_update_inode function). If the i_size is not updated, nfs_readpages() will not be called for loading data at server side while the client is reading files (Please refer to __do_page_cache_readahead function) To resolve this problem, I have made the patch for the kernel. After the patch is applied, the problem can be resolved.
Created attachment 244101 [details] The patch for nfs4proc.c of the kernel.
Thanks. Looks similar to a NFSv2/3 patch that we brought in late in the 4.5 update cycle. I'll have a closer look when I get a chance, but looks reasonable at first glance.
I've posted some test kernels with this patch on my people page: http://people.redhat.com/jlayton ..could you test them and confirm that the problem is resolved?
> ..could you test them and confirm that the problem is resolved? I have tested 'kernel-2.6.9-68.EL.jtltest.24.i686.rpm/kernel-2.6.9- 68.EL.jtltest.24.ia64.rpm', and confirmed that the problem is resolved. It is confirmed that the patched can really solve the problem.
Created attachment 282461 [details] Patch for rhel4.6
RHEL4.6 also have this problem. I have make patch for rhel4.6,and confirmed that the patch can fix this problem.
This request was evaluated by Red Hat Product Management for inclusion in a Red Hat Enterprise Linux maintenance release. Product Management has requested further review of this request by Red Hat Engineering, for potential inclusion in a Red Hat Enterprise Linux Update release for currently deployed products. This request is not yet committed for inclusion in an Update release.
Committed in 68.27.EL . RPMS are available at http://people.redhat.com/vgoyal/rhel4/
*** Bug 322871 has been marked as a duplicate of this bug. ***
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on therefore solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHSA-2008-0665.html