[CIFS] lseek polling returned stale EOF
authorSteve French <sfrench@us.ibm.com>
Thu, 1 Feb 2007 04:27:59 +0000 (04:27 +0000)
committerSteve French <sfrench@us.ibm.com>
Thu, 1 Feb 2007 04:27:59 +0000 (04:27 +0000)
Fixes Samba bug 4362

Discovered by Jeremy Allison

Clipper database polls on EOF via lseek and can get stale EOF
when file is open on different client

Signed-off-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Steve French <sfrench@us.ibm.com>
fs/cifs/cifsfs.c

index 10c90294cd1821c9fd273f688c50f6f85889d4cd..93ef09971d2fafb9f92ecd0eed6034c9661f1192 100644 (file)
@@ -511,7 +511,15 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin)
 {
        /* origin == SEEK_END => we must revalidate the cached file length */
        if (origin == SEEK_END) {
-               int retval = cifs_revalidate(file->f_path.dentry);
+               int retval;
+
+               /* some applications poll for the file length in this strange
+                  way so we must seek to end on non-oplocked files by
+                  setting the revalidate time to zero */
+               if(file->f_path.dentry->d_inode)                
+                       CIFS_I(file->f_path.dentry->d_inode)->time = 0;
+
+               retval = cifs_revalidate(file->f_path.dentry);
                if (retval < 0)
                        return (loff_t)retval;
        }