From 4fc696886e058b45c2e84a1f807103bfeec8e0d2 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Wed, 19 May 2004 02:39:46 -0700 Subject: [PATCH] [PATCH] kNFSd: Allow larger writes to sunrpc/svc caches. From: NeilBrown 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 | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 3e823aa8b194d..af2bd52ee0f53 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -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; } -- 2.53.0