public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH] client cannot get lock after other client got lock occur network partition.
@ 2009-11-09  9:19 Mi Jinlong
  2009-11-09 13:16 ` Trond Myklebust
  0 siblings, 1 reply; 6+ messages in thread
From: Mi Jinlong @ 2009-11-09  9:19 UTC (permalink / raw)
  To: Trond.Myklebust; +Cc: NFSv3 list, J. Bruce Fields

Hi Trond et all

There is a bug, when i test NFSv3 file's lock as followed:

Step1: ClientA and ClientB open a same nfs file;
Step2: ClientA locks file with write lock, it's ok;
Step3: Cut off the network between ClientA and Server;
Step4: ClientB can not acquire for write lock successful forever, even though
       the network partition larger than NLM_HOST_EXPIRE.

As i know, If use NFSv4, step4 can success after LEASE_TIME.

Is it necessary to fix NFSv3 ? 

The attached patch can make this case OK, but i am not sure it's good.

Signed-off-by: Mi Jinlong <mijinlong@cn.fujitsu.com>
---
 fs/lockd/host.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index 4600c20..c964327 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -550,8 +550,8 @@ nlm_gc_hosts(void)
 
 	for (chain = nlm_hosts; chain < nlm_hosts + NLM_HOST_NRHASH; ++chain) {
 		hlist_for_each_entry_safe(host, pos, next, chain, h_hash) {
-			if (atomic_read(&host->h_count) || host->h_inuse
-			 || time_before(jiffies, host->h_expires)) {
+			if (time_before(jiffies, host->h_expires)
+			    && (atomic_read(&host->h_count) || host->h_inuse))
 				dprintk("nlm_gc_hosts skipping %s (cnt %d use %d exp %ld)\n",
 					host->h_name, atomic_read(&host->h_count),
 					host->h_inuse, host->h_expires);
@@ -560,6 +560,7 @@ nlm_gc_hosts(void)
 			dprintk("lockd: delete host %s\n", host->h_name);
 			hlist_del_init(&host->h_hash);
 
+			nlmsvc_free_host_resources(host);
 			nlm_destroy_host(host);
 			nrhosts--;
 		}
---
thanks,
Mi Jinlong


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-11-11 14:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-09  9:19 [RFC][PATCH] client cannot get lock after other client got lock occur network partition Mi Jinlong
2009-11-09 13:16 ` Trond Myklebust
     [not found]   ` <1257772609.3754.11.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-11-10  9:38     ` Mi Jinlong
2009-11-10 12:35       ` Trond Myklebust
     [not found]         ` <1257856550.3046.6.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2009-11-11  9:34           ` Mi Jinlong
2009-11-11 14:02             ` Peter Staubach

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox