Thomas Gleixner | 1a59d1b8 | 2019-05-27 08:55:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) International Business Machines Corp., 2000-2004 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | */ |
| 5 | #ifndef _H_JFS_TYPES |
| 6 | #define _H_JFS_TYPES |
| 7 | |
| 8 | /* |
| 9 | * jfs_types.h: |
| 10 | * |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 11 | * basic type/utility definitions |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | * |
| 13 | * note: this header file must be the 1st include file |
| 14 | * of JFS include list in all JFS .c file. |
| 15 | */ |
| 16 | |
| 17 | #include <linux/types.h> |
| 18 | #include <linux/nls.h> |
| 19 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | /* |
| 21 | * transaction and lock id's |
| 22 | * |
| 23 | * Don't change these without carefully considering the impact on the |
| 24 | * size and alignment of all of the linelock variants |
| 25 | */ |
| 26 | typedef u16 tid_t; |
| 27 | typedef u16 lid_t; |
| 28 | |
| 29 | /* |
| 30 | * Almost identical to Linux's timespec, but not quite |
| 31 | */ |
| 32 | struct timestruc_t { |
| 33 | __le32 tv_sec; |
| 34 | __le32 tv_nsec; |
| 35 | }; |
| 36 | |
| 37 | /* |
| 38 | * handy |
| 39 | */ |
| 40 | |
| 41 | #define LEFTMOSTONE 0x80000000 |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 42 | #define HIGHORDER 0x80000000u /* high order bit on */ |
| 43 | #define ONES 0xffffffffu /* all bit on */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | * physical xd (pxd) |
Al Viro | e1f1fe7 | 2014-12-19 06:51:26 +0000 | [diff] [blame] | 47 | * |
| 48 | * The leftmost 24 bits of len_addr are the extent length. |
| 49 | * The rightmost 8 bits of len_addr are the most signficant bits of |
| 50 | * the extent address |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | */ |
| 52 | typedef struct { |
Al Viro | e1f1fe7 | 2014-12-19 06:51:26 +0000 | [diff] [blame] | 53 | __le32 len_addr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | __le32 addr2; |
| 55 | } pxd_t; |
| 56 | |
| 57 | /* xd_t field construction */ |
| 58 | |
Al Viro | e1f1fe7 | 2014-12-19 06:51:26 +0000 | [diff] [blame] | 59 | static inline void PXDlength(pxd_t *pxd, __u32 len) |
| 60 | { |
| 61 | pxd->len_addr = (pxd->len_addr & cpu_to_le32(~0xffffff)) | |
| 62 | cpu_to_le32(len & 0xffffff); |
| 63 | } |
| 64 | |
| 65 | static inline void PXDaddress(pxd_t *pxd, __u64 addr) |
| 66 | { |
| 67 | pxd->len_addr = (pxd->len_addr & cpu_to_le32(0xffffff)) | |
| 68 | cpu_to_le32((addr >> 32)<<24); |
| 69 | pxd->addr2 = cpu_to_le32(addr & 0xffffffff); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | /* xd_t field extraction */ |
Al Viro | e1f1fe7 | 2014-12-19 06:51:26 +0000 | [diff] [blame] | 73 | static inline __u32 lengthPXD(pxd_t *pxd) |
| 74 | { |
| 75 | return le32_to_cpu((pxd)->len_addr) & 0xffffff; |
| 76 | } |
| 77 | |
| 78 | static inline __u64 addressPXD(pxd_t *pxd) |
| 79 | { |
| 80 | __u64 n = le32_to_cpu(pxd->len_addr) & ~0xffffff; |
| 81 | return (n << 8) + le32_to_cpu(pxd->addr2); |
| 82 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | |
| 84 | #define MAXTREEHEIGHT 8 |
| 85 | /* pxd list */ |
| 86 | struct pxdlist { |
| 87 | s16 maxnpxd; |
| 88 | s16 npxd; |
| 89 | pxd_t pxd[MAXTREEHEIGHT]; |
| 90 | }; |
| 91 | |
| 92 | |
| 93 | /* |
| 94 | * data extent descriptor (dxd) |
| 95 | */ |
| 96 | typedef struct { |
Al Viro | e1f1fe7 | 2014-12-19 06:51:26 +0000 | [diff] [blame] | 97 | __u8 flag; /* 1: flags */ |
| 98 | __u8 rsrvd[3]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | __le32 size; /* 4: size in byte */ |
Al Viro | e1f1fe7 | 2014-12-19 06:51:26 +0000 | [diff] [blame] | 100 | pxd_t loc; /* 8: address and length in unit of fsblksize */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | } dxd_t; /* - 16 - */ |
| 102 | |
| 103 | /* dxd_t flags */ |
| 104 | #define DXD_INDEX 0x80 /* B+-tree index */ |
| 105 | #define DXD_INLINE 0x40 /* in-line data extent */ |
| 106 | #define DXD_EXTENT 0x20 /* out-of-line single extent */ |
| 107 | #define DXD_FILE 0x10 /* out-of-line file (inode) */ |
| 108 | #define DXD_CORRUPT 0x08 /* Inconsistency detected */ |
| 109 | |
| 110 | /* dxd_t field construction |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | */ |
Al Viro | e1f1fe7 | 2014-12-19 06:51:26 +0000 | [diff] [blame] | 112 | #define DXDlength(dxd, len) PXDlength(&(dxd)->loc, len) |
| 113 | #define DXDaddress(dxd, addr) PXDaddress(&(dxd)->loc, addr) |
| 114 | #define lengthDXD(dxd) lengthPXD(&(dxd)->loc) |
| 115 | #define addressDXD(dxd) addressPXD(&(dxd)->loc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | #define DXDsize(dxd, size32) ((dxd)->size = cpu_to_le32(size32)) |
| 117 | #define sizeDXD(dxd) le32_to_cpu((dxd)->size) |
| 118 | |
| 119 | /* |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 120 | * directory entry argument |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | */ |
| 122 | struct component_name { |
| 123 | int namlen; |
| 124 | wchar_t *name; |
| 125 | }; |
| 126 | |
| 127 | |
| 128 | /* |
| 129 | * DASD limit information - stored in directory inode |
| 130 | */ |
| 131 | struct dasd { |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 132 | u8 thresh; /* Alert Threshold (in percent) */ |
| 133 | u8 delta; /* Alert Threshold delta (in percent) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | u8 rsrvd1; |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 135 | u8 limit_hi; /* DASD limit (in logical blocks) */ |
| 136 | __le32 limit_lo; /* DASD limit (in logical blocks) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | u8 rsrvd2[3]; |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 138 | u8 used_hi; /* DASD usage (in logical blocks) */ |
| 139 | __le32 used_lo; /* DASD usage (in logical blocks) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | }; |
| 141 | |
| 142 | #define DASDLIMIT(dasdp) \ |
| 143 | (((u64)((dasdp)->limit_hi) << 32) + __le32_to_cpu((dasdp)->limit_lo)) |
| 144 | #define setDASDLIMIT(dasdp, limit)\ |
| 145 | {\ |
| 146 | (dasdp)->limit_hi = ((u64)limit) >> 32;\ |
| 147 | (dasdp)->limit_lo = __cpu_to_le32(limit);\ |
| 148 | } |
| 149 | #define DASDUSED(dasdp) \ |
| 150 | (((u64)((dasdp)->used_hi) << 32) + __le32_to_cpu((dasdp)->used_lo)) |
| 151 | #define setDASDUSED(dasdp, used)\ |
| 152 | {\ |
| 153 | (dasdp)->used_hi = ((u64)used) >> 32;\ |
| 154 | (dasdp)->used_lo = __cpu_to_le32(used);\ |
| 155 | } |
| 156 | |
| 157 | #endif /* !_H_JFS_TYPES */ |