[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Linux-cluster] What can cause dlm_pthread_init to generate an errno 13?



Just to close the loop on this so that some future googler who finds
this can see how this was resolved.

You'll want to dig through this bug report -
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=176350

The big thing to make sure of is that have udev properly configured so
that the custom lockspaces you create get the right permissions on
them.

I'm including two sample programs...

This one creates the lockspace and needs to run as root.  The
permissions of 777 is probably over the top.

#include <errno.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdint.h>

extern "C" {
 #include <libdlm.h>
}
#include <pthread.h>

main(int argc, char **argv)
{
 printf("hello world\n");
 char lockName[] = "foobar" ;

 dlm_lshandle_t *lockspace=0;
 lockspace=(dlm_lshandle_t*)dlm_create_lockspace("EEJ_TESTING_LOCKSPACE",0777);
 printf("lockspace result: %X\n",lockspace);
}


Then on the "hello world" lock program side, we have

#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdint.h>
#include <string.h>

extern "C" {
 #include <libdlm.h>
}
#include <pthread.h>

void my_ast(void *arg)
{
       printf("ast got arg %p\n", arg);
}

main(int argc, char **argv)
{
 printf("hello world\n");
 char lockName[] = "foobar" ;

 dlm_lshandle_t *lockspace=0;
 lockspace=(dlm_lshandle_t*)dlm_open_lockspace("EEJ_TESTING_LOCKSPACE");
 printf("Lockspace: %X\n",lockspace);

 int initStatus = dlm_ls_pthread_init(lockspace);
 printf("initStatus: %d, errno: %d\n",initStatus,errno);

 struct dlm_lksb lksb;

 printf("Getting the lock!\n");
 for(int i=0;i<1000000;++i) {
   memset(&lksb,0,sizeof(lksb));
   if (dlm_ls_lock_wait(lockspace, LKM_EXMODE, &lksb, 0 , "foo",
                        3,0,0,0,0) <0 ) {
     printf("dlm_lock failed: %d\n",errno);
   }
   if (dlm_ls_unlock_wait(lockspace,lksb.sb_lkid,0,&lksb)<0) {
     printf("dlm_unlock failed: %d\n",errno);
   }
 }
 printf("goodbye\n");
 return 1;
}


On my cute little box with an Opteron chip at 1.8 GHz - this program
takes about 40 seconds to run.

-Eric


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]