dlm_lock man page on Scientific

Man page or keyword search:  
man Server   26626 pages
apropos Keyword Search (all sections)
Output format
Scientific logo
[printable version]

DLM_LOCK(3)							   DLM_LOCK(3)

       dlm_lock - acquire or convert a DLM lock

	#include <libdlm.h>

       int dlm_lock(uint32_t mode,
		 struct dlm_lksb *lksb,
		 uint32_t flags,
		 const void *name,
		 unsigned int namelen,
		 uint32_t parent,	  /* unused */
		 void (*astaddr) (void *astarg),
		 void *astarg,
		 void (*bastaddr) (void *astarg),
		 void *range);		  /* unused */

       int dlm_lock_wait(uint32_t mode,
		 struct dlm_lksb *lksb,
		 uint32_t flags,
		 const void *name,
		 unsigned int namelen,
		 uint32_t parent,	  /* unused */
		 void *bastarg,
		 void (*bastaddr) (void *bastarg),
		 void *range);		  /* unused */

       int dlm_ls_lock(dlm_lshandle_t lockspace,
		 uint32_t mode,
		 struct dlm_lksb *lksb,
		 uint32_t flags,
		 const void *name,
		 unsigned int namelen,
		 uint32_t parent,	  /* unused */
		 void (*astaddr) (void *astarg),
		 void *astarg,
		 void (*bastaddr) (void *astarg),
		 void *range);		  /* unused */

       int dlm_ls_lock_wait(dlm_lshandle_t lockspace,
		 uint32_t mode,
		 struct dlm_lksb *lksb,
		 uint32_t flags,
		 const void *name,
		 unsigned int namelen,
		 uint32_t parent,	  /* unusued */
		 void *bastarg,
		 void (*bastaddr) (void *bastarg),
		 void *range);		  /* unused */

       int dlm_ls_lockx(dlm_lshandle_t lockspace,
		 uint32_t mode,
		 struct dlm_lksb *lksb,
		 uint32_t flags,
		 const void *name,
		 unsigned int namelen,
		 uint32_t parent,	  /* unused */
		 (*astaddr) (void *astarg),
		 void *astarg,
		 void (*bastaddr) (void *astarg),
		 uint64_t *xid,
		 uint64_t *timeout);

       dlm_lock and its variants acquire and convert locks in the DLM.

       dlm_lock() operations are asynchronous. If the call to dlm_lock returns
       an error then the operation has failed and the AST routine will not  be
       called. If dlm_lock returns 0 it is still possible that the lock opera‐
       tion will fail. The AST routine will be called when the locking is com‐
       plete   or  has	failed	and  the  status  is  returned	in  the	 lksb.
       dlm_lock_wait() will wait until the lock operation  has	completed  and
       returns	the  final  completion	status.	  dlm_ls_lock() is the same as
       dlm_lock() but takes a lockspace argument.  This	 lockspace  must  have
       been  previously	 opened	 by dlm_lockspace_open() or dlm_lockspace_cre‐

       For conversion operations the name and namelen are ignored and the lock
       ID in the LKSB is used to identify the lock to be converted.

       If  a  lock value block is specified then in general, a grant or a con‐
       version to an equal-level or higher-level  lock	mode  reads  the  lock
       value from the resource into the caller's lock value block. When a lock
       conversion from EX or PW to an equal-level  or  lower-level  lock  mode
       occurs,	the contents of the caller's lock value block are written into
       the resource. If the LVB is invalidated the lksb.sb_flags  member  will
       be  set	to DLM_SBF_VALNOTVALID. Lock values blocks are always 32 bytes

       If the AST routines or parameter are passed to a	 conversion  operation
       then  they  will	 overwrite those values that were passed to a previous
       dlm_lock call.

       mode Lock mode to acquire or convert to.
	 LKM_CRMODE   Concurrent read
	 LKM_CWMODE   Concurrent write
	 LKM_PRMODE   Protected read
	 LKM_PWMODE   Protected write
	 LKM_EXMODE   Exclusive

       flags Affect the operation of the lock call:
	 LKF_NOQUEUE	 Don't queue the lock. If it cannot be granted return
	 LKF_CONVERT	 Convert an existing lock
	 LKF_VALBLK	 Lock has a value block
	 LKF_QUECVT	 Put conversion to the back of the queue
	 LKF_EXPEDITE	 Grant a NL lock immediately regardless of other locks
			 on the conversion queue
	 LKF_PERSISTENT	 Specifies a lock that will not be unlocked when the
			 process exits; it will become an orphan lock.
	 LKF_CONVDEADLK	 Enable internal conversion deadlock resolution where
			 the lock's granted mode may be set to NL and
			 DLM_SBF_DEMOTED is returned in lksb.sb_flags.
	 LKF_NODLCKWT	 Do not consider this lock when trying to detect
			 deadlock conditions.
	 LKF_NODLCKBLK	 Not implemented
	 LKF_NOQUEUEBAST Send blocking ASTs even for NOQUEUE operations
	 LKF_HEADQUE	 Add locks to the head of the convert or waiting queue
	 LKF_NOORDER	 Avoid the VMS rules on grant order
	 LKF_ALTPR	 If the requested mode can't be granted (generally CW),
			 try to grant in PR and return DLM_SBF_ALTMODE.
	 LKF_ALTCW	 If the requested mode can't be granted (generally PR),
			 try to grant in CW and return DLM_SBF_ALTMODE.
	 LKF_TIMEOUT	 The lock will time out per the timeout arg.

       lksb Lock Status block
       This structure contains the returned lock ID, the actual status of  the
       lock  operation	(all lock ops are asynchronous) and the value block if
       LKF_VALBLK is set.

       Name of the lock. Can be binary, max 64 bytes. Ignored for lock conver‐
       sions.  (Should be a string to work with debugging tools.)

       Length of the above name. Ignored for lock conversions.

       ID  of  parent  lock  or NULL if this is a top-level lock. This is cur‐
       rently unused.

       Address of AST routine to be called when the lock operation  completes.
       The  final  completion  status of the lock will be in the lksb. the AST
       routine must not be NULL.

       Argument to pass to the AST routine (most people pass the lksb in  here
       but it can be anything you like.)

       Blocking	 AST  routine.	address	 of a function to call if this lock is
       blocking another. The function will be called with astargs.

       This is unused.

       Optional transaction ID for deadlock detection.

       Timeout in centiseconds. If it takes longer than this  to  acquire  the
       lock  (usually because it is already blocked by another lock), then the
       AST will trigger with ETIMEDOUT as the status. If the lock operation is
       a  conversion  then the lock will remain at its current status. If this
       is a new lock then the lock will not exist and any LKB in the lksb will
       be invalid.  This is ignored without the LKF_TIMEOUT flag.

   Return values
       0  is  returned	if  the	 call  completed  successfully.	 If not, -1 is
       returned and errno is set to one of the following:

       EINVAL	       An invalid parameter was passed to the call (eg bad lock
		       mode or flag)
       ENOMEM	       A (kernel) memory allocation failed
       EAGAIN	       LKF_NOQUEUE was requested and the lock could not be
       EBUSY	       The lock is currently being locked or converted
       EFAULT	       The userland buffer could not be read/written by the
		       kernel (this indicates a library problem)
       EDEADLOCK       The lock operation is causing a deadlock and has been
		       cancelled. If this was a conversion then the lock is
		       reverted to its previously granted state. If it was a
		       new lock then it has not been granted. (NB Only
		       conversion deadlocks are currently detected)

       If an error is returned in the AST, then lksb.sb_status is set to the one of the above values instead of zero.

       struct dlm_lksb {
	 int	  sb_status; /* Final status of lock operation */
	 uint32_t sb_lkid;   /* ID of lock. Returned from dlm_lock()
				on first use. Used as input to
				dlm_lock() for a conversion operation */
	 char	  sb_flags;  /* Completion flags, see above */
	 char	  sb_lvbptr; /* Optional pointer to lock value block */

       int status;
       struct dlm_lksb lksb;

       status = dlm_lock_wait(LKM_EXMODE,
			      0, // Parent,
			      NULL, // bast arg
			      NULL, // bast routine,
			      NULL); // Range

       if (status == 0)
	    dlm_unlock_wait(lksb.sb_lkid, 0, &lksb);

       libdlm(3),     dlm_unlock(3),	  dlm_open_lockspace(3),      dlm_cre‐
       ate_lockspace(3), dlm_close_lockspace(3), dlm_release_lockspace(3)

libdlm functions		 July 5, 2007			   DLM_LOCK(3)

List of man pages available for Scientific

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
Vote for polarhome
Free Shell Accounts :: the biggest list on the net