All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Teigland <teigland@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] Re: [RFC]Drop unused plock resource when no other plock request comes
Date: Tue, 25 Aug 2009 10:35:03 -0500	[thread overview]
Message-ID: <20090825153503.GA24475@redhat.com> (raw)
In-Reply-To: <f8c992a30908242010h27215991udee4ff6585843121@mail.gmail.com>

On Tue, Aug 25, 2009 at 11:10:03AM +0800, Jiaju Zhang wrote:
> On Mon, Aug 24, 2009 at 10:31 PM, David Teigland <teigland@redhat.com>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, that looks like it would do the job, but the code is a little
complicated.  Here's a simpler patch, I've not tried it so it may not work :)

Dave


diff --git a/group/dlm_controld/dlm_daemon.h b/group/dlm_controld/dlm_daemon.h
index df2e148..18479d7 100644
--- a/group/dlm_controld/dlm_daemon.h
+++ b/group/dlm_controld/dlm_daemon.h
@@ -73,6 +73,7 @@ extern int poll_fencing;
 extern int poll_quorum;
 extern int poll_fs;
 extern int poll_ignore_plock;
+extern int poll_drop_plock;
 extern int plock_fd;
 extern int plock_ci;
 extern struct list_head lockspaces;
@@ -296,6 +297,7 @@ void process_netlink(int ci);
 int setup_plocks(void);
 void close_plocks(void);
 void process_plocks(int ci);
+void drop_resources_all(void);
 int limit_plocks(void);
 void receive_plock(struct lockspace *ls, struct dlm_header *hd, int len);
 void receive_own(struct lockspace *ls, struct dlm_header *hd, int len);
diff --git a/group/dlm_controld/main.c b/group/dlm_controld/main.c
index 93b40f8..75ee55d 100644
--- a/group/dlm_controld/main.c
+++ b/group/dlm_controld/main.c
@@ -1011,6 +1011,13 @@ static void loop(void)
 			}
 			poll_timeout = 1000;
 		}
+
+		if (poll_drop_plock) {
+			drop_resources_all();
+			if (poll_drop_plock)
+				poll_timeout = 1000;
+		}
+
 		query_unlock();
 	}
  out:
@@ -1310,6 +1317,7 @@ int poll_fencing;
 int poll_quorum;
 int poll_fs;
 int poll_ignore_plock;
+int poll_drop_plock;
 int plock_fd;
 int plock_ci;
 struct list_head lockspaces;
diff --git a/group/dlm_controld/plock.c b/group/dlm_controld/plock.c
index 3d4431e..197b15c 100644
--- a/group/dlm_controld/plock.c
+++ b/group/dlm_controld/plock.c
@@ -1351,8 +1351,20 @@ static int drop_resources(struct lockspace *ls)
 	struct timeval now;
 	int count = 0;
 
+	if (!cfgd_plock_ownership)
+		return 0;
+
+	if (list_empty(&ls->plock_resources))
+		return 0;
+
 	gettimeofday(&now, NULL);
 
+	if (time_diff_ms(&ls->drop_resources_last, &now) <
+	    		 cfgd_drop_resources_time)
+		return 1;
+
+	ls->drop_resources_last = now;
+
 	/* try to drop the oldest, unused resources */
 
 	list_for_each_entry_reverse(r, &ls->plock_resources, list) {
@@ -1376,7 +1388,21 @@ static int drop_resources(struct lockspace *ls)
 		}
 	}
 
-	return 0;
+	return 1;
+}
+
+void drop_resources_all(void)
+{
+	struct lockspace *ls;
+	int rv = 0;
+
+	poll_drop_plock = 0;
+
+	list_for_each_entry(ls, &lockspaces, list) {
+		rv = drop_resources(ls);
+		if (rv)
+			poll_drop_plock = 1;
+	}
 }
 
 int limit_plocks(void)
@@ -1495,13 +1521,8 @@ void process_plocks(int ci)
 		save_pending_plock(ls, r, &info);
 	}
 
-	if (cfgd_plock_ownership &&
-	    time_diff_ms(&ls->drop_resources_last, &now) >=
-	    		 cfgd_drop_resources_time) {
-		ls->drop_resources_last = now;
-		drop_resources(ls);
-	}
-
+	if (cfgd_plock_ownership && !list_empty(&ls->plock_resources))
+		poll_drop_plock = 1;
 	return;
 
  fail:



  reply	other threads:[~2009-08-25 15:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-23  9:00 [Cluster-devel] [RFC]Drop unused plock resource when no other plock request comes Jiaju Zhang
2009-08-24 14:31 ` [Cluster-devel] " David Teigland
2009-08-25  3:10   ` Jiaju Zhang
2009-08-25 15:35     ` David Teigland [this message]
2009-08-26  6:54       ` Jiaju Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090825153503.GA24475@redhat.com \
    --to=teigland@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.