userdlm.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * userdlm.h
  4. *
  5. * Userspace dlm defines
  6. *
  7. * Copyright (C) 2002, 2004 Oracle. All rights reserved.
  8. */
  9. #ifndef USERDLM_H
  10. #define USERDLM_H
  11. #include <linux/module.h>
  12. #include <linux/fs.h>
  13. #include <linux/types.h>
  14. #include <linux/workqueue.h>
  15. /* user_lock_res->l_flags flags. */
  16. #define USER_LOCK_ATTACHED (0x00000001) /* we have initialized
  17. * the lvb */
  18. #define USER_LOCK_BUSY (0x00000002) /* we are currently in
  19. * dlm_lock */
  20. #define USER_LOCK_BLOCKED (0x00000004) /* blocked waiting to
  21. * downconvert*/
  22. #define USER_LOCK_IN_TEARDOWN (0x00000008) /* we're currently
  23. * destroying this
  24. * lock. */
  25. #define USER_LOCK_QUEUED (0x00000010) /* lock is on the
  26. * workqueue */
  27. #define USER_LOCK_IN_CANCEL (0x00000020)
  28. struct user_lock_res {
  29. spinlock_t l_lock;
  30. int l_flags;
  31. #define USER_DLM_LOCK_ID_MAX_LEN 32
  32. char l_name[USER_DLM_LOCK_ID_MAX_LEN];
  33. int l_namelen;
  34. int l_level;
  35. unsigned int l_ro_holders;
  36. unsigned int l_ex_holders;
  37. struct ocfs2_dlm_lksb l_lksb;
  38. int l_requested;
  39. int l_blocking;
  40. wait_queue_head_t l_event;
  41. struct work_struct l_work;
  42. };
  43. extern struct workqueue_struct *user_dlm_worker;
  44. void user_dlm_lock_res_init(struct user_lock_res *lockres,
  45. struct dentry *dentry);
  46. int user_dlm_destroy_lock(struct user_lock_res *lockres);
  47. int user_dlm_cluster_lock(struct user_lock_res *lockres,
  48. int level,
  49. int lkm_flags);
  50. void user_dlm_cluster_unlock(struct user_lock_res *lockres,
  51. int level);
  52. void user_dlm_write_lvb(struct inode *inode,
  53. const char *val,
  54. unsigned int len);
  55. bool user_dlm_read_lvb(struct inode *inode, char *val);
  56. struct ocfs2_cluster_connection *user_dlm_register(const struct qstr *name);
  57. void user_dlm_unregister(struct ocfs2_cluster_connection *conn);
  58. void user_dlm_set_locking_protocol(void);
  59. struct dlmfs_inode_private {
  60. struct ocfs2_cluster_connection *ip_conn;
  61. struct user_lock_res ip_lockres; /* unused for directories. */
  62. struct inode *ip_parent;
  63. struct inode ip_vfs_inode;
  64. };
  65. static inline struct dlmfs_inode_private *
  66. DLMFS_I(struct inode *inode)
  67. {
  68. return container_of(inode,
  69. struct dlmfs_inode_private,
  70. ip_vfs_inode);
  71. }
  72. struct dlmfs_filp_private {
  73. int fp_lock_level;
  74. };
  75. #define DLMFS_MAGIC 0x76a9f425
  76. #endif /* USERDLM_H */