diff options
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r-- | fs/cifs/file.c | 33 |
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) | |||
1904 | return rc; | 1904 | return rc; |
1905 | } | 1905 | } |
1906 | 1906 | ||
1907 | static int is_inode_writable(struct cifsInodeInfo *cifs_inode) | ||
1908 | { | ||
1909 | struct cifsFileInfo *open_file; | ||
1910 | |||
1911 | read_lock(&GlobalSMBSeslock); | ||
1912 | list_for_each_entry(open_file, &cifs_inode->openFileList, flist) { | ||
1913 | if (open_file->closePend) | ||
1914 | continue; | ||
1915 | if (open_file->pfile && | ||
1916 | ((open_file->pfile->f_flags & O_RDWR) || | ||
1917 | (open_file->pfile->f_flags & O_WRONLY))) { | ||
1918 | read_unlock(&GlobalSMBSeslock); | ||
1919 | return 1; | ||
1920 | } | ||
1921 | } | ||
1922 | read_unlock(&GlobalSMBSeslock); | ||
1923 | return 0; | ||
1924 | } | ||
1925 | |||
1907 | /* We do not want to update the file size from server for inodes | 1926 | /* We do not want to update the file size from server for inodes |
1908 | open for write - to avoid races with writepage extending | 1927 | open for write - to avoid races with writepage extending |
1909 | the file - in the future we could consider allowing | 1928 | the file - in the future we could consider allowing |
@@ -1912,19 +1931,13 @@ static int cifs_readpage(struct file *file, struct page *page) | |||
1912 | page caching in the current Linux kernel design */ | 1931 | page caching in the current Linux kernel design */ |
1913 | int is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file) | 1932 | int is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file) |
1914 | { | 1933 | { |
1915 | struct cifsFileInfo *open_file = NULL; | 1934 | if (!cifsInode) |
1916 | 1935 | return 1; | |
1917 | if (cifsInode) | ||
1918 | open_file = find_writable_file(cifsInode); | ||
1919 | 1936 | ||
1920 | if (open_file) { | 1937 | if (is_inode_writable(cifsInode)) { |
1938 | /* This inode is open for write at least once */ | ||
1921 | struct cifs_sb_info *cifs_sb; | 1939 | struct cifs_sb_info *cifs_sb; |
1922 | 1940 | ||
1923 | /* there is not actually a write pending so let | ||
1924 | this handle go free and allow it to | ||
1925 | be closable if needed */ | ||
1926 | atomic_dec(&open_file->wrtPending); | ||
1927 | |||
1928 | cifs_sb = CIFS_SB(cifsInode->vfs_inode.i_sb); | 1941 | cifs_sb = CIFS_SB(cifsInode->vfs_inode.i_sb); |
1929 | if ( cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO ) { | 1942 | if ( cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO ) { |
1930 | /* since no page cache to corrupt on directio | 1943 | /* since no page cache to corrupt on directio |