This service will be undergoing maintenance at 00:00 UTC, 2016-09-28. It is expected to last about 1 hours
Bug 359651 - [PATCH] nfsv4 fails to update content of files when open for write
[PATCH] nfsv4 fails to update content of files when open for write
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: kernel (Show other bugs)
4.5
All Linux
low Severity high
: ---
: ---
Assigned To: Jeff Layton
Martin Jenner
:
: 322871 (view as bug list)
Depends On:
Blocks: 430698
  Show dependency treegraph
 
Reported: 2007-10-31 01:29 EDT by jiangguiqing
Modified: 2008-07-24 15:19 EDT (History)
3 users (show)

See Also:
Fixed In Version: RHSA-2008-0665
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-07-24 15:19:02 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
The patch for nfs4proc.c of the kernel. (694 bytes, patch)
2007-10-31 01:29 EDT, jiangguiqing
no flags Details | Diff
Patch for rhel4.6 (694 bytes, patch)
2007-12-09 22:47 EST, jiangguiqing
no flags Details | Diff

  None (edit)
Description jiangguiqing 2007-10-31 01:29:21 EDT
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.
Comment 1 jiangguiqing 2007-10-31 01:29:21 EDT
Created attachment 244101 [details]
The patch for nfs4proc.c of the kernel.
Comment 2 Jeff Layton 2007-11-13 13:50:09 EST
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.
Comment 3 Jeff Layton 2007-11-19 20:30:19 EST
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?
Comment 4 jiangguiqing 2007-11-20 04:09:55 EST
> ..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. 
Comment 5 jiangguiqing 2007-12-09 22:47:41 EST
Created attachment 282461 [details]
Patch for rhel4.6
Comment 6 jiangguiqing 2007-12-09 22:49:58 EST
RHEL4.6 also have this problem.
I have make patch for rhel4.6,and confirmed that the patch can fix this problem.
Comment 8 RHEL Product and Program Management 2008-01-02 11:05:56 EST
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.
Comment 10 Vivek Goyal 2008-03-27 19:22:59 EDT
Committed in 68.27.EL . RPMS are available at http://people.redhat.com/vgoyal/rhel4/
Comment 12 Jeff Layton 2008-04-29 09:10:44 EDT
*** Bug 322871 has been marked as a duplicate of this bug. ***
Comment 15 errata-xmlrpc 2008-07-24 15:19:02 EDT
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

Note You need to log in before you can comment on or make changes to this bug.