]> git.neil.brown.name Git - history.git/commitdiff
NFSv2: Fix up NFSv2 reads so that they report when the server returned a short
authorTrond Myklebust <trond.myklebust@fys.uio.no>
Sat, 13 Mar 2004 17:00:15 +0000 (12:00 -0500)
committerTrond Myklebust <trond.myklebust@fys.uio.no>
Sat, 13 Mar 2004 17:00:15 +0000 (12:00 -0500)
       read due to EOF.

fs/nfs/proc.c
fs/nfs/read.c

index 3c974c3677905182d13876d2a8f033d91ba57b61..ca4eccd03adf0b47318dd1e653611b5d5df2bc88 100644 (file)
@@ -186,8 +186,14 @@ nfs_proc_read(struct nfs_read_data *rdata, struct file *filp)
        msg.rpc_cred = nfs_cred(inode, filp);
        status = rpc_call_sync(NFS_CLIENT(inode), &msg, flags);
 
-       if (status >= 0)
+       if (status >= 0) {
                nfs_refresh_inode(inode, fattr);
+               /* Emulate the eof flag, which isn't normally needed in NFSv2
+                * as it is guaranteed to always return the file attributes
+                */
+               if (rdata->args.offset + rdata->args.count >= fattr->size)
+                       rdata->res.eof = 1;
+       }
        dprintk("NFS reply read: %d\n", status);
        return status;
 }
@@ -541,8 +547,14 @@ nfs_read_done(struct rpc_task *task)
 {
        struct nfs_read_data *data = (struct nfs_read_data *) task->tk_calldata;
 
-       if (task->tk_status >= 0)
+       if (task->tk_status >= 0) {
                nfs_refresh_inode(data->inode, data->res.fattr);
+               /* Emulate the eof flag, which isn't normally needed in NFSv2
+                * as it is guaranteed to always return the file attributes
+                */
+               if (data->args.offset + data->args.count >= data->res.fattr->size)
+                       data->res.eof = 1;
+       }
        nfs_readpage_result(task);
 }
 
index 0aab44507ef5b2c55ce9198e655ed3740d3616cd..4b929887c5a4cd109bc7635c1c3c514b0d07e833 100644 (file)
@@ -121,7 +121,10 @@ nfs_readpage_sync(struct file *file, struct inode *inode, struct page *page)
                }
                count -= result;
                rdata.args.pgbase += result;
-               if (result < rdata.args.count)  /* NFSv2ism */
+               /* Note: result == 0 should only happen if we're caching
+                * a write that extends the file and punches a hole.
+                */
+               if (rdata.res.eof != 0 || result == 0)
                        break;
        } while (count);
        NFS_FLAGS(inode) |= NFS_INO_INVALID_ATIME;