Skip to content

Commit aa91c7e

Browse files
Suresh JayaramanSteve French
authored andcommitted
cifs: fix broken oplock handling
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 a6ce493 (2.6.30-rc3). So, all the affected versions will need this fix. Please Cc stable once reviewed and accepted. Cc: Stable <stable@kernel.org> Reviewed-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de> Signed-off-by: Steve French <sfrench@us.ibm.com>
1 parent a347ecb commit aa91c7e

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

fs/cifs/cifsproto.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time,
107107

108108
extern struct cifsFileInfo *cifs_new_fileinfo(struct inode *newinode,
109109
__u16 fileHandle, struct file *file,
110-
struct vfsmount *mnt, unsigned int oflags);
110+
struct vfsmount *mnt, unsigned int oflags,
111+
__u32 oplock);
111112
extern int cifs_posix_open(char *full_path, struct inode **pinode,
112113
struct super_block *sb,
113114
int mode, int oflags,

fs/cifs/dir.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ build_path_from_dentry(struct dentry *direntry)
132132

133133
struct cifsFileInfo *
134134
cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle,
135-
struct file *file, struct vfsmount *mnt, unsigned int oflags)
135+
struct file *file, struct vfsmount *mnt, unsigned int oflags,
136+
__u32 oplock)
136137
{
137-
int oplock = 0;
138138
struct cifsFileInfo *pCifsFile;
139139
struct cifsInodeInfo *pCifsInode;
140140
struct cifs_sb_info *cifs_sb = CIFS_SB(mnt->mnt_sb);
@@ -143,9 +143,6 @@ cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle,
143143
if (pCifsFile == NULL)
144144
return pCifsFile;
145145

146-
if (oplockEnabled)
147-
oplock = REQ_OPLOCK;
148-
149146
pCifsFile->netfid = fileHandle;
150147
pCifsFile->pid = current->tgid;
151148
pCifsFile->pInode = igrab(newinode);
@@ -468,7 +465,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
468465
}
469466

470467
pfile_info = cifs_new_fileinfo(newinode, fileHandle, filp,
471-
nd->path.mnt, oflags);
468+
nd->path.mnt, oflags, oplock);
472469
if (pfile_info == NULL) {
473470
fput(filp);
474471
CIFSSMBClose(xid, tcon, fileHandle);
@@ -729,7 +726,8 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
729726

730727
cfile = cifs_new_fileinfo(newInode, fileHandle, filp,
731728
nd->path.mnt,
732-
nd->intent.open.flags);
729+
nd->intent.open.flags,
730+
oplock);
733731
if (cfile == NULL) {
734732
fput(filp);
735733
CIFSSMBClose(xid, pTcon, fileHandle);

fs/cifs/file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ int cifs_open(struct inode *inode, struct file *file)
277277

278278
pCifsFile = cifs_new_fileinfo(inode, netfid, file,
279279
file->f_path.mnt,
280-
oflags);
280+
oflags, oplock);
281281
if (pCifsFile == NULL) {
282282
CIFSSMBClose(xid, tcon, netfid);
283283
rc = -ENOMEM;
@@ -370,7 +370,7 @@ int cifs_open(struct inode *inode, struct file *file)
370370
goto out;
371371

372372
pCifsFile = cifs_new_fileinfo(inode, netfid, file, file->f_path.mnt,
373-
file->f_flags);
373+
file->f_flags, oplock);
374374
if (pCifsFile == NULL) {
375375
rc = -ENOMEM;
376376
goto out;

0 commit comments

Comments
 (0)