Skip to content

Commit

Permalink
[GFS2] gfs2 misc endianness annotations
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
  • Loading branch information
Al Viro authored and Steven Whitehouse committed Nov 30, 2006
1 parent b62f963 commit b44b84d
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 71 deletions.
32 changes: 16 additions & 16 deletions fs/gfs2/bmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ struct metapath {
};

typedef int (*block_call_t) (struct gfs2_inode *ip, struct buffer_head *dibh,
struct buffer_head *bh, u64 *top,
u64 *bottom, unsigned int height,
struct buffer_head *bh, __be64 *top,
__be64 *bottom, unsigned int height,
void *data);

struct strip_mine {
Expand Down Expand Up @@ -230,7 +230,7 @@ static int build_height(struct inode *inode, unsigned height)
struct buffer_head *blocks[GFS2_MAX_META_HEIGHT];
struct gfs2_dinode *di;
int error;
u64 *bp;
__be64 *bp;
u64 bn;
unsigned n;

Expand All @@ -255,7 +255,7 @@ static int build_height(struct inode *inode, unsigned height)
GFS2_FORMAT_IN);
gfs2_buffer_clear_tail(blocks[n],
sizeof(struct gfs2_meta_header));
bp = (u64 *)(blocks[n]->b_data +
bp = (__be64 *)(blocks[n]->b_data +
sizeof(struct gfs2_meta_header));
*bp = cpu_to_be64(blocks[n+1]->b_blocknr);
brelse(blocks[n]);
Expand Down Expand Up @@ -360,15 +360,15 @@ static void find_metapath(struct gfs2_inode *ip, u64 block,
* metadata tree.
*/

static inline u64 *metapointer(struct buffer_head *bh, int *boundary,
static inline __be64 *metapointer(struct buffer_head *bh, int *boundary,
unsigned int height, const struct metapath *mp)
{
unsigned int head_size = (height > 0) ?
sizeof(struct gfs2_meta_header) : sizeof(struct gfs2_dinode);
u64 *ptr;
__be64 *ptr;
*boundary = 0;
ptr = ((u64 *)(bh->b_data + head_size)) + mp->mp_list[height];
if (ptr + 1 == (u64 *)(bh->b_data + bh->b_size))
ptr = ((__be64 *)(bh->b_data + head_size)) + mp->mp_list[height];
if (ptr + 1 == (__be64 *)(bh->b_data + bh->b_size))
*boundary = 1;
return ptr;
}
Expand All @@ -394,7 +394,7 @@ static int lookup_block(struct gfs2_inode *ip, struct buffer_head *bh,
int *new, u64 *block)
{
int boundary;
u64 *ptr = metapointer(bh, &boundary, height, mp);
__be64 *ptr = metapointer(bh, &boundary, height, mp);

if (*ptr) {
*block = be64_to_cpu(*ptr);
Expand Down Expand Up @@ -600,7 +600,7 @@ static int recursive_scan(struct gfs2_inode *ip, struct buffer_head *dibh,
{
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
struct buffer_head *bh = NULL;
u64 *top, *bottom;
__be64 *top, *bottom;
u64 bn;
int error;
int mh_size = sizeof(struct gfs2_meta_header);
Expand All @@ -611,17 +611,17 @@ static int recursive_scan(struct gfs2_inode *ip, struct buffer_head *dibh,
return error;
dibh = bh;

top = (u64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + mp->mp_list[0];
bottom = (u64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + sdp->sd_diptrs;
top = (__be64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + mp->mp_list[0];
bottom = (__be64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + sdp->sd_diptrs;
} else {
error = gfs2_meta_indirect_buffer(ip, height, block, 0, &bh);
if (error)
return error;

top = (u64 *)(bh->b_data + mh_size) +
top = (__be64 *)(bh->b_data + mh_size) +
(first ? mp->mp_list[height] : 0);

bottom = (u64 *)(bh->b_data + mh_size) + sdp->sd_inptrs;
bottom = (__be64 *)(bh->b_data + mh_size) + sdp->sd_inptrs;
}

error = bc(ip, dibh, bh, top, bottom, height, data);
Expand Down Expand Up @@ -660,15 +660,15 @@ static int recursive_scan(struct gfs2_inode *ip, struct buffer_head *dibh,
*/

static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
struct buffer_head *bh, u64 *top, u64 *bottom,
struct buffer_head *bh, __be64 *top, __be64 *bottom,
unsigned int height, void *data)
{
struct strip_mine *sm = data;
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
struct gfs2_rgrp_list rlist;
u64 bn, bstart;
u32 blen;
u64 *p;
__be64 *p;
unsigned int rg_blocks = 0;
int metadata;
unsigned int revokes = 0;
Expand Down
24 changes: 13 additions & 11 deletions fs/gfs2/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,12 +713,12 @@ static int get_leaf(struct gfs2_inode *dip, u64 leaf_no,
static int get_leaf_nr(struct gfs2_inode *dip, u32 index,
u64 *leaf_out)
{
u64 leaf_no;
__be64 leaf_no;
int error;

error = gfs2_dir_read_data(dip, (char *)&leaf_no,
index * sizeof(u64),
sizeof(u64), 0);
index * sizeof(__be64),
sizeof(__be64), 0);
if (error != sizeof(u64))
return (error < 0) ? error : -EIO;

Expand Down Expand Up @@ -837,7 +837,8 @@ static int dir_make_exhash(struct inode *inode)
struct gfs2_leaf *leaf;
int y;
u32 x;
u64 *lp, bn;
__be64 *lp;
u64 bn;
int error;

error = gfs2_meta_inode_buffer(dip, &dibh);
Expand Down Expand Up @@ -893,7 +894,7 @@ static int dir_make_exhash(struct inode *inode)
gfs2_trans_add_bh(dip->i_gl, dibh, 1);
gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));

lp = (u64 *)(dibh->b_data + sizeof(struct gfs2_dinode));
lp = (__be64 *)(dibh->b_data + sizeof(struct gfs2_dinode));

for (x = sdp->sd_hash_ptrs; x--; lp++)
*lp = cpu_to_be64(bn);
Expand Down Expand Up @@ -929,7 +930,8 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
struct gfs2_leaf *nleaf, *oleaf;
struct gfs2_dirent *dent = NULL, *prev = NULL, *next = NULL, *new;
u32 start, len, half_len, divider;
u64 bn, *lp, leaf_no;
u64 bn, leaf_no;
__be64 *lp;
u32 index;
int x, moved = 0;
int error;
Expand Down Expand Up @@ -974,7 +976,7 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
/* Change the pointers.
Don't bother distinguishing stuffed from non-stuffed.
This code is complicated enough already. */
lp = kmalloc(half_len * sizeof(u64), GFP_NOFS | __GFP_NOFAIL);
lp = kmalloc(half_len * sizeof(__be64), GFP_NOFS | __GFP_NOFAIL);
/* Change the pointers */
for (x = 0; x < half_len; x++)
lp[x] = cpu_to_be64(bn);
Expand Down Expand Up @@ -1341,7 +1343,7 @@ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque,
u32 hsize, len = 0;
u32 ht_offset, lp_offset, ht_offset_cur = -1;
u32 hash, index;
u64 *lp;
__be64 *lp;
int copied = 0;
int error = 0;
unsigned depth = 0;
Expand All @@ -1365,7 +1367,7 @@ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque,

if (ht_offset_cur != ht_offset) {
error = gfs2_dir_read_data(dip, (char *)lp,
ht_offset * sizeof(u64),
ht_offset * sizeof(__be64),
sdp->sd_hash_bsize, 1);
if (error != sdp->sd_hash_bsize) {
if (error >= 0)
Expand Down Expand Up @@ -1715,7 +1717,7 @@ static int foreach_leaf(struct gfs2_inode *dip, leaf_call_t lc, void *data)
u32 hsize, len;
u32 ht_offset, lp_offset, ht_offset_cur = -1;
u32 index = 0;
u64 *lp;
__be64 *lp;
u64 leaf_no;
int error = 0;

Expand All @@ -1735,7 +1737,7 @@ static int foreach_leaf(struct gfs2_inode *dip, leaf_call_t lc, void *data)

if (ht_offset_cur != ht_offset) {
error = gfs2_dir_read_data(dip, (char *)lp,
ht_offset * sizeof(u64),
ht_offset * sizeof(__be64),
sdp->sd_hash_bsize, 1);
if (error != sdp->sd_hash_bsize) {
if (error >= 0)
Expand Down
27 changes: 14 additions & 13 deletions fs/gfs2/eattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static int ea_foreach_i(struct gfs2_inode *ip, struct buffer_head *bh,
static int ea_foreach(struct gfs2_inode *ip, ea_call_t ea_call, void *data)
{
struct buffer_head *bh, *eabh;
u64 *eablk, *end;
__be64 *eablk, *end;
int error;

error = gfs2_meta_read(ip->i_gl, ip->i_di.di_eattr, DIO_WAIT, &bh);
Expand All @@ -129,7 +129,7 @@ static int ea_foreach(struct gfs2_inode *ip, ea_call_t ea_call, void *data)
goto out;
}

eablk = (u64 *)(bh->b_data + sizeof(struct gfs2_meta_header));
eablk = (__be64 *)(bh->b_data + sizeof(struct gfs2_meta_header));
end = eablk + GFS2_SB(&ip->i_inode)->sd_inptrs;

for (; eablk < end; eablk++) {
Expand Down Expand Up @@ -224,7 +224,8 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
struct gfs2_rgrpd *rgd;
struct gfs2_holder rg_gh;
struct buffer_head *dibh;
u64 *dataptrs, bn = 0;
__be64 *dataptrs;
u64 bn = 0;
u64 bstart = 0;
unsigned int blen = 0;
unsigned int blks = 0;
Expand Down Expand Up @@ -444,7 +445,7 @@ static int ea_get_unstuffed(struct gfs2_inode *ip, struct gfs2_ea_header *ea,
struct buffer_head **bh;
unsigned int amount = GFS2_EA_DATA_LEN(ea);
unsigned int nptrs = DIV_ROUND_UP(amount, sdp->sd_jbsize);
u64 *dataptrs = GFS2_EA2DATAPTRS(ea);
__be64 *dataptrs = GFS2_EA2DATAPTRS(ea);
unsigned int x;
int error = 0;

Expand Down Expand Up @@ -629,7 +630,7 @@ static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea,
ea->ea_num_ptrs = 0;
memcpy(GFS2_EA2DATA(ea), er->er_data, er->er_data_len);
} else {
u64 *dataptr = GFS2_EA2DATAPTRS(ea);
__be64 *dataptr = GFS2_EA2DATAPTRS(ea);
const char *data = er->er_data;
unsigned int data_len = er->er_data_len;
unsigned int copy;
Expand Down Expand Up @@ -931,12 +932,12 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er,
{
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
struct buffer_head *indbh, *newbh;
u64 *eablk;
__be64 *eablk;
int error;
int mh_size = sizeof(struct gfs2_meta_header);

if (ip->i_di.di_flags & GFS2_DIF_EA_INDIRECT) {
u64 *end;
__be64 *end;

error = gfs2_meta_read(ip->i_gl, ip->i_di.di_eattr, DIO_WAIT,
&indbh);
Expand All @@ -948,7 +949,7 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er,
goto out;
}

eablk = (u64 *)(indbh->b_data + mh_size);
eablk = (__be64 *)(indbh->b_data + mh_size);
end = eablk + sdp->sd_inptrs;

for (; eablk < end; eablk++)
Expand All @@ -971,7 +972,7 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er,
gfs2_metatype_set(indbh, GFS2_METATYPE_IN, GFS2_FORMAT_IN);
gfs2_buffer_clear_tail(indbh, mh_size);

eablk = (u64 *)(indbh->b_data + mh_size);
eablk = (__be64 *)(indbh->b_data + mh_size);
*eablk = cpu_to_be64(ip->i_di.di_eattr);
ip->i_di.di_eattr = blk;
ip->i_di.di_flags |= GFS2_DIF_EA_INDIRECT;
Expand Down Expand Up @@ -1202,7 +1203,7 @@ static int ea_acl_chmod_unstuffed(struct gfs2_inode *ip,
struct buffer_head **bh;
unsigned int amount = GFS2_EA_DATA_LEN(ea);
unsigned int nptrs = DIV_ROUND_UP(amount, sdp->sd_jbsize);
u64 *dataptrs = GFS2_EA2DATAPTRS(ea);
__be64 *dataptrs = GFS2_EA2DATAPTRS(ea);
unsigned int x;
int error;

Expand Down Expand Up @@ -1300,7 +1301,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
struct gfs2_rgrp_list rlist;
struct buffer_head *indbh, *dibh;
u64 *eablk, *end;
__be64 *eablk, *end;
unsigned int rg_blocks = 0;
u64 bstart = 0;
unsigned int blen = 0;
Expand All @@ -1319,7 +1320,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
goto out;
}

eablk = (u64 *)(indbh->b_data + sizeof(struct gfs2_meta_header));
eablk = (__be64 *)(indbh->b_data + sizeof(struct gfs2_meta_header));
end = eablk + sdp->sd_inptrs;

for (; eablk < end; eablk++) {
Expand Down Expand Up @@ -1363,7 +1364,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)

gfs2_trans_add_bh(ip->i_gl, indbh, 1);

eablk = (u64 *)(indbh->b_data + sizeof(struct gfs2_meta_header));
eablk = (__be64 *)(indbh->b_data + sizeof(struct gfs2_meta_header));
bstart = 0;
blen = 0;

Expand Down
6 changes: 3 additions & 3 deletions fs/gfs2/eattr.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct iattr;
#define GFS2_EA_SIZE(ea) \
ALIGN(sizeof(struct gfs2_ea_header) + (ea)->ea_name_len + \
((GFS2_EA_IS_STUFFED(ea)) ? GFS2_EA_DATA_LEN(ea) : \
(sizeof(u64) * (ea)->ea_num_ptrs)), 8)
(sizeof(__be64) * (ea)->ea_num_ptrs)), 8)

#define GFS2_EA_IS_STUFFED(ea) (!(ea)->ea_num_ptrs)
#define GFS2_EA_IS_LAST(ea) ((ea)->ea_flags & GFS2_EAFLAG_LAST)
Expand All @@ -29,13 +29,13 @@ ALIGN(sizeof(struct gfs2_ea_header) + (er)->er_name_len + (er)->er_data_len, 8)

#define GFS2_EAREQ_SIZE_UNSTUFFED(sdp, er) \
ALIGN(sizeof(struct gfs2_ea_header) + (er)->er_name_len + \
sizeof(u64) * DIV_ROUND_UP((er)->er_data_len, (sdp)->sd_jbsize), 8)
sizeof(__be64) * DIV_ROUND_UP((er)->er_data_len, (sdp)->sd_jbsize), 8)

#define GFS2_EA2NAME(ea) ((char *)((struct gfs2_ea_header *)(ea) + 1))
#define GFS2_EA2DATA(ea) (GFS2_EA2NAME(ea) + (ea)->ea_name_len)

#define GFS2_EA2DATAPTRS(ea) \
((u64 *)(GFS2_EA2NAME(ea) + ALIGN((ea)->ea_name_len, 8)))
((__be64 *)(GFS2_EA2NAME(ea) + ALIGN((ea)->ea_name_len, 8)))

#define GFS2_EA2NEXT(ea) \
((struct gfs2_ea_header *)((char *)(ea) + GFS2_EA_REC_LEN(ea)))
Expand Down
9 changes: 5 additions & 4 deletions fs/gfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,21 +500,22 @@ static int pick_formal_ino_2(struct gfs2_sbd *sdp, u64 *formal_ino)
if (!ir.ir_length) {
struct buffer_head *m_bh;
u64 x, y;
__be64 z;

error = gfs2_meta_inode_buffer(m_ip, &m_bh);
if (error)
goto out_brelse;

x = *(u64 *)(m_bh->b_data + sizeof(struct gfs2_dinode));
x = y = be64_to_cpu(x);
z = *(__be64 *)(m_bh->b_data + sizeof(struct gfs2_dinode));
x = y = be64_to_cpu(z);
ir.ir_start = x;
ir.ir_length = GFS2_INUM_QUANTUM;
x += GFS2_INUM_QUANTUM;
if (x < y)
gfs2_consist_inode(m_ip);
x = cpu_to_be64(x);
z = cpu_to_be64(x);
gfs2_trans_add_bh(m_ip->i_gl, m_bh, 1);
*(u64 *)(m_bh->b_data + sizeof(struct gfs2_dinode)) = x;
*(__be64 *)(m_bh->b_data + sizeof(struct gfs2_dinode)) = z;

brelse(m_bh);
}
Expand Down
Loading

0 comments on commit b44b84d

Please sign in to comment.