xref: /openbmc/linux/fs/dlm/lock.h (revision 72c2be776bd6eec5186e316e6d9dd4aab78d314d)
1e7fd4179SDavid Teigland /******************************************************************************
2e7fd4179SDavid Teigland *******************************************************************************
3e7fd4179SDavid Teigland **
4e7fd4179SDavid Teigland **  Copyright (C) 2005 Red Hat, Inc.  All rights reserved.
5e7fd4179SDavid Teigland **
6e7fd4179SDavid Teigland **  This copyrighted material is made available to anyone wishing to use,
7e7fd4179SDavid Teigland **  modify, copy, or redistribute it subject to the terms and conditions
8e7fd4179SDavid Teigland **  of the GNU General Public License v.2.
9e7fd4179SDavid Teigland **
10e7fd4179SDavid Teigland *******************************************************************************
11e7fd4179SDavid Teigland ******************************************************************************/
12e7fd4179SDavid Teigland 
13e7fd4179SDavid Teigland #ifndef __LOCK_DOT_H__
14e7fd4179SDavid Teigland #define __LOCK_DOT_H__
15e7fd4179SDavid Teigland 
16e7fd4179SDavid Teigland void dlm_print_rsb(struct dlm_rsb *r);
17a345da3eSDavid Teigland void dlm_dump_rsb(struct dlm_rsb *r);
18597d0caeSDavid Teigland void dlm_print_lkb(struct dlm_lkb *lkb);
19e7fd4179SDavid Teigland int dlm_receive_message(struct dlm_header *hd, int nodeid, int recovery);
20e7fd4179SDavid Teigland int dlm_modes_compat(int mode1, int mode2);
21e7fd4179SDavid Teigland int dlm_find_rsb(struct dlm_ls *ls, char *name, int namelen,
22e7fd4179SDavid Teigland 	unsigned int flags, struct dlm_rsb **r_ret);
23e7fd4179SDavid Teigland void dlm_put_rsb(struct dlm_rsb *r);
24e7fd4179SDavid Teigland void dlm_hold_rsb(struct dlm_rsb *r);
25e7fd4179SDavid Teigland int dlm_put_lkb(struct dlm_lkb *lkb);
26e7fd4179SDavid Teigland void dlm_scan_rsbs(struct dlm_ls *ls);
27e7fd4179SDavid Teigland 
28e7fd4179SDavid Teigland int dlm_purge_locks(struct dlm_ls *ls);
29e7fd4179SDavid Teigland void dlm_purge_mstcpy_locks(struct dlm_rsb *r);
3097a35d1eSDavid Teigland void dlm_grant_after_purge(struct dlm_ls *ls);
31e7fd4179SDavid Teigland int dlm_recover_waiters_post(struct dlm_ls *ls);
32e7fd4179SDavid Teigland void dlm_recover_waiters_pre(struct dlm_ls *ls);
33e7fd4179SDavid Teigland int dlm_recover_master_copy(struct dlm_ls *ls, struct dlm_rcom *rc);
34e7fd4179SDavid Teigland int dlm_recover_process_copy(struct dlm_ls *ls, struct dlm_rcom *rc);
35e7fd4179SDavid Teigland 
36597d0caeSDavid Teigland int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua, int mode,
37597d0caeSDavid Teigland 	uint32_t flags, void *name, unsigned int namelen, uint32_t parent_lkid);
38597d0caeSDavid Teigland int dlm_user_convert(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
39597d0caeSDavid Teigland 	int mode, uint32_t flags, uint32_t lkid, char *lvb_in);
40597d0caeSDavid Teigland int dlm_user_unlock(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
41597d0caeSDavid Teigland 	uint32_t flags, uint32_t lkid, char *lvb_in);
42597d0caeSDavid Teigland int dlm_user_cancel(struct dlm_ls *ls,  struct dlm_user_args *ua_tmp,
43597d0caeSDavid Teigland 	uint32_t flags, uint32_t lkid);
44*72c2be77SDavid Teigland int dlm_user_purge(struct dlm_ls *ls, struct dlm_user_proc *proc,
45*72c2be77SDavid Teigland 	int nodeid, int pid);
46597d0caeSDavid Teigland void dlm_clear_proc_locks(struct dlm_ls *ls, struct dlm_user_proc *proc);
47597d0caeSDavid Teigland 
48e7fd4179SDavid Teigland static inline int is_master(struct dlm_rsb *r)
49e7fd4179SDavid Teigland {
50e7fd4179SDavid Teigland 	return !r->res_nodeid;
51e7fd4179SDavid Teigland }
52e7fd4179SDavid Teigland 
53e7fd4179SDavid Teigland static inline void lock_rsb(struct dlm_rsb *r)
54e7fd4179SDavid Teigland {
5590135925SDavid Teigland 	mutex_lock(&r->res_mutex);
56e7fd4179SDavid Teigland }
57e7fd4179SDavid Teigland 
58e7fd4179SDavid Teigland static inline void unlock_rsb(struct dlm_rsb *r)
59e7fd4179SDavid Teigland {
6090135925SDavid Teigland 	mutex_unlock(&r->res_mutex);
61e7fd4179SDavid Teigland }
62e7fd4179SDavid Teigland 
63e7fd4179SDavid Teigland #endif
64e7fd4179SDavid Teigland 
65