Commit 90e4ee5d authored by Steve French's avatar Steve French

[CIFS] Fix double list addition in cifs posix open code

Remove adding open file entry twice to lists in the file
Do not fill file info twice in case of posix opens and creates
Signed-off-by: default avatarShirish Pargaonkar <shirishp@us.ibm.com>
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent ac683924
...@@ -281,6 +281,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, ...@@ -281,6 +281,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
int create_options = CREATE_NOT_DIR; int create_options = CREATE_NOT_DIR;
int oplock = 0; int oplock = 0;
int oflags; int oflags;
bool posix_create = false;
/* /*
* BB below access is probably too much for mknod to request * BB below access is probably too much for mknod to request
* but we have to do query and setpathinfo so requesting * but we have to do query and setpathinfo so requesting
...@@ -328,11 +329,13 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, ...@@ -328,11 +329,13 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
negotation. EREMOTE indicates DFS junction, which is not negotation. EREMOTE indicates DFS junction, which is not
handled in posix open */ handled in posix open */
if ((rc == 0) && (newinode == NULL)) if (rc == 0) {
goto cifs_create_get_file_info; /* query inode info */ posix_create = true;
else if (rc == 0) /* success, no need to query */ if (newinode == NULL) /* query inode info */
goto cifs_create_set_dentry; goto cifs_create_get_file_info;
else if ((rc != -EIO) && (rc != -EREMOTE) && else /* success, no need to query */
goto cifs_create_set_dentry;
} else if ((rc != -EIO) && (rc != -EREMOTE) &&
(rc != -EOPNOTSUPP)) /* path not found or net err */ (rc != -EOPNOTSUPP)) /* path not found or net err */
goto cifs_create_out; goto cifs_create_out;
/* else fallthrough to retry, using older open call, this is /* else fallthrough to retry, using older open call, this is
...@@ -464,7 +467,7 @@ cifs_create_set_dentry: ...@@ -464,7 +467,7 @@ cifs_create_set_dentry:
if ((nd == NULL) || (!(nd->flags & LOOKUP_OPEN))) { if ((nd == NULL) || (!(nd->flags & LOOKUP_OPEN))) {
/* mknod case - do not leave file open */ /* mknod case - do not leave file open */
CIFSSMBClose(xid, tcon, fileHandle); CIFSSMBClose(xid, tcon, fileHandle);
} else if (newinode) { } else if (!(posix_create) && (newinode)) {
cifs_fill_fileinfo(newinode, fileHandle, cifs_fill_fileinfo(newinode, fileHandle,
cifs_sb->tcon, write_only); cifs_sb->tcon, write_only);
} }
......
...@@ -129,15 +129,12 @@ static inline int cifs_posix_open_inode_helper(struct inode *inode, ...@@ -129,15 +129,12 @@ static inline int cifs_posix_open_inode_helper(struct inode *inode,
struct file *file, struct cifsInodeInfo *pCifsInode, struct file *file, struct cifsInodeInfo *pCifsInode,
struct cifsFileInfo *pCifsFile, int oplock, u16 netfid) struct cifsFileInfo *pCifsFile, int oplock, u16 netfid)
{ {
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
/* struct timespec temp; */ /* BB REMOVEME BB */
file->private_data = kmalloc(sizeof(struct cifsFileInfo), GFP_KERNEL); file->private_data = kmalloc(sizeof(struct cifsFileInfo), GFP_KERNEL);
if (file->private_data == NULL) if (file->private_data == NULL)
return -ENOMEM; return -ENOMEM;
pCifsFile = cifs_init_private(file->private_data, inode, file, netfid); pCifsFile = cifs_init_private(file->private_data, inode, file, netfid);
write_lock(&GlobalSMBSeslock); write_lock(&GlobalSMBSeslock);
list_add(&pCifsFile->tlist, &cifs_sb->tcon->openFileList);
pCifsInode = CIFS_I(file->f_path.dentry->d_inode); pCifsInode = CIFS_I(file->f_path.dentry->d_inode);
if (pCifsInode == NULL) { if (pCifsInode == NULL) {
...@@ -145,17 +142,6 @@ static inline int cifs_posix_open_inode_helper(struct inode *inode, ...@@ -145,17 +142,6 @@ static inline int cifs_posix_open_inode_helper(struct inode *inode,
return -EINVAL; return -EINVAL;
} }
/* want handles we can use to read with first
in the list so we do not have to walk the
list to search for one in write_begin */
if ((file->f_flags & O_ACCMODE) == O_WRONLY) {
list_add_tail(&pCifsFile->flist,
&pCifsInode->openFileList);
} else {
list_add(&pCifsFile->flist,
&pCifsInode->openFileList);
}
if (pCifsInode->clientCanCacheRead) { if (pCifsInode->clientCanCacheRead) {
/* we have the inode open somewhere else /* we have the inode open somewhere else
no need to discard cache data */ no need to discard cache data */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment