From 08afdbe58fd5ed4c1a038b1a8365e0c469074778 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Mon, 22 Sep 2008 21:33:33 -0400 Subject: [PATCH] --- yaml --- r: 111144 b: refs/heads/master c: 2846d3864738dd6e290755d0692cf377e09ba79f h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/cifs/file.c | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index 6be3e91c11b8..5eeb8bac9c68 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 232087cb734c7035c0a8947fb05d3e8092ff6c4d +refs/heads/master: 2846d3864738dd6e290755d0692cf377e09ba79f diff --git a/trunk/fs/cifs/file.c b/trunk/fs/cifs/file.c index cbefe1f1f9fe..d39e852a28a9 100644 --- a/trunk/fs/cifs/file.c +++ b/trunk/fs/cifs/file.c @@ -1065,6 +1065,7 @@ struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode) struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode) { struct cifsFileInfo *open_file; + bool any_available = false; int rc; /* Having a null inode here (because mapping->host was set to zero by @@ -1080,8 +1081,10 @@ 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) + if (open_file->closePend || + (!any_available && open_file->pid != current->tgid)) continue; + if (open_file->pfile && ((open_file->pfile->f_flags & O_RDWR) || (open_file->pfile->f_flags & O_WRONLY))) { @@ -1131,6 +1134,11 @@ struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode) of the loop here. */ } } + /* couldn't find useable FH with same pid, try any available */ + if (!any_available) { + any_available = true; + goto refind_writable; + } read_unlock(&GlobalSMBSeslock); return NULL; }