[PATCH] Sun HME: enable and map PCI ROM properly
[pandora-kernel.git] / fs / xfs / xfs_log.h
1 /*
2  * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
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 /* get lsn fields */
36
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])
41
42 #ifdef __KERNEL__
43 /*
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
46  */
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)
54 {
55         if (CYCLE_LSN(lsn1) != CYCLE_LSN(lsn2))
56                 return (CYCLE_LSN(lsn1)<CYCLE_LSN(lsn2))? -999 : 999;
57
58         if (BLOCK_LSN(lsn1) != BLOCK_LSN(lsn2))
59                 return (BLOCK_LSN(lsn1)<BLOCK_LSN(lsn2))? -999 : 999;
60
61         return 0;
62 }
63
64 #define XFS_LSN_CMP(x,y) _lsn_cmp(x,y)
65
66 /*
67  * Macros, structures, prototypes for interface to the log manager.
68  */
69
70 /*
71  * Flags to xfs_log_mount
72  */
73 #define XFS_LOG_RECOVER         0x1
74
75 /*
76  * Flags to xfs_log_done()
77  */
78 #define XFS_LOG_REL_PERM_RESERV 0x1
79
80
81 /*
82  * Flags to xfs_log_reserve()
83  *
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.
89  */
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)
94
95
96 /*
97  * Flags to xfs_log_force()
98  *
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.
102  *
103  * Note: Either XFS_LOG_FORCE or XFS_LOG_URGE must be set.
104  */
105 #define XFS_LOG_SYNC            0x1
106 #define XFS_LOG_FORCE           0x2
107 #define XFS_LOG_URGE            0x4
108
109 #endif  /* __KERNEL__ */
110
111
112 /* Log Clients */
113 #define XFS_TRANSACTION         0x69
114 #define XFS_VOLUME              0x2
115 #define XFS_LOG                 0xaa
116
117
118 /* Region types for iovec's i_type */
119 #if defined(XFS_LOG_RES_DEBUG)
120 #define XLOG_REG_TYPE_BFORMAT           1
121 #define XLOG_REG_TYPE_BCHUNK            2
122 #define XLOG_REG_TYPE_EFI_FORMAT        3
123 #define XLOG_REG_TYPE_EFD_FORMAT        4
124 #define XLOG_REG_TYPE_IFORMAT           5
125 #define XLOG_REG_TYPE_ICORE             6
126 #define XLOG_REG_TYPE_IEXT              7
127 #define XLOG_REG_TYPE_IBROOT            8
128 #define XLOG_REG_TYPE_ILOCAL            9
129 #define XLOG_REG_TYPE_IATTR_EXT         10
130 #define XLOG_REG_TYPE_IATTR_BROOT       11
131 #define XLOG_REG_TYPE_IATTR_LOCAL       12
132 #define XLOG_REG_TYPE_QFORMAT           13
133 #define XLOG_REG_TYPE_DQUOT             14
134 #define XLOG_REG_TYPE_QUOTAOFF          15
135 #define XLOG_REG_TYPE_LRHEADER          16
136 #define XLOG_REG_TYPE_UNMOUNT           17
137 #define XLOG_REG_TYPE_COMMIT            18
138 #define XLOG_REG_TYPE_TRANSHDR          19
139 #define XLOG_REG_TYPE_MAX               19
140 #endif
141
142 #if defined(XFS_LOG_RES_DEBUG)
143 #define XLOG_VEC_SET_TYPE(vecp, t) ((vecp)->i_type = (t))
144 #else
145 #define XLOG_VEC_SET_TYPE(vecp, t)
146 #endif
147
148
149 typedef struct xfs_log_iovec {
150         xfs_caddr_t             i_addr;         /* beginning address of region */
151         int             i_len;          /* length in bytes of region */
152 #if defined(XFS_LOG_RES_DEBUG)
153         uint            i_type;         /* type of region */
154 #endif
155 } xfs_log_iovec_t;
156
157 typedef void* xfs_log_ticket_t;
158
159 /*
160  * Structure used to pass callback function and the function's argument
161  * to the log manager.
162  */
163 typedef struct xfs_log_callback {
164         struct xfs_log_callback *cb_next;
165         void                    (*cb_func)(void *, int);
166         void                    *cb_arg;
167 } xfs_log_callback_t;
168
169
170 #ifdef __KERNEL__
171 /* Log manager interfaces */
172 struct xfs_mount;
173 xfs_lsn_t xfs_log_done(struct xfs_mount *mp,
174                        xfs_log_ticket_t ticket,
175                        void             **iclog,
176                        uint             flags);
177 int       xfs_log_force(struct xfs_mount *mp,
178                         xfs_lsn_t        lsn,
179                         uint             flags);
180 int       xfs_log_mount(struct xfs_mount        *mp,
181                         struct xfs_buftarg      *log_target,
182                         xfs_daddr_t             start_block,
183                         int                     num_bblocks);
184 int       xfs_log_mount_finish(struct xfs_mount *mp, int);
185 void      xfs_log_move_tail(struct xfs_mount    *mp,
186                             xfs_lsn_t           tail_lsn);
187 int       xfs_log_notify(struct xfs_mount       *mp,
188                          void                   *iclog,
189                          xfs_log_callback_t     *callback_entry);
190 int       xfs_log_release_iclog(struct xfs_mount *mp,
191                          void                    *iclog_hndl);
192 int       xfs_log_reserve(struct xfs_mount *mp,
193                           int              length,
194                           int              count,
195                           xfs_log_ticket_t *ticket,
196                           __uint8_t        clientid,
197                           uint             flags,
198                           uint             t_type);
199 int       xfs_log_write(struct xfs_mount *mp,
200                         xfs_log_iovec_t  region[],
201                         int              nentries,
202                         xfs_log_ticket_t ticket,
203                         xfs_lsn_t        *start_lsn);
204 int       xfs_log_unmount(struct xfs_mount *mp);
205 int       xfs_log_unmount_write(struct xfs_mount *mp);
206 void      xfs_log_unmount_dealloc(struct xfs_mount *mp);
207 int       xfs_log_force_umount(struct xfs_mount *mp, int logerror);
208 int       xfs_log_need_covered(struct xfs_mount *mp);
209
210 void      xlog_iodone(struct xfs_buf *);
211
212 #endif
213
214
215 extern int xlog_debug;          /* set to 1 to enable real log */
216
217
218 #endif  /* __XFS_LOG_H__ */