]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - include/xfs_log.h
Merge whitespace changes over
[thirdparty/xfsprogs-dev.git] / include / xfs_log.h
CommitLineData
2bd0ea18 1/*
0d3e0b37 2 * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
5000d01d 3 *
2bd0ea18
NS
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.
5000d01d 7 *
2bd0ea18
NS
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.
5000d01d 11 *
2bd0ea18
NS
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
dfc130f3 14 * or the like. Any license provided herein, whether implied or
2bd0ea18
NS
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.
5000d01d 18 *
2bd0ea18
NS
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.
5000d01d 22 *
2bd0ea18
NS
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
5000d01d
SL
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
2bd0ea18
NS
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */
dfc130f3 32#ifndef __XFS_LOG_H__
2bd0ea18
NS
33#define __XFS_LOG_H__
34
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)
38#else
39#define LSN_FIELD_CYCLE(arch) (0)
40#define LSN_FIELD_BLOCK(arch) (1)
41#endif
42
43/* get lsn fields */
5000d01d 44
2bd0ea18
NS
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))
5ce1d1f7
NS
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)])
2bd0ea18
NS
49
50#ifdef __KERNEL__
51/*
86d19f75 52 * By comparing each compnent, we don't have to worry about extra
2bd0ea18
NS
53 * endian issues in treating two 32 bit numbers as one 64 bit number
54 */
86d19f75 55static
4ca431fc
NS
56#if defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ == 95)
57__attribute__((unused)) /* gcc 2.95 miscompiles this when inlined */
58#else
86d19f75
NS
59__inline__
60#endif
8f9fbdf3 61xfs_lsn_t _lsn_cmp(xfs_lsn_t lsn1, xfs_lsn_t lsn2, xfs_arch_t arch)
2bd0ea18
NS
62{
63 if (CYCLE_LSN(lsn1, arch) != CYCLE_LSN(lsn2, arch))
64 return (CYCLE_LSN(lsn1, arch)<CYCLE_LSN(lsn2, arch))? -999 : 999;
65
5000d01d
SL
66 if (BLOCK_LSN(lsn1, arch) != BLOCK_LSN(lsn2, arch))
67 return (BLOCK_LSN(lsn1, arch)<BLOCK_LSN(lsn2, arch))? -999 : 999;
68
69 return 0;
2bd0ea18
NS
70}
71
dfc130f3
RC
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)
2bd0ea18
NS
76
77/*
78 * Macros, structures, prototypes for interface to the log manager.
79 */
80
81/*
82 * Flags to xfs_log_mount
83 */
84#define XFS_LOG_RECOVER 0x1
85
86/*
87 * Flags to xfs_log_done()
88 */
dfc130f3 89#define XFS_LOG_REL_PERM_RESERV 0x1
2bd0ea18
NS
90
91
92/*
93 * Flags to xfs_log_reserve()
94 *
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.
100 */
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)
105
106
107/*
108 * Flags to xfs_log_force()
109 *
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.
113 *
114 * Note: Either XFS_LOG_FORCE or XFS_LOG_URGE must be set.
115 */
116#define XFS_LOG_SYNC 0x1
117#define XFS_LOG_FORCE 0x2
118#define XFS_LOG_URGE 0x4
119
120#endif /* __KERNEL__ */
121
122
123/* Log Clients */
124#define XFS_TRANSACTION 0x69
125#define XFS_VOLUME 0x2
126#define XFS_LOG 0xaa
127
128typedef struct xfs_log_iovec {
129 xfs_caddr_t i_addr; /* beginning address of region */
130 int i_len; /* length in bytes of region */
131} xfs_log_iovec_t;
132
133typedef void* xfs_log_ticket_t;
134
135/*
136 * Structure used to pass callback function and the function's argument
137 * to the log manager.
138 */
139typedef struct xfs_log_callback {
dfc130f3 140 struct xfs_log_callback *cb_next;
2bd0ea18 141 void (*cb_func)(void *, int);
5000d01d 142 void *cb_arg;
2bd0ea18
NS
143} xfs_log_callback_t;
144
145
146#ifdef __KERNEL__
147/* Log manager interfaces */
148struct xfs_mount;
149xfs_lsn_t xfs_log_done(struct xfs_mount *mp,
150 xfs_log_ticket_t ticket,
5b5df80a 151 void **iclog,
2bd0ea18
NS
152 uint flags);
153int xfs_log_force(struct xfs_mount *mp,
154 xfs_lsn_t lsn,
155 uint flags);
156int xfs_log_init(void);
157int xfs_log_mount(struct xfs_mount *mp,
158 dev_t log_dev,
159 xfs_daddr_t start_block,
160 int num_bblocks);
161int xfs_log_mount_finish(struct xfs_mount *mp, int);
162void xfs_log_move_tail(struct xfs_mount *mp,
163 xfs_lsn_t tail_lsn);
5b5df80a
NS
164int xfs_log_notify(struct xfs_mount *mp,
165 void *iclog,
2bd0ea18 166 xfs_log_callback_t *callback_entry);
5b5df80a
NS
167int xfs_log_release_iclog(struct xfs_mount *mp,
168 void *iclog_hndl);
2bd0ea18
NS
169int xfs_log_reserve(struct xfs_mount *mp,
170 int length,
171 int count,
172 xfs_log_ticket_t *ticket,
a7565da0 173 __uint8_t clientid,
2bd0ea18
NS
174 uint flags);
175int xfs_log_write(struct xfs_mount *mp,
dfc130f3 176 xfs_log_iovec_t region[],
2bd0ea18
NS
177 int nentries,
178 xfs_log_ticket_t ticket,
179 xfs_lsn_t *start_lsn);
180int xfs_log_unmount(struct xfs_mount *mp);
181int xfs_log_unmount_write(struct xfs_mount *mp);
dfc130f3 182void xfs_log_unmount_dealloc(struct xfs_mount *mp);
2bd0ea18
NS
183int xfs_log_force_umount(struct xfs_mount *mp, int logerror);
184int xfs_log_need_covered(struct xfs_mount *mp);
185
186void xlog_iodone(struct xfs_buf *);
187
188#endif
189
190
191extern int xlog_debug; /* set to 1 to enable real log */
192
193
194#endif /* __XFS_LOG_H__ */