]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
cifs: fix broken oplock handling
authorSuresh Jayaraman <sjayaraman@suse.de>
Fri, 17 Sep 2010 13:26:39 +0000 (18:56 +0530)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 22 Nov 2010 18:59:45 +0000 (10:59 -0800)
commit aa91c7e4ab9b0842b7d7a7cbf8cca18b20df89b5 upstream.

cifs_new_fileinfo() does not use the 'oplock' value from the callers. Instead,
it sets it to REQ_OPLOCK which seems wrong. We should be using the oplock value
obtained from the Server to set the inode's clientCanCacheAll or
clientCanCacheRead flags. Fix this by passing oplock from the callers to
cifs_new_fileinfo().

This change dates back to commit a6ce4932 (2.6.30-rc3). So, all the affected
versions will need this fix. Please Cc stable once reviewed and accepted.

Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/cifs/cifsproto.h
fs/cifs/dir.c
fs/cifs/file.c

index fb6318b81509801a218d8a2248542e427b9516ce..4c54a8b3da5b62e4a3706e1df55bce0325f76792 100644 (file)
@@ -104,7 +104,8 @@ extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time,
 
 extern struct cifsFileInfo *cifs_new_fileinfo(struct inode *newinode,
                                __u16 fileHandle, struct file *file,
-                               struct vfsmount *mnt, unsigned int oflags);
+                               struct vfsmount *mnt, unsigned int oflags,
+                               __u32 oplock);
 extern int cifs_posix_open(char *full_path, struct inode **pinode,
                                struct super_block *sb,
                                int mode, int oflags,
index e7ae78b66fa15b89162b18a12d76c90f48b8b508..9c338780fbabbe2d3db1f6ab8a13b9b7cd3e77e8 100644 (file)
@@ -138,9 +138,9 @@ cifs_bp_rename_retry:
  */
 struct cifsFileInfo *
 cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle,
-                 struct file *file, struct vfsmount *mnt, unsigned int oflags)
+                 struct file *file, struct vfsmount *mnt, unsigned int oflags,
+                 __u32 oplock)
 {
-       int oplock = 0;
        struct cifsFileInfo *pCifsFile;
        struct cifsInodeInfo *pCifsInode;
        struct cifs_sb_info *cifs_sb = CIFS_SB(mnt->mnt_sb);
@@ -149,9 +149,6 @@ cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle,
        if (pCifsFile == NULL)
                return pCifsFile;
 
-       if (oplockEnabled)
-               oplock = REQ_OPLOCK;
-
        pCifsFile->netfid = fileHandle;
        pCifsFile->pid = current->tgid;
        pCifsFile->pInode = igrab(newinode);
@@ -476,7 +473,7 @@ cifs_create_set_dentry:
                }
 
                pfile_info = cifs_new_fileinfo(newinode, fileHandle, filp,
-                                              nd->path.mnt, oflags);
+                                              nd->path.mnt, oflags, oplock);
                if (pfile_info == NULL) {
                        fput(filp);
                        CIFSSMBClose(xid, tcon, fileHandle);
@@ -738,7 +735,8 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
 
                        cfile = cifs_new_fileinfo(newInode, fileHandle, filp,
                                                  nd->path.mnt,
-                                                 nd->intent.open.flags);
+                                                 nd->intent.open.flags,
+                                                 oplock);
                        if (cfile == NULL) {
                                fput(filp);
                                CIFSSMBClose(xid, pTcon, fileHandle);
index 409e4f523e61e56aae0e1b892c2a9021ebe3728d..de2e6c42e2439fc90525f21a970859c807317290 100644 (file)
@@ -277,7 +277,7 @@ int cifs_open(struct inode *inode, struct file *file)
 
                        pCifsFile = cifs_new_fileinfo(inode, netfid, file,
                                                        file->f_path.mnt,
-                                                       oflags);
+                                                       oflags, oplock);
                        if (pCifsFile == NULL) {
                                CIFSSMBClose(xid, tcon, netfid);
                                rc = -ENOMEM;
@@ -367,7 +367,7 @@ int cifs_open(struct inode *inode, struct file *file)
                goto out;
 
        pCifsFile = cifs_new_fileinfo(inode, netfid, file, file->f_path.mnt,
-                                       file->f_flags);
+                                       file->f_flags, oplock);
        if (pCifsFile == NULL) {
                rc = -ENOMEM;
                goto out;