xfs_log.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. typedef struct xfs_log_iovec {
  101. xfs_caddr_t i_addr; /* beginning address of region */
  102. int i_len; /* length in bytes of region */
  103. } xfs_log_iovec_t;
  104. typedef void* xfs_log_ticket_t;
  105. /*
  106. * Structure used to pass callback function and the function's argument
  107. * to the log manager.
  108. */
  109. typedef struct xfs_log_callback {
  110. struct xfs_log_callback *cb_next;
  111. void (*cb_func)(void *, int);
  112. void *cb_arg;
  113. } xfs_log_callback_t;
  114. #ifdef __KERNEL__
  115. /* Log manager interfaces */
  116. struct xfs_mount;
  117. xfs_lsn_t xfs_log_done(struct xfs_mount *mp,
  118. xfs_log_ticket_t ticket,
  119. void **iclog,
  120. uint flags);
  121. int xfs_log_force(struct xfs_mount *mp,
  122. xfs_lsn_t lsn,
  123. uint flags);
  124. int xfs_log_mount(struct xfs_mount *mp,
  125. struct xfs_buftarg *log_target,
  126. xfs_daddr_t start_block,
  127. int num_bblocks);
  128. int xfs_log_mount_finish(struct xfs_mount *mp, int);
  129. void xfs_log_move_tail(struct xfs_mount *mp,
  130. xfs_lsn_t tail_lsn);
  131. int xfs_log_notify(struct xfs_mount *mp,
  132. void *iclog,
  133. xfs_log_callback_t *callback_entry);
  134. int xfs_log_release_iclog(struct xfs_mount *mp,
  135. void *iclog_hndl);
  136. int xfs_log_reserve(struct xfs_mount *mp,
  137. int length,
  138. int count,
  139. xfs_log_ticket_t *ticket,
  140. __uint8_t clientid,
  141. uint flags);
  142. int xfs_log_write(struct xfs_mount *mp,
  143. xfs_log_iovec_t region[],
  144. int nentries,
  145. xfs_log_ticket_t ticket,
  146. xfs_lsn_t *start_lsn);
  147. int xfs_log_unmount(struct xfs_mount *mp);
  148. int xfs_log_unmount_write(struct xfs_mount *mp);
  149. void xfs_log_unmount_dealloc(struct xfs_mount *mp);
  150. int xfs_log_force_umount(struct xfs_mount *mp, int logerror);
  151. int xfs_log_need_covered(struct xfs_mount *mp);
  152. void xlog_iodone(struct xfs_buf *);
  153. #endif
  154. extern int xlog_debug; /* set to 1 to enable real log */
  155. #endif /* __XFS_LOG_H__ */