Commit 4fc69688 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] kNFSd: Allow larger writes to sunrpc/svc caches.

From: NeilBrown <neilb@cse.unsw.edu.au>

We currently serialize all writes to these caches with queue_io_sem, so we
only needed one buffer.

There is some need for larger-than-one-page writes, so we can just statically
allocate a buffer.
parent 00979a9f
...@@ -652,12 +652,13 @@ cache_read(struct file *filp, char *buf, size_t count, loff_t *ppos) ...@@ -652,12 +652,13 @@ cache_read(struct file *filp, char *buf, size_t count, loff_t *ppos)
return err ? err : count; return err ? err : count;
} }
static char write_buf[8192]; /* protected by queue_io_sem */
static ssize_t static ssize_t
cache_write(struct file *filp, const char *buf, size_t count, cache_write(struct file *filp, const char *buf, size_t count,
loff_t *ppos) loff_t *ppos)
{ {
int err; int err;
char *page;
struct cache_detail *cd = PDE(filp->f_dentry->d_inode)->data; struct cache_detail *cd = PDE(filp->f_dentry->d_inode)->data;
if (ppos != &filp->f_pos) if (ppos != &filp->f_pos)
...@@ -665,31 +666,22 @@ cache_write(struct file *filp, const char *buf, size_t count, ...@@ -665,31 +666,22 @@ cache_write(struct file *filp, const char *buf, size_t count,
if (count == 0) if (count == 0)
return 0; return 0;
if (count > PAGE_SIZE) if (count >= sizeof(write_buf))
return -EINVAL; return -EINVAL;
down(&queue_io_sem); down(&queue_io_sem);
page = kmalloc(PAGE_SIZE, GFP_KERNEL); if (copy_from_user(write_buf, buf, count)) {
if (page == NULL) {
up(&queue_io_sem);
return -ENOMEM;
}
if (copy_from_user(page, buf, count)) {
up(&queue_io_sem); up(&queue_io_sem);
kfree(page);
return -EFAULT; return -EFAULT;
} }
if (count < PAGE_SIZE) write_buf[count] = '\0';
page[count] = '\0';
if (cd->cache_parse) if (cd->cache_parse)
err = cd->cache_parse(cd, page, count); err = cd->cache_parse(cd, write_buf, count);
else else
err = -EINVAL; err = -EINVAL;
up(&queue_io_sem); up(&queue_io_sem);
kfree(page);
return err ? err : count; return err ? err : count;
} }
......
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