xfs_dmapi.h 6.6 KB

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