kNFSd - 6 of 8 - Use schedule_work to regular cache cleaning
Subsystems (3)
PATCH 1/1 kNFSd - 6 of 8 - Use schedule_work to regular cache cleaning
### Comments for ChangeSet
Cleaning of the export caches is currently done by idle nfsd threads which isn't very reliable.
This patch makes use of work_queues to do it all inside cache.c
----------- Diffstat output ------------
./fs/nfsd/nfssvc.c | 4 ++-- ./net/sunrpc/cache.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-)
fs/nfsd/nfssvc.c renamed from fs/nfsd/nfssvc.c~current~ +2 -2
@@ -209,8 +209,8 @@ nfsd(struct svc_rqst *rqstp)* recvfrom routine. */ while ((err =svc_recv (serv, rqstp, -5 *60 *HZ )) == -EAGAIN ) -cache_clean (); +60 *60 *HZ )) == -EAGAIN ) + ;if (err <0 )break ;update_thread_usage (atomic_read (&nfsd_busy));
net/sunrpc/cache.c renamed from net/sunrpc/cache.c~current~ +29 -0
@@ -25,6 +25,7 @@#include <linux/seq_file.h> #include <linux/proc_fs.h> #include <linux/net.h> +#include <linux/workqueue.h> #include <asm/ioctls.h> #include <linux/sunrpc/types.h> #include <linux/sunrpc/cache.h>
@@ -165,6 +166,9 @@ static struct file_operations cache_filestatic struct file_operations content_file_operations;static struct file_operations cache_flush_operations; +static void do_cache_clean (void *data); +static DECLARE_WORK(cache_cleaner, do_cache_clean, NULL); +void cache_register (struct cache_detail *cd) { cd->proc_ent =proc_mkdir (cd->name, proc_net_rpc);
@@ -208,6 +212,9 @@ void cache_register(struct cache_detail cd->last_close =0 ;list_add (&cd->others, &cache_list);spin_unlock (&cache_list_lock); + +/* start the cleaning process */ +schedule_work (&cache_cleaner); }int cache_unregister (struct cache_detail *cd)
@@ -229,6 +236,11 @@ int cache_unregister(struct cache_detail cd->proc_ent =NULL ;remove_proc_entry (cd->name, proc_net_rpc); } +if (list_empty (&cache_list)) { +/* module must be being unloaded so its safe to kill the worker */ +cancel_delayed_work (&cache_cleaner); +flush_scheduled_work (); + }return 0 ; }
@@ -341,6 +353,23 @@ int cache_clean(void)return rv; } +/* +* We want to regularly clean the cache, so we need to schedule some work ... +*/ +static void do_cache_clean (void *data) +{ +int delay =5 ; +if (cache_clean () ==-1 ) + delay =30 *HZ ; + +if (list_empty (&cache_list)) + delay =0 ; + +if (delay) +schedule_delayed_work (&cache_cleaner, delay); +} + +/* * Clean all caches promptly. This just calls cache_clean * repeatedly until we are sure that every cache has had a chance to
-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner. Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs