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
117 typedef struct xfs_log_iovec
{
118 xfs_caddr_t i_addr
; /* beginning address of region */
119 int i_len
; /* length in bytes of region */
122 typedef void* xfs_log_ticket_t
;
125 * Structure used to pass callback function and the function's argument
126 * to the log manager.
128 typedef struct xfs_log_callback
{
129 struct xfs_log_callback
*cb_next
;
130 void (*cb_func
)(void *, int);
132 } xfs_log_callback_t
;
136 /* Log manager interfaces */
138 xfs_lsn_t
xfs_log_done(struct xfs_mount
*mp
,
139 xfs_log_ticket_t ticket
,
142 int xfs_log_force(struct xfs_mount
*mp
,
145 int xfs_log_mount(struct xfs_mount
*mp
,
146 struct xfs_buftarg
*log_target
,
147 xfs_daddr_t start_block
,
149 int xfs_log_mount_finish(struct xfs_mount
*mp
, int);
150 void xfs_log_move_tail(struct xfs_mount
*mp
,
152 int xfs_log_notify(struct xfs_mount
*mp
,
154 xfs_log_callback_t
*callback_entry
);
155 int xfs_log_release_iclog(struct xfs_mount
*mp
,
157 int xfs_log_reserve(struct xfs_mount
*mp
,
160 xfs_log_ticket_t
*ticket
,
163 int xfs_log_write(struct xfs_mount
*mp
,
164 xfs_log_iovec_t region
[],
166 xfs_log_ticket_t ticket
,
167 xfs_lsn_t
*start_lsn
);
168 int xfs_log_unmount(struct xfs_mount
*mp
);
169 int xfs_log_unmount_write(struct xfs_mount
*mp
);
170 void xfs_log_unmount_dealloc(struct xfs_mount
*mp
);
171 int xfs_log_force_umount(struct xfs_mount
*mp
, int logerror
);
172 int xfs_log_need_covered(struct xfs_mount
*mp
);
174 void xlog_iodone(struct xfs_buf
*);
179 extern int xlog_debug
; /* set to 1 to enable real log */
182 #endif /* __XFS_LOG_H__ */