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