blob: 8f602dcb51fab6ea2ef8bb72582cbd50c822a196 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 *
Dave Kleikampf720e3b2007-06-06 15:28:35 -050024 * basic type/utility definitions
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 *
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070033/*
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 */
39typedef u16 tid_t;
40typedef u16 lid_t;
41
42/*
43 * Almost identical to Linux's timespec, but not quite
44 */
45struct timestruc_t {
46 __le32 tv_sec;
47 __le32 tv_nsec;
48};
49
50/*
51 * handy
52 */
53
54#define LEFTMOSTONE 0x80000000
Dave Kleikampf720e3b2007-06-06 15:28:35 -050055#define HIGHORDER 0x80000000u /* high order bit on */
56#define ONES 0xffffffffu /* all bit on */
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
Linus Torvalds1da177e2005-04-16 15:20:36 -070058/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 * physical xd (pxd)
Al Viroe1f1fe72014-12-19 06:51:26 +000060 *
61 * The leftmost 24 bits of len_addr are the extent length.
62 * The rightmost 8 bits of len_addr are the most signficant bits of
63 * the extent address
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 */
65typedef struct {
Al Viroe1f1fe72014-12-19 06:51:26 +000066 __le32 len_addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 __le32 addr2;
68} pxd_t;
69
70/* xd_t field construction */
71
Al Viroe1f1fe72014-12-19 06:51:26 +000072static inline void PXDlength(pxd_t *pxd, __u32 len)
73{
74 pxd->len_addr = (pxd->len_addr & cpu_to_le32(~0xffffff)) |
75 cpu_to_le32(len & 0xffffff);
76}
77
78static inline void PXDaddress(pxd_t *pxd, __u64 addr)
79{
80 pxd->len_addr = (pxd->len_addr & cpu_to_le32(0xffffff)) |
81 cpu_to_le32((addr >> 32)<<24);
82 pxd->addr2 = cpu_to_le32(addr & 0xffffffff);
Linus Torvalds1da177e2005-04-16 15:20:36 -070083}
84
85/* xd_t field extraction */
Al Viroe1f1fe72014-12-19 06:51:26 +000086static inline __u32 lengthPXD(pxd_t *pxd)
87{
88 return le32_to_cpu((pxd)->len_addr) & 0xffffff;
89}
90
91static inline __u64 addressPXD(pxd_t *pxd)
92{
93 __u64 n = le32_to_cpu(pxd->len_addr) & ~0xffffff;
94 return (n << 8) + le32_to_cpu(pxd->addr2);
95}
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
97#define MAXTREEHEIGHT 8
98/* pxd list */
99struct pxdlist {
100 s16 maxnpxd;
101 s16 npxd;
102 pxd_t pxd[MAXTREEHEIGHT];
103};
104
105
106/*
107 * data extent descriptor (dxd)
108 */
109typedef struct {
Al Viroe1f1fe72014-12-19 06:51:26 +0000110 __u8 flag; /* 1: flags */
111 __u8 rsrvd[3];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 __le32 size; /* 4: size in byte */
Al Viroe1f1fe72014-12-19 06:51:26 +0000113 pxd_t loc; /* 8: address and length in unit of fsblksize */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114} dxd_t; /* - 16 - */
115
116/* dxd_t flags */
117#define DXD_INDEX 0x80 /* B+-tree index */
118#define DXD_INLINE 0x40 /* in-line data extent */
119#define DXD_EXTENT 0x20 /* out-of-line single extent */
120#define DXD_FILE 0x10 /* out-of-line file (inode) */
121#define DXD_CORRUPT 0x08 /* Inconsistency detected */
122
123/* dxd_t field construction
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 */
Al Viroe1f1fe72014-12-19 06:51:26 +0000125#define DXDlength(dxd, len) PXDlength(&(dxd)->loc, len)
126#define DXDaddress(dxd, addr) PXDaddress(&(dxd)->loc, addr)
127#define lengthDXD(dxd) lengthPXD(&(dxd)->loc)
128#define addressDXD(dxd) addressPXD(&(dxd)->loc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129#define DXDsize(dxd, size32) ((dxd)->size = cpu_to_le32(size32))
130#define sizeDXD(dxd) le32_to_cpu((dxd)->size)
131
132/*
Dave Kleikampf720e3b2007-06-06 15:28:35 -0500133 * directory entry argument
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 */
135struct component_name {
136 int namlen;
137 wchar_t *name;
138};
139
140
141/*
142 * DASD limit information - stored in directory inode
143 */
144struct dasd {
Dave Kleikampf720e3b2007-06-06 15:28:35 -0500145 u8 thresh; /* Alert Threshold (in percent) */
146 u8 delta; /* Alert Threshold delta (in percent) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 u8 rsrvd1;
Dave Kleikampf720e3b2007-06-06 15:28:35 -0500148 u8 limit_hi; /* DASD limit (in logical blocks) */
149 __le32 limit_lo; /* DASD limit (in logical blocks) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 u8 rsrvd2[3];
Dave Kleikampf720e3b2007-06-06 15:28:35 -0500151 u8 used_hi; /* DASD usage (in logical blocks) */
152 __le32 used_lo; /* DASD usage (in logical blocks) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153};
154
155#define DASDLIMIT(dasdp) \
156 (((u64)((dasdp)->limit_hi) << 32) + __le32_to_cpu((dasdp)->limit_lo))
157#define setDASDLIMIT(dasdp, limit)\
158{\
159 (dasdp)->limit_hi = ((u64)limit) >> 32;\
160 (dasdp)->limit_lo = __cpu_to_le32(limit);\
161}
162#define DASDUSED(dasdp) \
163 (((u64)((dasdp)->used_hi) << 32) + __le32_to_cpu((dasdp)->used_lo))
164#define setDASDUSED(dasdp, used)\
165{\
166 (dasdp)->used_hi = ((u64)used) >> 32;\
167 (dasdp)->used_lo = __cpu_to_le32(used);\
168}
169
170#endif /* !_H_JFS_TYPES */