add an NFS memory pool
Subsystems (2)
PATCH 1/1 add an NFS memory pool
Ensure that we can still flush out a minimum number of read, write, and commit requests if memory gets low.
Cheers,
Trond
fs/nfs/nfs3proc.c +1 -1
@@ -811,7 +811,7 @@rpc_init_task (task,NFS_CLIENT (inode), nfs3_commit_done, flags); task->tk_calldata = data;/* Release requests */ - task->tk_release = nfs_writedata_release; + task->tk_release = nfs_commit_release; msg.rpc_proc =NFS3PROC_COMMIT ; msg.rpc_argp = &data->u.v3.args;
fs/nfs/nfs4proc.c +1 -1
@@ -1481,7 +1481,7 @@rpc_init_task (task,NFS_CLIENT (inode), nfs4_commit_done, flags); task->tk_calldata = data;/* Release requests */ - task->tk_release = nfs_writedata_release; + task->tk_release = nfs_commit_release;rpc_call_setup (task, &msg,0 ); }
fs/nfs/read.c +14 -2
@@ -24,6 +24,7 @@#include <linux/mm.h> #include <linux/slab.h> #include <linux/pagemap.h> +#include <linux/mempool.h> #include <linux/sunrpc/clnt.h> #include <linux/nfs_fs.h> #include <linux/nfs_page.h>
@@ -37,11 +38,14 @@static int nfs_pagein_one (struct list_head *,struct inode *);static kmem_cache_t *nfs_rdata_cachep; +static mempool_t *nfs_rdata_mempool; + +#define MIN_POOL_READ (32)static __inline__struct nfs_read_data *nfs_readdata_alloc (void ) {struct nfs_read_data *p; - p =kmem_cache_alloc (nfs_rdata_cachep,SLAB_NOFS ); + p = (struct nfs_read_data *)mempool_alloc (nfs_rdata_mempool,SLAB_NOFS );if (p) {memset (p,0 ,sizeof (*p));INIT_LIST_HEAD (&p->pages);
@@ -51,7 +55,7 @@static __inline__void nfs_readdata_free (struct nfs_read_data *p) { -kmem_cache_free (nfs_rdata_cachep, p); +mempool_free (p, nfs_rdata_mempool); }void nfs_readdata_release (struct rpc_task *task)
@@ -417,11 +421,19 @@if (nfs_rdata_cachep ==NULL )return -ENOMEM ; + nfs_rdata_mempool =mempool_create (MIN_POOL_READ , + mempool_alloc_slab, + mempool_free_slab, + nfs_rdata_cachep); +if (nfs_rdata_mempool ==NULL ) +return -ENOMEM ; +return 0 ; }void nfs_destroy_readpagecache (void ) { +mempool_destroy (nfs_rdata_mempool);if (kmem_cache_destroy (nfs_rdata_cachep))printk (KERN_INFO "nfs_read_data: not all structures were freed\n" ); }
fs/nfs/write.c +47 -3
98 lines not on this page · raw message
include/linux/nfs_fs.h +1 -0
@@ -327,6 +327,7 @@extern void nfs_writedata_release (struct rpc_task *task);#if defined(CONFIG_NFS_V3 ) || defined(CONFIG_NFS_V4 ) +extern void nfs_commit_release (struct rpc_task *task);extern void nfs_commit_done (struct rpc_task *);#endif