Commit 40474c44 authored by Steve French's avatar Steve French Committed by Steve French

check for close pending and invalid file struct on writing out page

parent ec9b2be0
Version 1.16 Version 1.16
------------ ------------
Fix incorrect file size in file handle based setattr on big endian hardware. Fix incorrect file size in file handle based setattr on big endian hardware.
Fix oops in build_path_from_dentry when out of memory. Fix oops in build_path_from_dentry when out of memory. Add checks for invalid
and closing file structs in writepage/partialpagewrite
Version 1.15 Version 1.15
------------ ------------
......
...@@ -558,6 +558,9 @@ cifs_write(struct file * file, const char *write_data, ...@@ -558,6 +558,9 @@ cifs_write(struct file * file, const char *write_data,
int xid, long_op; int xid, long_op;
struct cifsFileInfo * open_file; struct cifsFileInfo * open_file;
if(file->f_dentry == NULL)
return -EBADF;
xid = GetXid(); xid = GetXid();
cifs_sb = CIFS_SB(file->f_dentry->d_sb); cifs_sb = CIFS_SB(file->f_dentry->d_sb);
...@@ -686,6 +689,8 @@ cifs_partialpagewrite(struct page *page,unsigned from, unsigned to) ...@@ -686,6 +689,8 @@ cifs_partialpagewrite(struct page *page,unsigned from, unsigned to)
read_lock(&GlobalSMBSeslock); read_lock(&GlobalSMBSeslock);
list_for_each_safe(tmp, tmp1, &cifsInode->openFileList) { list_for_each_safe(tmp, tmp1, &cifsInode->openFileList) {
open_file = list_entry(tmp,struct cifsFileInfo, flist); open_file = list_entry(tmp,struct cifsFileInfo, flist);
if(open_file->closePend)
continue;
/* We check if file is open for writing first */ /* We check if file is open for writing first */
if((open_file->pfile) && if((open_file->pfile) &&
((open_file->pfile->f_flags & O_RDWR) || ((open_file->pfile->f_flags & O_RDWR) ||
...@@ -699,6 +704,14 @@ cifs_partialpagewrite(struct page *page,unsigned from, unsigned to) ...@@ -699,6 +704,14 @@ cifs_partialpagewrite(struct page *page,unsigned from, unsigned to)
if ((bytes_written > 0) && (offset)) { if ((bytes_written > 0) && (offset)) {
rc = 0; rc = 0;
} else if(bytes_written < 0) { } else if(bytes_written < 0) {
if(rc == -EBADF) {
/* have seen a case in which
kernel seemed to have closed/freed a file
even with writes active so we might as well
see if there are other file structs to try
for the same inode before giving up */
continue;
} else
rc = bytes_written; rc = bytes_written;
} }
break; /* now that we found a valid file handle break; /* now that we found a valid file handle
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment