Linux-2.6.12-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / fs / xfs / xfs_log.h
blob0db122ddda3f3f1322ed27bf498c620cdaaf05cb
1 /*
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:
26 * http://www.sgi.com
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
32 #ifndef __XFS_LOG_H__
33 #define __XFS_LOG_H__
35 /* get lsn fields */
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])
42 #ifdef __KERNEL__
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
47 static
48 #if defined(__GNUC__) && (__GNUC__ == 2) && ( (__GNUC_MINOR__ == 95) || (__GNUC_MINOR__ == 96))
49 __attribute__((unused)) /* gcc 2.95, 2.96 miscompile this when inlined */
50 #else
51 __inline__
52 #endif
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;
61 return 0;
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__ */
112 /* Log Clients */
113 #define XFS_TRANSACTION 0x69
114 #define XFS_VOLUME 0x2
115 #define XFS_LOG 0xaa
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 */
120 } xfs_log_iovec_t;
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);
131 void *cb_arg;
132 } xfs_log_callback_t;
135 #ifdef __KERNEL__
136 /* Log manager interfaces */
137 struct xfs_mount;
138 xfs_lsn_t xfs_log_done(struct xfs_mount *mp,
139 xfs_log_ticket_t ticket,
140 void **iclog,
141 uint flags);
142 int xfs_log_force(struct xfs_mount *mp,
143 xfs_lsn_t lsn,
144 uint flags);
145 int xfs_log_mount(struct xfs_mount *mp,
146 struct xfs_buftarg *log_target,
147 xfs_daddr_t start_block,
148 int num_bblocks);
149 int xfs_log_mount_finish(struct xfs_mount *mp, int);
150 void xfs_log_move_tail(struct xfs_mount *mp,
151 xfs_lsn_t tail_lsn);
152 int xfs_log_notify(struct xfs_mount *mp,
153 void *iclog,
154 xfs_log_callback_t *callback_entry);
155 int xfs_log_release_iclog(struct xfs_mount *mp,
156 void *iclog_hndl);
157 int xfs_log_reserve(struct xfs_mount *mp,
158 int length,
159 int count,
160 xfs_log_ticket_t *ticket,
161 __uint8_t clientid,
162 uint flags);
163 int xfs_log_write(struct xfs_mount *mp,
164 xfs_log_iovec_t region[],
165 int nentries,
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 *);
176 #endif
179 extern int xlog_debug; /* set to 1 to enable real log */
182 #endif /* __XFS_LOG_H__ */