xfs_dmapi.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /*
  2. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it would be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write the Free Software Foundation,
  16. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef __XFS_DMAPI_H__
  19. #define __XFS_DMAPI_H__
  20. /* Values used to define the on-disk version of dm_attrname_t. All
  21. * on-disk attribute names start with the 8-byte string "SGI_DMI_".
  22. *
  23. * In the on-disk inode, DMAPI attribute names consist of the user-provided
  24. * name with the DMATTR_PREFIXSTRING pre-pended. This string must NEVER be
  25. * changed.
  26. */
  27. #define DMATTR_PREFIXLEN 8
  28. #define DMATTR_PREFIXSTRING "SGI_DMI_"
  29. typedef enum {
  30. DM_EVENT_INVALID = -1,
  31. DM_EVENT_CANCEL = 0, /* not supported */
  32. DM_EVENT_MOUNT = 1,
  33. DM_EVENT_PREUNMOUNT = 2,
  34. DM_EVENT_UNMOUNT = 3,
  35. DM_EVENT_DEBUT = 4, /* not supported */
  36. DM_EVENT_CREATE = 5,
  37. DM_EVENT_CLOSE = 6, /* not supported */
  38. DM_EVENT_POSTCREATE = 7,
  39. DM_EVENT_REMOVE = 8,
  40. DM_EVENT_POSTREMOVE = 9,
  41. DM_EVENT_RENAME = 10,
  42. DM_EVENT_POSTRENAME = 11,
  43. DM_EVENT_LINK = 12,
  44. DM_EVENT_POSTLINK = 13,
  45. DM_EVENT_SYMLINK = 14,
  46. DM_EVENT_POSTSYMLINK = 15,
  47. DM_EVENT_READ = 16,
  48. DM_EVENT_WRITE = 17,
  49. DM_EVENT_TRUNCATE = 18,
  50. DM_EVENT_ATTRIBUTE = 19,
  51. DM_EVENT_DESTROY = 20,
  52. DM_EVENT_NOSPACE = 21,
  53. DM_EVENT_USER = 22,
  54. DM_EVENT_MAX = 23
  55. } dm_eventtype_t;
  56. #define HAVE_DM_EVENTTYPE_T
  57. typedef enum {
  58. DM_RIGHT_NULL,
  59. DM_RIGHT_SHARED,
  60. DM_RIGHT_EXCL
  61. } dm_right_t;
  62. #define HAVE_DM_RIGHT_T
  63. /* Defines for determining if an event message should be sent. */
  64. #define DM_EVENT_ENABLED(vfsp, ip, event) ( \
  65. unlikely ((vfsp)->vfs_flag & VFS_DMI) && \
  66. ( ((ip)->i_d.di_dmevmask & (1 << event)) || \
  67. ((ip)->i_mount->m_dmevmask & (1 << event)) ) \
  68. )
  69. #define DM_EVENT_ENABLED_IO(vfsp, io, event) ( \
  70. unlikely ((vfsp)->vfs_flag & VFS_DMI) && \
  71. ( ((io)->io_dmevmask & (1 << event)) || \
  72. ((io)->io_mount->m_dmevmask & (1 << event)) ) \
  73. )
  74. #define DM_XFS_VALID_FS_EVENTS ( \
  75. (1 << DM_EVENT_PREUNMOUNT) | \
  76. (1 << DM_EVENT_UNMOUNT) | \
  77. (1 << DM_EVENT_NOSPACE) | \
  78. (1 << DM_EVENT_DEBUT) | \
  79. (1 << DM_EVENT_CREATE) | \
  80. (1 << DM_EVENT_POSTCREATE) | \
  81. (1 << DM_EVENT_REMOVE) | \
  82. (1 << DM_EVENT_POSTREMOVE) | \
  83. (1 << DM_EVENT_RENAME) | \
  84. (1 << DM_EVENT_POSTRENAME) | \
  85. (1 << DM_EVENT_LINK) | \
  86. (1 << DM_EVENT_POSTLINK) | \
  87. (1 << DM_EVENT_SYMLINK) | \
  88. (1 << DM_EVENT_POSTSYMLINK) | \
  89. (1 << DM_EVENT_ATTRIBUTE) | \
  90. (1 << DM_EVENT_DESTROY) )
  91. /* Events valid in dm_set_eventlist() when called with a file handle for
  92. a regular file or a symlink. These events are persistent.
  93. */
  94. #define DM_XFS_VALID_FILE_EVENTS ( \
  95. (1 << DM_EVENT_ATTRIBUTE) | \
  96. (1 << DM_EVENT_DESTROY) )
  97. /* Events valid in dm_set_eventlist() when called with a file handle for
  98. a directory. These events are persistent.
  99. */
  100. #define DM_XFS_VALID_DIRECTORY_EVENTS ( \
  101. (1 << DM_EVENT_CREATE) | \
  102. (1 << DM_EVENT_POSTCREATE) | \
  103. (1 << DM_EVENT_REMOVE) | \
  104. (1 << DM_EVENT_POSTREMOVE) | \
  105. (1 << DM_EVENT_RENAME) | \
  106. (1 << DM_EVENT_POSTRENAME) | \
  107. (1 << DM_EVENT_LINK) | \
  108. (1 << DM_EVENT_POSTLINK) | \
  109. (1 << DM_EVENT_SYMLINK) | \
  110. (1 << DM_EVENT_POSTSYMLINK) | \
  111. (1 << DM_EVENT_ATTRIBUTE) | \
  112. (1 << DM_EVENT_DESTROY) )
  113. /* Events supported by the XFS filesystem. */
  114. #define DM_XFS_SUPPORTED_EVENTS ( \
  115. (1 << DM_EVENT_MOUNT) | \
  116. (1 << DM_EVENT_PREUNMOUNT) | \
  117. (1 << DM_EVENT_UNMOUNT) | \
  118. (1 << DM_EVENT_NOSPACE) | \
  119. (1 << DM_EVENT_CREATE) | \
  120. (1 << DM_EVENT_POSTCREATE) | \
  121. (1 << DM_EVENT_REMOVE) | \
  122. (1 << DM_EVENT_POSTREMOVE) | \
  123. (1 << DM_EVENT_RENAME) | \
  124. (1 << DM_EVENT_POSTRENAME) | \
  125. (1 << DM_EVENT_LINK) | \
  126. (1 << DM_EVENT_POSTLINK) | \
  127. (1 << DM_EVENT_SYMLINK) | \
  128. (1 << DM_EVENT_POSTSYMLINK) | \
  129. (1 << DM_EVENT_READ) | \
  130. (1 << DM_EVENT_WRITE) | \
  131. (1 << DM_EVENT_TRUNCATE) | \
  132. (1 << DM_EVENT_ATTRIBUTE) | \
  133. (1 << DM_EVENT_DESTROY) )
  134. /*
  135. * Definitions used for the flags field on dm_send_*_event().
  136. */
  137. #define DM_FLAGS_NDELAY 0x001 /* return EAGAIN after dm_pending() */
  138. #define DM_FLAGS_UNWANTED 0x002 /* event not in fsys dm_eventset_t */
  139. #define DM_FLAGS_ISEM 0x004 /* thread holds i_sem */
  140. #define DM_FLAGS_IALLOCSEM_RD 0x010 /* thread holds i_alloc_sem rd */
  141. #define DM_FLAGS_IALLOCSEM_WR 0x020 /* thread holds i_alloc_sem wr */
  142. /*
  143. * Based on IO_ISDIRECT, decide which i_ flag is set.
  144. */
  145. #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
  146. #define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
  147. DM_FLAGS_ISEM : 0)
  148. #define DM_SEM_FLAG_WR (DM_FLAGS_IALLOCSEM_WR | DM_FLAGS_ISEM)
  149. #endif
  150. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)) && \
  151. (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,22))
  152. #define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
  153. DM_FLAGS_IALLOCSEM_RD : DM_FLAGS_ISEM)
  154. #define DM_SEM_FLAG_WR (DM_FLAGS_IALLOCSEM_WR | DM_FLAGS_ISEM)
  155. #endif
  156. #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,4,21)
  157. #define DM_SEM_FLAG_RD(ioflags) (((ioflags) & IO_ISDIRECT) ? \
  158. 0 : DM_FLAGS_ISEM)
  159. #define DM_SEM_FLAG_WR (DM_FLAGS_ISEM)
  160. #endif
  161. /*
  162. * Macros to turn caller specified delay/block flags into
  163. * dm_send_xxxx_event flag DM_FLAGS_NDELAY.
  164. */
  165. #define FILP_DELAY_FLAG(filp) ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) ? \
  166. DM_FLAGS_NDELAY : 0)
  167. #define AT_DELAY_FLAG(f) ((f&ATTR_NONBLOCK) ? DM_FLAGS_NDELAY : 0)
  168. extern struct bhv_vfsops xfs_dmops;
  169. #ifdef CONFIG_XFS_DMAPI
  170. void xfs_dm_init(struct file_system_type *);
  171. void xfs_dm_exit(struct file_system_type *);
  172. #define XFS_DM_INIT(fstype) xfs_dm_init(fstype)
  173. #define XFS_DM_EXIT(fstype) xfs_dm_exit(fstype)
  174. #else
  175. #define XFS_DM_INIT(fstype)
  176. #define XFS_DM_EXIT(fstype)
  177. #endif
  178. #endif /* __XFS_DMAPI_H__ */