userdlm.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* -*- mode: c; c-basic-offset: 8; -*-
  2. * vim: noexpandtab sw=8 ts=8 sts=0:
  3. *
  4. * userdlm.h
  5. *
  6. * Userspace dlm defines
  7. *
  8. * Copyright (C) 2002, 2004 Oracle. All rights reserved.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public
  12. * License as published by the Free Software Foundation; either
  13. * version 2 of the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public
  21. * License along with this program; if not, write to the
  22. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  23. * Boston, MA 021110-1307, USA.
  24. */
  25. #ifndef USERDLM_H
  26. #define USERDLM_H
  27. #include <linux/module.h>
  28. #include <linux/fs.h>
  29. #include <linux/types.h>
  30. #include <linux/workqueue.h>
  31. /* user_lock_res->l_flags flags. */
  32. #define USER_LOCK_ATTACHED (0x00000001) /* we have initialized
  33. * the lvb */
  34. #define USER_LOCK_BUSY (0x00000002) /* we are currently in
  35. * dlm_lock */
  36. #define USER_LOCK_BLOCKED (0x00000004) /* blocked waiting to
  37. * downconvert*/
  38. #define USER_LOCK_IN_TEARDOWN (0x00000008) /* we're currently
  39. * destroying this
  40. * lock. */
  41. #define USER_LOCK_QUEUED (0x00000010) /* lock is on the
  42. * workqueue */
  43. #define USER_LOCK_IN_CANCEL (0x00000020)
  44. struct user_lock_res {
  45. spinlock_t l_lock;
  46. int l_flags;
  47. #define USER_DLM_LOCK_ID_MAX_LEN 32
  48. char l_name[USER_DLM_LOCK_ID_MAX_LEN];
  49. int l_namelen;
  50. int l_level;
  51. unsigned int l_ro_holders;
  52. unsigned int l_ex_holders;
  53. struct ocfs2_dlm_lksb l_lksb;
  54. int l_requested;
  55. int l_blocking;
  56. wait_queue_head_t l_event;
  57. struct work_struct l_work;
  58. };
  59. extern struct workqueue_struct *user_dlm_worker;
  60. void user_dlm_lock_res_init(struct user_lock_res *lockres,
  61. struct dentry *dentry);
  62. int user_dlm_destroy_lock(struct user_lock_res *lockres);
  63. int user_dlm_cluster_lock(struct user_lock_res *lockres,
  64. int level,
  65. int lkm_flags);
  66. void user_dlm_cluster_unlock(struct user_lock_res *lockres,
  67. int level);
  68. void user_dlm_write_lvb(struct inode *inode,
  69. const char *val,
  70. unsigned int len);
  71. ssize_t user_dlm_read_lvb(struct inode *inode,
  72. char *val,
  73. unsigned int len);
  74. struct ocfs2_cluster_connection *user_dlm_register(const struct qstr *name);
  75. void user_dlm_unregister(struct ocfs2_cluster_connection *conn);
  76. void user_dlm_set_locking_protocol(void);
  77. struct dlmfs_inode_private {
  78. struct ocfs2_cluster_connection *ip_conn;
  79. struct user_lock_res ip_lockres; /* unused for directories. */
  80. struct inode *ip_parent;
  81. struct inode ip_vfs_inode;
  82. };
  83. static inline struct dlmfs_inode_private *
  84. DLMFS_I(struct inode *inode)
  85. {
  86. return container_of(inode,
  87. struct dlmfs_inode_private,
  88. ip_vfs_inode);
  89. }
  90. struct dlmfs_filp_private {
  91. int fp_lock_level;
  92. };
  93. #define DLMFS_MAGIC 0x76a9f425
  94. #endif /* USERDLM_H */