xfs_dmapi.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. #ifdef HAVE_DMAPI
  65. #define DM_EVENT_ENABLED(ip, event) ( \
  66. unlikely ((ip)->i_mount->m_flags & XFS_MOUNT_DMAPI) && \
  67. ( ((ip)->i_d.di_dmevmask & (1 << event)) || \
  68. ((ip)->i_mount->m_dmevmask & (1 << event)) ) \
  69. )
  70. #else
  71. #define DM_EVENT_ENABLED(ip, event) (0)
  72. #endif
  73. #define DM_XFS_VALID_FS_EVENTS ( \
  74. (1 << DM_EVENT_PREUNMOUNT) | \
  75. (1 << DM_EVENT_UNMOUNT) | \
  76. (1 << DM_EVENT_NOSPACE) | \
  77. (1 << DM_EVENT_DEBUT) | \
  78. (1 << DM_EVENT_CREATE) | \
  79. (1 << DM_EVENT_POSTCREATE) | \
  80. (1 << DM_EVENT_REMOVE) | \
  81. (1 << DM_EVENT_POSTREMOVE) | \
  82. (1 << DM_EVENT_RENAME) | \
  83. (1 << DM_EVENT_POSTRENAME) | \
  84. (1 << DM_EVENT_LINK) | \
  85. (1 << DM_EVENT_POSTLINK) | \
  86. (1 << DM_EVENT_SYMLINK) | \
  87. (1 << DM_EVENT_POSTSYMLINK) | \
  88. (1 << DM_EVENT_ATTRIBUTE) | \
  89. (1 << DM_EVENT_DESTROY) )
  90. /* Events valid in dm_set_eventlist() when called with a file handle for
  91. a regular file or a symlink. These events are persistent.
  92. */
  93. #define DM_XFS_VALID_FILE_EVENTS ( \
  94. (1 << DM_EVENT_ATTRIBUTE) | \
  95. (1 << DM_EVENT_DESTROY) )
  96. /* Events valid in dm_set_eventlist() when called with a file handle for
  97. a directory. These events are persistent.
  98. */
  99. #define DM_XFS_VALID_DIRECTORY_EVENTS ( \
  100. (1 << DM_EVENT_CREATE) | \
  101. (1 << DM_EVENT_POSTCREATE) | \
  102. (1 << DM_EVENT_REMOVE) | \
  103. (1 << DM_EVENT_POSTREMOVE) | \
  104. (1 << DM_EVENT_RENAME) | \
  105. (1 << DM_EVENT_POSTRENAME) | \
  106. (1 << DM_EVENT_LINK) | \
  107. (1 << DM_EVENT_POSTLINK) | \
  108. (1 << DM_EVENT_SYMLINK) | \
  109. (1 << DM_EVENT_POSTSYMLINK) | \
  110. (1 << DM_EVENT_ATTRIBUTE) | \
  111. (1 << DM_EVENT_DESTROY) )
  112. /* Events supported by the XFS filesystem. */
  113. #define DM_XFS_SUPPORTED_EVENTS ( \
  114. (1 << DM_EVENT_MOUNT) | \
  115. (1 << DM_EVENT_PREUNMOUNT) | \
  116. (1 << DM_EVENT_UNMOUNT) | \
  117. (1 << DM_EVENT_NOSPACE) | \
  118. (1 << DM_EVENT_CREATE) | \
  119. (1 << DM_EVENT_POSTCREATE) | \
  120. (1 << DM_EVENT_REMOVE) | \
  121. (1 << DM_EVENT_POSTREMOVE) | \
  122. (1 << DM_EVENT_RENAME) | \
  123. (1 << DM_EVENT_POSTRENAME) | \
  124. (1 << DM_EVENT_LINK) | \
  125. (1 << DM_EVENT_POSTLINK) | \
  126. (1 << DM_EVENT_SYMLINK) | \
  127. (1 << DM_EVENT_POSTSYMLINK) | \
  128. (1 << DM_EVENT_READ) | \
  129. (1 << DM_EVENT_WRITE) | \
  130. (1 << DM_EVENT_TRUNCATE) | \
  131. (1 << DM_EVENT_ATTRIBUTE) | \
  132. (1 << DM_EVENT_DESTROY) )
  133. /*
  134. * Definitions used for the flags field on dm_send_*_event().
  135. */
  136. #define DM_FLAGS_NDELAY 0x001 /* return EAGAIN after dm_pending() */
  137. #define DM_FLAGS_UNWANTED 0x002 /* event not in fsys dm_eventset_t */
  138. #define DM_FLAGS_IMUX 0x004 /* thread holds i_mutex */
  139. #define DM_FLAGS_IALLOCSEM_RD 0x010 /* thread holds i_alloc_sem rd */
  140. #define DM_FLAGS_IALLOCSEM_WR 0x020 /* thread holds i_alloc_sem wr */
  141. /*
  142. * Pull in platform specific event flags defines
  143. */
  144. #include "xfs_dmapi_priv.h"
  145. /*
  146. * Macros to turn caller specified delay/block flags into
  147. * dm_send_xxxx_event flag DM_FLAGS_NDELAY.
  148. */
  149. #define FILP_DELAY_FLAG(filp) ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) ? \
  150. DM_FLAGS_NDELAY : 0)
  151. #define AT_DELAY_FLAG(f) ((f & XFS_ATTR_NONBLOCK) ? DM_FLAGS_NDELAY : 0)
  152. #endif /* __XFS_DMAPI_H__ */