aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r--fs/cifs/file.c840
1 files changed, 374 insertions, 466 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index de748c652d11..06c3e83fa387 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -60,34 +60,32 @@ static inline int cifs_convert_flags(unsigned int flags)
60 FILE_READ_DATA); 60 FILE_READ_DATA);
61} 61}
62 62
63static inline fmode_t cifs_posix_convert_flags(unsigned int flags) 63static u32 cifs_posix_convert_flags(unsigned int flags)
64{ 64{
65 fmode_t posix_flags = 0; 65 u32 posix_flags = 0;
66 66
67 if ((flags & O_ACCMODE) == O_RDONLY) 67 if ((flags & O_ACCMODE) == O_RDONLY)
68 posix_flags = FMODE_READ; 68 posix_flags = SMB_O_RDONLY;
69 else if ((flags & O_ACCMODE) == O_WRONLY) 69 else if ((flags & O_ACCMODE) == O_WRONLY)
70 posix_flags = FMODE_WRITE; 70 posix_flags = SMB_O_WRONLY;
71 else if ((flags & O_ACCMODE) == O_RDWR) { 71 else if ((flags & O_ACCMODE) == O_RDWR)
72 /* GENERIC_ALL is too much permission to request 72 posix_flags = SMB_O_RDWR;
73 can cause unnecessary access denied on create */ 73
74 /* return GENERIC_ALL; */ 74 if (flags & O_CREAT)
75 posix_flags = FMODE_READ | FMODE_WRITE; 75 posix_flags |= SMB_O_CREAT;
76 } 76 if (flags & O_EXCL)
77 /* can not map O_CREAT or O_EXCL or O_TRUNC flags when 77 posix_flags |= SMB_O_EXCL;
78 reopening a file. They had their effect on the original open */ 78 if (flags & O_TRUNC)
79 if (flags & O_APPEND) 79 posix_flags |= SMB_O_TRUNC;
80 posix_flags |= (fmode_t)O_APPEND; 80 /* be safe and imply O_SYNC for O_DSYNC */
81 if (flags & O_DSYNC) 81 if (flags & O_DSYNC)
82 posix_flags |= (fmode_t)O_DSYNC; 82 posix_flags |= SMB_O_SYNC;
83 if (flags & __O_SYNC)
84 posix_flags |= (fmode_t)__O_SYNC;
85 if (flags & O_DIRECTORY) 83 if (flags & O_DIRECTORY)
86 posix_flags |= (fmode_t)O_DIRECTORY; 84 posix_flags |= SMB_O_DIRECTORY;
87 if (flags & O_NOFOLLOW) 85 if (flags & O_NOFOLLOW)
88 posix_flags |= (fmode_t)O_NOFOLLOW; 86 posix_flags |= SMB_O_NOFOLLOW;
89 if (flags & O_DIRECT) 87 if (flags & O_DIRECT)
90 posix_flags |= (fmode_t)O_DIRECT; 88 posix_flags |= SMB_O_DIRECT;
91 89
92 return posix_flags; 90 return posix_flags;
93} 91}
@@ -106,66 +104,8 @@ static inline int cifs_get_disposition(unsigned int flags)
106 return FILE_OPEN; 104 return FILE_OPEN;
107} 105}
108 106
109/* all arguments to this function must be checked for validity in caller */
110static inline int
111cifs_posix_open_inode_helper(struct inode *inode, struct file *file,
112 struct cifsInodeInfo *pCifsInode, __u32 oplock,
113 u16 netfid)
114{
115
116 write_lock(&GlobalSMBSeslock);
117
118 pCifsInode = CIFS_I(file->f_path.dentry->d_inode);
119 if (pCifsInode == NULL) {
120 write_unlock(&GlobalSMBSeslock);
121 return -EINVAL;
122 }
123
124 if (pCifsInode->clientCanCacheRead) {
125 /* we have the inode open somewhere else
126 no need to discard cache data */
127 goto psx_client_can_cache;
128 }
129
130 /* BB FIXME need to fix this check to move it earlier into posix_open
131 BB fIX following section BB FIXME */
132
133 /* if not oplocked, invalidate inode pages if mtime or file
134 size changed */
135/* temp = cifs_NTtimeToUnix(le64_to_cpu(buf->LastWriteTime));
136 if (timespec_equal(&file->f_path.dentry->d_inode->i_mtime, &temp) &&
137 (file->f_path.dentry->d_inode->i_size ==
138 (loff_t)le64_to_cpu(buf->EndOfFile))) {
139 cFYI(1, "inode unchanged on server");
140 } else {
141 if (file->f_path.dentry->d_inode->i_mapping) {
142 rc = filemap_write_and_wait(file->f_path.dentry->d_inode->i_mapping);
143 if (rc != 0)
144 CIFS_I(file->f_path.dentry->d_inode)->write_behind_rc = rc;
145 }
146 cFYI(1, "invalidating remote inode since open detected it "
147 "changed");
148 invalidate_remote_inode(file->f_path.dentry->d_inode);
149 } */
150
151psx_client_can_cache:
152 if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
153 pCifsInode->clientCanCacheAll = true;
154 pCifsInode->clientCanCacheRead = true;
155 cFYI(1, "Exclusive Oplock granted on inode %p",
156 file->f_path.dentry->d_inode);
157 } else if ((oplock & 0xF) == OPLOCK_READ)
158 pCifsInode->clientCanCacheRead = true;
159
160 /* will have to change the unlock if we reenable the
161 filemap_fdatawrite (which does not seem necessary */
162 write_unlock(&GlobalSMBSeslock);
163 return 0;
164}
165
166/* all arguments to this function must be checked for validity in caller */
167static inline int cifs_open_inode_helper(struct inode *inode, 107static inline int cifs_open_inode_helper(struct inode *inode,
168 struct cifsTconInfo *pTcon, int *oplock, FILE_ALL_INFO *buf, 108 struct cifsTconInfo *pTcon, __u32 oplock, FILE_ALL_INFO *buf,
169 char *full_path, int xid) 109 char *full_path, int xid)
170{ 110{
171 struct cifsInodeInfo *pCifsInode = CIFS_I(inode); 111 struct cifsInodeInfo *pCifsInode = CIFS_I(inode);
@@ -191,8 +131,7 @@ static inline int cifs_open_inode_helper(struct inode *inode,
191 /* BB no need to lock inode until after invalidate 131 /* BB no need to lock inode until after invalidate
192 since namei code should already have it locked? */ 132 since namei code should already have it locked? */
193 rc = filemap_write_and_wait(inode->i_mapping); 133 rc = filemap_write_and_wait(inode->i_mapping);
194 if (rc != 0) 134 mapping_set_error(inode->i_mapping, rc);
195 pCifsInode->write_behind_rc = rc;
196 } 135 }
197 cFYI(1, "invalidating remote inode since open detected it " 136 cFYI(1, "invalidating remote inode since open detected it "
198 "changed"); 137 "changed");
@@ -207,16 +146,166 @@ client_can_cache:
207 rc = cifs_get_inode_info(&inode, full_path, buf, inode->i_sb, 146 rc = cifs_get_inode_info(&inode, full_path, buf, inode->i_sb,
208 xid, NULL); 147 xid, NULL);
209 148
210 if ((*oplock & 0xF) == OPLOCK_EXCLUSIVE) { 149 cifs_set_oplock_level(pCifsInode, oplock);
211 pCifsInode->clientCanCacheAll = true; 150
212 pCifsInode->clientCanCacheRead = true; 151 return rc;
213 cFYI(1, "Exclusive Oplock granted on inode %p", inode); 152}
214 } else if ((*oplock & 0xF) == OPLOCK_READ) 153
215 pCifsInode->clientCanCacheRead = true; 154int cifs_posix_open(char *full_path, struct inode **pinode,
155 struct super_block *sb, int mode, unsigned int f_flags,
156 __u32 *poplock, __u16 *pnetfid, int xid)
157{
158 int rc;
159 FILE_UNIX_BASIC_INFO *presp_data;
160 __u32 posix_flags = 0;
161 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
162 struct cifs_fattr fattr;
163 struct tcon_link *tlink;
164 struct cifsTconInfo *tcon;
165
166 cFYI(1, "posix open %s", full_path);
167
168 presp_data = kzalloc(sizeof(FILE_UNIX_BASIC_INFO), GFP_KERNEL);
169 if (presp_data == NULL)
170 return -ENOMEM;
171
172 tlink = cifs_sb_tlink(cifs_sb);
173 if (IS_ERR(tlink)) {
174 rc = PTR_ERR(tlink);
175 goto posix_open_ret;
176 }
177
178 tcon = tlink_tcon(tlink);
179 mode &= ~current_umask();
180
181 posix_flags = cifs_posix_convert_flags(f_flags);
182 rc = CIFSPOSIXCreate(xid, tcon, posix_flags, mode, pnetfid, presp_data,
183 poplock, full_path, cifs_sb->local_nls,
184 cifs_sb->mnt_cifs_flags &
185 CIFS_MOUNT_MAP_SPECIAL_CHR);
186 cifs_put_tlink(tlink);
187
188 if (rc)
189 goto posix_open_ret;
190
191 if (presp_data->Type == cpu_to_le32(-1))
192 goto posix_open_ret; /* open ok, caller does qpathinfo */
193
194 if (!pinode)
195 goto posix_open_ret; /* caller does not need info */
196
197 cifs_unix_basic_to_fattr(&fattr, presp_data, cifs_sb);
198
199 /* get new inode and set it up */
200 if (*pinode == NULL) {
201 cifs_fill_uniqueid(sb, &fattr);
202 *pinode = cifs_iget(sb, &fattr);
203 if (!*pinode) {
204 rc = -ENOMEM;
205 goto posix_open_ret;
206 }
207 } else {
208 cifs_fattr_to_inode(*pinode, &fattr);
209 }
216 210
211posix_open_ret:
212 kfree(presp_data);
217 return rc; 213 return rc;
218} 214}
219 215
216struct cifsFileInfo *
217cifs_new_fileinfo(__u16 fileHandle, struct file *file,
218 struct tcon_link *tlink, __u32 oplock)
219{
220 struct dentry *dentry = file->f_path.dentry;
221 struct inode *inode = dentry->d_inode;
222 struct cifsInodeInfo *pCifsInode = CIFS_I(inode);
223 struct cifsFileInfo *pCifsFile;
224
225 pCifsFile = kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL);
226 if (pCifsFile == NULL)
227 return pCifsFile;
228
229 pCifsFile->count = 1;
230 pCifsFile->netfid = fileHandle;
231 pCifsFile->pid = current->tgid;
232 pCifsFile->uid = current_fsuid();
233 pCifsFile->dentry = dget(dentry);
234 pCifsFile->f_flags = file->f_flags;
235 pCifsFile->invalidHandle = false;
236 pCifsFile->tlink = cifs_get_tlink(tlink);
237 mutex_init(&pCifsFile->fh_mutex);
238 mutex_init(&pCifsFile->lock_mutex);
239 INIT_LIST_HEAD(&pCifsFile->llist);
240 INIT_WORK(&pCifsFile->oplock_break, cifs_oplock_break);
241
242 spin_lock(&cifs_file_list_lock);
243 list_add(&pCifsFile->tlist, &(tlink_tcon(tlink)->openFileList));
244 /* if readable file instance put first in list*/
245 if (file->f_mode & FMODE_READ)
246 list_add(&pCifsFile->flist, &pCifsInode->openFileList);
247 else
248 list_add_tail(&pCifsFile->flist, &pCifsInode->openFileList);
249 spin_unlock(&cifs_file_list_lock);
250
251 cifs_set_oplock_level(pCifsInode, oplock);
252
253 file->private_data = pCifsFile;
254 return pCifsFile;
255}
256
257/*
258 * Release a reference on the file private data. This may involve closing
259 * the filehandle out on the server. Must be called without holding
260 * cifs_file_list_lock.
261 */
262void cifsFileInfo_put(struct cifsFileInfo *cifs_file)
263{
264 struct inode *inode = cifs_file->dentry->d_inode;
265 struct cifsTconInfo *tcon = tlink_tcon(cifs_file->tlink);
266 struct cifsInodeInfo *cifsi = CIFS_I(inode);
267 struct cifsLockInfo *li, *tmp;
268
269 spin_lock(&cifs_file_list_lock);
270 if (--cifs_file->count > 0) {
271 spin_unlock(&cifs_file_list_lock);
272 return;
273 }
274
275 /* remove it from the lists */
276 list_del(&cifs_file->flist);
277 list_del(&cifs_file->tlist);
278
279 if (list_empty(&cifsi->openFileList)) {
280 cFYI(1, "closing last open instance for inode %p",
281 cifs_file->dentry->d_inode);
282 cifs_set_oplock_level(cifsi, 0);
283 }
284 spin_unlock(&cifs_file_list_lock);
285
286 if (!tcon->need_reconnect && !cifs_file->invalidHandle) {
287 int xid, rc;
288
289 xid = GetXid();
290 rc = CIFSSMBClose(xid, tcon, cifs_file->netfid);
291 FreeXid(xid);
292 }
293
294 /* Delete any outstanding lock records. We'll lose them when the file
295 * is closed anyway.
296 */
297 mutex_lock(&cifs_file->lock_mutex);
298 list_for_each_entry_safe(li, tmp, &cifs_file->llist, llist) {
299 list_del(&li->llist);
300 kfree(li);
301 }
302 mutex_unlock(&cifs_file->lock_mutex);
303
304 cifs_put_tlink(cifs_file->tlink);
305 dput(cifs_file->dentry);
306 kfree(cifs_file);
307}
308
220int cifs_open(struct inode *inode, struct file *file) 309int cifs_open(struct inode *inode, struct file *file)
221{ 310{
222 int rc = -EACCES; 311 int rc = -EACCES;
@@ -224,6 +313,7 @@ int cifs_open(struct inode *inode, struct file *file)
224 __u32 oplock; 313 __u32 oplock;
225 struct cifs_sb_info *cifs_sb; 314 struct cifs_sb_info *cifs_sb;
226 struct cifsTconInfo *tcon; 315 struct cifsTconInfo *tcon;
316 struct tcon_link *tlink;
227 struct cifsFileInfo *pCifsFile = NULL; 317 struct cifsFileInfo *pCifsFile = NULL;
228 struct cifsInodeInfo *pCifsInode; 318 struct cifsInodeInfo *pCifsInode;
229 char *full_path = NULL; 319 char *full_path = NULL;
@@ -235,7 +325,12 @@ int cifs_open(struct inode *inode, struct file *file)
235 xid = GetXid(); 325 xid = GetXid();
236 326
237 cifs_sb = CIFS_SB(inode->i_sb); 327 cifs_sb = CIFS_SB(inode->i_sb);
238 tcon = cifs_sb->tcon; 328 tlink = cifs_sb_tlink(cifs_sb);
329 if (IS_ERR(tlink)) {
330 FreeXid(xid);
331 return PTR_ERR(tlink);
332 }
333 tcon = tlink_tcon(tlink);
239 334
240 pCifsInode = CIFS_I(file->f_path.dentry->d_inode); 335 pCifsInode = CIFS_I(file->f_path.dentry->d_inode);
241 336
@@ -257,27 +352,15 @@ int cifs_open(struct inode *inode, struct file *file)
257 (tcon->ses->capabilities & CAP_UNIX) && 352 (tcon->ses->capabilities & CAP_UNIX) &&
258 (CIFS_UNIX_POSIX_PATH_OPS_CAP & 353 (CIFS_UNIX_POSIX_PATH_OPS_CAP &
259 le64_to_cpu(tcon->fsUnixInfo.Capability))) { 354 le64_to_cpu(tcon->fsUnixInfo.Capability))) {
260 int oflags = (int) cifs_posix_convert_flags(file->f_flags);
261 oflags |= SMB_O_CREAT;
262 /* can not refresh inode info since size could be stale */ 355 /* can not refresh inode info since size could be stale */
263 rc = cifs_posix_open(full_path, &inode, inode->i_sb, 356 rc = cifs_posix_open(full_path, &inode, inode->i_sb,
264 cifs_sb->mnt_file_mode /* ignored */, 357 cifs_sb->mnt_file_mode /* ignored */,
265 oflags, &oplock, &netfid, xid); 358 file->f_flags, &oplock, &netfid, xid);
266 if (rc == 0) { 359 if (rc == 0) {
267 cFYI(1, "posix open succeeded"); 360 cFYI(1, "posix open succeeded");
268 /* no need for special case handling of setting mode
269 on read only files needed here */
270
271 rc = cifs_posix_open_inode_helper(inode, file,
272 pCifsInode, oplock, netfid);
273 if (rc != 0) {
274 CIFSSMBClose(xid, tcon, netfid);
275 goto out;
276 }
277 361
278 pCifsFile = cifs_new_fileinfo(inode, netfid, file, 362 pCifsFile = cifs_new_fileinfo(netfid, file, tlink,
279 file->f_path.mnt, 363 oplock);
280 oflags);
281 if (pCifsFile == NULL) { 364 if (pCifsFile == NULL) {
282 CIFSSMBClose(xid, tcon, netfid); 365 CIFSSMBClose(xid, tcon, netfid);
283 rc = -ENOMEM; 366 rc = -ENOMEM;
@@ -345,7 +428,7 @@ int cifs_open(struct inode *inode, struct file *file)
345 goto out; 428 goto out;
346 } 429 }
347 430
348 if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS) 431 if (tcon->ses->capabilities & CAP_NT_SMBS)
349 rc = CIFSSMBOpen(xid, tcon, full_path, disposition, 432 rc = CIFSSMBOpen(xid, tcon, full_path, disposition,
350 desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf, 433 desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf,
351 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags 434 cifs_sb->local_nls, cifs_sb->mnt_cifs_flags
@@ -365,12 +448,11 @@ int cifs_open(struct inode *inode, struct file *file)
365 goto out; 448 goto out;
366 } 449 }
367 450
368 rc = cifs_open_inode_helper(inode, tcon, &oplock, buf, full_path, xid); 451 rc = cifs_open_inode_helper(inode, tcon, oplock, buf, full_path, xid);
369 if (rc != 0) 452 if (rc != 0)
370 goto out; 453 goto out;
371 454
372 pCifsFile = cifs_new_fileinfo(inode, netfid, file, file->f_path.mnt, 455 pCifsFile = cifs_new_fileinfo(netfid, file, tlink, oplock);
373 file->f_flags);
374 if (pCifsFile == NULL) { 456 if (pCifsFile == NULL) {
375 rc = -ENOMEM; 457 rc = -ENOMEM;
376 goto out; 458 goto out;
@@ -402,6 +484,7 @@ out:
402 kfree(buf); 484 kfree(buf);
403 kfree(full_path); 485 kfree(full_path);
404 FreeXid(xid); 486 FreeXid(xid);
487 cifs_put_tlink(tlink);
405 return rc; 488 return rc;
406} 489}
407 490
@@ -416,14 +499,13 @@ static int cifs_relock_file(struct cifsFileInfo *cifsFile)
416 return rc; 499 return rc;
417} 500}
418 501
419static int cifs_reopen_file(struct file *file, bool can_flush) 502static int cifs_reopen_file(struct cifsFileInfo *pCifsFile, bool can_flush)
420{ 503{
421 int rc = -EACCES; 504 int rc = -EACCES;
422 int xid; 505 int xid;
423 __u32 oplock; 506 __u32 oplock;
424 struct cifs_sb_info *cifs_sb; 507 struct cifs_sb_info *cifs_sb;
425 struct cifsTconInfo *tcon; 508 struct cifsTconInfo *tcon;
426 struct cifsFileInfo *pCifsFile;
427 struct cifsInodeInfo *pCifsInode; 509 struct cifsInodeInfo *pCifsInode;
428 struct inode *inode; 510 struct inode *inode;
429 char *full_path = NULL; 511 char *full_path = NULL;
@@ -431,11 +513,6 @@ static int cifs_reopen_file(struct file *file, bool can_flush)
431 int disposition = FILE_OPEN; 513 int disposition = FILE_OPEN;
432 __u16 netfid; 514 __u16 netfid;
433 515
434 if (file->private_data)
435 pCifsFile = file->private_data;
436 else
437 return -EBADF;
438
439 xid = GetXid(); 516 xid = GetXid();
440 mutex_lock(&pCifsFile->fh_mutex); 517 mutex_lock(&pCifsFile->fh_mutex);
441 if (!pCifsFile->invalidHandle) { 518 if (!pCifsFile->invalidHandle) {
@@ -445,39 +522,24 @@ static int cifs_reopen_file(struct file *file, bool can_flush)
445 return rc; 522 return rc;
446 } 523 }
447 524
448 if (file->f_path.dentry == NULL) { 525 inode = pCifsFile->dentry->d_inode;
449 cERROR(1, "no valid name if dentry freed");
450 dump_stack();
451 rc = -EBADF;
452 goto reopen_error_exit;
453 }
454
455 inode = file->f_path.dentry->d_inode;
456 if (inode == NULL) {
457 cERROR(1, "inode not valid");
458 dump_stack();
459 rc = -EBADF;
460 goto reopen_error_exit;
461 }
462
463 cifs_sb = CIFS_SB(inode->i_sb); 526 cifs_sb = CIFS_SB(inode->i_sb);
464 tcon = cifs_sb->tcon; 527 tcon = tlink_tcon(pCifsFile->tlink);
465 528
466/* can not grab rename sem here because various ops, including 529/* can not grab rename sem here because various ops, including
467 those that already have the rename sem can end up causing writepage 530 those that already have the rename sem can end up causing writepage
468 to get called and if the server was down that means we end up here, 531 to get called and if the server was down that means we end up here,
469 and we can never tell if the caller already has the rename_sem */ 532 and we can never tell if the caller already has the rename_sem */
470 full_path = build_path_from_dentry(file->f_path.dentry); 533 full_path = build_path_from_dentry(pCifsFile->dentry);
471 if (full_path == NULL) { 534 if (full_path == NULL) {
472 rc = -ENOMEM; 535 rc = -ENOMEM;
473reopen_error_exit:
474 mutex_unlock(&pCifsFile->fh_mutex); 536 mutex_unlock(&pCifsFile->fh_mutex);
475 FreeXid(xid); 537 FreeXid(xid);
476 return rc; 538 return rc;
477 } 539 }
478 540
479 cFYI(1, "inode = 0x%p file flags 0x%x for %s", 541 cFYI(1, "inode = 0x%p file flags 0x%x for %s",
480 inode, file->f_flags, full_path); 542 inode, pCifsFile->f_flags, full_path);
481 543
482 if (oplockEnabled) 544 if (oplockEnabled)
483 oplock = REQ_OPLOCK; 545 oplock = REQ_OPLOCK;
@@ -487,8 +549,14 @@ reopen_error_exit:
487 if (tcon->unix_ext && (tcon->ses->capabilities & CAP_UNIX) && 549 if (tcon->unix_ext && (tcon->ses->capabilities & CAP_UNIX) &&
488 (CIFS_UNIX_POSIX_PATH_OPS_CAP & 550 (CIFS_UNIX_POSIX_PATH_OPS_CAP &
489 le64_to_cpu(tcon->fsUnixInfo.Capability))) { 551 le64_to_cpu(tcon->fsUnixInfo.Capability))) {
490 int oflags = (int) cifs_posix_convert_flags(file->f_flags); 552
491 /* can not refresh inode info since size could be stale */ 553 /*
554 * O_CREAT, O_EXCL and O_TRUNC already had their effect on the
555 * original open. Must mask them off for a reopen.
556 */
557 unsigned int oflags = pCifsFile->f_flags &
558 ~(O_CREAT | O_EXCL | O_TRUNC);
559
492 rc = cifs_posix_open(full_path, NULL, inode->i_sb, 560 rc = cifs_posix_open(full_path, NULL, inode->i_sb,
493 cifs_sb->mnt_file_mode /* ignored */, 561 cifs_sb->mnt_file_mode /* ignored */,
494 oflags, &oplock, &netfid, xid); 562 oflags, &oplock, &netfid, xid);
@@ -500,7 +568,7 @@ reopen_error_exit:
500 in the reconnect path it is important to retry hard */ 568 in the reconnect path it is important to retry hard */
501 } 569 }
502 570
503 desiredAccess = cifs_convert_flags(file->f_flags); 571 desiredAccess = cifs_convert_flags(pCifsFile->f_flags);
504 572
505 /* Can not refresh inode by passing in file_info buf to be returned 573 /* Can not refresh inode by passing in file_info buf to be returned
506 by SMBOpen and then calling get_inode_info with returned buf 574 by SMBOpen and then calling get_inode_info with returned buf
@@ -516,49 +584,38 @@ reopen_error_exit:
516 mutex_unlock(&pCifsFile->fh_mutex); 584 mutex_unlock(&pCifsFile->fh_mutex);
517 cFYI(1, "cifs_open returned 0x%x", rc); 585 cFYI(1, "cifs_open returned 0x%x", rc);
518 cFYI(1, "oplock: %d", oplock); 586 cFYI(1, "oplock: %d", oplock);
519 } else { 587 goto reopen_error_exit;
520reopen_success:
521 pCifsFile->netfid = netfid;
522 pCifsFile->invalidHandle = false;
523 mutex_unlock(&pCifsFile->fh_mutex);
524 pCifsInode = CIFS_I(inode);
525 if (pCifsInode) {
526 if (can_flush) {
527 rc = filemap_write_and_wait(inode->i_mapping);
528 if (rc != 0)
529 CIFS_I(inode)->write_behind_rc = rc;
530 /* temporarily disable caching while we
531 go to server to get inode info */
532 pCifsInode->clientCanCacheAll = false;
533 pCifsInode->clientCanCacheRead = false;
534 if (tcon->unix_ext)
535 rc = cifs_get_inode_info_unix(&inode,
536 full_path, inode->i_sb, xid);
537 else
538 rc = cifs_get_inode_info(&inode,
539 full_path, NULL, inode->i_sb,
540 xid, NULL);
541 } /* else we are writing out data to server already
542 and could deadlock if we tried to flush data, and
543 since we do not know if we have data that would
544 invalidate the current end of file on the server
545 we can not go to the server to get the new inod
546 info */
547 if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
548 pCifsInode->clientCanCacheAll = true;
549 pCifsInode->clientCanCacheRead = true;
550 cFYI(1, "Exclusive Oplock granted on inode %p",
551 file->f_path.dentry->d_inode);
552 } else if ((oplock & 0xF) == OPLOCK_READ) {
553 pCifsInode->clientCanCacheRead = true;
554 pCifsInode->clientCanCacheAll = false;
555 } else {
556 pCifsInode->clientCanCacheRead = false;
557 pCifsInode->clientCanCacheAll = false;
558 }
559 cifs_relock_file(pCifsFile);
560 }
561 } 588 }
589
590reopen_success:
591 pCifsFile->netfid = netfid;
592 pCifsFile->invalidHandle = false;
593 mutex_unlock(&pCifsFile->fh_mutex);
594 pCifsInode = CIFS_I(inode);
595
596 if (can_flush) {
597 rc = filemap_write_and_wait(inode->i_mapping);
598 mapping_set_error(inode->i_mapping, rc);
599
600 if (tcon->unix_ext)
601 rc = cifs_get_inode_info_unix(&inode,
602 full_path, inode->i_sb, xid);
603 else
604 rc = cifs_get_inode_info(&inode,
605 full_path, NULL, inode->i_sb,
606 xid, NULL);
607 } /* else we are writing out data to server already
608 and could deadlock if we tried to flush data, and
609 since we do not know if we have data that would
610 invalidate the current end of file on the server
611 we can not go to the server to get the new inod
612 info */
613
614 cifs_set_oplock_level(pCifsInode, oplock);
615
616 cifs_relock_file(pCifsFile);
617
618reopen_error_exit:
562 kfree(full_path); 619 kfree(full_path);
563 FreeXid(xid); 620 FreeXid(xid);
564 return rc; 621 return rc;
@@ -566,79 +623,11 @@ reopen_success:
566 623
567int cifs_close(struct inode *inode, struct file *file) 624int cifs_close(struct inode *inode, struct file *file)
568{ 625{
569 int rc = 0; 626 cifsFileInfo_put(file->private_data);
570 int xid, timeout; 627 file->private_data = NULL;
571 struct cifs_sb_info *cifs_sb;
572 struct cifsTconInfo *pTcon;
573 struct cifsFileInfo *pSMBFile = file->private_data;
574
575 xid = GetXid();
576 628
577 cifs_sb = CIFS_SB(inode->i_sb); 629 /* return code from the ->release op is always ignored */
578 pTcon = cifs_sb->tcon; 630 return 0;
579 if (pSMBFile) {
580 struct cifsLockInfo *li, *tmp;
581 write_lock(&GlobalSMBSeslock);
582 pSMBFile->closePend = true;
583 if (pTcon) {
584 /* no sense reconnecting to close a file that is
585 already closed */
586 if (!pTcon->need_reconnect) {
587 write_unlock(&GlobalSMBSeslock);
588 timeout = 2;
589 while ((atomic_read(&pSMBFile->count) != 1)
590 && (timeout <= 2048)) {
591 /* Give write a better chance to get to
592 server ahead of the close. We do not
593 want to add a wait_q here as it would
594 increase the memory utilization as
595 the struct would be in each open file,
596 but this should give enough time to
597 clear the socket */
598 cFYI(DBG2, "close delay, write pending");
599 msleep(timeout);
600 timeout *= 4;
601 }
602 if (!pTcon->need_reconnect &&
603 !pSMBFile->invalidHandle)
604 rc = CIFSSMBClose(xid, pTcon,
605 pSMBFile->netfid);
606 } else
607 write_unlock(&GlobalSMBSeslock);
608 } else
609 write_unlock(&GlobalSMBSeslock);
610
611 /* Delete any outstanding lock records.
612 We'll lose them when the file is closed anyway. */
613 mutex_lock(&pSMBFile->lock_mutex);
614 list_for_each_entry_safe(li, tmp, &pSMBFile->llist, llist) {
615 list_del(&li->llist);
616 kfree(li);
617 }
618 mutex_unlock(&pSMBFile->lock_mutex);
619
620 write_lock(&GlobalSMBSeslock);
621 list_del(&pSMBFile->flist);
622 list_del(&pSMBFile->tlist);
623 write_unlock(&GlobalSMBSeslock);
624 cifsFileInfo_put(file->private_data);
625 file->private_data = NULL;
626 } else
627 rc = -EBADF;
628
629 read_lock(&GlobalSMBSeslock);
630 if (list_empty(&(CIFS_I(inode)->openFileList))) {
631 cFYI(1, "closing last open instance for inode %p", inode);
632 /* if the file is not open we do not know if we can cache info
633 on this inode, much less write behind and read ahead */
634 CIFS_I(inode)->clientCanCacheRead = false;
635 CIFS_I(inode)->clientCanCacheAll = false;
636 }
637 read_unlock(&GlobalSMBSeslock);
638 if ((rc == 0) && CIFS_I(inode)->write_behind_rc)
639 rc = CIFS_I(inode)->write_behind_rc;
640 FreeXid(xid);
641 return rc;
642} 631}
643 632
644int cifs_closedir(struct inode *inode, struct file *file) 633int cifs_closedir(struct inode *inode, struct file *file)
@@ -653,25 +642,21 @@ int cifs_closedir(struct inode *inode, struct file *file)
653 xid = GetXid(); 642 xid = GetXid();
654 643
655 if (pCFileStruct) { 644 if (pCFileStruct) {
656 struct cifsTconInfo *pTcon; 645 struct cifsTconInfo *pTcon = tlink_tcon(pCFileStruct->tlink);
657 struct cifs_sb_info *cifs_sb =
658 CIFS_SB(file->f_path.dentry->d_sb);
659
660 pTcon = cifs_sb->tcon;
661 646
662 cFYI(1, "Freeing private data in close dir"); 647 cFYI(1, "Freeing private data in close dir");
663 write_lock(&GlobalSMBSeslock); 648 spin_lock(&cifs_file_list_lock);
664 if (!pCFileStruct->srch_inf.endOfSearch && 649 if (!pCFileStruct->srch_inf.endOfSearch &&
665 !pCFileStruct->invalidHandle) { 650 !pCFileStruct->invalidHandle) {
666 pCFileStruct->invalidHandle = true; 651 pCFileStruct->invalidHandle = true;
667 write_unlock(&GlobalSMBSeslock); 652 spin_unlock(&cifs_file_list_lock);
668 rc = CIFSFindClose(xid, pTcon, pCFileStruct->netfid); 653 rc = CIFSFindClose(xid, pTcon, pCFileStruct->netfid);
669 cFYI(1, "Closing uncompleted readdir with rc %d", 654 cFYI(1, "Closing uncompleted readdir with rc %d",
670 rc); 655 rc);
671 /* not much we can do if it fails anyway, ignore rc */ 656 /* not much we can do if it fails anyway, ignore rc */
672 rc = 0; 657 rc = 0;
673 } else 658 } else
674 write_unlock(&GlobalSMBSeslock); 659 spin_unlock(&cifs_file_list_lock);
675 ptmp = pCFileStruct->srch_inf.ntwrk_buf_start; 660 ptmp = pCFileStruct->srch_inf.ntwrk_buf_start;
676 if (ptmp) { 661 if (ptmp) {
677 cFYI(1, "closedir free smb buf in srch struct"); 662 cFYI(1, "closedir free smb buf in srch struct");
@@ -681,6 +666,7 @@ int cifs_closedir(struct inode *inode, struct file *file)
681 else 666 else
682 cifs_buf_release(ptmp); 667 cifs_buf_release(ptmp);
683 } 668 }
669 cifs_put_tlink(pCFileStruct->tlink);
684 kfree(file->private_data); 670 kfree(file->private_data);
685 file->private_data = NULL; 671 file->private_data = NULL;
686 } 672 }
@@ -767,13 +753,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
767 cFYI(1, "Unknown type of lock"); 753 cFYI(1, "Unknown type of lock");
768 754
769 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 755 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
770 tcon = cifs_sb->tcon; 756 tcon = tlink_tcon(((struct cifsFileInfo *)file->private_data)->tlink);
771
772 if (file->private_data == NULL) {
773 rc = -EBADF;
774 FreeXid(xid);
775 return rc;
776 }
777 netfid = ((struct cifsFileInfo *)file->private_data)->netfid; 757 netfid = ((struct cifsFileInfo *)file->private_data)->netfid;
778 758
779 if ((tcon->ses->capabilities & CAP_UNIX) && 759 if ((tcon->ses->capabilities & CAP_UNIX) &&
@@ -949,6 +929,7 @@ cifs_update_eof(struct cifsInodeInfo *cifsi, loff_t offset,
949ssize_t cifs_user_write(struct file *file, const char __user *write_data, 929ssize_t cifs_user_write(struct file *file, const char __user *write_data,
950 size_t write_size, loff_t *poffset) 930 size_t write_size, loff_t *poffset)
951{ 931{
932 struct inode *inode = file->f_path.dentry->d_inode;
952 int rc = 0; 933 int rc = 0;
953 unsigned int bytes_written = 0; 934 unsigned int bytes_written = 0;
954 unsigned int total_written; 935 unsigned int total_written;
@@ -956,18 +937,18 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
956 struct cifsTconInfo *pTcon; 937 struct cifsTconInfo *pTcon;
957 int xid, long_op; 938 int xid, long_op;
958 struct cifsFileInfo *open_file; 939 struct cifsFileInfo *open_file;
959 struct cifsInodeInfo *cifsi = CIFS_I(file->f_path.dentry->d_inode); 940 struct cifsInodeInfo *cifsi = CIFS_I(inode);
960 941
961 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 942 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
962 943
963 pTcon = cifs_sb->tcon;
964
965 /* cFYI(1, " write %d bytes to offset %lld of %s", write_size, 944 /* cFYI(1, " write %d bytes to offset %lld of %s", write_size,
966 *poffset, file->f_path.dentry->d_name.name); */ 945 *poffset, file->f_path.dentry->d_name.name); */
967 946
968 if (file->private_data == NULL) 947 if (file->private_data == NULL)
969 return -EBADF; 948 return -EBADF;
949
970 open_file = file->private_data; 950 open_file = file->private_data;
951 pTcon = tlink_tcon(open_file->tlink);
971 952
972 rc = generic_write_checks(file, poffset, &write_size, 0); 953 rc = generic_write_checks(file, poffset, &write_size, 0);
973 if (rc) 954 if (rc)
@@ -988,19 +969,12 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
988 we blocked so return what we managed to write */ 969 we blocked so return what we managed to write */
989 return total_written; 970 return total_written;
990 } 971 }
991 if (open_file->closePend) {
992 FreeXid(xid);
993 if (total_written)
994 return total_written;
995 else
996 return -EBADF;
997 }
998 if (open_file->invalidHandle) { 972 if (open_file->invalidHandle) {
999 /* we could deadlock if we called 973 /* we could deadlock if we called
1000 filemap_fdatawait from here so tell 974 filemap_fdatawait from here so tell
1001 reopen_file not to flush data to server 975 reopen_file not to flush data to server
1002 now */ 976 now */
1003 rc = cifs_reopen_file(file, false); 977 rc = cifs_reopen_file(open_file, false);
1004 if (rc != 0) 978 if (rc != 0)
1005 break; 979 break;
1006 } 980 }
@@ -1029,27 +1003,24 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
1029 1003
1030 cifs_stats_bytes_written(pTcon, total_written); 1004 cifs_stats_bytes_written(pTcon, total_written);
1031 1005
1032 /* since the write may have blocked check these pointers again */
1033 if ((file->f_path.dentry) && (file->f_path.dentry->d_inode)) {
1034 struct inode *inode = file->f_path.dentry->d_inode;
1035/* Do not update local mtime - server will set its actual value on write 1006/* Do not update local mtime - server will set its actual value on write
1036 * inode->i_ctime = inode->i_mtime = 1007 * inode->i_ctime = inode->i_mtime =
1037 * current_fs_time(inode->i_sb);*/ 1008 * current_fs_time(inode->i_sb);*/
1038 if (total_written > 0) { 1009 if (total_written > 0) {
1039 spin_lock(&inode->i_lock); 1010 spin_lock(&inode->i_lock);
1040 if (*poffset > file->f_path.dentry->d_inode->i_size) 1011 if (*poffset > inode->i_size)
1041 i_size_write(file->f_path.dentry->d_inode, 1012 i_size_write(inode, *poffset);
1042 *poffset); 1013 spin_unlock(&inode->i_lock);
1043 spin_unlock(&inode->i_lock);
1044 }
1045 mark_inode_dirty_sync(file->f_path.dentry->d_inode);
1046 } 1014 }
1015 mark_inode_dirty_sync(inode);
1016
1047 FreeXid(xid); 1017 FreeXid(xid);
1048 return total_written; 1018 return total_written;
1049} 1019}
1050 1020
1051static ssize_t cifs_write(struct file *file, const char *write_data, 1021static ssize_t cifs_write(struct cifsFileInfo *open_file,
1052 size_t write_size, loff_t *poffset) 1022 const char *write_data, size_t write_size,
1023 loff_t *poffset)
1053{ 1024{
1054 int rc = 0; 1025 int rc = 0;
1055 unsigned int bytes_written = 0; 1026 unsigned int bytes_written = 0;
@@ -1057,19 +1028,15 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
1057 struct cifs_sb_info *cifs_sb; 1028 struct cifs_sb_info *cifs_sb;
1058 struct cifsTconInfo *pTcon; 1029 struct cifsTconInfo *pTcon;
1059 int xid, long_op; 1030 int xid, long_op;
1060 struct cifsFileInfo *open_file; 1031 struct dentry *dentry = open_file->dentry;
1061 struct cifsInodeInfo *cifsi = CIFS_I(file->f_path.dentry->d_inode); 1032 struct cifsInodeInfo *cifsi = CIFS_I(dentry->d_inode);
1062
1063 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
1064 1033
1065 pTcon = cifs_sb->tcon; 1034 cifs_sb = CIFS_SB(dentry->d_sb);
1066 1035
1067 cFYI(1, "write %zd bytes to offset %lld of %s", write_size, 1036 cFYI(1, "write %zd bytes to offset %lld of %s", write_size,
1068 *poffset, file->f_path.dentry->d_name.name); 1037 *poffset, dentry->d_name.name);
1069 1038
1070 if (file->private_data == NULL) 1039 pTcon = tlink_tcon(open_file->tlink);
1071 return -EBADF;
1072 open_file = file->private_data;
1073 1040
1074 xid = GetXid(); 1041 xid = GetXid();
1075 1042
@@ -1078,28 +1045,12 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
1078 total_written += bytes_written) { 1045 total_written += bytes_written) {
1079 rc = -EAGAIN; 1046 rc = -EAGAIN;
1080 while (rc == -EAGAIN) { 1047 while (rc == -EAGAIN) {
1081 if (file->private_data == NULL) {
1082 /* file has been closed on us */
1083 FreeXid(xid);
1084 /* if we have gotten here we have written some data
1085 and blocked, and the file has been freed on us
1086 while we blocked so return what we managed to
1087 write */
1088 return total_written;
1089 }
1090 if (open_file->closePend) {
1091 FreeXid(xid);
1092 if (total_written)
1093 return total_written;
1094 else
1095 return -EBADF;
1096 }
1097 if (open_file->invalidHandle) { 1048 if (open_file->invalidHandle) {
1098 /* we could deadlock if we called 1049 /* we could deadlock if we called
1099 filemap_fdatawait from here so tell 1050 filemap_fdatawait from here so tell
1100 reopen_file not to flush data to 1051 reopen_file not to flush data to
1101 server now */ 1052 server now */
1102 rc = cifs_reopen_file(file, false); 1053 rc = cifs_reopen_file(open_file, false);
1103 if (rc != 0) 1054 if (rc != 0)
1104 break; 1055 break;
1105 } 1056 }
@@ -1146,43 +1097,41 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
1146 1097
1147 cifs_stats_bytes_written(pTcon, total_written); 1098 cifs_stats_bytes_written(pTcon, total_written);
1148 1099
1149 /* since the write may have blocked check these pointers again */ 1100 if (total_written > 0) {
1150 if ((file->f_path.dentry) && (file->f_path.dentry->d_inode)) { 1101 spin_lock(&dentry->d_inode->i_lock);
1151/*BB We could make this contingent on superblock ATIME flag too */ 1102 if (*poffset > dentry->d_inode->i_size)
1152/* file->f_path.dentry->d_inode->i_ctime = 1103 i_size_write(dentry->d_inode, *poffset);
1153 file->f_path.dentry->d_inode->i_mtime = CURRENT_TIME;*/ 1104 spin_unlock(&dentry->d_inode->i_lock);
1154 if (total_written > 0) {
1155 spin_lock(&file->f_path.dentry->d_inode->i_lock);
1156 if (*poffset > file->f_path.dentry->d_inode->i_size)
1157 i_size_write(file->f_path.dentry->d_inode,
1158 *poffset);
1159 spin_unlock(&file->f_path.dentry->d_inode->i_lock);
1160 }
1161 mark_inode_dirty_sync(file->f_path.dentry->d_inode);
1162 } 1105 }
1106 mark_inode_dirty_sync(dentry->d_inode);
1163 FreeXid(xid); 1107 FreeXid(xid);
1164 return total_written; 1108 return total_written;
1165} 1109}
1166 1110
1167#ifdef CONFIG_CIFS_EXPERIMENTAL 1111#ifdef CONFIG_CIFS_EXPERIMENTAL
1168struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode) 1112struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode,
1113 bool fsuid_only)
1169{ 1114{
1170 struct cifsFileInfo *open_file = NULL; 1115 struct cifsFileInfo *open_file = NULL;
1116 struct cifs_sb_info *cifs_sb = CIFS_SB(cifs_inode->vfs_inode.i_sb);
1117
1118 /* only filter by fsuid on multiuser mounts */
1119 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER))
1120 fsuid_only = false;
1171 1121
1172 read_lock(&GlobalSMBSeslock); 1122 spin_lock(&cifs_file_list_lock);
1173 /* we could simply get the first_list_entry since write-only entries 1123 /* we could simply get the first_list_entry since write-only entries
1174 are always at the end of the list but since the first entry might 1124 are always at the end of the list but since the first entry might
1175 have a close pending, we go through the whole list */ 1125 have a close pending, we go through the whole list */
1176 list_for_each_entry(open_file, &cifs_inode->openFileList, flist) { 1126 list_for_each_entry(open_file, &cifs_inode->openFileList, flist) {
1177 if (open_file->closePend) 1127 if (fsuid_only && open_file->uid != current_fsuid())
1178 continue; 1128 continue;
1179 if (open_file->pfile && ((open_file->pfile->f_flags & O_RDWR) || 1129 if (OPEN_FMODE(open_file->f_flags) & FMODE_READ) {
1180 (open_file->pfile->f_flags & O_RDONLY))) {
1181 if (!open_file->invalidHandle) { 1130 if (!open_file->invalidHandle) {
1182 /* found a good file */ 1131 /* found a good file */
1183 /* lock it so it will not be closed on us */ 1132 /* lock it so it will not be closed on us */
1184 cifsFileInfo_get(open_file); 1133 cifsFileInfo_get(open_file);
1185 read_unlock(&GlobalSMBSeslock); 1134 spin_unlock(&cifs_file_list_lock);
1186 return open_file; 1135 return open_file;
1187 } /* else might as well continue, and look for 1136 } /* else might as well continue, and look for
1188 another, or simply have the caller reopen it 1137 another, or simply have the caller reopen it
@@ -1190,14 +1139,16 @@ struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode)
1190 } else /* write only file */ 1139 } else /* write only file */
1191 break; /* write only files are last so must be done */ 1140 break; /* write only files are last so must be done */
1192 } 1141 }
1193 read_unlock(&GlobalSMBSeslock); 1142 spin_unlock(&cifs_file_list_lock);
1194 return NULL; 1143 return NULL;
1195} 1144}
1196#endif 1145#endif
1197 1146
1198struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode) 1147struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode,
1148 bool fsuid_only)
1199{ 1149{
1200 struct cifsFileInfo *open_file; 1150 struct cifsFileInfo *open_file;
1151 struct cifs_sb_info *cifs_sb;
1201 bool any_available = false; 1152 bool any_available = false;
1202 int rc; 1153 int rc;
1203 1154
@@ -1211,53 +1162,41 @@ struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode)
1211 return NULL; 1162 return NULL;
1212 } 1163 }
1213 1164
1214 read_lock(&GlobalSMBSeslock); 1165 cifs_sb = CIFS_SB(cifs_inode->vfs_inode.i_sb);
1166
1167 /* only filter by fsuid on multiuser mounts */
1168 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER))
1169 fsuid_only = false;
1170
1171 spin_lock(&cifs_file_list_lock);
1215refind_writable: 1172refind_writable:
1216 list_for_each_entry(open_file, &cifs_inode->openFileList, flist) { 1173 list_for_each_entry(open_file, &cifs_inode->openFileList, flist) {
1217 if (open_file->closePend || 1174 if (!any_available && open_file->pid != current->tgid)
1218 (!any_available && open_file->pid != current->tgid))
1219 continue; 1175 continue;
1220 1176 if (fsuid_only && open_file->uid != current_fsuid())
1221 if (open_file->pfile && 1177 continue;
1222 ((open_file->pfile->f_flags & O_RDWR) || 1178 if (OPEN_FMODE(open_file->f_flags) & FMODE_WRITE) {
1223 (open_file->pfile->f_flags & O_WRONLY))) {
1224 cifsFileInfo_get(open_file); 1179 cifsFileInfo_get(open_file);
1225 1180
1226 if (!open_file->invalidHandle) { 1181 if (!open_file->invalidHandle) {
1227 /* found a good writable file */ 1182 /* found a good writable file */
1228 read_unlock(&GlobalSMBSeslock); 1183 spin_unlock(&cifs_file_list_lock);
1229 return open_file; 1184 return open_file;
1230 } 1185 }
1231 1186
1232 read_unlock(&GlobalSMBSeslock); 1187 spin_unlock(&cifs_file_list_lock);
1188
1233 /* Had to unlock since following call can block */ 1189 /* Had to unlock since following call can block */
1234 rc = cifs_reopen_file(open_file->pfile, false); 1190 rc = cifs_reopen_file(open_file, false);
1235 if (!rc) { 1191 if (!rc)
1236 if (!open_file->closePend) 1192 return open_file;
1237 return open_file;
1238 else { /* start over in case this was deleted */
1239 /* since the list could be modified */
1240 read_lock(&GlobalSMBSeslock);
1241 cifsFileInfo_put(open_file);
1242 goto refind_writable;
1243 }
1244 }
1245 1193
1246 /* if it fails, try another handle if possible - 1194 /* if it fails, try another handle if possible */
1247 (we can not do this if closePending since
1248 loop could be modified - in which case we
1249 have to start at the beginning of the list
1250 again. Note that it would be bad
1251 to hold up writepages here (rather than
1252 in caller) with continuous retries */
1253 cFYI(1, "wp failed on reopen file"); 1195 cFYI(1, "wp failed on reopen file");
1254 read_lock(&GlobalSMBSeslock);
1255 /* can not use this handle, no write
1256 pending on this one after all */
1257 cifsFileInfo_put(open_file); 1196 cifsFileInfo_put(open_file);
1258 1197
1259 if (open_file->closePend) /* list could have changed */ 1198 spin_lock(&cifs_file_list_lock);
1260 goto refind_writable; 1199
1261 /* else we simply continue to the next entry. Thus 1200 /* else we simply continue to the next entry. Thus
1262 we do not loop on reopen errors. If we 1201 we do not loop on reopen errors. If we
1263 can not reopen the file, for example if we 1202 can not reopen the file, for example if we
@@ -1272,7 +1211,7 @@ refind_writable:
1272 any_available = true; 1211 any_available = true;
1273 goto refind_writable; 1212 goto refind_writable;
1274 } 1213 }
1275 read_unlock(&GlobalSMBSeslock); 1214 spin_unlock(&cifs_file_list_lock);
1276 return NULL; 1215 return NULL;
1277} 1216}
1278 1217
@@ -1284,7 +1223,6 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
1284 int rc = -EFAULT; 1223 int rc = -EFAULT;
1285 int bytes_written = 0; 1224 int bytes_written = 0;
1286 struct cifs_sb_info *cifs_sb; 1225 struct cifs_sb_info *cifs_sb;
1287 struct cifsTconInfo *pTcon;
1288 struct inode *inode; 1226 struct inode *inode;
1289 struct cifsFileInfo *open_file; 1227 struct cifsFileInfo *open_file;
1290 1228
@@ -1293,7 +1231,6 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
1293 1231
1294 inode = page->mapping->host; 1232 inode = page->mapping->host;
1295 cifs_sb = CIFS_SB(inode->i_sb); 1233 cifs_sb = CIFS_SB(inode->i_sb);
1296 pTcon = cifs_sb->tcon;
1297 1234
1298 offset += (loff_t)from; 1235 offset += (loff_t)from;
1299 write_data = kmap(page); 1236 write_data = kmap(page);
@@ -1314,10 +1251,10 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
1314 if (mapping->host->i_size - offset < (loff_t)to) 1251 if (mapping->host->i_size - offset < (loff_t)to)
1315 to = (unsigned)(mapping->host->i_size - offset); 1252 to = (unsigned)(mapping->host->i_size - offset);
1316 1253
1317 open_file = find_writable_file(CIFS_I(mapping->host)); 1254 open_file = find_writable_file(CIFS_I(mapping->host), false);
1318 if (open_file) { 1255 if (open_file) {
1319 bytes_written = cifs_write(open_file->pfile, write_data, 1256 bytes_written = cifs_write(open_file, write_data,
1320 to-from, &offset); 1257 to - from, &offset);
1321 cifsFileInfo_put(open_file); 1258 cifsFileInfo_put(open_file);
1322 /* Does mm or vfs already set times? */ 1259 /* Does mm or vfs already set times? */
1323 inode->i_atime = inode->i_mtime = current_fs_time(inode->i_sb); 1260 inode->i_atime = inode->i_mtime = current_fs_time(inode->i_sb);
@@ -1337,7 +1274,6 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
1337static int cifs_writepages(struct address_space *mapping, 1274static int cifs_writepages(struct address_space *mapping,
1338 struct writeback_control *wbc) 1275 struct writeback_control *wbc)
1339{ 1276{
1340 struct backing_dev_info *bdi = mapping->backing_dev_info;
1341 unsigned int bytes_to_write; 1277 unsigned int bytes_to_write;
1342 unsigned int bytes_written; 1278 unsigned int bytes_written;
1343 struct cifs_sb_info *cifs_sb; 1279 struct cifs_sb_info *cifs_sb;
@@ -1352,6 +1288,7 @@ static int cifs_writepages(struct address_space *mapping,
1352 int nr_pages; 1288 int nr_pages;
1353 __u64 offset = 0; 1289 __u64 offset = 0;
1354 struct cifsFileInfo *open_file; 1290 struct cifsFileInfo *open_file;
1291 struct cifsTconInfo *tcon;
1355 struct cifsInodeInfo *cifsi = CIFS_I(mapping->host); 1292 struct cifsInodeInfo *cifsi = CIFS_I(mapping->host);
1356 struct page *page; 1293 struct page *page;
1357 struct pagevec pvec; 1294 struct pagevec pvec;
@@ -1368,26 +1305,29 @@ static int cifs_writepages(struct address_space *mapping,
1368 if (cifs_sb->wsize < PAGE_CACHE_SIZE) 1305 if (cifs_sb->wsize < PAGE_CACHE_SIZE)
1369 return generic_writepages(mapping, wbc); 1306 return generic_writepages(mapping, wbc);
1370 1307
1371 if ((cifs_sb->tcon->ses) && (cifs_sb->tcon->ses->server))
1372 if (cifs_sb->tcon->ses->server->secMode &
1373 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
1374 if (!experimEnabled)
1375 return generic_writepages(mapping, wbc);
1376
1377 iov = kmalloc(32 * sizeof(struct kvec), GFP_KERNEL); 1308 iov = kmalloc(32 * sizeof(struct kvec), GFP_KERNEL);
1378 if (iov == NULL) 1309 if (iov == NULL)
1379 return generic_writepages(mapping, wbc); 1310 return generic_writepages(mapping, wbc);
1380 1311
1381
1382 /* 1312 /*
1383 * BB: Is this meaningful for a non-block-device file system? 1313 * if there's no open file, then this is likely to fail too,
1384 * If it is, we should test it again after we do I/O 1314 * but it'll at least handle the return. Maybe it should be
1315 * a BUG() instead?
1385 */ 1316 */
1386 if (wbc->nonblocking && bdi_write_congested(bdi)) { 1317 open_file = find_writable_file(CIFS_I(mapping->host), false);
1387 wbc->encountered_congestion = 1; 1318 if (!open_file) {
1388 kfree(iov); 1319 kfree(iov);
1389 return 0; 1320 return generic_writepages(mapping, wbc);
1321 }
1322
1323 tcon = tlink_tcon(open_file->tlink);
1324 if (!experimEnabled && tcon->ses->server->secMode &
1325 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) {
1326 cifsFileInfo_put(open_file);
1327 kfree(iov);
1328 return generic_writepages(mapping, wbc);
1390 } 1329 }
1330 cifsFileInfo_put(open_file);
1391 1331
1392 xid = GetXid(); 1332 xid = GetXid();
1393 1333
@@ -1492,38 +1432,29 @@ retry:
1492 break; 1432 break;
1493 } 1433 }
1494 if (n_iov) { 1434 if (n_iov) {
1495 /* Search for a writable handle every time we call 1435 open_file = find_writable_file(CIFS_I(mapping->host),
1496 * CIFSSMBWrite2. We can't rely on the last handle 1436 false);
1497 * we used to still be valid
1498 */
1499 open_file = find_writable_file(CIFS_I(mapping->host));
1500 if (!open_file) { 1437 if (!open_file) {
1501 cERROR(1, "No writable handles for inode"); 1438 cERROR(1, "No writable handles for inode");
1502 rc = -EBADF; 1439 rc = -EBADF;
1503 } else { 1440 } else {
1504 long_op = cifs_write_timeout(cifsi, offset); 1441 long_op = cifs_write_timeout(cifsi, offset);
1505 rc = CIFSSMBWrite2(xid, cifs_sb->tcon, 1442 rc = CIFSSMBWrite2(xid, tcon, open_file->netfid,
1506 open_file->netfid,
1507 bytes_to_write, offset, 1443 bytes_to_write, offset,
1508 &bytes_written, iov, n_iov, 1444 &bytes_written, iov, n_iov,
1509 long_op); 1445 long_op);
1510 cifsFileInfo_put(open_file); 1446 cifsFileInfo_put(open_file);
1511 cifs_update_eof(cifsi, offset, bytes_written); 1447 cifs_update_eof(cifsi, offset, bytes_written);
1448 }
1512 1449
1513 if (rc || bytes_written < bytes_to_write) { 1450 if (rc || bytes_written < bytes_to_write) {
1514 cERROR(1, "Write2 ret %d, wrote %d", 1451 cERROR(1, "Write2 ret %d, wrote %d",
1515 rc, bytes_written); 1452 rc, bytes_written);
1516 /* BB what if continued retry is 1453 mapping_set_error(mapping, rc);
1517 requested via mount flags? */ 1454 } else {
1518 if (rc == -ENOSPC) 1455 cifs_stats_bytes_written(tcon, bytes_written);
1519 set_bit(AS_ENOSPC, &mapping->flags);
1520 else
1521 set_bit(AS_EIO, &mapping->flags);
1522 } else {
1523 cifs_stats_bytes_written(cifs_sb->tcon,
1524 bytes_written);
1525 }
1526 } 1456 }
1457
1527 for (i = 0; i < n_iov; i++) { 1458 for (i = 0; i < n_iov; i++) {
1528 page = pvec.pages[first + i]; 1459 page = pvec.pages[first + i];
1529 /* Should we also set page error on 1460 /* Should we also set page error on
@@ -1624,7 +1555,8 @@ static int cifs_write_end(struct file *file, struct address_space *mapping,
1624 /* BB check if anything else missing out of ppw 1555 /* BB check if anything else missing out of ppw
1625 such as updating last write time */ 1556 such as updating last write time */
1626 page_data = kmap(page); 1557 page_data = kmap(page);
1627 rc = cifs_write(file, page_data + offset, copied, &pos); 1558 rc = cifs_write(file->private_data, page_data + offset,
1559 copied, &pos);
1628 /* if (rc < 0) should we set writebehind rc? */ 1560 /* if (rc < 0) should we set writebehind rc? */
1629 kunmap(page); 1561 kunmap(page);
1630 1562
@@ -1663,11 +1595,10 @@ int cifs_fsync(struct file *file, int datasync)
1663 1595
1664 rc = filemap_write_and_wait(inode->i_mapping); 1596 rc = filemap_write_and_wait(inode->i_mapping);
1665 if (rc == 0) { 1597 if (rc == 0) {
1666 rc = CIFS_I(inode)->write_behind_rc; 1598 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
1667 CIFS_I(inode)->write_behind_rc = 0; 1599
1668 tcon = CIFS_SB(inode->i_sb)->tcon; 1600 tcon = tlink_tcon(smbfile->tlink);
1669 if (!rc && tcon && smbfile && 1601 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC))
1670 !(CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC))
1671 rc = CIFSSMBFlush(xid, tcon, smbfile->netfid); 1602 rc = CIFSSMBFlush(xid, tcon, smbfile->netfid);
1672 } 1603 }
1673 1604
@@ -1712,21 +1643,8 @@ int cifs_flush(struct file *file, fl_owner_t id)
1712 struct inode *inode = file->f_path.dentry->d_inode; 1643 struct inode *inode = file->f_path.dentry->d_inode;
1713 int rc = 0; 1644 int rc = 0;
1714 1645
1715 /* Rather than do the steps manually: 1646 if (file->f_mode & FMODE_WRITE)
1716 lock the inode for writing 1647 rc = filemap_write_and_wait(inode->i_mapping);
1717 loop through pages looking for write behind data (dirty pages)
1718 coalesce into contiguous 16K (or smaller) chunks to write to server
1719 send to server (prefer in parallel)
1720 deal with writebehind errors
1721 unlock inode for writing
1722 filemapfdatawrite appears easier for the time being */
1723
1724 rc = filemap_fdatawrite(inode->i_mapping);
1725 /* reset wb rc if we were able to write out dirty pages */
1726 if (!rc) {
1727 rc = CIFS_I(inode)->write_behind_rc;
1728 CIFS_I(inode)->write_behind_rc = 0;
1729 }
1730 1648
1731 cFYI(1, "Flush inode %p file %p rc %d", inode, file, rc); 1649 cFYI(1, "Flush inode %p file %p rc %d", inode, file, rc);
1732 1650
@@ -1750,7 +1668,6 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
1750 1668
1751 xid = GetXid(); 1669 xid = GetXid();
1752 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 1670 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
1753 pTcon = cifs_sb->tcon;
1754 1671
1755 if (file->private_data == NULL) { 1672 if (file->private_data == NULL) {
1756 rc = -EBADF; 1673 rc = -EBADF;
@@ -1758,6 +1675,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
1758 return rc; 1675 return rc;
1759 } 1676 }
1760 open_file = file->private_data; 1677 open_file = file->private_data;
1678 pTcon = tlink_tcon(open_file->tlink);
1761 1679
1762 if ((file->f_flags & O_ACCMODE) == O_WRONLY) 1680 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
1763 cFYI(1, "attempting read on write only file instance"); 1681 cFYI(1, "attempting read on write only file instance");
@@ -1771,9 +1689,8 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
1771 smb_read_data = NULL; 1689 smb_read_data = NULL;
1772 while (rc == -EAGAIN) { 1690 while (rc == -EAGAIN) {
1773 int buf_type = CIFS_NO_BUFFER; 1691 int buf_type = CIFS_NO_BUFFER;
1774 if ((open_file->invalidHandle) && 1692 if (open_file->invalidHandle) {
1775 (!open_file->closePend)) { 1693 rc = cifs_reopen_file(open_file, true);
1776 rc = cifs_reopen_file(file, true);
1777 if (rc != 0) 1694 if (rc != 0)
1778 break; 1695 break;
1779 } 1696 }
@@ -1831,7 +1748,6 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
1831 1748
1832 xid = GetXid(); 1749 xid = GetXid();
1833 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 1750 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
1834 pTcon = cifs_sb->tcon;
1835 1751
1836 if (file->private_data == NULL) { 1752 if (file->private_data == NULL) {
1837 rc = -EBADF; 1753 rc = -EBADF;
@@ -1839,6 +1755,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
1839 return rc; 1755 return rc;
1840 } 1756 }
1841 open_file = file->private_data; 1757 open_file = file->private_data;
1758 pTcon = tlink_tcon(open_file->tlink);
1842 1759
1843 if ((file->f_flags & O_ACCMODE) == O_WRONLY) 1760 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
1844 cFYI(1, "attempting read on write only file instance"); 1761 cFYI(1, "attempting read on write only file instance");
@@ -1857,9 +1774,8 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
1857 } 1774 }
1858 rc = -EAGAIN; 1775 rc = -EAGAIN;
1859 while (rc == -EAGAIN) { 1776 while (rc == -EAGAIN) {
1860 if ((open_file->invalidHandle) && 1777 if (open_file->invalidHandle) {
1861 (!open_file->closePend)) { 1778 rc = cifs_reopen_file(open_file, true);
1862 rc = cifs_reopen_file(file, true);
1863 if (rc != 0) 1779 if (rc != 0)
1864 break; 1780 break;
1865 } 1781 }
@@ -1974,7 +1890,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
1974 } 1890 }
1975 open_file = file->private_data; 1891 open_file = file->private_data;
1976 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 1892 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
1977 pTcon = cifs_sb->tcon; 1893 pTcon = tlink_tcon(open_file->tlink);
1978 1894
1979 /* 1895 /*
1980 * Reads as many pages as possible from fscache. Returns -ENOBUFS 1896 * Reads as many pages as possible from fscache. Returns -ENOBUFS
@@ -2022,9 +1938,8 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
2022 read_size, contig_pages); 1938 read_size, contig_pages);
2023 rc = -EAGAIN; 1939 rc = -EAGAIN;
2024 while (rc == -EAGAIN) { 1940 while (rc == -EAGAIN) {
2025 if ((open_file->invalidHandle) && 1941 if (open_file->invalidHandle) {
2026 (!open_file->closePend)) { 1942 rc = cifs_reopen_file(open_file, true);
2027 rc = cifs_reopen_file(file, true);
2028 if (rc != 0) 1943 if (rc != 0)
2029 break; 1944 break;
2030 } 1945 }
@@ -2173,18 +2088,14 @@ static int is_inode_writable(struct cifsInodeInfo *cifs_inode)
2173{ 2088{
2174 struct cifsFileInfo *open_file; 2089 struct cifsFileInfo *open_file;
2175 2090
2176 read_lock(&GlobalSMBSeslock); 2091 spin_lock(&cifs_file_list_lock);
2177 list_for_each_entry(open_file, &cifs_inode->openFileList, flist) { 2092 list_for_each_entry(open_file, &cifs_inode->openFileList, flist) {
2178 if (open_file->closePend) 2093 if (OPEN_FMODE(open_file->f_flags) & FMODE_WRITE) {
2179 continue; 2094 spin_unlock(&cifs_file_list_lock);
2180 if (open_file->pfile &&
2181 ((open_file->pfile->f_flags & O_RDWR) ||
2182 (open_file->pfile->f_flags & O_WRONLY))) {
2183 read_unlock(&GlobalSMBSeslock);
2184 return 1; 2095 return 1;
2185 } 2096 }
2186 } 2097 }
2187 read_unlock(&GlobalSMBSeslock); 2098 spin_unlock(&cifs_file_list_lock);
2188 return 0; 2099 return 0;
2189} 2100}
2190 2101
@@ -2310,10 +2221,9 @@ void cifs_oplock_break(struct work_struct *work)
2310{ 2221{
2311 struct cifsFileInfo *cfile = container_of(work, struct cifsFileInfo, 2222 struct cifsFileInfo *cfile = container_of(work, struct cifsFileInfo,
2312 oplock_break); 2223 oplock_break);
2313 struct inode *inode = cfile->pInode; 2224 struct inode *inode = cfile->dentry->d_inode;
2314 struct cifsInodeInfo *cinode = CIFS_I(inode); 2225 struct cifsInodeInfo *cinode = CIFS_I(inode);
2315 struct cifs_sb_info *cifs_sb = CIFS_SB(cfile->mnt->mnt_sb); 2226 int rc = 0;
2316 int rc, waitrc = 0;
2317 2227
2318 if (inode && S_ISREG(inode->i_mode)) { 2228 if (inode && S_ISREG(inode->i_mode)) {
2319 if (cinode->clientCanCacheRead) 2229 if (cinode->clientCanCacheRead)
@@ -2322,13 +2232,10 @@ void cifs_oplock_break(struct work_struct *work)
2322 break_lease(inode, O_WRONLY); 2232 break_lease(inode, O_WRONLY);
2323 rc = filemap_fdatawrite(inode->i_mapping); 2233 rc = filemap_fdatawrite(inode->i_mapping);
2324 if (cinode->clientCanCacheRead == 0) { 2234 if (cinode->clientCanCacheRead == 0) {
2325 waitrc = filemap_fdatawait(inode->i_mapping); 2235 rc = filemap_fdatawait(inode->i_mapping);
2236 mapping_set_error(inode->i_mapping, rc);
2326 invalidate_remote_inode(inode); 2237 invalidate_remote_inode(inode);
2327 } 2238 }
2328 if (!rc)
2329 rc = waitrc;
2330 if (rc)
2331 cinode->write_behind_rc = rc;
2332 cFYI(1, "Oplock flush inode %p rc %d", inode, rc); 2239 cFYI(1, "Oplock flush inode %p rc %d", inode, rc);
2333 } 2240 }
2334 2241
@@ -2338,33 +2245,34 @@ void cifs_oplock_break(struct work_struct *work)
2338 * not bother sending an oplock release if session to server still is 2245 * not bother sending an oplock release if session to server still is
2339 * disconnected since oplock already released by the server 2246 * disconnected since oplock already released by the server
2340 */ 2247 */
2341 if (!cfile->closePend && !cfile->oplock_break_cancelled) { 2248 if (!cfile->oplock_break_cancelled) {
2342 rc = CIFSSMBLock(0, cifs_sb->tcon, cfile->netfid, 0, 0, 0, 0, 2249 rc = CIFSSMBLock(0, tlink_tcon(cfile->tlink), cfile->netfid, 0,
2343 LOCKING_ANDX_OPLOCK_RELEASE, false); 2250 0, 0, 0, LOCKING_ANDX_OPLOCK_RELEASE, false);
2344 cFYI(1, "Oplock release rc = %d", rc); 2251 cFYI(1, "Oplock release rc = %d", rc);
2345 } 2252 }
2346 2253
2347 /* 2254 /*
2348 * We might have kicked in before is_valid_oplock_break() 2255 * We might have kicked in before is_valid_oplock_break()
2349 * finished grabbing reference for us. Make sure it's done by 2256 * finished grabbing reference for us. Make sure it's done by
2350 * waiting for GlobalSMSSeslock. 2257 * waiting for cifs_file_list_lock.
2351 */ 2258 */
2352 write_lock(&GlobalSMBSeslock); 2259 spin_lock(&cifs_file_list_lock);
2353 write_unlock(&GlobalSMBSeslock); 2260 spin_unlock(&cifs_file_list_lock);
2354 2261
2355 cifs_oplock_break_put(cfile); 2262 cifs_oplock_break_put(cfile);
2356} 2263}
2357 2264
2265/* must be called while holding cifs_file_list_lock */
2358void cifs_oplock_break_get(struct cifsFileInfo *cfile) 2266void cifs_oplock_break_get(struct cifsFileInfo *cfile)
2359{ 2267{
2360 mntget(cfile->mnt); 2268 cifs_sb_active(cfile->dentry->d_sb);
2361 cifsFileInfo_get(cfile); 2269 cifsFileInfo_get(cfile);
2362} 2270}
2363 2271
2364void cifs_oplock_break_put(struct cifsFileInfo *cfile) 2272void cifs_oplock_break_put(struct cifsFileInfo *cfile)
2365{ 2273{
2366 mntput(cfile->mnt);
2367 cifsFileInfo_put(cfile); 2274 cifsFileInfo_put(cfile);
2275 cifs_sb_deactive(cfile->dentry->d_sb);
2368} 2276}
2369 2277
2370const struct address_space_operations cifs_addr_ops = { 2278const struct address_space_operations cifs_addr_ops = {