lkml.org 
[lkml]   [2010]   [Dec]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[080/289] NFS: Dont SIGBUS if nfs_vm_page_mkwrite races with a cache invalidation
    2.6.36-stable review patch.  If anyone has any objections, please let us know.

    ------------------

    From: Trond Myklebust <Trond.Myklebust@netapp.com>

    commit bc4866b6e0b44f8ea0df22a16e5927714beb4983 upstream.

    In the case where we lock the page, and then find out that the page has
    been thrown out of the page cache, we should just return VM_FAULT_NOPAGE.
    This is what block_page_mkwrite() does in these situations.

    Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

    ---
    fs/nfs/file.c | 17 ++++++++---------
    1 file changed, 8 insertions(+), 9 deletions(-)

    --- a/fs/nfs/file.c
    +++ b/fs/nfs/file.c
    @@ -551,7 +551,7 @@ static int nfs_vm_page_mkwrite(struct vm
    struct file *filp = vma->vm_file;
    struct dentry *dentry = filp->f_path.dentry;
    unsigned pagelen;
    - int ret = -EINVAL;
    + int ret = VM_FAULT_NOPAGE;
    struct address_space *mapping;

    dfprintk(PAGECACHE, "NFS: vm_page_mkwrite(%s/%s(%ld), offset %lld)\n",
    @@ -567,21 +567,20 @@ static int nfs_vm_page_mkwrite(struct vm
    if (mapping != dentry->d_inode->i_mapping)
    goto out_unlock;

    - ret = 0;
    pagelen = nfs_page_length(page);
    if (pagelen == 0)
    goto out_unlock;

    - ret = nfs_flush_incompatible(filp, page);
    - if (ret != 0)
    - goto out_unlock;
    + ret = VM_FAULT_LOCKED;
    + if (nfs_flush_incompatible(filp, page) == 0 &&
    + nfs_updatepage(filp, page, 0, pagelen) == 0)
    + goto out;

    - ret = nfs_updatepage(filp, page, 0, pagelen);
    + ret = VM_FAULT_SIGBUS;
    out_unlock:
    - if (!ret)
    - return VM_FAULT_LOCKED;
    unlock_page(page);
    - return VM_FAULT_SIGBUS;
    +out:
    + return ret;
    }

    static const struct vm_operations_struct nfs_file_vm_ops = {



    \
     
     \ /
      Last update: 2010-12-08 02:49    [W:4.080 / U:21.756 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site