
From: NeilBrown <neilb@cse.unsw.edu.au>

From: "J. Bruce Fields" <bfields@fieldses.org>

To help the user diagnose problems caused by user-level daemons not running.


---

 25-akpm/include/linux/sunrpc/cache.h |    3 ++-
 25-akpm/net/sunrpc/cache.c           |   18 ++++++++++++++----
 2 files changed, 16 insertions(+), 5 deletions(-)

diff -puN include/linux/sunrpc/cache.h~knfsd-10-of-10-add-a-warning-when-upcalls-fail include/linux/sunrpc/cache.h
--- 25/include/linux/sunrpc/cache.h~knfsd-10-of-10-add-a-warning-when-upcalls-fail	Tue May 18 15:27:55 2004
+++ 25-akpm/include/linux/sunrpc/cache.h	Tue May 18 15:27:55 2004
@@ -97,7 +97,8 @@ struct cache_detail {
 	struct proc_dir_entry   *flush_ent, *channel_ent, *content_ent;
 
 	atomic_t		readers;		/* how many time is /chennel open */
-	time_t			last_close;		/* it no readers, when did last close */
+	time_t			last_close;		/* if no readers, when did last close */
+	time_t			last_warn;		/* when we last warned about no readers */
 };
 
 
diff -puN net/sunrpc/cache.c~knfsd-10-of-10-add-a-warning-when-upcalls-fail net/sunrpc/cache.c
--- 25/net/sunrpc/cache.c~knfsd-10-of-10-add-a-warning-when-upcalls-fail	Tue May 18 15:27:55 2004
+++ 25-akpm/net/sunrpc/cache.c	Tue May 18 15:27:55 2004
@@ -214,6 +214,7 @@ void cache_register(struct cache_detail 
 	cd->entries = 0;
 	atomic_set(&cd->readers, 0);
 	cd->last_close = 0;
+	cd->last_warn = -1;
 	list_add(&cd->others, &cache_list);
 	spin_unlock(&cache_list_lock);
 
@@ -905,7 +906,15 @@ void qword_addhex(char **bpp, int *lp, c
 	*lp = len;
 }
 
-			
+void warn_no_listener(struct cache_detail *detail)
+{
+	if (detail->last_warn != detail->last_close) {
+		detail->last_warn = detail->last_close;
+		printk(KERN_WARNING "nfsd: nobody listening for %s upcall;"
+				" has some daemon %s?\n", detail->name,
+		      		detail->last_close?"died" : "not been started");
+	}
+}
 
 /*
  * register an upcall request to user-space.
@@ -923,9 +932,10 @@ static int cache_make_upcall(struct cach
 		return -EINVAL;
 
 	if (atomic_read(&detail->readers) == 0 &&
-	    detail->last_close < get_seconds() - 60)
-		/* nobody is listening */
-		return -EINVAL;
+	    detail->last_close < get_seconds() - 30) {
+			warn_no_listener(detail);
+			return -EINVAL;
+	}
 
 	buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
 	if (!buf)

_
