more changes on original files
[linux-2.4.git] / fs / jfs / jfs_types.h
1 /*
2  *   Copyright (C) International Business Machines Corp., 2000-2004
3  *
4  *   This program is free software;  you can redistribute it and/or modify
5  *   it under the terms of the GNU General Public License as published by
6  *   the Free Software Foundation; either version 2 of the License, or
7  *   (at your option) any later version.
8  *
9  *   This program is distributed in the hope that it will be useful,
10  *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
12  *   the GNU General Public License for more details.
13  *
14  *   You should have received a copy of the GNU General Public License
15  *   along with this program;  if not, write to the Free Software
16  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */
18 #ifndef _H_JFS_TYPES
19 #define _H_JFS_TYPES
20
21 /*
22  *      jfs_types.h:
23  *
24  * basic type/utility  definitions
25  *
26  * note: this header file must be the 1st include file
27  * of JFS include list in all JFS .c file.
28  */
29
30 #include <linux/types.h>
31 #include <linux/nls.h>
32
33 /*
34  * transaction and lock id's
35  *
36  * Don't change these without carefully considering the impact on the
37  * size and alignment of all of the linelock variants
38  */
39 typedef u16 tid_t;
40 typedef u16 lid_t;
41
42 /*
43  * Almost identical to Linux's timespec, but not quite
44  */
45 struct timestruc_t {
46         u32 tv_sec;
47         u32 tv_nsec;
48 };
49
50 /*
51  *      handy
52  */
53
54 #define LEFTMOSTONE     0x80000000
55 #define HIGHORDER       0x80000000u     /* high order bit on            */
56 #define ONES            0xffffffffu     /* all bit on                   */
57
58 typedef int boolean_t;
59 #define TRUE 1
60 #define FALSE 0
61
62 /*
63  *      logical xd (lxd)
64  */
65 typedef struct {
66         unsigned len:24;
67         unsigned off1:8;
68         u32 off2;
69 } lxd_t;
70
71 /* lxd_t field construction */
72 #define LXDlength(lxd, length32)        ( (lxd)->len = length32 )
73 #define LXDoffset(lxd, offset64)\
74 {\
75         (lxd)->off1 = ((s64)offset64) >> 32;\
76         (lxd)->off2 = (offset64) & 0xffffffff;\
77 }
78
79 /* lxd_t field extraction */
80 #define lengthLXD(lxd)  ( (lxd)->len )
81 #define offsetLXD(lxd)\
82         ( ((s64)((lxd)->off1)) << 32 | (lxd)->off2 )
83
84 /* lxd list */
85 struct lxdlist {
86         s16 maxnlxd;
87         s16 nlxd;
88         lxd_t *lxd;
89 };
90
91 /*
92  *      physical xd (pxd)
93  */
94 typedef struct {
95         unsigned len:24;
96         unsigned addr1:8;
97         u32 addr2;
98 } pxd_t;
99
100 /* xd_t field construction */
101
102 #define PXDlength(pxd, length32)        ((pxd)->len = __cpu_to_le24(length32))
103 #define PXDaddress(pxd, address64)\
104 {\
105         (pxd)->addr1 = ((s64)address64) >> 32;\
106         (pxd)->addr2 = __cpu_to_le32((address64) & 0xffffffff);\
107 }
108
109 /* xd_t field extraction */
110 #define lengthPXD(pxd)  __le24_to_cpu((pxd)->len)
111 #define addressPXD(pxd)\
112         ( ((s64)((pxd)->addr1)) << 32 | __le32_to_cpu((pxd)->addr2))
113
114 #define MAXTREEHEIGHT 8
115 /* pxd list */
116 struct pxdlist {
117         s16 maxnpxd;
118         s16 npxd;
119         pxd_t pxd[MAXTREEHEIGHT];
120 };
121
122
123 /*
124  *      data extent descriptor (dxd)
125  */
126 typedef struct {
127         unsigned flag:8;        /* 1: flags */
128         unsigned rsrvd:24;      /* 3: */
129         u32 size;               /* 4: size in byte */
130         unsigned len:24;        /* 3: length in unit of fsblksize */
131         unsigned addr1:8;       /* 1: address in unit of fsblksize */
132         u32 addr2;              /* 4: address in unit of fsblksize */
133 } dxd_t;                        /* - 16 - */
134
135 /* dxd_t flags */
136 #define DXD_INDEX       0x80    /* B+-tree index */
137 #define DXD_INLINE      0x40    /* in-line data extent */
138 #define DXD_EXTENT      0x20    /* out-of-line single extent */
139 #define DXD_FILE        0x10    /* out-of-line file (inode) */
140 #define DXD_CORRUPT     0x08    /* Inconsistency detected */
141
142 /* dxd_t field construction
143  *      Conveniently, the PXD macros work for DXD
144  */
145 #define DXDlength       PXDlength
146 #define DXDaddress      PXDaddress
147 #define lengthDXD       lengthPXD
148 #define addressDXD      addressPXD
149 #define DXDsize(dxd, size32) ((dxd)->size = cpu_to_le32(size32))
150 #define sizeDXD(dxd)    le32_to_cpu((dxd)->size)
151
152 /*
153  *      directory entry argument
154  */
155 struct component_name {
156         int namlen;
157         wchar_t *name;
158 };
159
160
161 /*
162  *      DASD limit information - stored in directory inode
163  */
164 struct dasd {
165         u8 thresh;              /* Alert Threshold (in percent) */
166         u8 delta;               /* Alert Threshold delta (in percent)   */
167         u8 rsrvd1;
168         u8 limit_hi;            /* DASD limit (in logical blocks)       */
169         u32 limit_lo;           /* DASD limit (in logical blocks)       */
170         u8 rsrvd2[3];
171         u8 used_hi;             /* DASD usage (in logical blocks)       */
172         u32 used_lo;            /* DASD usage (in logical blocks)       */
173 };
174
175 #define DASDLIMIT(dasdp) \
176         (((u64)((dasdp)->limit_hi) << 32) + __le32_to_cpu((dasdp)->limit_lo))
177 #define setDASDLIMIT(dasdp, limit)\
178 {\
179         (dasdp)->limit_hi = ((u64)limit) >> 32;\
180         (dasdp)->limit_lo = __cpu_to_le32(limit);\
181 }
182 #define DASDUSED(dasdp) \
183         (((u64)((dasdp)->used_hi) << 32) + __le32_to_cpu((dasdp)->used_lo))
184 #define setDASDUSED(dasdp, used)\
185 {\
186         (dasdp)->used_hi = ((u64)used) >> 32;\
187         (dasdp)->used_lo = __cpu_to_le32(used);\
188 }
189
190 #endif                          /* !_H_JFS_TYPES */