0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef USERDLM_H
0012 #define USERDLM_H
0013
0014 #include <linux/module.h>
0015 #include <linux/fs.h>
0016 #include <linux/types.h>
0017 #include <linux/workqueue.h>
0018
0019
0020 #define USER_LOCK_ATTACHED (0x00000001)
0021
0022 #define USER_LOCK_BUSY (0x00000002)
0023
0024 #define USER_LOCK_BLOCKED (0x00000004)
0025
0026 #define USER_LOCK_IN_TEARDOWN (0x00000008)
0027
0028
0029 #define USER_LOCK_QUEUED (0x00000010)
0030
0031 #define USER_LOCK_IN_CANCEL (0x00000020)
0032
0033 struct user_lock_res {
0034 spinlock_t l_lock;
0035
0036 int l_flags;
0037
0038 #define USER_DLM_LOCK_ID_MAX_LEN 32
0039 char l_name[USER_DLM_LOCK_ID_MAX_LEN];
0040 int l_namelen;
0041 int l_level;
0042 unsigned int l_ro_holders;
0043 unsigned int l_ex_holders;
0044 struct ocfs2_dlm_lksb l_lksb;
0045
0046 int l_requested;
0047 int l_blocking;
0048
0049 wait_queue_head_t l_event;
0050
0051 struct work_struct l_work;
0052 };
0053
0054 extern struct workqueue_struct *user_dlm_worker;
0055
0056 void user_dlm_lock_res_init(struct user_lock_res *lockres,
0057 struct dentry *dentry);
0058 int user_dlm_destroy_lock(struct user_lock_res *lockres);
0059 int user_dlm_cluster_lock(struct user_lock_res *lockres,
0060 int level,
0061 int lkm_flags);
0062 void user_dlm_cluster_unlock(struct user_lock_res *lockres,
0063 int level);
0064 void user_dlm_write_lvb(struct inode *inode,
0065 const char *val,
0066 unsigned int len);
0067 bool user_dlm_read_lvb(struct inode *inode, char *val);
0068 struct ocfs2_cluster_connection *user_dlm_register(const struct qstr *name);
0069 void user_dlm_unregister(struct ocfs2_cluster_connection *conn);
0070 void user_dlm_set_locking_protocol(void);
0071
0072 struct dlmfs_inode_private {
0073 struct ocfs2_cluster_connection *ip_conn;
0074
0075 struct user_lock_res ip_lockres;
0076 struct inode *ip_parent;
0077
0078 struct inode ip_vfs_inode;
0079 };
0080
0081 static inline struct dlmfs_inode_private *
0082 DLMFS_I(struct inode *inode)
0083 {
0084 return container_of(inode,
0085 struct dlmfs_inode_private,
0086 ip_vfs_inode);
0087 }
0088
0089 struct dlmfs_filp_private {
0090 int fp_lock_level;
0091 };
0092
0093 #define DLMFS_MAGIC 0x76a9f425
0094
0095 #endif