xfs_log.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. * Copyright (c) 2000-2003 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_LOG_H__
  33. #define __XFS_LOG_H__
  34. /* get lsn fields */
  35. #define CYCLE_LSN(lsn) ((uint)((lsn)>>32))
  36. #define BLOCK_LSN(lsn) ((uint)(lsn))
  37. /* this is used in a spot where we might otherwise double-endian-flip */
  38. #define CYCLE_LSN_DISK(lsn) (((uint *)&(lsn))[0])
  39. #ifdef __KERNEL__
  40. /*
  41. * By comparing each compnent, we don't have to worry about extra
  42. * endian issues in treating two 32 bit numbers as one 64 bit number
  43. */
  44. static
  45. #if defined(__GNUC__) && (__GNUC__ == 2) && ( (__GNUC_MINOR__ == 95) || (__GNUC_MINOR__ == 96))
  46. __attribute__((unused)) /* gcc 2.95, 2.96 miscompile this when inlined */
  47. #else
  48. __inline__
  49. #endif
  50. xfs_lsn_t _lsn_cmp(xfs_lsn_t lsn1, xfs_lsn_t lsn2)
  51. {
  52. if (CYCLE_LSN(lsn1) != CYCLE_LSN(lsn2))
  53. return (CYCLE_LSN(lsn1)<CYCLE_LSN(lsn2))? -999 : 999;
  54. if (BLOCK_LSN(lsn1) != BLOCK_LSN(lsn2))
  55. return (BLOCK_LSN(lsn1)<BLOCK_LSN(lsn2))? -999 : 999;
  56. return 0;
  57. }
  58. #define XFS_LSN_CMP(x,y) _lsn_cmp(x,y)
  59. /*
  60. * Macros, structures, prototypes for interface to the log manager.
  61. */
  62. /*
  63. * Flags to xfs_log_mount
  64. */
  65. #define XFS_LOG_RECOVER 0x1
  66. /*
  67. * Flags to xfs_log_done()
  68. */
  69. #define XFS_LOG_REL_PERM_RESERV 0x1
  70. /*
  71. * Flags to xfs_log_reserve()
  72. *
  73. * XFS_LOG_SLEEP: If space is not available, sleep (default)
  74. * XFS_LOG_NOSLEEP: If space is not available, return error
  75. * XFS_LOG_PERM_RESERV: Permanent reservation. When writes are
  76. * performed against this type of reservation, the reservation
  77. * is not decreased. Long running transactions should use this.
  78. */
  79. #define XFS_LOG_SLEEP 0x0
  80. #define XFS_LOG_NOSLEEP 0x1
  81. #define XFS_LOG_PERM_RESERV 0x2
  82. #define XFS_LOG_RESV_ALL (XFS_LOG_NOSLEEP|XFS_LOG_PERM_RESERV)
  83. /*
  84. * Flags to xfs_log_force()
  85. *
  86. * XFS_LOG_SYNC: Synchronous force in-core log to disk
  87. * XFS_LOG_FORCE: Start in-core log write now.
  88. * XFS_LOG_URGE: Start write within some window of time.
  89. *
  90. * Note: Either XFS_LOG_FORCE or XFS_LOG_URGE must be set.
  91. */
  92. #define XFS_LOG_SYNC 0x1
  93. #define XFS_LOG_FORCE 0x2
  94. #define XFS_LOG_URGE 0x4
  95. #endif /* __KERNEL__ */
  96. /* Log Clients */
  97. #define XFS_TRANSACTION 0x69
  98. #define XFS_VOLUME 0x2
  99. #define XFS_LOG 0xaa
  100. /* Region types for iovec's i_type */
  101. #if defined(XFS_LOG_RES_DEBUG)
  102. #define XLOG_REG_TYPE_BFORMAT 1
  103. #define XLOG_REG_TYPE_BCHUNK 2
  104. #define XLOG_REG_TYPE_EFI_FORMAT 3
  105. #define XLOG_REG_TYPE_EFD_FORMAT 4
  106. #define XLOG_REG_TYPE_IFORMAT 5
  107. #define XLOG_REG_TYPE_ICORE 6
  108. #define XLOG_REG_TYPE_IEXT 7
  109. #define XLOG_REG_TYPE_IBROOT 8
  110. #define XLOG_REG_TYPE_ILOCAL 9
  111. #define XLOG_REG_TYPE_IATTR_EXT 10
  112. #define XLOG_REG_TYPE_IATTR_BROOT 11
  113. #define XLOG_REG_TYPE_IATTR_LOCAL 12
  114. #define XLOG_REG_TYPE_QFORMAT 13
  115. #define XLOG_REG_TYPE_DQUOT 14
  116. #define XLOG_REG_TYPE_QUOTAOFF 15
  117. #define XLOG_REG_TYPE_LRHEADER 16
  118. #define XLOG_REG_TYPE_UNMOUNT 17
  119. #define XLOG_REG_TYPE_COMMIT 18
  120. #define XLOG_REG_TYPE_TRANSHDR 19
  121. #define XLOG_REG_TYPE_MAX 19
  122. #endif
  123. #if defined(XFS_LOG_RES_DEBUG)
  124. #define XLOG_VEC_SET_TYPE(vecp, t) ((vecp)->i_type = (t))
  125. #else
  126. #define XLOG_VEC_SET_TYPE(vecp, t)
  127. #endif
  128. typedef struct xfs_log_iovec {
  129. xfs_caddr_t i_addr; /* beginning address of region */
  130. int i_len; /* length in bytes of region */
  131. #if defined(XFS_LOG_RES_DEBUG)
  132. uint i_type; /* type of region */
  133. #endif
  134. } xfs_log_iovec_t;
  135. typedef void* xfs_log_ticket_t;
  136. /*
  137. * Structure used to pass callback function and the function's argument
  138. * to the log manager.
  139. */
  140. typedef struct xfs_log_callback {
  141. struct xfs_log_callback *cb_next;
  142. void (*cb_func)(void *, int);
  143. void *cb_arg;
  144. } xfs_log_callback_t;
  145. #ifdef __KERNEL__
  146. /* Log manager interfaces */
  147. struct xfs_mount;
  148. xfs_lsn_t xfs_log_done(struct xfs_mount *mp,
  149. xfs_log_ticket_t ticket,
  150. void **iclog,
  151. uint flags);
  152. int xfs_log_force(struct xfs_mount *mp,
  153. xfs_lsn_t lsn,
  154. uint flags);
  155. int xfs_log_mount(struct xfs_mount *mp,
  156. struct xfs_buftarg *log_target,
  157. xfs_daddr_t start_block,
  158. int num_bblocks);
  159. int xfs_log_mount_finish(struct xfs_mount *mp, int);
  160. void xfs_log_move_tail(struct xfs_mount *mp,
  161. xfs_lsn_t tail_lsn);
  162. int xfs_log_notify(struct xfs_mount *mp,
  163. void *iclog,
  164. xfs_log_callback_t *callback_entry);
  165. int xfs_log_release_iclog(struct xfs_mount *mp,
  166. void *iclog_hndl);
  167. int xfs_log_reserve(struct xfs_mount *mp,
  168. int length,
  169. int count,
  170. xfs_log_ticket_t *ticket,
  171. __uint8_t clientid,
  172. uint flags,
  173. uint t_type);
  174. int xfs_log_write(struct xfs_mount *mp,
  175. xfs_log_iovec_t region[],
  176. int nentries,
  177. xfs_log_ticket_t ticket,
  178. xfs_lsn_t *start_lsn);
  179. int xfs_log_unmount(struct xfs_mount *mp);
  180. int xfs_log_unmount_write(struct xfs_mount *mp);
  181. void xfs_log_unmount_dealloc(struct xfs_mount *mp);
  182. int xfs_log_force_umount(struct xfs_mount *mp, int logerror);
  183. int xfs_log_need_covered(struct xfs_mount *mp);
  184. void xlog_iodone(struct xfs_buf *);
  185. #endif
  186. extern int xlog_debug; /* set to 1 to enable real log */
  187. #endif /* __XFS_LOG_H__ */