All of lore.kernel.org
 help / color / mirror / Atom feed
diff for duplicates of <1516754851.18068.3.camel@gmail.com>

diff --git a/a/1.txt b/N1/1.txt
index be7b33e..066eee3 100644
--- a/a/1.txt
+++ b/N1/1.txt
@@ -25,3 +25,58 @@ I applied these patches to my linux-next a couple of weeks ago.
 What say we fix the issue with something like the following?
 
 8<------------------------------------------------------------
+>From 83ce0f55ca54337a573f1d70038714815a9cd645 Mon Sep 17 00:00:00 2001
+From: Trond Myklebust <trondmy@gmail.com>
+Date: Tue, 23 Jan 2018 19:39:04 -0500
+Subject: [PATCH] lockd: Fix server refcounting
+
+The server shouldn't actually delete the struct nlm_host until it hits
+the garbage collector. In order to make that work correctly with the
+refcount API, we can bump the refcount by one, and then use
+refcount_dec_if_one() in the garbage collector.
+
+Signed-off-by: Trond Myklebust <trondmy@gmail.com>
+---
+ fs/lockd/host.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/fs/lockd/host.c b/fs/lockd/host.c
+index 7d6ab72bbe65..d35cd6be0675 100644
+--- a/fs/lockd/host.c
++++ b/fs/lockd/host.c
+@@ -388,6 +388,8 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
+ 	ln->nrhosts++;
+ 	nrhosts++;
+ 
++	refcount_inc(&host->h_count);
++
+ 	dprintk("lockd: %s created host %s (%s)\n",
+ 		__func__, host->h_name, host->h_addrbuf);
+ 
+@@ -662,8 +664,7 @@ nlm_gc_hosts(struct net *net)
+ 	for_each_host_safe(host, next, chain, nlm_server_hosts) {
+ 		if (net && host->net != net)
+ 			continue;
+-		if (refcount_read(&host->h_count) || host->h_inuse
+-		 || time_before(jiffies, host->h_expires)) {
++		if (host->h_inuse || time_before(jiffies, host->h_expires)) {
+ 			dprintk("nlm_gc_hosts skipping %s "
+ 				"(cnt %d use %d exp %ld net %x)\n",
+ 				host->h_name, refcount_read(&host->h_count),
+@@ -671,7 +672,8 @@ nlm_gc_hosts(struct net *net)
+ 				host->net->ns.inum);
+ 			continue;
+ 		}
+-		nlm_destroy_host_locked(host);
++		if (refcount_dec_if_one(&host->h_count))
++			nlm_destroy_host_locked(host);
+ 	}
+ 
+ 	if (net) {
+-- 
+2.14.3
+
+-- 
+Trond Myklebust
+Linux NFS client maintainer, PrimaryData
+trond.myklebust@primarydata.com
diff --git a/a/content_digest b/N1/content_digest
index cd7df52..a81a363 100644
--- a/a/content_digest
+++ b/N1/content_digest
@@ -46,6 +46,61 @@
  "\n"
  "What say we fix the issue with something like the following?\n"
  "\n"
- 8<------------------------------------------------------------
+ "8<------------------------------------------------------------\n"
+ ">From 83ce0f55ca54337a573f1d70038714815a9cd645 Mon Sep 17 00:00:00 2001\n"
+ "From: Trond Myklebust <trondmy@gmail.com>\n"
+ "Date: Tue, 23 Jan 2018 19:39:04 -0500\n"
+ "Subject: [PATCH] lockd: Fix server refcounting\n"
+ "\n"
+ "The server shouldn't actually delete the struct nlm_host until it hits\n"
+ "the garbage collector. In order to make that work correctly with the\n"
+ "refcount API, we can bump the refcount by one, and then use\n"
+ "refcount_dec_if_one() in the garbage collector.\n"
+ "\n"
+ "Signed-off-by: Trond Myklebust <trondmy@gmail.com>\n"
+ "---\n"
+ " fs/lockd/host.c | 8 +++++---\n"
+ " 1 file changed, 5 insertions(+), 3 deletions(-)\n"
+ "\n"
+ "diff --git a/fs/lockd/host.c b/fs/lockd/host.c\n"
+ "index 7d6ab72bbe65..d35cd6be0675 100644\n"
+ "--- a/fs/lockd/host.c\n"
+ "+++ b/fs/lockd/host.c\n"
+ "@@ -388,6 +388,8 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,\n"
+ " \tln->nrhosts++;\n"
+ " \tnrhosts++;\n"
+ " \n"
+ "+\trefcount_inc(&host->h_count);\n"
+ "+\n"
+ " \tdprintk(\"lockd: %s created host %s (%s)\\n\",\n"
+ " \t\t__func__, host->h_name, host->h_addrbuf);\n"
+ " \n"
+ "@@ -662,8 +664,7 @@ nlm_gc_hosts(struct net *net)\n"
+ " \tfor_each_host_safe(host, next, chain, nlm_server_hosts) {\n"
+ " \t\tif (net && host->net != net)\n"
+ " \t\t\tcontinue;\n"
+ "-\t\tif (refcount_read(&host->h_count) || host->h_inuse\n"
+ "-\t\t || time_before(jiffies, host->h_expires)) {\n"
+ "+\t\tif (host->h_inuse || time_before(jiffies, host->h_expires)) {\n"
+ " \t\t\tdprintk(\"nlm_gc_hosts skipping %s \"\n"
+ " \t\t\t\t\"(cnt %d use %d exp %ld net %x)\\n\",\n"
+ " \t\t\t\thost->h_name, refcount_read(&host->h_count),\n"
+ "@@ -671,7 +672,8 @@ nlm_gc_hosts(struct net *net)\n"
+ " \t\t\t\thost->net->ns.inum);\n"
+ " \t\t\tcontinue;\n"
+ " \t\t}\n"
+ "-\t\tnlm_destroy_host_locked(host);\n"
+ "+\t\tif (refcount_dec_if_one(&host->h_count))\n"
+ "+\t\t\tnlm_destroy_host_locked(host);\n"
+ " \t}\n"
+ " \n"
+ " \tif (net) {\n"
+ "-- \n"
+ "2.14.3\n"
+ "\n"
+ "-- \n"
+ "Trond Myklebust\n"
+ "Linux NFS client maintainer, PrimaryData\n"
+ trond.myklebust@primarydata.com
 
-08948ba9b3a7131b5af3192e99d42e3ee3dbabe8002800c68e9fb7a9d74f7525
+cd98dd7f76713fa6ec58cc641bed3c44eeec06e8c4b3b0575a3dd7eb65f062cc

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.