Skip to contentSkip to conversation

cifs: fix revalidation test in cifs_llseek()

PATCH Superseded Dan Carpenter 5 participants 6 messages Apr 19, 2012 – Apr 30, 2012 2 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: fix revalidation test in cifs_llseek()

This test is always true so it means we revalidate the length every time, which generates more network traffic. This was introduced in 06222e491e "fs: handle SEEK_HOLE/SEEK_DATA properly in all fs's that define their own llseek".

---
Josef, there were three other places that had this same problem but I think they've all been fixed now. Except that I had a question about nfs_file_llseek(). Isn't that reversed? It seems like it only revalidates when it's not supposed to. I chose to copy what fuse_file_llseek() does instead.

fs/cifs/cifsfs.c +1 -1
index d342128..97d26c7 100644
@@ -695,7 +695,7 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin)
 	 * origin = SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate
 	 * the cached file length
 	 */
-	if (origin != SEEK_SET || origin != SEEK_CUR) {
+	if (origin = SEEK_SET || origin = SEEK_CUR) {
 		int rc;
 		struct inode *inode = file->f_path.dentry->d_inode;
 
#2 lore raw
In reply to a message not in the archive

20 ÁĞÒÅÌÑ 2012šÇ. 1:06 ĞÏÌØÚÏ×ÁÔÅÌØ Dan Carpenter
<[email protected]> ÎÁĞÉÓÁÌ:

Quoted 18 lines

This test is always true so it means we revalidate the length every time, which generates more network traffic. šThis was introduced in 06222e491e "fs: handle SEEK_HOLE/SEEK_DATA properly in all fs's that define their own llseek".

---
Josef, there were three other places that had this same problem but I think they've all been fixed now. šExcept that I had a question about nfs_file_llseek(). šIsn't that reversed? šIt seems like it only revalidates when it's not supposed to. šI chose to copy what fuse_file_llseek() does instead.

fs/cifs/cifsfs.c +0 -0
index d342128..97d26c7 100644
@@ -695,7 +695,7 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin)
Quoted 8 lines

š š š š * origin = SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate š š š š * the cached file length
š š š š */
- š š š if (origin != SEEK_SET || origin != SEEK_CUR) {
+ š š š if (origin = SEEK_SET || origin = SEEK_CUR) {
š š š š š š š šint rc;
š š š š š š š šstruct inode *inode = file->f_path.dentry->d_inode;

In this case the semantic contradict the comment above. May be it should be "if (origin != SEEK_SET && origin != SEEK_CUR)"?

Signature · 6 lines
Best regards,
Pavel Shilovsky.
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw
In reply to a message not in the archive

Could you please unscribe me from this list

-----Original Message-----
From: samba-technical-bounces-w/[email protected] [mailto:samba-technical-bounces-w/[email protected]] On Behalf Of Pavel Shilovsky
Sent: Friday, April 27, 2012 6:29 PM
To: Dan Carpenter
Cc: Steve French; [email protected]; kernel-janitors-u79uwXL29Tb/[email protected]; samba-technical-w/[email protected]; Josef Bacik
Subject: Re: [patch] cifs: fix revalidation test in cifs_llseek()

20 апреля 2012 г. 1:06 пользователь Dan Carpenter <[email protected]> написал:

Quoted 18 lines

This test is always true so it means we revalidate the length every time, which generates more network traffic. This was introduced in 06222e491e "fs: handle SEEK_HOLE/SEEK_DATA properly in all fs's that define their own llseek".

---
Josef, there were three other places that had this same problem but I think they've all been fixed now. Except that I had a question about nfs_file_llseek(). Isn't that reversed? It seems like it only revalidates when it's not supposed to. I chose to copy what fuse_file_llseek() does instead.

fs/cifs/cifsfs.c +0 -0
index d342128..97d26c7 100644

fs/cifs/cifsfs.c static loff_t cifs_llseek(struct file *file, loff_t offset, int origin) · line 701

Quoted 8 lines
fs/cifs/cifsfs.c +1 -1
@@ -695,7 +695,7 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin)
        * origin == SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate
        * the cached file length
        */
-       if (origin != SEEK_SET || origin != SEEK_CUR) {
+       if (origin == SEEK_SET || origin == SEEK_CUR) {
               int rc;
               struct inode *inode = file->f_path.dentry->d_inode;
 

In this case the semantic contradict the comment above. May be it should be "if (origin != SEEK_SET && origin != SEEK_CUR)"?

--
Best regards,
Pavel Shilovsky.

::DISCLAIMER::
-----------------------------------------------------------------------------------------------------------------------

The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses.The e mail and its contents (with or without referred errors) shall therefore not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, Modification, distribution and/or publication of this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately. Before opening any mail and attachments please check them for viruses and defect.

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

#5 lore raw
In reply to Pavel Shilovsky
Quoted 15 lines · On Fri, 27 Apr 2012 16:59:07 +0400 Pavel Shilovsky <[email protected]> wrote:

20 апреля 2012 г. 1:06 пользователь Dan Carpenter
<[email protected]> написал:

Quoted 13 lines

This test is always true so it means we revalidate the length every time, which generates more network traffic.  This was introduced in 06222e491e "fs: handle SEEK_HOLE/SEEK_DATA properly in all fs's that define their own llseek".

---
Josef, there were three other places that had this same problem but I think they've all been fixed now.  Except that I had a question about nfs_file_llseek().  Isn't that reversed?  It seems like it only revalidates when it's not supposed to.  I chose to copy what fuse_file_llseek() does instead.

Quoted 17 lines

fs/cifs/cifsfs.c static loff_t cifs_llseek(struct file *file, loff_t offset, int origin) · line 701

Quoted 13 lines
fs/cifs/cifsfs.c +1 -1
index d342128..97d26c7 100644
@@ -695,7 +695,7 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin)
         * origin = SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate
         * the cached file length
         */
-       if (origin != SEEK_SET || origin != SEEK_CUR) {
+       if (origin = SEEK_SET || origin = SEEK_CUR) {
                int rc;
                struct inode *inode = file->f_path.dentry->d_inode;
 

In this case the semantic contradict the comment above. May be it should be "if (origin != SEEK_SET && origin != SEEK_CUR)"?

Agreed, I think Pavel is correct here. The stuff inside the if block revalidates the file size, and we only need to do that if whence is not SEEK_SET or SEEK_CUR.

Signature · 1 line
Jeff Layton <[email protected]>
#6 lore raw

PATCH v2 1/1 cifs: fix revalidation test in cifs_llseek()

In reply to Pavel Shilovsky

This test is always true so it means we revalidate the length every time, which generates more network traffic. When it is SEEK_SET or SEEK_CUR, then we don't need to revalidate.

---
v2: I had the test reversed in the first version.

fs/cifs/cifsfs.c +1 -1
index 811245b..4a6ad20 100644
@@ -699,7 +699,7 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin)
 	 * origin = SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate
 	 * the cached file length
 	 */
-	if (origin != SEEK_SET || origin != SEEK_CUR) {
+	if (origin != SEEK_SET && origin != SEEK_CUR) {
 		int rc;
 		struct inode *inode = file->f_path.dentry->d_inode;
 
Reviewed-by on v2 1/1
#7 lore raw
Quoted 13 lines · On Mon, 30 Apr 2012 17:36:21 +0300 Dan Carpenter <[email protected]>…

This test is always true so it means we revalidate the length every time, which generates more network traffic. When it is SEEK_SET or SEEK_CUR, then we don't need to revalidate.

---
v2: I had the test reversed in the first version.

fs/cifs/cifsfs.c +0 -0
index 811245b..4a6ad20 100644

fs/cifs/cifsfs.c static loff_t cifs_llseek(struct file *file, loff_t offset, int origin) · line 705

Quoted 8 lines
fs/cifs/cifsfs.c +1 -1
@@ -699,7 +699,7 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin)
 	 * origin = SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate
 	 * the cached file length
 	 */
-	if (origin != SEEK_SET || origin != SEEK_CUR) {
+	if (origin != SEEK_SET && origin != SEEK_CUR) {
 		int rc;
 		struct inode *inode = file->f_path.dentry->d_inode;
 

Looks good.