diff options
author | Al Viro <viro@ZenIV.linux.org.uk> | 2014-12-19 01:51:26 -0500 |
---|---|---|
committer | Dave Kleikamp <dave.kleikamp@oracle.com> | 2014-12-23 18:01:24 -0500 |
commit | e1f1fe798d2f2eab904624125ba924d08205f960 (patch) | |
tree | 7da293aa0c88034b38b03afeb7e46823a7f87751 /fs/jfs | |
parent | 53262d12d1658669029ab39a63e3d314108abe66 (diff) |
jfs: get rid of homegrown endianness helpers
Get rid of le24 stuff, along with the bitfields use - all that stuff
can be done with standard stuff, in sparse-verifiable manner. Moreover,
that way (shift-and-mask) often generates better code - gcc optimizer
sucks on bitfields...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
----
Diffstat (limited to 'fs/jfs')
-rw-r--r-- | fs/jfs/endian24.h | 49 | ||||
-rw-r--r-- | fs/jfs/jfs_dtree.c | 4 | ||||
-rw-r--r-- | fs/jfs/jfs_types.h | 55 | ||||
-rw-r--r-- | fs/jfs/jfs_xtree.h | 25 |
4 files changed, 44 insertions, 89 deletions
diff --git a/fs/jfs/endian24.h b/fs/jfs/endian24.h deleted file mode 100644 index fa92f7f1d0d0..000000000000 --- a/fs/jfs/endian24.h +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) International Business Machines Corp., 2001 | ||
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_ENDIAN24 | ||
19 | #define _H_ENDIAN24 | ||
20 | |||
21 | /* | ||
22 | * endian24.h: | ||
23 | * | ||
24 | * Endian conversion for 24-byte data | ||
25 | * | ||
26 | */ | ||
27 | #define __swab24(x) \ | ||
28 | ({ \ | ||
29 | __u32 __x = (x); \ | ||
30 | ((__u32)( \ | ||
31 | ((__x & (__u32)0x000000ffUL) << 16) | \ | ||
32 | (__x & (__u32)0x0000ff00UL) | \ | ||
33 | ((__x & (__u32)0x00ff0000UL) >> 16) )); \ | ||
34 | }) | ||
35 | |||
36 | #if (defined(__KERNEL__) && defined(__LITTLE_ENDIAN)) || (defined(__BYTE_ORDER) && (__BYTE_ORDER == __LITTLE_ENDIAN)) | ||
37 | #define __cpu_to_le24(x) ((__u32)(x)) | ||
38 | #define __le24_to_cpu(x) ((__u32)(x)) | ||
39 | #else | ||
40 | #define __cpu_to_le24(x) __swab24(x) | ||
41 | #define __le24_to_cpu(x) __swab24(x) | ||
42 | #endif | ||
43 | |||
44 | #ifdef __KERNEL__ | ||
45 | #define cpu_to_le24 __cpu_to_le24 | ||
46 | #define le24_to_cpu __le24_to_cpu | ||
47 | #endif | ||
48 | |||
49 | #endif /* !_H_ENDIAN24 */ | ||
diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c index 984c2bbf4f61..d88576e23fe4 100644 --- a/fs/jfs/jfs_dtree.c +++ b/fs/jfs/jfs_dtree.c | |||
@@ -1040,8 +1040,8 @@ static int dtSplitUp(tid_t tid, | |||
1040 | pxdlist.maxnpxd = 1; | 1040 | pxdlist.maxnpxd = 1; |
1041 | pxdlist.npxd = 0; | 1041 | pxdlist.npxd = 0; |
1042 | pxd = &pxdlist.pxd[0]; | 1042 | pxd = &pxdlist.pxd[0]; |
1043 | PXDaddress(pxd, nxaddr) | 1043 | PXDaddress(pxd, nxaddr); |
1044 | PXDlength(pxd, xlen + n); | 1044 | PXDlength(pxd, xlen + n); |
1045 | split->pxdlist = &pxdlist; | 1045 | split->pxdlist = &pxdlist; |
1046 | if ((rc = dtExtendPage(tid, ip, split, btstack))) { | 1046 | if ((rc = dtExtendPage(tid, ip, split, btstack))) { |
1047 | nxaddr = addressPXD(pxd); | 1047 | nxaddr = addressPXD(pxd); |
diff --git a/fs/jfs/jfs_types.h b/fs/jfs/jfs_types.h index 43ea3713c083..8f602dcb51fa 100644 --- a/fs/jfs/jfs_types.h +++ b/fs/jfs/jfs_types.h | |||
@@ -30,8 +30,6 @@ | |||
30 | #include <linux/types.h> | 30 | #include <linux/types.h> |
31 | #include <linux/nls.h> | 31 | #include <linux/nls.h> |
32 | 32 | ||
33 | #include "endian24.h" | ||
34 | |||
35 | /* | 33 | /* |
36 | * transaction and lock id's | 34 | * transaction and lock id's |
37 | * | 35 | * |
@@ -59,26 +57,42 @@ struct timestruc_t { | |||
59 | 57 | ||
60 | /* | 58 | /* |
61 | * physical xd (pxd) | 59 | * physical xd (pxd) |
60 | * | ||
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 | ||
62 | */ | 64 | */ |
63 | typedef struct { | 65 | typedef struct { |
64 | unsigned len:24; | 66 | __le32 len_addr; |
65 | unsigned addr1:8; | ||
66 | __le32 addr2; | 67 | __le32 addr2; |
67 | } pxd_t; | 68 | } pxd_t; |
68 | 69 | ||
69 | /* xd_t field construction */ | 70 | /* xd_t field construction */ |
70 | 71 | ||
71 | #define PXDlength(pxd, length32) ((pxd)->len = __cpu_to_le24(length32)) | 72 | static inline void PXDlength(pxd_t *pxd, __u32 len) |
72 | #define PXDaddress(pxd, address64)\ | 73 | { |
73 | {\ | 74 | pxd->len_addr = (pxd->len_addr & cpu_to_le32(~0xffffff)) | |
74 | (pxd)->addr1 = ((s64)address64) >> 32;\ | 75 | cpu_to_le32(len & 0xffffff); |
75 | (pxd)->addr2 = __cpu_to_le32((address64) & 0xffffffff);\ | 76 | } |
77 | |||
78 | static 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); | ||
76 | } | 83 | } |
77 | 84 | ||
78 | /* xd_t field extraction */ | 85 | /* xd_t field extraction */ |
79 | #define lengthPXD(pxd) __le24_to_cpu((pxd)->len) | 86 | static inline __u32 lengthPXD(pxd_t *pxd) |
80 | #define addressPXD(pxd)\ | 87 | { |
81 | ( ((s64)((pxd)->addr1)) << 32 | __le32_to_cpu((pxd)->addr2)) | 88 | return le32_to_cpu((pxd)->len_addr) & 0xffffff; |
89 | } | ||
90 | |||
91 | static 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 | } | ||
82 | 96 | ||
83 | #define MAXTREEHEIGHT 8 | 97 | #define MAXTREEHEIGHT 8 |
84 | /* pxd list */ | 98 | /* pxd list */ |
@@ -93,12 +107,10 @@ struct pxdlist { | |||
93 | * data extent descriptor (dxd) | 107 | * data extent descriptor (dxd) |
94 | */ | 108 | */ |
95 | typedef struct { | 109 | typedef struct { |
96 | unsigned flag:8; /* 1: flags */ | 110 | __u8 flag; /* 1: flags */ |
97 | unsigned rsrvd:24; | 111 | __u8 rsrvd[3]; |
98 | __le32 size; /* 4: size in byte */ | 112 | __le32 size; /* 4: size in byte */ |
99 | unsigned len:24; /* 3: length in unit of fsblksize */ | 113 | pxd_t loc; /* 8: address and 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 - */ | 114 | } dxd_t; /* - 16 - */ |
103 | 115 | ||
104 | /* dxd_t flags */ | 116 | /* dxd_t flags */ |
@@ -109,12 +121,11 @@ typedef struct { | |||
109 | #define DXD_CORRUPT 0x08 /* Inconsistency detected */ | 121 | #define DXD_CORRUPT 0x08 /* Inconsistency detected */ |
110 | 122 | ||
111 | /* dxd_t field construction | 123 | /* dxd_t field construction |
112 | * Conveniently, the PXD macros work for DXD | ||
113 | */ | 124 | */ |
114 | #define DXDlength PXDlength | 125 | #define DXDlength(dxd, len) PXDlength(&(dxd)->loc, len) |
115 | #define DXDaddress PXDaddress | 126 | #define DXDaddress(dxd, addr) PXDaddress(&(dxd)->loc, addr) |
116 | #define lengthDXD lengthPXD | 127 | #define lengthDXD(dxd) lengthPXD(&(dxd)->loc) |
117 | #define addressDXD addressPXD | 128 | #define addressDXD(dxd) addressPXD(&(dxd)->loc) |
118 | #define DXDsize(dxd, size32) ((dxd)->size = cpu_to_le32(size32)) | 129 | #define DXDsize(dxd, size32) ((dxd)->size = cpu_to_le32(size32)) |
119 | #define sizeDXD(dxd) le32_to_cpu((dxd)->size) | 130 | #define sizeDXD(dxd) le32_to_cpu((dxd)->size) |
120 | 131 | ||
diff --git a/fs/jfs/jfs_xtree.h b/fs/jfs/jfs_xtree.h index 08c0c749b986..1e0987986d5f 100644 --- a/fs/jfs/jfs_xtree.h +++ b/fs/jfs/jfs_xtree.h | |||
@@ -29,13 +29,11 @@ | |||
29 | * extent allocation descriptor (xad) | 29 | * extent allocation descriptor (xad) |
30 | */ | 30 | */ |
31 | typedef struct xad { | 31 | typedef struct xad { |
32 | unsigned flag:8; /* 1: flag */ | 32 | __u8 flag; /* 1: flag */ |
33 | unsigned rsvrd:16; /* 2: reserved */ | 33 | __u8 rsvrd[2]; /* 2: reserved */ |
34 | unsigned off1:8; /* 1: offset in unit of fsblksize */ | 34 | __u8 off1; /* 1: offset in unit of fsblksize */ |
35 | __le32 off2; /* 4: offset in unit of fsblksize */ | 35 | __le32 off2; /* 4: offset in unit of fsblksize */ |
36 | unsigned len:24; /* 3: length in unit of fsblksize */ | 36 | pxd_t loc; /* 8: length and address in unit of fsblksize */ |
37 | unsigned addr1:8; /* 1: address in unit of fsblksize */ | ||
38 | __le32 addr2; /* 4: address in unit of fsblksize */ | ||
39 | } xad_t; /* (16) */ | 37 | } xad_t; /* (16) */ |
40 | 38 | ||
41 | #define MAXXLEN ((1 << 24) - 1) | 39 | #define MAXXLEN ((1 << 24) - 1) |
@@ -49,19 +47,14 @@ typedef struct xad { | |||
49 | (xad)->off1 = ((u64)offset64) >> 32;\ | 47 | (xad)->off1 = ((u64)offset64) >> 32;\ |
50 | (xad)->off2 = __cpu_to_le32((offset64) & 0xffffffff);\ | 48 | (xad)->off2 = __cpu_to_le32((offset64) & 0xffffffff);\ |
51 | } | 49 | } |
52 | #define XADaddress(xad, address64)\ | 50 | #define XADaddress(xad, address64) PXDaddress(&(xad)->loc, address64) |
53 | {\ | 51 | #define XADlength(xad, length32) PXDlength(&(xad)->loc, length32) |
54 | (xad)->addr1 = ((u64)address64) >> 32;\ | ||
55 | (xad)->addr2 = __cpu_to_le32((address64) & 0xffffffff);\ | ||
56 | } | ||
57 | #define XADlength(xad, length32) (xad)->len = __cpu_to_le24(length32) | ||
58 | 52 | ||
59 | /* xad_t field extraction */ | 53 | /* xad_t field extraction */ |
60 | #define offsetXAD(xad)\ | 54 | #define offsetXAD(xad)\ |
61 | ( ((s64)((xad)->off1)) << 32 | __le32_to_cpu((xad)->off2)) | 55 | ( ((s64)((xad)->off1)) << 32 | __le32_to_cpu((xad)->off2)) |
62 | #define addressXAD(xad)\ | 56 | #define addressXAD(xad) addressPXD(&(xad)->loc) |
63 | ( ((s64)((xad)->addr1)) << 32 | __le32_to_cpu((xad)->addr2)) | 57 | #define lengthXAD(xad) lengthPXD(&(xad)->loc) |
64 | #define lengthXAD(xad) __le24_to_cpu((xad)->len) | ||
65 | 58 | ||
66 | /* xad list */ | 59 | /* xad list */ |
67 | struct xadlist { | 60 | struct xadlist { |