Skip to content

Commit

Permalink
jfs: get rid of homegrown endianness helpers
Browse files Browse the repository at this point in the history
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>
----
  • Loading branch information
Al Viro authored and Dave Kleikamp committed Dec 23, 2014
1 parent 53262d1 commit e1f1fe7
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 89 deletions.
49 changes: 0 additions & 49 deletions fs/jfs/endian24.h

This file was deleted.

4 changes: 2 additions & 2 deletions fs/jfs/jfs_dtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1040,8 +1040,8 @@ static int dtSplitUp(tid_t tid,
pxdlist.maxnpxd = 1;
pxdlist.npxd = 0;
pxd = &pxdlist.pxd[0];
PXDaddress(pxd, nxaddr)
PXDlength(pxd, xlen + n);
PXDaddress(pxd, nxaddr);
PXDlength(pxd, xlen + n);
split->pxdlist = &pxdlist;
if ((rc = dtExtendPage(tid, ip, split, btstack))) {
nxaddr = addressPXD(pxd);
Expand Down
55 changes: 33 additions & 22 deletions fs/jfs/jfs_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
#include <linux/types.h>
#include <linux/nls.h>

#include "endian24.h"

/*
* transaction and lock id's
*
Expand Down Expand Up @@ -59,26 +57,42 @@ struct timestruc_t {

/*
* physical xd (pxd)
*
* The leftmost 24 bits of len_addr are the extent length.
* The rightmost 8 bits of len_addr are the most signficant bits of
* the extent address
*/
typedef struct {
unsigned len:24;
unsigned addr1:8;
__le32 len_addr;
__le32 addr2;
} pxd_t;

/* xd_t field construction */

#define PXDlength(pxd, length32) ((pxd)->len = __cpu_to_le24(length32))
#define PXDaddress(pxd, address64)\
{\
(pxd)->addr1 = ((s64)address64) >> 32;\
(pxd)->addr2 = __cpu_to_le32((address64) & 0xffffffff);\
static inline void PXDlength(pxd_t *pxd, __u32 len)
{
pxd->len_addr = (pxd->len_addr & cpu_to_le32(~0xffffff)) |
cpu_to_le32(len & 0xffffff);
}

static inline void PXDaddress(pxd_t *pxd, __u64 addr)
{
pxd->len_addr = (pxd->len_addr & cpu_to_le32(0xffffff)) |
cpu_to_le32((addr >> 32)<<24);
pxd->addr2 = cpu_to_le32(addr & 0xffffffff);
}

/* xd_t field extraction */
#define lengthPXD(pxd) __le24_to_cpu((pxd)->len)
#define addressPXD(pxd)\
( ((s64)((pxd)->addr1)) << 32 | __le32_to_cpu((pxd)->addr2))
static inline __u32 lengthPXD(pxd_t *pxd)
{
return le32_to_cpu((pxd)->len_addr) & 0xffffff;
}

static inline __u64 addressPXD(pxd_t *pxd)
{
__u64 n = le32_to_cpu(pxd->len_addr) & ~0xffffff;
return (n << 8) + le32_to_cpu(pxd->addr2);
}

#define MAXTREEHEIGHT 8
/* pxd list */
Expand All @@ -93,12 +107,10 @@ struct pxdlist {
* data extent descriptor (dxd)
*/
typedef struct {
unsigned flag:8; /* 1: flags */
unsigned rsrvd:24;
__u8 flag; /* 1: flags */
__u8 rsrvd[3];
__le32 size; /* 4: size in byte */
unsigned len:24; /* 3: length in unit of fsblksize */
unsigned addr1:8; /* 1: address in unit of fsblksize */
__le32 addr2; /* 4: address in unit of fsblksize */
pxd_t loc; /* 8: address and length in unit of fsblksize */
} dxd_t; /* - 16 - */

/* dxd_t flags */
Expand All @@ -109,12 +121,11 @@ typedef struct {
#define DXD_CORRUPT 0x08 /* Inconsistency detected */

/* dxd_t field construction
* Conveniently, the PXD macros work for DXD
*/
#define DXDlength PXDlength
#define DXDaddress PXDaddress
#define lengthDXD lengthPXD
#define addressDXD addressPXD
#define DXDlength(dxd, len) PXDlength(&(dxd)->loc, len)
#define DXDaddress(dxd, addr) PXDaddress(&(dxd)->loc, addr)
#define lengthDXD(dxd) lengthPXD(&(dxd)->loc)
#define addressDXD(dxd) addressPXD(&(dxd)->loc)
#define DXDsize(dxd, size32) ((dxd)->size = cpu_to_le32(size32))
#define sizeDXD(dxd) le32_to_cpu((dxd)->size)

Expand Down
25 changes: 9 additions & 16 deletions fs/jfs/jfs_xtree.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@
* extent allocation descriptor (xad)
*/
typedef struct xad {
unsigned flag:8; /* 1: flag */
unsigned rsvrd:16; /* 2: reserved */
unsigned off1:8; /* 1: offset in unit of fsblksize */
__le32 off2; /* 4: offset in unit of fsblksize */
unsigned len:24; /* 3: length in unit of fsblksize */
unsigned addr1:8; /* 1: address in unit of fsblksize */
__le32 addr2; /* 4: address in unit of fsblksize */
__u8 flag; /* 1: flag */
__u8 rsvrd[2]; /* 2: reserved */
__u8 off1; /* 1: offset in unit of fsblksize */
__le32 off2; /* 4: offset in unit of fsblksize */
pxd_t loc; /* 8: length and address in unit of fsblksize */
} xad_t; /* (16) */

#define MAXXLEN ((1 << 24) - 1)
Expand All @@ -49,19 +47,14 @@ typedef struct xad {
(xad)->off1 = ((u64)offset64) >> 32;\
(xad)->off2 = __cpu_to_le32((offset64) & 0xffffffff);\
}
#define XADaddress(xad, address64)\
{\
(xad)->addr1 = ((u64)address64) >> 32;\
(xad)->addr2 = __cpu_to_le32((address64) & 0xffffffff);\
}
#define XADlength(xad, length32) (xad)->len = __cpu_to_le24(length32)
#define XADaddress(xad, address64) PXDaddress(&(xad)->loc, address64)
#define XADlength(xad, length32) PXDlength(&(xad)->loc, length32)

/* xad_t field extraction */
#define offsetXAD(xad)\
( ((s64)((xad)->off1)) << 32 | __le32_to_cpu((xad)->off2))
#define addressXAD(xad)\
( ((s64)((xad)->addr1)) << 32 | __le32_to_cpu((xad)->addr2))
#define lengthXAD(xad) __le24_to_cpu((xad)->len)
#define addressXAD(xad) addressPXD(&(xad)->loc)
#define lengthXAD(xad) lengthPXD(&(xad)->loc)

/* xad list */
struct xadlist {
Expand Down

0 comments on commit e1f1fe7

Please sign in to comment.