]> git.hungrycats.org Git - linux/commitdiff
[PATCH] kNFSd: Allow larger writes to sunrpc/svc caches.
authorAndrew Morton <akpm@osdl.org>
Wed, 19 May 2004 09:39:46 +0000 (02:39 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Wed, 19 May 2004 09:39:46 +0000 (02:39 -0700)
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.

net/sunrpc/cache.c

index 3e823aa8b194db004e61d81d8369857afcb25b81..af2bd52ee0f53e97633efd1747a9bb666305399f 100644 (file)
@@ -652,12 +652,13 @@ cache_read(struct file *filp, char *buf, size_t count, loff_t *ppos)
        return err ? err :  count;
 }
 
+static char write_buf[8192]; /* protected by queue_io_sem */
+
 static ssize_t
 cache_write(struct file *filp, const char *buf, size_t count,
            loff_t *ppos)
 {
        int err;
-       char *page;
        struct cache_detail *cd = PDE(filp->f_dentry->d_inode)->data;
 
        if (ppos != &filp->f_pos)
@@ -665,31 +666,22 @@ cache_write(struct file *filp, const char *buf, size_t count,
 
        if (count == 0)
                return 0;
-       if (count > PAGE_SIZE)
+       if (count >= sizeof(write_buf))
                return -EINVAL;
 
        down(&queue_io_sem);
 
-       page = kmalloc(PAGE_SIZE, GFP_KERNEL);
-       if (page == NULL) {
-               up(&queue_io_sem);
-               return -ENOMEM;
-       }
-
-       if (copy_from_user(page, buf, count)) {
+       if (copy_from_user(write_buf, buf, count)) {
                up(&queue_io_sem);
-               kfree(page);
                return -EFAULT;
        }
-       if (count < PAGE_SIZE)
-               page[count] = '\0';
+       write_buf[count] = '\0';
        if (cd->cache_parse)
-               err = cd->cache_parse(cd, page, count);
+               err = cd->cache_parse(cd, write_buf, count);
        else
                err = -EINVAL;
 
        up(&queue_io_sem);
-       kfree(page);
        return err ? err : count;
 }