]>
Commit | Line | Data |
---|---|---|
2bd0ea18 | 1 | /* |
cc08d43e | 2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. |
2bd0ea18 NS |
3 | * |
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. | |
7 | * | |
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. | |
11 | * | |
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. | |
18 | * | |
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. | |
22 | * | |
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | |
24 | * Mountain View, CA 94043, or: | |
25 | * | |
26 | * http://www.sgi.com | |
27 | * | |
28 | * For further information regarding this notice, see: | |
29 | * | |
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | |
31 | */ | |
32 | #ifndef __XFS_LOG_H__ | |
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 */ | |
44 | ||
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__ | |
d663096d SL |
51 | #if (__GNUC__ == 2) && (__GNUC_MINOR__ == 95) |
52 | extern xfs_lsn_t _lsn_cmp(xfs_lsn_t, xfs_lsn_t, xfs_arch_t); | |
53 | #define _lsn_cmp _xfs_lsn_cmp | |
54 | #endif | |
55 | ||
2bd0ea18 | 56 | /* |
d663096d | 57 | * By comparing each component, we don't have to worry about extra |
2bd0ea18 NS |
58 | * endian issues in treating two 32 bit numbers as one 64 bit number |
59 | */ | |
d663096d | 60 | static inline |
8f9fbdf3 | 61 | xfs_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 | ||
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; | |
70 | } | |
71 | ||
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) | |
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 | */ | |
89 | #define XFS_LOG_REL_PERM_RESERV 0x1 | |
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 | ||
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 */ | |
131 | } xfs_log_iovec_t; | |
132 | ||
133 | typedef 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 | */ | |
139 | typedef struct xfs_log_callback { | |
140 | struct xfs_log_callback *cb_next; | |
141 | void (*cb_func)(void *, int); | |
142 | void *cb_arg; | |
143 | } xfs_log_callback_t; | |
144 | ||
145 | ||
146 | #ifdef __KERNEL__ | |
147 | /* Log manager interfaces */ | |
148 | struct xfs_mount; | |
149 | xfs_lsn_t xfs_log_done(struct xfs_mount *mp, | |
150 | xfs_log_ticket_t ticket, | |
151 | uint flags); | |
152 | int xfs_log_force(struct xfs_mount *mp, | |
153 | xfs_lsn_t lsn, | |
154 | uint flags); | |
155 | int xfs_log_init(void); | |
156 | int xfs_log_mount(struct xfs_mount *mp, | |
157 | dev_t log_dev, | |
158 | xfs_daddr_t start_block, | |
159 | int num_bblocks); | |
160 | int xfs_log_mount_finish(struct xfs_mount *mp, int); | |
161 | void xfs_log_move_tail(struct xfs_mount *mp, | |
162 | xfs_lsn_t tail_lsn); | |
163 | void xfs_log_notify(struct xfs_mount *mp, | |
164 | xfs_lsn_t lsn, | |
165 | xfs_log_callback_t *callback_entry); | |
166 | int xfs_log_reserve(struct xfs_mount *mp, | |
167 | int length, | |
168 | int count, | |
169 | xfs_log_ticket_t *ticket, | |
a7565da0 | 170 | __uint8_t clientid, |
2bd0ea18 NS |
171 | uint flags); |
172 | int xfs_log_write(struct xfs_mount *mp, | |
173 | xfs_log_iovec_t region[], | |
174 | int nentries, | |
175 | xfs_log_ticket_t ticket, | |
176 | xfs_lsn_t *start_lsn); | |
177 | int xfs_log_unmount(struct xfs_mount *mp); | |
178 | int xfs_log_unmount_write(struct xfs_mount *mp); | |
179 | void xfs_log_unmount_dealloc(struct xfs_mount *mp); | |
180 | int xfs_log_force_umount(struct xfs_mount *mp, int logerror); | |
181 | int xfs_log_need_covered(struct xfs_mount *mp); | |
182 | ||
183 | void xlog_iodone(struct xfs_buf *); | |
184 | ||
185 | #endif | |
186 | ||
187 | ||
188 | extern int xlog_debug; /* set to 1 to enable real log */ | |
189 | ||
190 | ||
191 | #endif /* __XFS_LOG_H__ */ |