xfs_dmapi.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. #include <linux/version.h>
  21. /* Values used to define the on-disk version of dm_attrname_t. All
  22. * on-disk attribute names start with the 8-byte string "SGI_DMI_".
  23. *
  24. * In the on-disk inode, DMAPI attribute names consist of the user-provided
  25. * name with the DMATTR_PREFIXSTRING pre-pended. This string must NEVER be
  26. * changed.
  27. */
  28. #define DMATTR_PREFIXLEN 8
  29. #define DMATTR_PREFIXSTRING "SGI_DMI_"
  30. typedef enum {
  31. DM_EVENT_INVALID = -1,
  32. DM_EVENT_CANCEL = 0, /* not supported */
  33. DM_EVENT_MOUNT = 1,
  34. DM_EVENT_PREUNMOUNT = 2,
  35. DM_EVENT_UNMOUNT = 3,
  36. DM_EVENT_DEBUT = 4, /* not supported */
  37. DM_EVENT_CREATE = 5,
  38. DM_EVENT_CLOSE = 6, /* not supported */
  39. DM_EVENT_POSTCREATE = 7,
  40. DM_EVENT_REMOVE = 8,
  41. DM_EVENT_POSTREMOVE = 9,
  42. DM_EVENT_RENAME = 10,
  43. DM_EVENT_POSTRENAME = 11,
  44. DM_EVENT_LINK = 12,
  45. DM_EVENT_POSTLINK = 13,
  46. DM_EVENT_SYMLINK = 14,
  47. DM_EVENT_POSTSYMLINK = 15,
  48. DM_EVENT_READ = 16,
  49. DM_EVENT_WRITE = 17,
  50. DM_EVENT_TRUNCATE = 18,
  51. DM_EVENT_ATTRIBUTE = 19,
  52. DM_EVENT_DESTROY = 20,
  53. DM_EVENT_NOSPACE = 21,
  54. DM_EVENT_USER = 22,
  55. DM_EVENT_MAX = 23
  56. } dm_eventtype_t;
  57. #define HAVE_DM_EVENTTYPE_T
  58. typedef enum {
  59. DM_RIGHT_NULL,
  60. DM_RIGHT_SHARED,
  61. DM_RIGHT_EXCL
  62. } dm_right_t;
  63. #define HAVE_DM_RIGHT_T
  64. /* Defines for determining if an event message should be sent. */
  65. #define DM_EVENT_ENABLED(vfsp, ip, event) ( \
  66. unlikely ((vfsp)->vfs_flag & VFS_DMI) && \
  67. ( ((ip)->i_d.di_dmevmask & (1 << event)) || \
  68. ((ip)->i_mount->m_dmevmask & (1 << event)) ) \
  69. )
  70. #define DM_EVENT_ENABLED_IO(vfsp, io, event) ( \
  71. unlikely ((vfsp)->vfs_flag & VFS_DMI) && \
  72. ( ((io)->io_dmevmask & (1 << event)) || \
  73. ((io)->io_mount->m_dmevmask & (1 << event)) ) \
  74. )
  75. #define DM_XFS_VALID_FS_EVENTS ( \
  76. (1 << DM_EVENT_PREUNMOUNT) | \
  77. (1 << DM_EVENT_UNMOUNT) | \
  78. (1 << DM_EVENT_NOSPACE) | \
  79. (1 << DM_EVENT_DEBUT) | \
  80. (1 << DM_EVENT_CREATE) | \
  81. (1 << DM_EVENT_POSTCREATE) | \
  82. (1 << DM_EVENT_REMOVE) | \
  83. (1 << DM_EVENT_POSTREMOVE) | \
  84. (1 << DM_EVENT_RENAME) | \
  85. (1 << DM_EVENT_POSTRENAME) | \
  86. (1 << DM_EVENT_LINK) | \
  87. (1 << DM_EVENT_POSTLINK) | \
  88. (1 << DM_EVENT_SYMLINK) | \
  89. (1 << DM_EVENT_POSTSYMLINK) | \
  90. (1 << DM_EVENT_ATTRIBUTE) | \
  91. (1 << DM_EVENT_DESTROY) )
  92. /* Events valid in dm_set_eventlist() when called with a file handle for
  93. a regular file or a symlink. These events are persistent.
  94. */
  95. #define DM_XFS_VALID_FILE_EVENTS ( \
  96. (1 << DM_EVENT_ATTRIBUTE) | \
  97. (1 << DM_EVENT_DESTROY) )
  98. /* Events valid in dm_set_eventlist() when called with a file handle for
  99. a directory. These events are persistent.
  100. */
  101. #define DM_XFS_VALID_DIRECTORY_EVENTS ( \
  102. (1 << DM_EVENT_CREATE) | \
  103. (1 << DM_EVENT_POSTCREATE) | \
  104. (1 << DM_EVENT_REMOVE) | \
  105. (1 << DM_EVENT_POSTREMOVE) | \
  106. (1 << DM_EVENT_RENAME) | \
  107. (1 << DM_EVENT_POSTRENAME) | \
  108. (1 << DM_EVENT_LINK) | \
  109. (1 << DM_EVENT_POSTLINK) | \
  110. (1 << DM_EVENT_SYMLINK) | \
  111. (1 << DM_EVENT_POSTSYMLINK) | \
  112. (1 << DM_EVENT_ATTRIBUTE) | \
  113. (1 << DM_EVENT_DESTROY) )
  114. /* Events supported by the XFS filesystem. */
  115. #define DM_XFS_SUPPORTED_EVENTS ( \
  116. (1 << DM_EVENT_MOUNT) | \
  117. (1 << DM_EVENT_PREUNMOUNT) | \
  118. (1 << DM_EVENT_UNMOUNT) | \
  119. (1 << DM_EVENT_NOSPACE) | \
  120. (1 << DM_EVENT_CREATE) | \
  121. (1 << DM_EVENT_POSTCREATE) | \
  122. (1 << DM_EVENT_REMOVE) | \
  123. (1 << DM_EVENT_POSTREMOVE) | \
  124. (1 << DM_EVENT_RENAME) | \
  125. (1 << DM_EVENT_POSTRENAME) | \
  126. (1 << DM_EVENT_LINK) | \
  127. (1 << DM_EVENT_POSTLINK) | \
  128. (1 << DM_EVENT_SYMLINK) | \
  129. (1 << DM_EVENT_POSTSYMLINK) | \
  130. (1 << DM_EVENT_READ) | \
  131. (1 << DM_EVENT_WRITE) | \
  132. (1 << DM_EVENT_TRUNCATE) | \
  133. (1 << DM_EVENT_ATTRIBUTE) | \
  134. (1 << DM_EVENT_DESTROY) )
  135. /*
  136. * Definitions used for the flags field on dm_send_*_event().
  137. */
  138. #define DM_FLAGS_NDELAY 0x001 /* return EAGAIN after dm_pending() */
  139. #define DM_FLAGS_UNWANTED 0x002 /* event not in fsys dm_eventset_t */
  140. #define DM_FLAGS_IMUX 0x004 /* thread holds i_mutex */
  141. #define DM_FLAGS_IALLOCSEM_RD 0x010 /* thread holds i_alloc_sem rd */
  142. #define DM_FLAGS_IALLOCSEM_WR 0x020 /* thread holds i_alloc_sem wr */
  143. /*
  144. * Pull in platform specific event flags defines
  145. */
  146. #include "xfs_dmapi_priv.h"
  147. /*
  148. * Macros to turn caller specified delay/block flags into
  149. * dm_send_xxxx_event flag DM_FLAGS_NDELAY.
  150. */
  151. #define FILP_DELAY_FLAG(filp) ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) ? \
  152. DM_FLAGS_NDELAY : 0)
  153. #define AT_DELAY_FLAG(f) ((f&ATTR_NONBLOCK) ? DM_FLAGS_NDELAY : 0)
  154. extern struct bhv_module_vfsops xfs_dmops;
  155. #endif /* __XFS_DMAPI_H__ */