mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-06 14:48:06 +00:00
cifs: have find_writeable_file prefer filehandles opened by same task
When the CIFS client goes to write out pages, it needs to pick a filehandle to write to. find_writeable_file however just picks the first filehandle that it finds. This can cause problems when a lock is issued against a particular filehandle and we pick a different filehandle to write to. This patch tries to avert this situation by having find_writable_file prefer filehandles that have a pid that matches the current task. This seems to fix lock test 11 from the connectathon test suite when run against a windows server. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
This commit is contained in:
parent
232087cb73
commit
2846d38647
1 changed files with 9 additions and 1 deletions
|
@ -1065,6 +1065,7 @@ struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode)
|
||||||
struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode)
|
struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode)
|
||||||
{
|
{
|
||||||
struct cifsFileInfo *open_file;
|
struct cifsFileInfo *open_file;
|
||||||
|
bool any_available = false;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Having a null inode here (because mapping->host was set to zero by
|
/* 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);
|
read_lock(&GlobalSMBSeslock);
|
||||||
refind_writable:
|
refind_writable:
|
||||||
list_for_each_entry(open_file, &cifs_inode->openFileList, flist) {
|
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;
|
continue;
|
||||||
|
|
||||||
if (open_file->pfile &&
|
if (open_file->pfile &&
|
||||||
((open_file->pfile->f_flags & O_RDWR) ||
|
((open_file->pfile->f_flags & O_RDWR) ||
|
||||||
(open_file->pfile->f_flags & O_WRONLY))) {
|
(open_file->pfile->f_flags & O_WRONLY))) {
|
||||||
|
@ -1131,6 +1134,11 @@ refind_writable:
|
||||||
of the loop here. */
|
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);
|
read_unlock(&GlobalSMBSeslock);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue