Commit d8c2ddb6 authored by Steve French's avatar Steve French Committed by Steve French

handle partial page update of page in cache that is not uptodate better for...

handle partial page update of page in cache that is not uptodate better for the situation in which file is open writeonly
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent e22fe382
...@@ -778,6 +778,9 @@ cifs_writepage(struct page* page, struct writeback_control *wbc) ...@@ -778,6 +778,9 @@ cifs_writepage(struct page* page, struct writeback_control *wbc)
xid = GetXid(); xid = GetXid();
/* BB add check for wbc flags */ /* BB add check for wbc flags */
page_cache_get(page); page_cache_get(page);
if (!PageUptodate(page)) {
cFYI(1,("ppw - page not up to date"));
}
rc = cifs_partialpagewrite(page,0,PAGE_CACHE_SIZE); rc = cifs_partialpagewrite(page,0,PAGE_CACHE_SIZE);
SetPageUptodate(page); /* BB add check for error and Clearuptodate? */ SetPageUptodate(page); /* BB add check for error and Clearuptodate? */
...@@ -795,8 +798,7 @@ cifs_commit_write(struct file *file, struct page *page, unsigned offset, ...@@ -795,8 +798,7 @@ cifs_commit_write(struct file *file, struct page *page, unsigned offset,
int rc = 0; int rc = 0;
struct inode *inode = page->mapping->host; struct inode *inode = page->mapping->host;
loff_t position = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to; loff_t position = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
/* struct cifsFileInfo *open_file; char * page_data;
struct cifs_sb_info *cifs_sb; */
xid = GetXid(); xid = GetXid();
cFYI(1,("commit write for page %p up to position %lld for %d",page,position,to)); cFYI(1,("commit write for page %p up to position %lld for %d",page,position,to));
...@@ -827,7 +829,31 @@ cifs_commit_write(struct file *file, struct page *page, unsigned offset, ...@@ -827,7 +829,31 @@ cifs_commit_write(struct file *file, struct page *page, unsigned offset,
cFYI(1,(" SetEOF (commit write) rc = %d",rc)); cFYI(1,(" SetEOF (commit write) rc = %d",rc));
}*/ }*/
} }
if (!PageUptodate(page)) {
position = ((loff_t)page->index << PAGE_CACHE_SHIFT) + offset;
/* can not rely on (or let) writepage write this data */
if(to < offset) {
cFYI(1,("Illegal offsets, can not copy from %d to %d",
offset,to));
FreeXid(xid);
return rc;
}
/* this is probably better than directly calling
partialpage_write since in this function
the file handle is known which we might as well
leverage */
/* BB check if anything else missing out of ppw */
/* such as updating last write time */
page_data = kmap(page);
rc = cifs_write(file, page_data+offset,to-offset,
&position);
if(rc > 0)
rc = 0;
/* else if rc < 0 should we set writebehind rc? */
kunmap(page);
} else {
set_page_dirty(page); set_page_dirty(page);
}
FreeXid(xid); FreeXid(xid);
return rc; return rc;
...@@ -2003,10 +2029,14 @@ int cifs_prepare_write(struct file *file, struct page *page, ...@@ -2003,10 +2029,14 @@ int cifs_prepare_write(struct file *file, struct page *page,
SetPageUptodate(page); SetPageUptodate(page);
/* might as well read a page, it is fast enough */ /* might as well read a page, it is fast enough */
if((file->f_flags & O_ACCMODE) != O_WRONLY) {
rc = cifs_readpage_worker(file,page,&offset); rc = cifs_readpage_worker(file,page,&offset);
/* if this returns an error should we try using another } else {
/* should we try using another
file handle if there is one - how would we lock it file handle if there is one - how would we lock it
to prevent close of that handle racing with this read? */ to prevent close of that handle racing with this read? */
/* In any case this will be written out by commit_write */
}
} }
/* BB should we pass any errors back? e.g. if we do not have read access to the file */ /* BB should we pass any errors back? e.g. if we do not have read access to the file */
......
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