Commit c8c855b5 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] smb_writepage retval fix

->writepage() is supposed to return zero or a negative error code.  Returning
the number of bytes written will confuse the VFS.
parent 1b2569fb
...@@ -121,31 +121,33 @@ smb_writepage_sync(struct inode *inode, struct page *page, ...@@ -121,31 +121,33 @@ smb_writepage_sync(struct inode *inode, struct page *page,
char *buffer = kmap(page) + pageoffset; char *buffer = kmap(page) + pageoffset;
struct smb_sb_info *server = server_from_inode(inode); struct smb_sb_info *server = server_from_inode(inode);
unsigned int wsize = smb_get_wsize(server); unsigned int wsize = smb_get_wsize(server);
int result, written = 0; int ret = 0;
offset = ((loff_t)page->index << PAGE_CACHE_SHIFT) + pageoffset; offset = ((loff_t)page->index << PAGE_CACHE_SHIFT) + pageoffset;
VERBOSE("file ino=%ld, fileid=%d, count=%d@%Ld, wsize=%d\n", VERBOSE("file ino=%ld, fileid=%d, count=%d@%Ld, wsize=%d\n",
inode->i_ino, SMB_I(inode)->fileid, count, offset, wsize); inode->i_ino, SMB_I(inode)->fileid, count, offset, wsize);
do { do {
int write_ret;
if (count < wsize) if (count < wsize)
wsize = count; wsize = count;
result = server->ops->write(inode, offset, wsize, buffer); write_ret = server->ops->write(inode, offset, wsize, buffer);
if (result < 0) { if (write_ret < 0) {
PARANOIA("failed write, wsize=%d, result=%d\n", PARANOIA("failed write, wsize=%d, write_ret=%d\n",
wsize, result); wsize, write_ret);
ret = write_ret;
break; break;
} }
/* N.B. what if result < wsize?? */ /* N.B. what if result < wsize?? */
#ifdef SMBFS_PARANOIA #ifdef SMBFS_PARANOIA
if (result < wsize) if (write_ret < wsize)
PARANOIA("short write, wsize=%d, result=%d\n", PARANOIA("short write, wsize=%d, write_ret=%d\n",
wsize, result); wsize, write_ret);
#endif #endif
buffer += wsize; buffer += wsize;
offset += wsize; offset += wsize;
written += wsize;
count -= wsize; count -= wsize;
/* /*
* Update the inode now rather than waiting for a refresh. * Update the inode now rather than waiting for a refresh.
...@@ -157,7 +159,7 @@ smb_writepage_sync(struct inode *inode, struct page *page, ...@@ -157,7 +159,7 @@ smb_writepage_sync(struct inode *inode, struct page *page,
} while (count); } while (count);
kunmap(page); kunmap(page);
return written ? written : result; return ret;
} }
/* /*
......
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