Commit 338be654 authored by Trond Myklebust's avatar Trond Myklebust

nfs_writepage_sync stack reduction

Patch from akpm
parent 58c4a5c1
......@@ -179,7 +179,13 @@ static int nfs_writepage_sync(struct file *file, struct inode *inode,
{
unsigned int wsize = NFS_SERVER(inode)->wsize;
int result, written = 0;
struct nfs_write_data wdata = {
struct nfs_write_data *wdata;
wdata = kmalloc(sizeof(*wdata), GFP_NOFS);
if (!wdata)
return -ENOMEM;
*wdata = (struct nfs_write_data) {
.flags = how,
.cred = NULL,
.inode = inode,
......@@ -192,8 +198,8 @@ static int nfs_writepage_sync(struct file *file, struct inode *inode,
.count = wsize,
},
.res = {
.fattr = &wdata.fattr,
.verf = &wdata.verf,
.fattr = &wdata->fattr,
.verf = &wdata->verf,
},
};
......@@ -205,22 +211,22 @@ static int nfs_writepage_sync(struct file *file, struct inode *inode,
nfs_begin_data_update(inode);
do {
if (count < wsize)
wdata.args.count = count;
wdata.args.offset = page_offset(page) + wdata.args.pgbase;
wdata->args.count = count;
wdata->args.offset = page_offset(page) + wdata->args.pgbase;
result = NFS_PROTO(inode)->write(&wdata, file);
result = NFS_PROTO(inode)->write(wdata, file);
if (result < 0) {
/* Must mark the page invalid after I/O error */
ClearPageUptodate(page);
goto io_error;
}
if (result < wdata.args.count)
if (result < wdata->args.count)
printk(KERN_WARNING "NFS: short write, count=%u, result=%d\n",
wdata.args.count, result);
wdata->args.count, result);
wdata.args.offset += result;
wdata.args.pgbase += result;
wdata->args.offset += result;
wdata->args.pgbase += result;
written += result;
count -= result;
} while (count);
......@@ -234,9 +240,10 @@ static int nfs_writepage_sync(struct file *file, struct inode *inode,
io_error:
nfs_end_data_update_defer(inode);
if (wdata.cred)
put_rpccred(wdata.cred);
if (wdata->cred)
put_rpccred(wdata->cred);
kfree(wdata);
return written ? written : result;
}
......
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