Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 71565
b: refs/heads/master
c: 9b22b0b
h: refs/heads/master
i:
  71563: 40045bd
v: v3
  • Loading branch information
Steve French committed Oct 2, 2007
1 parent aef3242 commit d5b0bcf
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4084973dbae9a24e58598d6cdf60f0e5e4a3cabf
refs/heads/master: 9b22b0b726c6e46048767728a0900c8c05f93c21
54 changes: 39 additions & 15 deletions trunk/fs/cifs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1042,33 +1042,57 @@ struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode)
}

read_lock(&GlobalSMBSeslock);
refind_writable:
list_for_each_entry(open_file, &cifs_inode->openFileList, flist) {
if (open_file->closePend)
continue;
if (open_file->pfile &&
((open_file->pfile->f_flags & O_RDWR) ||
(open_file->pfile->f_flags & O_WRONLY))) {
atomic_inc(&open_file->wrtPending);

if (!open_file->invalidHandle) {
/* found a good writable file */
read_unlock(&GlobalSMBSeslock);
return open_file;
}

read_unlock(&GlobalSMBSeslock);
if (open_file->invalidHandle) {
rc = cifs_reopen_file(open_file->pfile, FALSE);
/* if it fails, try another handle - might be */
/* dangerous to hold up writepages with retry */
if (rc) {
cFYI(1, ("wp failed on reopen file"));
/* Had to unlock since following call can block */
rc = cifs_reopen_file(open_file->pfile, FALSE);
if (!rc) {
if (!open_file->closePend)
return open_file;
else { /* start over in case this was deleted */
/* since the list could be modified */
read_lock(&GlobalSMBSeslock);
/* can not use this handle, no write
pending on this one after all */
atomic_dec(&open_file->wrtPending);
continue;
goto refind_writable;
}
}
if (open_file->closePend) {
read_lock(&GlobalSMBSeslock);
atomic_dec(&open_file->wrtPending);
continue;
}
return open_file;

/* if it fails, try another handle if possible -
(we can not do this if closePending since
loop could be modified - in which case we
have to start at the beginning of the list
again. Note that it would be bad
to hold up writepages here (rather than
in caller) with continuous retries */
cFYI(1, ("wp failed on reopen file"));
read_lock(&GlobalSMBSeslock);
/* can not use this handle, no write
pending on this one after all */
atomic_dec(&open_file->wrtPending);

if (open_file->closePend) /* list could have changed */
goto refind_writable;
/* else we simply continue to the next entry. Thus
we do not loop on reopen errors. If we
can not reopen the file, for example if we
reconnected to a server with another client
racing to delete or lock the file we would not
make progress if we restarted before the beginning
of the loop here. */
}
}
read_unlock(&GlobalSMBSeslock);
Expand Down

0 comments on commit d5b0bcf

Please sign in to comment.