diff options
author | Jeff Layton <jlayton@redhat.com> | 2009-09-21 14:08:18 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2009-09-24 15:35:18 -0400 |
commit | 086f68bd97126618ecb2dcff5f766f3a21722df7 (patch) | |
tree | 25f5785dc4ce4ffdc8c852b6c04e52324dd334b0 /fs/cifs/dir.c | |
parent | 3bc303c254335dbd7c7012cc1760b12f1d5514d3 (diff) |
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: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/dir.c')
-rw-r--r-- | fs/cifs/dir.c | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index 9a5df7a84698..627a60a6c1b1 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c | |||
@@ -130,9 +130,9 @@ cifs_bp_rename_retry: | |||
130 | return full_path; | 130 | return full_path; |
131 | } | 131 | } |
132 | 132 | ||
133 | static void | 133 | struct cifsFileInfo * |
134 | cifs_fill_fileinfo(struct inode *newinode, __u16 fileHandle, | 134 | cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle, |
135 | struct vfsmount *mnt, bool write_only) | 135 | struct file *file, struct vfsmount *mnt, unsigned int oflags) |
136 | { | 136 | { |
137 | int oplock = 0; | 137 | int oplock = 0; |
138 | struct cifsFileInfo *pCifsFile; | 138 | struct cifsFileInfo *pCifsFile; |
@@ -140,9 +140,8 @@ cifs_fill_fileinfo(struct inode *newinode, __u16 fileHandle, | |||
140 | struct cifs_sb_info *cifs_sb = CIFS_SB(mnt->mnt_sb); | 140 | struct cifs_sb_info *cifs_sb = CIFS_SB(mnt->mnt_sb); |
141 | 141 | ||
142 | pCifsFile = kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL); | 142 | pCifsFile = kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL); |
143 | |||
144 | if (pCifsFile == NULL) | 143 | if (pCifsFile == NULL) |
145 | return; | 144 | return pCifsFile; |
146 | 145 | ||
147 | if (oplockEnabled) | 146 | if (oplockEnabled) |
148 | oplock = REQ_OPLOCK; | 147 | oplock = REQ_OPLOCK; |
@@ -151,6 +150,7 @@ cifs_fill_fileinfo(struct inode *newinode, __u16 fileHandle, | |||
151 | pCifsFile->pid = current->tgid; | 150 | pCifsFile->pid = current->tgid; |
152 | pCifsFile->pInode = igrab(newinode); | 151 | pCifsFile->pInode = igrab(newinode); |
153 | pCifsFile->mnt = mnt; | 152 | pCifsFile->mnt = mnt; |
153 | pCifsFile->pfile = file; | ||
154 | pCifsFile->invalidHandle = false; | 154 | pCifsFile->invalidHandle = false; |
155 | pCifsFile->closePend = false; | 155 | pCifsFile->closePend = false; |
156 | mutex_init(&pCifsFile->fh_mutex); | 156 | mutex_init(&pCifsFile->fh_mutex); |
@@ -159,18 +159,16 @@ cifs_fill_fileinfo(struct inode *newinode, __u16 fileHandle, | |||
159 | atomic_set(&pCifsFile->count, 1); | 159 | atomic_set(&pCifsFile->count, 1); |
160 | slow_work_init(&pCifsFile->oplock_break, &cifs_oplock_break_ops); | 160 | slow_work_init(&pCifsFile->oplock_break, &cifs_oplock_break_ops); |
161 | 161 | ||
162 | /* set the following in open now | ||
163 | pCifsFile->pfile = file; */ | ||
164 | write_lock(&GlobalSMBSeslock); | 162 | write_lock(&GlobalSMBSeslock); |
165 | list_add(&pCifsFile->tlist, &cifs_sb->tcon->openFileList); | 163 | list_add(&pCifsFile->tlist, &cifs_sb->tcon->openFileList); |
166 | pCifsInode = CIFS_I(newinode); | 164 | pCifsInode = CIFS_I(newinode); |
167 | if (pCifsInode) { | 165 | if (pCifsInode) { |
168 | /* if readable file instance put first in list*/ | 166 | /* if readable file instance put first in list*/ |
169 | if (write_only) | 167 | if (oflags & FMODE_READ) |
168 | list_add(&pCifsFile->flist, &pCifsInode->openFileList); | ||
169 | else | ||
170 | list_add_tail(&pCifsFile->flist, | 170 | list_add_tail(&pCifsFile->flist, |
171 | &pCifsInode->openFileList); | 171 | &pCifsInode->openFileList); |
172 | else | ||
173 | list_add(&pCifsFile->flist, &pCifsInode->openFileList); | ||
174 | 172 | ||
175 | if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) { | 173 | if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) { |
176 | pCifsInode->clientCanCacheAll = true; | 174 | pCifsInode->clientCanCacheAll = true; |
@@ -180,6 +178,8 @@ cifs_fill_fileinfo(struct inode *newinode, __u16 fileHandle, | |||
180 | pCifsInode->clientCanCacheRead = true; | 178 | pCifsInode->clientCanCacheRead = true; |
181 | } | 179 | } |
182 | write_unlock(&GlobalSMBSeslock); | 180 | write_unlock(&GlobalSMBSeslock); |
181 | |||
182 | return pCifsFile; | ||
183 | } | 183 | } |
184 | 184 | ||
185 | int cifs_posix_open(char *full_path, struct inode **pinode, | 185 | 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 | __u32 *poplock, __u16 *pnetfid, int xid) | 187 | __u32 *poplock, __u16 *pnetfid, int xid) |
188 | { | 188 | { |
189 | int rc; | 189 | int rc; |
190 | bool write_only = false; | ||
191 | FILE_UNIX_BASIC_INFO *presp_data; | 190 | FILE_UNIX_BASIC_INFO *presp_data; |
192 | __u32 posix_flags = 0; | 191 | __u32 posix_flags = 0; |
193 | struct cifs_sb_info *cifs_sb = CIFS_SB(mnt->mnt_sb); | 192 | 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 | if (oflags & O_DIRECT) | 225 | if (oflags & O_DIRECT) |
227 | posix_flags |= SMB_O_DIRECT; | 226 | posix_flags |= SMB_O_DIRECT; |
228 | 227 | ||
229 | if (!(oflags & FMODE_READ)) | ||
230 | write_only = true; | ||
231 | |||
232 | mode &= ~current_umask(); | 228 | mode &= ~current_umask(); |
233 | rc = CIFSPOSIXCreate(xid, cifs_sb->tcon, posix_flags, mode, | 229 | rc = CIFSPOSIXCreate(xid, cifs_sb->tcon, posix_flags, mode, |
234 | pnetfid, presp_data, poplock, full_path, | 230 | pnetfid, presp_data, poplock, full_path, |
@@ -256,7 +252,7 @@ int cifs_posix_open(char *full_path, struct inode **pinode, | |||
256 | cifs_fattr_to_inode(*pinode, &fattr); | 252 | cifs_fattr_to_inode(*pinode, &fattr); |
257 | } | 253 | } |
258 | 254 | ||
259 | cifs_fill_fileinfo(*pinode, *pnetfid, mnt, write_only); | 255 | cifs_new_fileinfo(*pinode, *pnetfid, NULL, mnt, oflags); |
260 | 256 | ||
261 | posix_open_ret: | 257 | posix_open_ret: |
262 | kfree(presp_data); | 258 | kfree(presp_data); |
@@ -301,7 +297,6 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, | |||
301 | FILE_ALL_INFO *buf = NULL; | 297 | FILE_ALL_INFO *buf = NULL; |
302 | struct inode *newinode = NULL; | 298 | struct inode *newinode = NULL; |
303 | int disposition = FILE_OVERWRITE_IF; | 299 | int disposition = FILE_OVERWRITE_IF; |
304 | bool write_only = false; | ||
305 | 300 | ||
306 | xid = GetXid(); | 301 | xid = GetXid(); |
307 | 302 | ||
@@ -354,11 +349,8 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, | |||
354 | desiredAccess = 0; | 349 | desiredAccess = 0; |
355 | if (oflags & FMODE_READ) | 350 | if (oflags & FMODE_READ) |
356 | desiredAccess |= GENERIC_READ; /* is this too little? */ | 351 | desiredAccess |= GENERIC_READ; /* is this too little? */ |
357 | if (oflags & FMODE_WRITE) { | 352 | if (oflags & FMODE_WRITE) |
358 | desiredAccess |= GENERIC_WRITE; | 353 | desiredAccess |= GENERIC_WRITE; |
359 | if (!(oflags & FMODE_READ)) | ||
360 | write_only = true; | ||
361 | } | ||
362 | 354 | ||
363 | if ((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) | 355 | if ((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) |
364 | disposition = FILE_CREATE; | 356 | disposition = FILE_CREATE; |
@@ -473,8 +465,8 @@ cifs_create_set_dentry: | |||
473 | /* mknod case - do not leave file open */ | 465 | /* mknod case - do not leave file open */ |
474 | CIFSSMBClose(xid, tcon, fileHandle); | 466 | CIFSSMBClose(xid, tcon, fileHandle); |
475 | } else if (!(posix_create) && (newinode)) { | 467 | } else if (!(posix_create) && (newinode)) { |
476 | cifs_fill_fileinfo(newinode, fileHandle, nd->path.mnt, | 468 | cifs_new_fileinfo(newinode, fileHandle, NULL, |
477 | write_only); | 469 | nd->path.mnt, oflags); |
478 | } | 470 | } |
479 | cifs_create_out: | 471 | cifs_create_out: |
480 | kfree(buf); | 472 | kfree(buf); |