Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-block.git] / fs / nfsd / vfs.h
index c11ba316f23f9b36b6ff57f7d9e5be94a0771962..2d573ec057f801d6406ccf51d21549eb59009a44 100644 (file)
@@ -139,4 +139,23 @@ static inline int nfsd_create_is_exclusive(int createmode)
               || createmode == NFS4_CREATE_EXCLUSIVE4_1;
 }
 
+static inline bool nfsd_eof_on_read(long requested, long read,
+                               loff_t offset, loff_t size)
+{
+       /* We assume a short read means eof: */
+       if (requested > read)
+               return true;
+       /*
+        * A non-short read might also reach end of file.  The spec
+        * still requires us to set eof in that case.
+        *
+        * Further operations may have modified the file size since
+        * the read, so the following check is not atomic with the read.
+        * We've only seen that cause a problem for a client in the case
+        * where the read returned a count of 0 without setting eof.
+        * That case was fixed by the addition of the above check.
+        */
+       return (offset + read >= size);
+}
+
 #endif /* LINUX_NFSD_VFS_H */