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 #include "endian24.h"
34 
35 /*
36  * transaction and lock id's
37  *
38  * Don't change these without carefully considering the impact on the
39  * size and alignment of all of the linelock variants
40  */
41 typedef u16 tid_t;
42 typedef u16 lid_t;
43 
44 /*
45  * Almost identical to Linux's timespec, but not quite
46  */
47 struct timestruc_t {
48 	__le32 tv_sec;
49 	__le32 tv_nsec;
50 };
51 
52 /*
53  *	handy
54  */
55 
56 #define LEFTMOSTONE	0x80000000
57 #define	HIGHORDER	0x80000000u	/* high order bit on	*/
58 #define	ONES		0xffffffffu	/* all bit on		*/
59 
60 /*
61  *	physical xd (pxd)
62  */
63 typedef struct {
64 	unsigned len:24;
65 	unsigned addr1:8;
66 	__le32 addr2;
67 } pxd_t;
68 
69 /* xd_t field construction */
70 
71 #define	PXDlength(pxd, length32)	((pxd)->len = __cpu_to_le24(length32))
72 #define	PXDaddress(pxd, address64)\
73 {\
74 	(pxd)->addr1 = ((s64)address64) >> 32;\
75 	(pxd)->addr2 = __cpu_to_le32((address64) & 0xffffffff);\
76 }
77 
78 /* xd_t field extraction */
79 #define	lengthPXD(pxd)	__le24_to_cpu((pxd)->len)
80 #define	addressPXD(pxd)\
81 	( ((s64)((pxd)->addr1)) << 32 | __le32_to_cpu((pxd)->addr2))
82 
83 #define MAXTREEHEIGHT 8
84 /* pxd list */
85 struct pxdlist {
86 	s16 maxnpxd;
87 	s16 npxd;
88 	pxd_t pxd[MAXTREEHEIGHT];
89 };
90 
91 
92 /*
93  *	data extent descriptor (dxd)
94  */
95 typedef struct {
96 	unsigned flag:8;	/* 1: flags */
97 	unsigned rsrvd:24;
98 	__le32 size;		/* 4: size in byte */
99 	unsigned len:24;	/* 3: length in unit of fsblksize */
100 	unsigned addr1:8;	/* 1: address in unit of fsblksize */
101 	__le32 addr2;		/* 4: address in unit of fsblksize */
102 } dxd_t;			/* - 16 - */
103 
104 /* dxd_t flags */
105 #define	DXD_INDEX	0x80	/* B+-tree index */
106 #define	DXD_INLINE	0x40	/* in-line data extent */
107 #define	DXD_EXTENT	0x20	/* out-of-line single extent */
108 #define	DXD_FILE	0x10	/* out-of-line file (inode) */
109 #define DXD_CORRUPT	0x08	/* Inconsistency detected */
110 
111 /* dxd_t field construction
112  *	Conveniently, the PXD macros work for DXD
113  */
114 #define	DXDlength	PXDlength
115 #define	DXDaddress	PXDaddress
116 #define	lengthDXD	lengthPXD
117 #define	addressDXD	addressPXD
118 #define DXDsize(dxd, size32) ((dxd)->size = cpu_to_le32(size32))
119 #define sizeDXD(dxd)	le32_to_cpu((dxd)->size)
120 
121 /*
122  *	directory entry argument
123  */
124 struct component_name {
125 	int namlen;
126 	wchar_t *name;
127 };
128 
129 
130 /*
131  *	DASD limit information - stored in directory inode
132  */
133 struct dasd {
134 	u8 thresh;		/* Alert Threshold (in percent)		*/
135 	u8 delta;		/* Alert Threshold delta (in percent)	*/
136 	u8 rsrvd1;
137 	u8 limit_hi;		/* DASD limit (in logical blocks)	*/
138 	__le32 limit_lo;	/* DASD limit (in logical blocks)	*/
139 	u8 rsrvd2[3];
140 	u8 used_hi;		/* DASD usage (in logical blocks)	*/
141 	__le32 used_lo;		/* DASD usage (in logical blocks)	*/
142 };
143 
144 #define DASDLIMIT(dasdp) \
145 	(((u64)((dasdp)->limit_hi) << 32) + __le32_to_cpu((dasdp)->limit_lo))
146 #define setDASDLIMIT(dasdp, limit)\
147 {\
148 	(dasdp)->limit_hi = ((u64)limit) >> 32;\
149 	(dasdp)->limit_lo = __cpu_to_le32(limit);\
150 }
151 #define DASDUSED(dasdp) \
152 	(((u64)((dasdp)->used_hi) << 32) + __le32_to_cpu((dasdp)->used_lo))
153 #define setDASDUSED(dasdp, used)\
154 {\
155 	(dasdp)->used_hi = ((u64)used) >> 32;\
156 	(dasdp)->used_lo = __cpu_to_le32(used);\
157 }
158 
159 #endif				/* !_H_JFS_TYPES */
160