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/
35 #if __BYTE_ORDER == __LITTLE_ENDIAN
36 #define LSN_FIELD_CYCLE(arch) (((arch)==ARCH_NOCONVERT)?1:0)
37 #define LSN_FIELD_BLOCK(arch) (((arch)==ARCH_NOCONVERT)?0:1)
39 #define LSN_FIELD_CYCLE(arch) (0)
40 #define LSN_FIELD_BLOCK(arch) (1)
45 #define CYCLE_LSN(lsn,arch) (INT_GET(((uint *)&(lsn))[LSN_FIELD_CYCLE(arch)], arch))
46 #define BLOCK_LSN(lsn,arch) (INT_GET(((uint *)&(lsn))[LSN_FIELD_BLOCK(arch)], arch))
47 /* this is used in a spot where we might otherwise double-endian-flip */
48 #define CYCLE_LSN_NOCONV(lsn,arch) (((uint *)&(lsn))[LSN_FIELD_CYCLE(arch)])
52 * By comparing each compnent, we don't have to worry about extra
53 * endian issues in treating two 32 bit numbers as one 64 bit number
56 #if defined(__GNUC__) && (__GNUC__ == 2) && ( (__GNUC_MINOR__ == 95) || (__GNUC_MINOR__ == 96))
57 __attribute__((unused)) /* gcc 2.95, 2.96 miscompile this when inlined */
61 xfs_lsn_t _lsn_cmp(xfs_lsn_t lsn1, xfs_lsn_t lsn2, xfs_arch_t arch)
63 if (CYCLE_LSN(lsn1, arch) != CYCLE_LSN(lsn2, arch))
64 return (CYCLE_LSN(lsn1, arch)<CYCLE_LSN(lsn2, arch))? -999 : 999;
66 if (BLOCK_LSN(lsn1, arch) != BLOCK_LSN(lsn2, arch))
67 return (BLOCK_LSN(lsn1, arch)<BLOCK_LSN(lsn2, arch))? -999 : 999;
72 #define XFS_LSN_CMP_ARCH(x,y,arch) _lsn_cmp(x, y, arch)
73 #define XFS_LSN_CMP(x,y) XFS_LSN_CMP_ARCH(x,y,ARCH_NOCONVERT)
74 #define XFS_LSN_DIFF_ARCH(x,y,arch) _lsn_cmp(x, y, arch)
75 #define XFS_LSN_DIFF(x,y) XFS_LSN_DIFF_ARCH(x,y,ARCH_NOCONVERT)
78 * Macros, structures, prototypes for interface to the log manager.
82 * Flags to xfs_log_mount
84 #define XFS_LOG_RECOVER 0x1
87 * Flags to xfs_log_done()
89 #define XFS_LOG_REL_PERM_RESERV 0x1
93 * Flags to xfs_log_reserve()
95 * XFS_LOG_SLEEP: If space is not available, sleep (default)
96 * XFS_LOG_NOSLEEP: If space is not available, return error
97 * XFS_LOG_PERM_RESERV: Permanent reservation. When writes are
98 * performed against this type of reservation, the reservation
99 * is not decreased. Long running transactions should use this.
101 #define XFS_LOG_SLEEP 0x0
102 #define XFS_LOG_NOSLEEP 0x1
103 #define XFS_LOG_PERM_RESERV 0x2
104 #define XFS_LOG_RESV_ALL (XFS_LOG_NOSLEEP|XFS_LOG_PERM_RESERV)
108 * Flags to xfs_log_force()
110 * XFS_LOG_SYNC: Synchronous force in-core log to disk
111 * XFS_LOG_FORCE: Start in-core log write now.
112 * XFS_LOG_URGE: Start write within some window of time.
114 * Note: Either XFS_LOG_FORCE or XFS_LOG_URGE must be set.
116 #define XFS_LOG_SYNC 0x1
117 #define XFS_LOG_FORCE 0x2
118 #define XFS_LOG_URGE 0x4
120 #endif /* __KERNEL__ */
124 #define XFS_TRANSACTION 0x69
125 #define XFS_VOLUME 0x2
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 */
133 typedef void* xfs_log_ticket_t;
136 * Structure used to pass callback function and the function's argument
137 * to the log manager.
139 typedef struct xfs_log_callback {
140 struct xfs_log_callback *cb_next;
141 void (*cb_func)(void *, int);
143 } xfs_log_callback_t;
147 /* Log manager interfaces */
149 xfs_lsn_t xfs_log_done(struct xfs_mount *mp,
150 xfs_log_ticket_t ticket,
153 int xfs_log_force(struct xfs_mount *mp,
156 int xfs_log_mount(struct xfs_mount *mp,
157 struct xfs_buftarg *log_target,
158 xfs_daddr_t start_block,
160 int xfs_log_mount_finish(struct xfs_mount *mp, int);
161 void xfs_log_move_tail(struct xfs_mount *mp,
163 int xfs_log_notify(struct xfs_mount *mp,
165 xfs_log_callback_t *callback_entry);
166 int xfs_log_release_iclog(struct xfs_mount *mp,
168 int xfs_log_reserve(struct xfs_mount *mp,
171 xfs_log_ticket_t *ticket,
174 int xfs_log_write(struct xfs_mount *mp,
175 xfs_log_iovec_t region[],
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);
185 void xlog_iodone(struct xfs_buf *);
190 extern int xlog_debug; /* set to 1 to enable real log */
193 #endif /* __XFS_LOG_H__ */