From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jiaju Zhang Date: Tue, 25 Aug 2009 11:10:03 +0800 Subject: [Cluster-devel] Re: [RFC]Drop unused plock resource when no other plock request comes In-Reply-To: <20090824143128.GA25798@redhat.com> References: <20090824143128.GA25798@redhat.com> Message-ID: List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Mon, Aug 24, 2009 at 10:31 PM, David Teigland wrote: > > You're correct; yes the daemon could easily be changed to drop resources > when > there's no locking activity. We'd just set a poll timeout when > plock_resources is non-empty and call drop_resources() if it times out. > > (If you simply want to work around this, you can write a little program to > lock a file on the fs to trigger the drop.) > > Dave Many thanks for your guidance :-) So I write a patch to try to fix this. Review and comments are welcome. Thanks, Jiaju diff -Nupr a/group/dlm_controld/dlm_daemon.h b/group/dlm_controld/dlm_daemon.h --- a/group/dlm_controld/dlm_daemon.h 2009-07-03 14:53:42.000000000 +0800 +++ b/group/dlm_controld/dlm_daemon.h 2009-08-25 10:38:17.000000000 +0800 @@ -300,6 +300,8 @@ void store_plocks(struct lockspace *ls); void retrieve_plocks(struct lockspace *ls); void purge_plocks(struct lockspace *ls, int nodeid, int unmount); int fill_plock_dump_buf(struct lockspace *ls); +unsigned long time_diff_ms(struct timeval *begin, struct timeval *end); +int drop_resources(struct lockspace *ls); /* logging.c */ diff -Nupr a/group/dlm_controld/main.c b/group/dlm_controld/main.c --- a/group/dlm_controld/main.c 2009-07-03 14:53:42.000000000 +0800 +++ b/group/dlm_controld/main.c 2009-08-25 07:59:53.000000000 +0800 @@ -842,6 +842,8 @@ static void loop(void) struct lockspace *ls; int poll_timeout = -1; int rv, i; + int need_to_drop = 0; + struct timeval now, last_access; void (*workfn) (int ci); void (*deadfn) (int ci); @@ -963,6 +965,30 @@ static void loop(void) } poll_timeout = 1000; } + + if (cfgd_plock_ownership) { + gettimeofday(&now, NULL); + if (need_to_drop && time_diff_ms(&last_access, &now) >= cfgd_drop_resources_time) { + list_for_each_entry(ls, &lockspaces, list) { + if (!list_empty(&ls->plock_resources)) { + poll_timeout = cfgd_drop_resources_time; + ls->drop_resources_last = now; + drop_resources(ls); + } + } + need_to_drop = 0; + last_access = now; + } else { + list_for_each_entry(ls, &lockspaces, list) { + if (!list_empty(&ls->plock_resources)) { + poll_timeout = cfgd_drop_resources_time; + need_to_drop = 1; + last_access = now; + break; + } + } + } + } query_unlock(); } out: diff -Nupr a/group/dlm_controld/plock.c b/group/dlm_controld/plock.c --- a/group/dlm_controld/plock.c 2009-07-27 12:04:07.000000000 +0800 +++ b/group/dlm_controld/plock.c 2009-08-25 10:37:43.000000000 +0800 @@ -216,7 +216,7 @@ static uint32_t mg_to_ls_id(uint32_t fsi /* FIXME: unify these two */ -static unsigned long time_diff_ms(struct timeval *begin, struct timeval *end) +unsigned long time_diff_ms(struct timeval *begin, struct timeval *end) { struct timeval result; timersub(end, begin, &result); @@ -1344,7 +1344,7 @@ void receive_drop(struct lockspace *ls, /* FIXME: in the transition from owner = us, to owner = 0, to drop; we want the second period to be shorter than the first */ -static int drop_resources(struct lockspace *ls) +int drop_resources(struct lockspace *ls) { struct resource *r; struct timeval now; -------------- next part -------------- An HTML attachment was scrubbed... URL: