2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
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.
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.
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.
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.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
37 #define CYCLE_LSN(lsn) ((uint)((lsn)>>32))
38 #define BLOCK_LSN(lsn) ((uint)(lsn))
39 /* this is used in a spot where we might otherwise double-endian-flip */
40 #define CYCLE_LSN_DISK(lsn) (((uint *)&(lsn))[0])
44 * By comparing each compnent, we don't have to worry about extra
45 * endian issues in treating two 32 bit numbers as one 64 bit number
48 #if defined(__GNUC__) && (__GNUC__ == 2) && ( (__GNUC_MINOR__ == 95) || (__GNUC_MINOR__ == 96))
49 __attribute__((unused
)) /* gcc 2.95, 2.96 miscompile this when inlined */
53 xfs_lsn_t
_lsn_cmp(xfs_lsn_t lsn1
, xfs_lsn_t lsn2
)
55 if (CYCLE_LSN(lsn1
) != CYCLE_LSN(lsn2
))
56 return (CYCLE_LSN(lsn1
)<CYCLE_LSN(lsn2
))? -999 : 999;
58 if (BLOCK_LSN(lsn1
) != BLOCK_LSN(lsn2
))
59 return (BLOCK_LSN(lsn1
)<BLOCK_LSN(lsn2
))? -999 : 999;
64 #define XFS_LSN_CMP(x,y) _lsn_cmp(x,y)
67 * Macros, structures, prototypes for interface to the log manager.
71 * Flags to xfs_log_mount
73 #define XFS_LOG_RECOVER 0x1
76 * Flags to xfs_log_done()
78 #define XFS_LOG_REL_PERM_RESERV 0x1
82 * Flags to xfs_log_reserve()
84 * XFS_LOG_SLEEP: If space is not available, sleep (default)
85 * XFS_LOG_NOSLEEP: If space is not available, return error
86 * XFS_LOG_PERM_RESERV: Permanent reservation. When writes are
87 * performed against this type of reservation, the reservation
88 * is not decreased. Long running transactions should use this.
90 #define XFS_LOG_SLEEP 0x0
91 #define XFS_LOG_NOSLEEP 0x1
92 #define XFS_LOG_PERM_RESERV 0x2
93 #define XFS_LOG_RESV_ALL (XFS_LOG_NOSLEEP|XFS_LOG_PERM_RESERV)
97 * Flags to xfs_log_force()
99 * XFS_LOG_SYNC: Synchronous force in-core log to disk
100 * XFS_LOG_FORCE: Start in-core log write now.
101 * XFS_LOG_URGE: Start write within some window of time.
103 * Note: Either XFS_LOG_FORCE or XFS_LOG_URGE must be set.
105 #define XFS_LOG_SYNC 0x1
106 #define XFS_LOG_FORCE 0x2
107 #define XFS_LOG_URGE 0x4
109 #endif /* __KERNEL__ */
113 #define XFS_TRANSACTION 0x69
114 #define XFS_VOLUME 0x2
118 /* Region types for iovec's i_type */
119 #if defined(XFS_LOG_RES_DEBUG)
120 #define XLOG_REG_TYPE_BFORMAT 1
121 #define XLOG_REG_TYPE_BCHUNK 2
122 #define XLOG_REG_TYPE_EFI_FORMAT 3
123 #define XLOG_REG_TYPE_EFD_FORMAT 4
124 #define XLOG_REG_TYPE_IFORMAT 5
125 #define XLOG_REG_TYPE_ICORE 6
126 #define XLOG_REG_TYPE_IEXT 7
127 #define XLOG_REG_TYPE_IBROOT 8
128 #define XLOG_REG_TYPE_ILOCAL 9
129 #define XLOG_REG_TYPE_IATTR_EXT 10
130 #define XLOG_REG_TYPE_IATTR_BROOT 11
131 #define XLOG_REG_TYPE_IATTR_LOCAL 12
132 #define XLOG_REG_TYPE_QFORMAT 13
133 #define XLOG_REG_TYPE_DQUOT 14
134 #define XLOG_REG_TYPE_QUOTAOFF 15
135 #define XLOG_REG_TYPE_LRHEADER 16
136 #define XLOG_REG_TYPE_UNMOUNT 17
137 #define XLOG_REG_TYPE_COMMIT 18
138 #define XLOG_REG_TYPE_TRANSHDR 19
139 #define XLOG_REG_TYPE_MAX 19
142 #if defined(XFS_LOG_RES_DEBUG)
143 #define XLOG_VEC_SET_TYPE(vecp, t) ((vecp)->i_type = (t))
145 #define XLOG_VEC_SET_TYPE(vecp, t)
149 typedef struct xfs_log_iovec
{
150 xfs_caddr_t i_addr
; /* beginning address of region */
151 int i_len
; /* length in bytes of region */
152 #if defined(XFS_LOG_RES_DEBUG)
153 uint i_type
; /* type of region */
157 typedef void* xfs_log_ticket_t
;
160 * Structure used to pass callback function and the function's argument
161 * to the log manager.
163 typedef struct xfs_log_callback
{
164 struct xfs_log_callback
*cb_next
;
165 void (*cb_func
)(void *, int);
167 } xfs_log_callback_t
;
171 /* Log manager interfaces */
173 xfs_lsn_t
xfs_log_done(struct xfs_mount
*mp
,
174 xfs_log_ticket_t ticket
,
177 int xfs_log_force(struct xfs_mount
*mp
,
180 int xfs_log_mount(struct xfs_mount
*mp
,
181 struct xfs_buftarg
*log_target
,
182 xfs_daddr_t start_block
,
184 int xfs_log_mount_finish(struct xfs_mount
*mp
, int);
185 void xfs_log_move_tail(struct xfs_mount
*mp
,
187 int xfs_log_notify(struct xfs_mount
*mp
,
189 xfs_log_callback_t
*callback_entry
);
190 int xfs_log_release_iclog(struct xfs_mount
*mp
,
192 int xfs_log_reserve(struct xfs_mount
*mp
,
195 xfs_log_ticket_t
*ticket
,
199 int xfs_log_write(struct xfs_mount
*mp
,
200 xfs_log_iovec_t region
[],
202 xfs_log_ticket_t ticket
,
203 xfs_lsn_t
*start_lsn
);
204 int xfs_log_unmount(struct xfs_mount
*mp
);
205 int xfs_log_unmount_write(struct xfs_mount
*mp
);
206 void xfs_log_unmount_dealloc(struct xfs_mount
*mp
);
207 int xfs_log_force_umount(struct xfs_mount
*mp
, int logerror
);
208 int xfs_log_need_covered(struct xfs_mount
*mp
);
210 void xlog_iodone(struct xfs_buf
*);
215 extern int xlog_debug
; /* set to 1 to enable real log */
218 #endif /* __XFS_LOG_H__ */