aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/file.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-08-18 09:30:07 -0700
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-08-18 09:30:07 -0700
commitedd5f25f7475013b44f7942bb3b25022792a9c9d (patch)
tree6db5ebb2deb385b029158c5727835b5b71c9603b /fs/cifs/file.c
parentReset current->pdeath_signal on SUID binary execution (diff)
parent[CIFS] Check return code on failed alloc (diff)
downloadlinux-dev-edd5f25f7475013b44f7942bb3b25022792a9c9d.tar.xz
linux-dev-edd5f25f7475013b44f7942bb3b25022792a9c9d.zip
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6: [CIFS] Check return code on failed alloc [CIFS] Update CIFS project web site [CIFS] Fix hang in find_writable_file
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r--fs/cifs/file.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index e13592afca9c..894b1f7b299d 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1904,6 +1904,25 @@ static int cifs_readpage(struct file *file, struct page *page)
return rc;
}
+static int is_inode_writable(struct cifsInodeInfo *cifs_inode)
+{
+ struct cifsFileInfo *open_file;
+
+ read_lock(&GlobalSMBSeslock);
+ 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))) {
+ read_unlock(&GlobalSMBSeslock);
+ return 1;
+ }
+ }
+ read_unlock(&GlobalSMBSeslock);
+ return 0;
+}
+
/* We do not want to update the file size from server for inodes
open for write - to avoid races with writepage extending
the file - in the future we could consider allowing
@@ -1912,19 +1931,13 @@ static int cifs_readpage(struct file *file, struct page *page)
page caching in the current Linux kernel design */
int is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file)
{
- struct cifsFileInfo *open_file = NULL;
-
- if (cifsInode)
- open_file = find_writable_file(cifsInode);
+ if (!cifsInode)
+ return 1;
- if (open_file) {
+ if (is_inode_writable(cifsInode)) {
+ /* This inode is open for write at least once */
struct cifs_sb_info *cifs_sb;
- /* there is not actually a write pending so let
- this handle go free and allow it to
- be closable if needed */
- atomic_dec(&open_file->wrtPending);
-
cifs_sb = CIFS_SB(cifsInode->vfs_inode.i_sb);
if ( cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO ) {
/* since no page cache to corrupt on directio