CTDB with GlusterFS.
Michael Adam
obnox at samba.org
Wed Nov 11 07:03:05 UTC 2015
On 2015-11-11 at 07:26 +0100, Ralph Boehme wrote:
> On Wed, Nov 11, 2015 at 05:12:31PM +1100, Martin Schwenke wrote:
> > This would allow you to test the fcntl(2) locking without having all of
> > CTDB in the way.
> >
> > If you're not a C programmer (though I think this could probably be
> > done with Python too) then please yell and I'll whip something up for
> > you to test with... :-)
>
> fwiw, I have this WIP patch for ping_pong in a working branch.
It is not as nice but you can test correct functioning of
fcntl byte range lock contention with ping_pong without
code changes:
You run 2 instances of:
"ping_pong /path/to/file 2"
one on each node (pointing to the same file).
When starting the second process, you should see:
"lock at 0 failed! - Resource deadlock avoided"
printed by both processes. ==> then lock coherens is working.
If instead you see both these processes printing lock rates,
then it is not working.
That being said, ctdb / samba on top of gluster do work
for me (and a lot of other people), so we need a little
more information about your system, Matthew:
What is the OS, what version of ctdb/samba are you using?
What kind of builds for gluster and ctdb/samba are you using?
The configs (ctdb , ...).
Cheers - Michael
> -Ralph
>
> --
> SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
> phone: +49-551-370000-0, fax: +49-551-370000-9
> AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
> http://www.sernet.de,mailto:kontakt@sernet.de
> From 57bb4d07a3f30c1782515d23c82e8d0c3c4290d8 Mon Sep 17 00:00:00 2001
> From: Ralph Boehme <slow at samba.org>
> Date: Sun, 10 May 2015 01:39:16 +0200
> Subject: [PATCH] ping_pong: add -l option
>
> Add a simple test for working POSIX byte range locks. Usage:
>
> node1$ ./bin/ping_pong -l /path/to/cluster-fs/FILE
> Holding lock, press any key to continue...
> You should run the same command on another node now.
>
> node2$ ./bin/ping_pong -l /path/to/cluster-fs/FILE
>
> Output can eithe be:
>
> Holding lock, press any key to continue...
>
> This indicated POSIX byte range locks are not working.
>
> If you instead see:
>
> file already locked, calling check_lock to tell us who has it locked...:
> check_lock failed: lock held: pid='27375', type='1', start='0', len='0'
> Working POSIX byte range locks
>
> Congrats, you have a cluster fs with functional byte range locks!
>
> Signed-off-by: Ralph Boehme <slow at samba.org>
> ---
> ctdb/utils/ping_pong/ping_pong.c | 56 ++++++++++++++++++++++++++++++++--------
> 1 file changed, 45 insertions(+), 11 deletions(-)
>
> diff --git a/ctdb/utils/ping_pong/ping_pong.c b/ctdb/utils/ping_pong/ping_pong.c
> index fdb575d..84fafdf 100644
> --- a/ctdb/utils/ping_pong/ping_pong.c
> +++ b/ctdb/utils/ping_pong/ping_pong.c
> @@ -39,10 +39,11 @@
> #include <unistd.h>
> #include <fcntl.h>
> #include <sys/mman.h>
> +#include <stdbool.h>
>
> static struct timeval tp1,tp2;
>
> -static int do_reads, do_writes, use_mmap, do_check;
> +static int do_reads, do_writes, use_mmap, do_check, do_brl_test;
>
> static void start_timer(void)
> {
> @@ -57,7 +58,7 @@ static double end_timer(void)
> }
>
> /* lock a byte range in a open file */
> -static int lock_range(int fd, int offset, int len)
> +static int lock_range(int fd, int offset, int len, bool wait)
> {
> struct flock lock;
>
> @@ -67,7 +68,7 @@ static int lock_range(int fd, int offset, int len)
> lock.l_len = len;
> lock.l_pid = 0;
>
> - return fcntl(fd,F_SETLKW,&lock);
> + return fcntl(fd, wait ? F_SETLKW : F_SETLK, &lock);
> }
>
> /* check whether we could place a lock */
> @@ -147,11 +148,11 @@ static void ping_pong(int fd, int num_locks)
>
> start_timer();
>
> - lock_range(fd, 0, 1);
> + lock_range(fd, 0, 1, true);
> i = 0;
>
> while (1) {
> - if (lock_range(fd, (i+1) % num_locks, 1) != 0) {
> + if (lock_range(fd, (i+1) % num_locks, 1, true) != 0) {
> printf("lock at %d failed! - %s\n",
> (i+1) % num_locks, strerror(errno));
> }
> @@ -204,7 +205,7 @@ int main(int argc, char *argv[])
> int fd, num_locks;
> int c;
>
> - while ((c = getopt(argc, argv, "rwmc")) != -1) {
> + while ((c = getopt(argc, argv, "rwmcl")) != -1) {
> switch (c){
> case 'w':
> do_writes = 1;
> @@ -218,6 +219,9 @@ int main(int argc, char *argv[])
> case 'c':
> do_check = 1;
> break;
> + case 'l':
> + do_brl_test = 1;
> + break;
> default:
> fprintf(stderr, "Unknown option '%c'\n", c);
> exit(1);
> @@ -227,25 +231,55 @@ int main(int argc, char *argv[])
> argv += optind;
> argc -= optind;
>
> - if (argc < 2) {
> - printf("ping_pong [options] <file> <num_locks>\n");
> + if (argc < 1) {
> + printf("ping_pong -rwmc <file> <num_locks>\n");
> + printf("ping_pong -l <file>\n");
> printf(" -r do reads\n");
> printf(" -w do writes\n");
> printf(" -m use mmap\n");
> printf(" -c check locks\n");
> + printf(" -l test for working byte range locks\n");
> exit(1);
> }
>
> fname = argv[0];
> +
> + fd = open(fname, O_CREAT|O_RDWR, 0600);
> + if (fd == -1) {
> + exit(1);
> + }
> +
> + if (do_brl_test) {
> + if (lock_range(fd, 0, 0, false) != 0) {
> + printf("file already locked, calling check_lock to tell us who has it locked:\n");
> + (void)check_lock(fd, 0, 0);
> + printf("Working POSIX byte range locks\n");
> + exit(1);
> + }
> + printf("Holding lock, press any key to continue...\n");
> + printf("You should run the same command on another node now.\n");
> + getchar();
> + printf("Good bye.\n");
> + exit(0);
> + }
> +
> + if (argc < 2) {
> + printf("ping_pong -rwmc <file> <num_locks>\n");
> + printf("ping_pong -l <file>\n");
> + printf(" -r do reads\n");
> + printf(" -w do writes\n");
> + printf(" -m use mmap\n");
> + printf(" -c check locks\n");
> + printf(" -l test for working byte range locks\n");
> + exit(1);
> + }
> +
> num_locks = atoi(argv[1]);
> if (num_locks <= 0) {
> printf("num_locks should be > 0\n");
> exit(1);
> }
>
> - fd = open(fname, O_CREAT|O_RDWR, 0600);
> - if (fd == -1) exit(1);
> -
> ping_pong(fd, num_locks);
>
> return 0;
> --
> 2.5.0
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20151111/7366fc70/signature.sig>
More information about the samba-technical
mailing list