nfs: don't create zero-length requests
authorBenjamin Coddington <bcodding@redhat.com>
Mon, 18 Jul 2016 14:41:57 +0000 (10:41 -0400)
committerBen Hutchings <ben@decadent.org.uk>
Sun, 20 Nov 2016 01:01:28 +0000 (01:01 +0000)
commit 149a4fddd0a72d526abbeac0c8deaab03559836a upstream.

NFS doesn't expect requests with wb_bytes set to zero and may make
unexpected decisions about how to handle that request at the page IO layer.
Skip request creation if we won't have any wb_bytes in the request.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Reviewed-by: Weston Andros Adamson <dros@primarydata.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
fs/nfs/write.c

index 301391a..fccc545 100644 (file)
@@ -747,6 +747,9 @@ int nfs_updatepage(struct file *file, struct page *page,
                file->f_path.dentry->d_name.name, count,
                (long long)(page_offset(page) + offset));
 
+       if (!count)
+               goto out;
+
        /* If we're not using byte range locks, and we know the page
         * is up to date, it may be more efficient to extend the write
         * to cover the entire page in order to avoid fragmentation
@@ -764,7 +767,7 @@ int nfs_updatepage(struct file *file, struct page *page,
                nfs_set_pageerror(page);
        else
                __set_page_dirty_nobuffers(page);
-
+out:
        dprintk("NFS:       nfs_updatepage returns %d (isize %lld)\n",
                        status, (long long)i_size_read(inode));
        return status;