diff options
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r-- | fs/cifs/file.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 1e7e4c06d9e3..68ad4ca0cfa3 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c | |||
@@ -1026,6 +1026,37 @@ static ssize_t cifs_write(struct file *file, const char *write_data, | |||
1026 | return total_written; | 1026 | return total_written; |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | #ifdef CONFIG_CIFS_EXPERIMENTAL | ||
1030 | struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode) | ||
1031 | { | ||
1032 | struct cifsFileInfo *open_file = NULL; | ||
1033 | |||
1034 | read_lock(&GlobalSMBSeslock); | ||
1035 | /* we could simply get the first_list_entry since write-only entries | ||
1036 | are always at the end of the list but since the first entry might | ||
1037 | have a close pending, we go through the whole list */ | ||
1038 | list_for_each_entry(open_file, &cifs_inode->openFileList, flist) { | ||
1039 | if (open_file->closePend) | ||
1040 | continue; | ||
1041 | if (open_file->pfile && ((open_file->pfile->f_flags & O_RDWR) || | ||
1042 | (open_file->pfile->f_flags & O_RDONLY))) { | ||
1043 | if (!open_file->invalidHandle) { | ||
1044 | /* found a good file */ | ||
1045 | /* lock it so it will not be closed on us */ | ||
1046 | atomic_inc(&open_file->wrtPending); | ||
1047 | read_unlock(&GlobalSMBSeslock); | ||
1048 | return open_file; | ||
1049 | } /* else might as well continue, and look for | ||
1050 | another, or simply have the caller reopen it | ||
1051 | again rather than trying to fix this handle */ | ||
1052 | } else /* write only file */ | ||
1053 | break; /* write only files are last so must be done */ | ||
1054 | } | ||
1055 | read_unlock(&GlobalSMBSeslock); | ||
1056 | return NULL; | ||
1057 | } | ||
1058 | #endif | ||
1059 | |||
1029 | struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode) | 1060 | struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode) |
1030 | { | 1061 | { |
1031 | struct cifsFileInfo *open_file; | 1062 | struct cifsFileInfo *open_file; |