Commit 086f68bd authored by Jeff Layton's avatar Jeff Layton Committed by Steve French

cifs: eliminate cifs_init_private

...it does the same thing as cifs_fill_fileinfo, but doesn't handle the
flist ordering correctly. Also rename cifs_fill_fileinfo to a more
descriptive name and have it take an open flags arg instead of just a
write_only flag. That makes the logic in the callers a little simpler.
Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent 3bc303c2
...@@ -91,6 +91,9 @@ extern u64 cifs_UnixTimeToNT(struct timespec); ...@@ -91,6 +91,9 @@ extern u64 cifs_UnixTimeToNT(struct timespec);
extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time, extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time,
int offset); int offset);
extern struct cifsFileInfo *cifs_new_fileinfo(struct inode *newinode,
__u16 fileHandle, struct file *file,
struct cifsTconInfo *tcon, unsigned int oflags);
extern int cifs_posix_open(char *full_path, struct inode **pinode, extern int cifs_posix_open(char *full_path, struct inode **pinode,
struct vfsmount *mnt, int mode, int oflags, struct vfsmount *mnt, int mode, int oflags,
__u32 *poplock, __u16 *pnetfid, int xid); __u32 *poplock, __u16 *pnetfid, int xid);
......
...@@ -130,9 +130,9 @@ build_path_from_dentry(struct dentry *direntry) ...@@ -130,9 +130,9 @@ build_path_from_dentry(struct dentry *direntry)
return full_path; return full_path;
} }
static void struct cifsFileInfo *
cifs_fill_fileinfo(struct inode *newinode, __u16 fileHandle, cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle,
struct vfsmount *mnt, bool write_only) struct file *file, struct vfsmount *mnt, unsigned int oflags)
{ {
int oplock = 0; int oplock = 0;
struct cifsFileInfo *pCifsFile; struct cifsFileInfo *pCifsFile;
...@@ -140,9 +140,8 @@ cifs_fill_fileinfo(struct inode *newinode, __u16 fileHandle, ...@@ -140,9 +140,8 @@ cifs_fill_fileinfo(struct inode *newinode, __u16 fileHandle,
struct cifs_sb_info *cifs_sb = CIFS_SB(mnt->mnt_sb); struct cifs_sb_info *cifs_sb = CIFS_SB(mnt->mnt_sb);
pCifsFile = kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL); pCifsFile = kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL);
if (pCifsFile == NULL) if (pCifsFile == NULL)
return; return pCifsFile;
if (oplockEnabled) if (oplockEnabled)
oplock = REQ_OPLOCK; oplock = REQ_OPLOCK;
...@@ -151,6 +150,7 @@ cifs_fill_fileinfo(struct inode *newinode, __u16 fileHandle, ...@@ -151,6 +150,7 @@ cifs_fill_fileinfo(struct inode *newinode, __u16 fileHandle,
pCifsFile->pid = current->tgid; pCifsFile->pid = current->tgid;
pCifsFile->pInode = igrab(newinode); pCifsFile->pInode = igrab(newinode);
pCifsFile->mnt = mnt; pCifsFile->mnt = mnt;
pCifsFile->pfile = file;
pCifsFile->invalidHandle = false; pCifsFile->invalidHandle = false;
pCifsFile->closePend = false; pCifsFile->closePend = false;
mutex_init(&pCifsFile->fh_mutex); mutex_init(&pCifsFile->fh_mutex);
...@@ -159,18 +159,16 @@ cifs_fill_fileinfo(struct inode *newinode, __u16 fileHandle, ...@@ -159,18 +159,16 @@ cifs_fill_fileinfo(struct inode *newinode, __u16 fileHandle,
atomic_set(&pCifsFile->count, 1); atomic_set(&pCifsFile->count, 1);
slow_work_init(&pCifsFile->oplock_break, &cifs_oplock_break_ops); slow_work_init(&pCifsFile->oplock_break, &cifs_oplock_break_ops);
/* set the following in open now
pCifsFile->pfile = file; */
write_lock(&GlobalSMBSeslock); write_lock(&GlobalSMBSeslock);
list_add(&pCifsFile->tlist, &cifs_sb->tcon->openFileList); list_add(&pCifsFile->tlist, &cifs_sb->tcon->openFileList);
pCifsInode = CIFS_I(newinode); pCifsInode = CIFS_I(newinode);
if (pCifsInode) { if (pCifsInode) {
/* if readable file instance put first in list*/ /* if readable file instance put first in list*/
if (write_only) if (oflags & FMODE_READ)
list_add(&pCifsFile->flist, &pCifsInode->openFileList);
else
list_add_tail(&pCifsFile->flist, list_add_tail(&pCifsFile->flist,
&pCifsInode->openFileList); &pCifsInode->openFileList);
else
list_add(&pCifsFile->flist, &pCifsInode->openFileList);
if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) { if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
pCifsInode->clientCanCacheAll = true; pCifsInode->clientCanCacheAll = true;
...@@ -180,6 +178,8 @@ cifs_fill_fileinfo(struct inode *newinode, __u16 fileHandle, ...@@ -180,6 +178,8 @@ cifs_fill_fileinfo(struct inode *newinode, __u16 fileHandle,
pCifsInode->clientCanCacheRead = true; pCifsInode->clientCanCacheRead = true;
} }
write_unlock(&GlobalSMBSeslock); write_unlock(&GlobalSMBSeslock);
return pCifsFile;
} }
int cifs_posix_open(char *full_path, struct inode **pinode, int cifs_posix_open(char *full_path, struct inode **pinode,
...@@ -187,7 +187,6 @@ int cifs_posix_open(char *full_path, struct inode **pinode, ...@@ -187,7 +187,6 @@ int cifs_posix_open(char *full_path, struct inode **pinode,
__u32 *poplock, __u16 *pnetfid, int xid) __u32 *poplock, __u16 *pnetfid, int xid)
{ {
int rc; int rc;
bool write_only = false;
FILE_UNIX_BASIC_INFO *presp_data; FILE_UNIX_BASIC_INFO *presp_data;
__u32 posix_flags = 0; __u32 posix_flags = 0;
struct cifs_sb_info *cifs_sb = CIFS_SB(mnt->mnt_sb); struct cifs_sb_info *cifs_sb = CIFS_SB(mnt->mnt_sb);
...@@ -226,9 +225,6 @@ int cifs_posix_open(char *full_path, struct inode **pinode, ...@@ -226,9 +225,6 @@ int cifs_posix_open(char *full_path, struct inode **pinode,
if (oflags & O_DIRECT) if (oflags & O_DIRECT)
posix_flags |= SMB_O_DIRECT; posix_flags |= SMB_O_DIRECT;
if (!(oflags & FMODE_READ))
write_only = true;
mode &= ~current_umask(); mode &= ~current_umask();
rc = CIFSPOSIXCreate(xid, cifs_sb->tcon, posix_flags, mode, rc = CIFSPOSIXCreate(xid, cifs_sb->tcon, posix_flags, mode,
pnetfid, presp_data, poplock, full_path, pnetfid, presp_data, poplock, full_path,
...@@ -256,7 +252,7 @@ int cifs_posix_open(char *full_path, struct inode **pinode, ...@@ -256,7 +252,7 @@ int cifs_posix_open(char *full_path, struct inode **pinode,
cifs_fattr_to_inode(*pinode, &fattr); cifs_fattr_to_inode(*pinode, &fattr);
} }
cifs_fill_fileinfo(*pinode, *pnetfid, mnt, write_only); cifs_new_fileinfo(*pinode, *pnetfid, NULL, mnt, oflags);
posix_open_ret: posix_open_ret:
kfree(presp_data); kfree(presp_data);
...@@ -301,7 +297,6 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, ...@@ -301,7 +297,6 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
FILE_ALL_INFO *buf = NULL; FILE_ALL_INFO *buf = NULL;
struct inode *newinode = NULL; struct inode *newinode = NULL;
int disposition = FILE_OVERWRITE_IF; int disposition = FILE_OVERWRITE_IF;
bool write_only = false;
xid = GetXid(); xid = GetXid();
...@@ -354,11 +349,8 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, ...@@ -354,11 +349,8 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
desiredAccess = 0; desiredAccess = 0;
if (oflags & FMODE_READ) if (oflags & FMODE_READ)
desiredAccess |= GENERIC_READ; /* is this too little? */ desiredAccess |= GENERIC_READ; /* is this too little? */
if (oflags & FMODE_WRITE) { if (oflags & FMODE_WRITE)
desiredAccess |= GENERIC_WRITE; desiredAccess |= GENERIC_WRITE;
if (!(oflags & FMODE_READ))
write_only = true;
}
if ((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) if ((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
disposition = FILE_CREATE; disposition = FILE_CREATE;
...@@ -473,8 +465,8 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, ...@@ -473,8 +465,8 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
/* mknod case - do not leave file open */ /* mknod case - do not leave file open */
CIFSSMBClose(xid, tcon, fileHandle); CIFSSMBClose(xid, tcon, fileHandle);
} else if (!(posix_create) && (newinode)) { } else if (!(posix_create) && (newinode)) {
cifs_fill_fileinfo(newinode, fileHandle, nd->path.mnt, cifs_new_fileinfo(newinode, fileHandle, NULL,
write_only); nd->path.mnt, oflags);
} }
cifs_create_out: cifs_create_out:
kfree(buf); kfree(buf);
......
...@@ -40,29 +40,6 @@ ...@@ -40,29 +40,6 @@
#include "cifs_debug.h" #include "cifs_debug.h"
#include "cifs_fs_sb.h" #include "cifs_fs_sb.h"
static inline struct cifsFileInfo *cifs_init_private(
struct cifsFileInfo *private_data, struct inode *inode,
struct file *file, __u16 netfid)
{
memset(private_data, 0, sizeof(struct cifsFileInfo));
private_data->netfid = netfid;
private_data->pid = current->tgid;
mutex_init(&private_data->fh_mutex);
mutex_init(&private_data->lock_mutex);
INIT_LIST_HEAD(&private_data->llist);
private_data->pfile = file; /* needed for writepage */
private_data->pInode = igrab(inode);
private_data->mnt = file->f_path.mnt;
private_data->invalidHandle = false;
private_data->closePend = false;
/* Initialize reference count to one. The private data is
freed on the release of the last reference */
atomic_set(&private_data->count, 1);
slow_work_init(&private_data->oplock_break, &cifs_oplock_break_ops);
return private_data;
}
static inline int cifs_convert_flags(unsigned int flags) static inline int cifs_convert_flags(unsigned int flags)
{ {
if ((flags & O_ACCMODE) == O_RDONLY) if ((flags & O_ACCMODE) == O_RDONLY)
...@@ -420,15 +397,13 @@ int cifs_open(struct inode *inode, struct file *file) ...@@ -420,15 +397,13 @@ int cifs_open(struct inode *inode, struct file *file)
cFYI(1, ("cifs_open returned 0x%x", rc)); cFYI(1, ("cifs_open returned 0x%x", rc));
goto out; goto out;
} }
file->private_data = pCifsFile = cifs_new_fileinfo(inode, netfid, file, file->f_path.mnt,
kmalloc(sizeof(struct cifsFileInfo), GFP_KERNEL); file->f_flags);
file->private_data = pCifsFile;
if (file->private_data == NULL) { if (file->private_data == NULL) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
} }
pCifsFile = cifs_init_private(file->private_data, inode, file, netfid);
write_lock(&GlobalSMBSeslock);
list_add(&pCifsFile->tlist, &tcon->openFileList);
pCifsInode = CIFS_I(file->f_path.dentry->d_inode); pCifsInode = CIFS_I(file->f_path.dentry->d_inode);
if (pCifsInode) { if (pCifsInode) {
......
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