aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/cache.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2009-08-09 15:14:29 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2009-08-09 15:14:29 -0400
commitbc74b4f5e63a09fb78e245794a0de1e5a2716bbe (patch)
tree5e96e63fd69303162456549f12bff5f9b2ee2a22 /net/sunrpc/cache.c
parentda77005f0d64486cd760f43d9b7cc2379262a363 (diff)
SUNRPC: Allow the cache_detail to specify alternative upcall mechanisms
For events that are rare, such as referral DNS lookups, it makes limited sense to have a daemon constantly listening for upcalls on a channel. An alternative in those cases might simply be to run the app that fills the cache using call_usermodehelper_exec() and friends. The following patch allows the cache_detail to specify alternative upcall mechanisms for these particular cases. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/cache.c')
-rw-r--r--net/sunrpc/cache.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index c8e7d2d07260..e438352bed7b 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -176,7 +176,13 @@ struct cache_head *sunrpc_cache_update(struct cache_detail *detail,
176} 176}
177EXPORT_SYMBOL_GPL(sunrpc_cache_update); 177EXPORT_SYMBOL_GPL(sunrpc_cache_update);
178 178
179static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h); 179static int cache_make_upcall(struct cache_detail *cd, struct cache_head *h)
180{
181 if (!cd->cache_upcall)
182 return -EINVAL;
183 return cd->cache_upcall(cd, h);
184}
185
180/* 186/*
181 * This is the generic cache management routine for all 187 * This is the generic cache management routine for all
182 * the authentication caches. 188 * the authentication caches.
@@ -322,7 +328,7 @@ static int create_cache_proc_entries(struct cache_detail *cd)
322 if (p == NULL) 328 if (p == NULL)
323 goto out_nomem; 329 goto out_nomem;
324 330
325 if (cd->cache_request || cd->cache_parse) { 331 if (cd->cache_upcall || cd->cache_parse) {
326 p = proc_create_data("channel", S_IFREG|S_IRUSR|S_IWUSR, 332 p = proc_create_data("channel", S_IFREG|S_IRUSR|S_IWUSR,
327 cd->proc_ent, &cache_file_operations, cd); 333 cd->proc_ent, &cache_file_operations, cd);
328 cd->channel_ent = p; 334 cd->channel_ent = p;
@@ -1080,10 +1086,16 @@ static void warn_no_listener(struct cache_detail *detail)
1080} 1086}
1081 1087
1082/* 1088/*
1083 * register an upcall request to user-space. 1089 * register an upcall request to user-space and queue it up for read() by the
1090 * upcall daemon.
1091 *
1084 * Each request is at most one page long. 1092 * Each request is at most one page long.
1085 */ 1093 */
1086static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h) 1094int sunrpc_cache_pipe_upcall(struct cache_detail *detail, struct cache_head *h,
1095 void (*cache_request)(struct cache_detail *,
1096 struct cache_head *,
1097 char **,
1098 int *))
1087{ 1099{
1088 1100
1089 char *buf; 1101 char *buf;
@@ -1091,9 +1103,6 @@ static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h)
1091 char *bp; 1103 char *bp;
1092 int len; 1104 int len;
1093 1105
1094 if (detail->cache_request == NULL)
1095 return -EINVAL;
1096
1097 if (atomic_read(&detail->readers) == 0 && 1106 if (atomic_read(&detail->readers) == 0 &&
1098 detail->last_close < get_seconds() - 30) { 1107 detail->last_close < get_seconds() - 30) {
1099 warn_no_listener(detail); 1108 warn_no_listener(detail);
@@ -1112,7 +1121,7 @@ static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h)
1112 1121
1113 bp = buf; len = PAGE_SIZE; 1122 bp = buf; len = PAGE_SIZE;
1114 1123
1115 detail->cache_request(detail, h, &bp, &len); 1124 cache_request(detail, h, &bp, &len);
1116 1125
1117 if (len < 0) { 1126 if (len < 0) {
1118 kfree(buf); 1127 kfree(buf);
@@ -1130,6 +1139,7 @@ static int cache_make_upcall(struct cache_detail *detail, struct cache_head *h)
1130 wake_up(&queue_wait); 1139 wake_up(&queue_wait);
1131 return 0; 1140 return 0;
1132} 1141}
1142EXPORT_SYMBOL_GPL(sunrpc_cache_pipe_upcall);
1133 1143
1134/* 1144/*
1135 * parse a message from user-space and pass it 1145 * parse a message from user-space and pass it