Commit b44b84d765b02f813a67b96bf79e3b5d4d621631

Authored by Al Viro
Committed by Steven Whitehouse
1 parent b62f963e1f

[GFS2] gfs2 misc endianness annotations

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>

Showing 8 changed files with 66 additions and 71 deletions Side-by-side Diff

... ... @@ -38,8 +38,8 @@
38 38 };
39 39  
40 40 typedef int (*block_call_t) (struct gfs2_inode *ip, struct buffer_head *dibh,
41   - struct buffer_head *bh, u64 *top,
42   - u64 *bottom, unsigned int height,
  41 + struct buffer_head *bh, __be64 *top,
  42 + __be64 *bottom, unsigned int height,
43 43 void *data);
44 44  
45 45 struct strip_mine {
... ... @@ -230,7 +230,7 @@
230 230 struct buffer_head *blocks[GFS2_MAX_META_HEIGHT];
231 231 struct gfs2_dinode *di;
232 232 int error;
233   - u64 *bp;
  233 + __be64 *bp;
234 234 u64 bn;
235 235 unsigned n;
236 236  
... ... @@ -255,7 +255,7 @@
255 255 GFS2_FORMAT_IN);
256 256 gfs2_buffer_clear_tail(blocks[n],
257 257 sizeof(struct gfs2_meta_header));
258   - bp = (u64 *)(blocks[n]->b_data +
  258 + bp = (__be64 *)(blocks[n]->b_data +
259 259 sizeof(struct gfs2_meta_header));
260 260 *bp = cpu_to_be64(blocks[n+1]->b_blocknr);
261 261 brelse(blocks[n]);
262 262  
263 263  
... ... @@ -360,15 +360,15 @@
360 360 * metadata tree.
361 361 */
362 362  
363   -static inline u64 *metapointer(struct buffer_head *bh, int *boundary,
  363 +static inline __be64 *metapointer(struct buffer_head *bh, int *boundary,
364 364 unsigned int height, const struct metapath *mp)
365 365 {
366 366 unsigned int head_size = (height > 0) ?
367 367 sizeof(struct gfs2_meta_header) : sizeof(struct gfs2_dinode);
368   - u64 *ptr;
  368 + __be64 *ptr;
369 369 *boundary = 0;
370   - ptr = ((u64 *)(bh->b_data + head_size)) + mp->mp_list[height];
371   - if (ptr + 1 == (u64 *)(bh->b_data + bh->b_size))
  370 + ptr = ((__be64 *)(bh->b_data + head_size)) + mp->mp_list[height];
  371 + if (ptr + 1 == (__be64 *)(bh->b_data + bh->b_size))
372 372 *boundary = 1;
373 373 return ptr;
374 374 }
... ... @@ -394,7 +394,7 @@
394 394 int *new, u64 *block)
395 395 {
396 396 int boundary;
397   - u64 *ptr = metapointer(bh, &boundary, height, mp);
  397 + __be64 *ptr = metapointer(bh, &boundary, height, mp);
398 398  
399 399 if (*ptr) {
400 400 *block = be64_to_cpu(*ptr);
... ... @@ -600,7 +600,7 @@
600 600 {
601 601 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
602 602 struct buffer_head *bh = NULL;
603   - u64 *top, *bottom;
  603 + __be64 *top, *bottom;
604 604 u64 bn;
605 605 int error;
606 606 int mh_size = sizeof(struct gfs2_meta_header);
607 607  
608 608  
... ... @@ -611,17 +611,17 @@
611 611 return error;
612 612 dibh = bh;
613 613  
614   - top = (u64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + mp->mp_list[0];
615   - bottom = (u64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + sdp->sd_diptrs;
  614 + top = (__be64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + mp->mp_list[0];
  615 + bottom = (__be64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + sdp->sd_diptrs;
616 616 } else {
617 617 error = gfs2_meta_indirect_buffer(ip, height, block, 0, &bh);
618 618 if (error)
619 619 return error;
620 620  
621   - top = (u64 *)(bh->b_data + mh_size) +
  621 + top = (__be64 *)(bh->b_data + mh_size) +
622 622 (first ? mp->mp_list[height] : 0);
623 623  
624   - bottom = (u64 *)(bh->b_data + mh_size) + sdp->sd_inptrs;
  624 + bottom = (__be64 *)(bh->b_data + mh_size) + sdp->sd_inptrs;
625 625 }
626 626  
627 627 error = bc(ip, dibh, bh, top, bottom, height, data);
... ... @@ -660,7 +660,7 @@
660 660 */
661 661  
662 662 static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
663   - struct buffer_head *bh, u64 *top, u64 *bottom,
  663 + struct buffer_head *bh, __be64 *top, __be64 *bottom,
664 664 unsigned int height, void *data)
665 665 {
666 666 struct strip_mine *sm = data;
... ... @@ -668,7 +668,7 @@
668 668 struct gfs2_rgrp_list rlist;
669 669 u64 bn, bstart;
670 670 u32 blen;
671   - u64 *p;
  671 + __be64 *p;
672 672 unsigned int rg_blocks = 0;
673 673 int metadata;
674 674 unsigned int revokes = 0;
... ... @@ -713,12 +713,12 @@
713 713 static int get_leaf_nr(struct gfs2_inode *dip, u32 index,
714 714 u64 *leaf_out)
715 715 {
716   - u64 leaf_no;
  716 + __be64 leaf_no;
717 717 int error;
718 718  
719 719 error = gfs2_dir_read_data(dip, (char *)&leaf_no,
720   - index * sizeof(u64),
721   - sizeof(u64), 0);
  720 + index * sizeof(__be64),
  721 + sizeof(__be64), 0);
722 722 if (error != sizeof(u64))
723 723 return (error < 0) ? error : -EIO;
724 724  
... ... @@ -837,7 +837,8 @@
837 837 struct gfs2_leaf *leaf;
838 838 int y;
839 839 u32 x;
840   - u64 *lp, bn;
  840 + __be64 *lp;
  841 + u64 bn;
841 842 int error;
842 843  
843 844 error = gfs2_meta_inode_buffer(dip, &dibh);
... ... @@ -893,7 +894,7 @@
893 894 gfs2_trans_add_bh(dip->i_gl, dibh, 1);
894 895 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
895 896  
896   - lp = (u64 *)(dibh->b_data + sizeof(struct gfs2_dinode));
  897 + lp = (__be64 *)(dibh->b_data + sizeof(struct gfs2_dinode));
897 898  
898 899 for (x = sdp->sd_hash_ptrs; x--; lp++)
899 900 *lp = cpu_to_be64(bn);
... ... @@ -929,7 +930,8 @@
929 930 struct gfs2_leaf *nleaf, *oleaf;
930 931 struct gfs2_dirent *dent = NULL, *prev = NULL, *next = NULL, *new;
931 932 u32 start, len, half_len, divider;
932   - u64 bn, *lp, leaf_no;
  933 + u64 bn, leaf_no;
  934 + __be64 *lp;
933 935 u32 index;
934 936 int x, moved = 0;
935 937 int error;
... ... @@ -974,7 +976,7 @@
974 976 /* Change the pointers.
975 977 Don't bother distinguishing stuffed from non-stuffed.
976 978 This code is complicated enough already. */
977   - lp = kmalloc(half_len * sizeof(u64), GFP_NOFS | __GFP_NOFAIL);
  979 + lp = kmalloc(half_len * sizeof(__be64), GFP_NOFS | __GFP_NOFAIL);
978 980 /* Change the pointers */
979 981 for (x = 0; x < half_len; x++)
980 982 lp[x] = cpu_to_be64(bn);
... ... @@ -1341,7 +1343,7 @@
1341 1343 u32 hsize, len = 0;
1342 1344 u32 ht_offset, lp_offset, ht_offset_cur = -1;
1343 1345 u32 hash, index;
1344   - u64 *lp;
  1346 + __be64 *lp;
1345 1347 int copied = 0;
1346 1348 int error = 0;
1347 1349 unsigned depth = 0;
... ... @@ -1365,7 +1367,7 @@
1365 1367  
1366 1368 if (ht_offset_cur != ht_offset) {
1367 1369 error = gfs2_dir_read_data(dip, (char *)lp,
1368   - ht_offset * sizeof(u64),
  1370 + ht_offset * sizeof(__be64),
1369 1371 sdp->sd_hash_bsize, 1);
1370 1372 if (error != sdp->sd_hash_bsize) {
1371 1373 if (error >= 0)
... ... @@ -1715,7 +1717,7 @@
1715 1717 u32 hsize, len;
1716 1718 u32 ht_offset, lp_offset, ht_offset_cur = -1;
1717 1719 u32 index = 0;
1718   - u64 *lp;
  1720 + __be64 *lp;
1719 1721 u64 leaf_no;
1720 1722 int error = 0;
1721 1723  
... ... @@ -1735,7 +1737,7 @@
1735 1737  
1736 1738 if (ht_offset_cur != ht_offset) {
1737 1739 error = gfs2_dir_read_data(dip, (char *)lp,
1738   - ht_offset * sizeof(u64),
  1740 + ht_offset * sizeof(__be64),
1739 1741 sdp->sd_hash_bsize, 1);
1740 1742 if (error != sdp->sd_hash_bsize) {
1741 1743 if (error >= 0)
... ... @@ -112,7 +112,7 @@
112 112 static int ea_foreach(struct gfs2_inode *ip, ea_call_t ea_call, void *data)
113 113 {
114 114 struct buffer_head *bh, *eabh;
115   - u64 *eablk, *end;
  115 + __be64 *eablk, *end;
116 116 int error;
117 117  
118 118 error = gfs2_meta_read(ip->i_gl, ip->i_di.di_eattr, DIO_WAIT, &bh);
... ... @@ -129,7 +129,7 @@
129 129 goto out;
130 130 }
131 131  
132   - eablk = (u64 *)(bh->b_data + sizeof(struct gfs2_meta_header));
  132 + eablk = (__be64 *)(bh->b_data + sizeof(struct gfs2_meta_header));
133 133 end = eablk + GFS2_SB(&ip->i_inode)->sd_inptrs;
134 134  
135 135 for (; eablk < end; eablk++) {
... ... @@ -224,7 +224,8 @@
224 224 struct gfs2_rgrpd *rgd;
225 225 struct gfs2_holder rg_gh;
226 226 struct buffer_head *dibh;
227   - u64 *dataptrs, bn = 0;
  227 + __be64 *dataptrs;
  228 + u64 bn = 0;
228 229 u64 bstart = 0;
229 230 unsigned int blen = 0;
230 231 unsigned int blks = 0;
... ... @@ -444,7 +445,7 @@
444 445 struct buffer_head **bh;
445 446 unsigned int amount = GFS2_EA_DATA_LEN(ea);
446 447 unsigned int nptrs = DIV_ROUND_UP(amount, sdp->sd_jbsize);
447   - u64 *dataptrs = GFS2_EA2DATAPTRS(ea);
  448 + __be64 *dataptrs = GFS2_EA2DATAPTRS(ea);
448 449 unsigned int x;
449 450 int error = 0;
450 451  
... ... @@ -629,7 +630,7 @@
629 630 ea->ea_num_ptrs = 0;
630 631 memcpy(GFS2_EA2DATA(ea), er->er_data, er->er_data_len);
631 632 } else {
632   - u64 *dataptr = GFS2_EA2DATAPTRS(ea);
  633 + __be64 *dataptr = GFS2_EA2DATAPTRS(ea);
633 634 const char *data = er->er_data;
634 635 unsigned int data_len = er->er_data_len;
635 636 unsigned int copy;
636 637  
... ... @@ -931,12 +932,12 @@
931 932 {
932 933 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
933 934 struct buffer_head *indbh, *newbh;
934   - u64 *eablk;
  935 + __be64 *eablk;
935 936 int error;
936 937 int mh_size = sizeof(struct gfs2_meta_header);
937 938  
938 939 if (ip->i_di.di_flags & GFS2_DIF_EA_INDIRECT) {
939   - u64 *end;
  940 + __be64 *end;
940 941  
941 942 error = gfs2_meta_read(ip->i_gl, ip->i_di.di_eattr, DIO_WAIT,
942 943 &indbh);
... ... @@ -948,7 +949,7 @@
948 949 goto out;
949 950 }
950 951  
951   - eablk = (u64 *)(indbh->b_data + mh_size);
  952 + eablk = (__be64 *)(indbh->b_data + mh_size);
952 953 end = eablk + sdp->sd_inptrs;
953 954  
954 955 for (; eablk < end; eablk++)
... ... @@ -971,7 +972,7 @@
971 972 gfs2_metatype_set(indbh, GFS2_METATYPE_IN, GFS2_FORMAT_IN);
972 973 gfs2_buffer_clear_tail(indbh, mh_size);
973 974  
974   - eablk = (u64 *)(indbh->b_data + mh_size);
  975 + eablk = (__be64 *)(indbh->b_data + mh_size);
975 976 *eablk = cpu_to_be64(ip->i_di.di_eattr);
976 977 ip->i_di.di_eattr = blk;
977 978 ip->i_di.di_flags |= GFS2_DIF_EA_INDIRECT;
... ... @@ -1202,7 +1203,7 @@
1202 1203 struct buffer_head **bh;
1203 1204 unsigned int amount = GFS2_EA_DATA_LEN(ea);
1204 1205 unsigned int nptrs = DIV_ROUND_UP(amount, sdp->sd_jbsize);
1205   - u64 *dataptrs = GFS2_EA2DATAPTRS(ea);
  1206 + __be64 *dataptrs = GFS2_EA2DATAPTRS(ea);
1206 1207 unsigned int x;
1207 1208 int error;
1208 1209  
... ... @@ -1300,7 +1301,7 @@
1300 1301 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
1301 1302 struct gfs2_rgrp_list rlist;
1302 1303 struct buffer_head *indbh, *dibh;
1303   - u64 *eablk, *end;
  1304 + __be64 *eablk, *end;
1304 1305 unsigned int rg_blocks = 0;
1305 1306 u64 bstart = 0;
1306 1307 unsigned int blen = 0;
... ... @@ -1319,7 +1320,7 @@
1319 1320 goto out;
1320 1321 }
1321 1322  
1322   - eablk = (u64 *)(indbh->b_data + sizeof(struct gfs2_meta_header));
  1323 + eablk = (__be64 *)(indbh->b_data + sizeof(struct gfs2_meta_header));
1323 1324 end = eablk + sdp->sd_inptrs;
1324 1325  
1325 1326 for (; eablk < end; eablk++) {
... ... @@ -1363,7 +1364,7 @@
1363 1364  
1364 1365 gfs2_trans_add_bh(ip->i_gl, indbh, 1);
1365 1366  
1366   - eablk = (u64 *)(indbh->b_data + sizeof(struct gfs2_meta_header));
  1367 + eablk = (__be64 *)(indbh->b_data + sizeof(struct gfs2_meta_header));
1367 1368 bstart = 0;
1368 1369 blen = 0;
1369 1370  
... ... @@ -19,7 +19,7 @@
19 19 #define GFS2_EA_SIZE(ea) \
20 20 ALIGN(sizeof(struct gfs2_ea_header) + (ea)->ea_name_len + \
21 21 ((GFS2_EA_IS_STUFFED(ea)) ? GFS2_EA_DATA_LEN(ea) : \
22   - (sizeof(u64) * (ea)->ea_num_ptrs)), 8)
  22 + (sizeof(__be64) * (ea)->ea_num_ptrs)), 8)
23 23  
24 24 #define GFS2_EA_IS_STUFFED(ea) (!(ea)->ea_num_ptrs)
25 25 #define GFS2_EA_IS_LAST(ea) ((ea)->ea_flags & GFS2_EAFLAG_LAST)
26 26  
... ... @@ -29,13 +29,13 @@
29 29  
30 30 #define GFS2_EAREQ_SIZE_UNSTUFFED(sdp, er) \
31 31 ALIGN(sizeof(struct gfs2_ea_header) + (er)->er_name_len + \
32   - sizeof(u64) * DIV_ROUND_UP((er)->er_data_len, (sdp)->sd_jbsize), 8)
  32 + sizeof(__be64) * DIV_ROUND_UP((er)->er_data_len, (sdp)->sd_jbsize), 8)
33 33  
34 34 #define GFS2_EA2NAME(ea) ((char *)((struct gfs2_ea_header *)(ea) + 1))
35 35 #define GFS2_EA2DATA(ea) (GFS2_EA2NAME(ea) + (ea)->ea_name_len)
36 36  
37 37 #define GFS2_EA2DATAPTRS(ea) \
38   -((u64 *)(GFS2_EA2NAME(ea) + ALIGN((ea)->ea_name_len, 8)))
  38 +((__be64 *)(GFS2_EA2NAME(ea) + ALIGN((ea)->ea_name_len, 8)))
39 39  
40 40 #define GFS2_EA2NEXT(ea) \
41 41 ((struct gfs2_ea_header *)((char *)(ea) + GFS2_EA_REC_LEN(ea)))
... ... @@ -500,21 +500,22 @@
500 500 if (!ir.ir_length) {
501 501 struct buffer_head *m_bh;
502 502 u64 x, y;
  503 + __be64 z;
503 504  
504 505 error = gfs2_meta_inode_buffer(m_ip, &m_bh);
505 506 if (error)
506 507 goto out_brelse;
507 508  
508   - x = *(u64 *)(m_bh->b_data + sizeof(struct gfs2_dinode));
509   - x = y = be64_to_cpu(x);
  509 + z = *(__be64 *)(m_bh->b_data + sizeof(struct gfs2_dinode));
  510 + x = y = be64_to_cpu(z);
510 511 ir.ir_start = x;
511 512 ir.ir_length = GFS2_INUM_QUANTUM;
512 513 x += GFS2_INUM_QUANTUM;
513 514 if (x < y)
514 515 gfs2_consist_inode(m_ip);
515   - x = cpu_to_be64(x);
  516 + z = cpu_to_be64(x);
516 517 gfs2_trans_add_bh(m_ip->i_gl, m_bh, 1);
517   - *(u64 *)(m_bh->b_data + sizeof(struct gfs2_dinode)) = x;
  518 + *(__be64 *)(m_bh->b_data + sizeof(struct gfs2_dinode)) = z;
518 519  
519 520 brelse(m_bh);
520 521 }
fs/gfs2/ops_export.c
... ... @@ -27,13 +27,14 @@
27 27 #include "util.h"
28 28  
29 29 static struct dentry *gfs2_decode_fh(struct super_block *sb,
30   - __u32 *fh,
  30 + __u32 *p,
31 31 int fh_len,
32 32 int fh_type,
33 33 int (*acceptable)(void *context,
34 34 struct dentry *dentry),
35 35 void *context)
36 36 {
  37 + __be32 *fh = (__force __be32 *)p;
37 38 struct gfs2_fh_obj fh_obj;
38 39 struct gfs2_inum_host *this, parent;
39 40  
40 41  
... ... @@ -65,9 +66,10 @@
65 66 acceptable, context);
66 67 }
67 68  
68   -static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len,
  69 +static int gfs2_encode_fh(struct dentry *dentry, __u32 *p, int *len,
69 70 int connectable)
70 71 {
  72 + __be32 *fh = (__force __be32 *)p;
71 73 struct inode *inode = dentry->d_inode;
72 74 struct super_block *sb = inode->i_sb;
73 75 struct gfs2_inode *ip = GFS2_I(inode);
... ... @@ -76,14 +78,10 @@
76 78 (connectable && *len < GFS2_LARGE_FH_SIZE))
77 79 return 255;
78 80  
79   - fh[0] = ip->i_num.no_formal_ino >> 32;
80   - fh[0] = cpu_to_be32(fh[0]);
81   - fh[1] = ip->i_num.no_formal_ino & 0xFFFFFFFF;
82   - fh[1] = cpu_to_be32(fh[1]);
83   - fh[2] = ip->i_num.no_addr >> 32;
84   - fh[2] = cpu_to_be32(fh[2]);
85   - fh[3] = ip->i_num.no_addr & 0xFFFFFFFF;
86   - fh[3] = cpu_to_be32(fh[3]);
  81 + fh[0] = cpu_to_be32(ip->i_num.no_formal_ino >> 32);
  82 + fh[1] = cpu_to_be32(ip->i_num.no_formal_ino & 0xFFFFFFFF);
  83 + fh[2] = cpu_to_be32(ip->i_num.no_addr >> 32);
  84 + fh[3] = cpu_to_be32(ip->i_num.no_addr & 0xFFFFFFFF);
87 85 *len = GFS2_SMALL_FH_SIZE;
88 86  
89 87 if (!connectable || inode == sb->s_root->d_inode)
... ... @@ -95,14 +93,10 @@
95 93 igrab(inode);
96 94 spin_unlock(&dentry->d_lock);
97 95  
98   - fh[4] = ip->i_num.no_formal_ino >> 32;
99   - fh[4] = cpu_to_be32(fh[4]);
100   - fh[5] = ip->i_num.no_formal_ino & 0xFFFFFFFF;
101   - fh[5] = cpu_to_be32(fh[5]);
102   - fh[6] = ip->i_num.no_addr >> 32;
103   - fh[6] = cpu_to_be32(fh[6]);
104   - fh[7] = ip->i_num.no_addr & 0xFFFFFFFF;
105   - fh[7] = cpu_to_be32(fh[7]);
  96 + fh[4] = cpu_to_be32(ip->i_num.no_formal_ino >> 32);
  97 + fh[5] = cpu_to_be32(ip->i_num.no_formal_ino & 0xFFFFFFFF);
  98 + fh[6] = cpu_to_be32(ip->i_num.no_addr >> 32);
  99 + fh[7] = cpu_to_be32(ip->i_num.no_addr & 0xFFFFFFFF);
106 100  
107 101 fh[8] = cpu_to_be32(inode->i_mode);
108 102 fh[9] = 0; /* pad to double word */
... ... @@ -539,8 +539,7 @@
539 539 qc->qc_id = cpu_to_be32(qd->qd_id);
540 540 }
541 541  
542   - x = qc->qc_change;
543   - x = be64_to_cpu(x) + change;
  542 + x = be64_to_cpu(qc->qc_change) + change;
544 543 qc->qc_change = cpu_to_be64(x);
545 544  
546 545 spin_lock(&sdp->sd_quota_spin);
... ... @@ -83,8 +83,7 @@
83 83 char *file, unsigned int line)
84 84 {
85 85 struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
86   - u32 magic = mh->mh_magic;
87   - magic = be32_to_cpu(magic);
  86 + u32 magic = be32_to_cpu(mh->mh_magic);
88 87 if (unlikely(magic != GFS2_MAGIC))
89 88 return gfs2_meta_check_ii(sdp, bh, "magic number", function,
90 89 file, line);
91 90  
... ... @@ -107,9 +106,8 @@
107 106 char *file, unsigned int line)
108 107 {
109 108 struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
110   - u32 magic = mh->mh_magic;
  109 + u32 magic = be32_to_cpu(mh->mh_magic);
111 110 u16 t = be32_to_cpu(mh->mh_type);
112   - magic = be32_to_cpu(magic);
113 111 if (unlikely(magic != GFS2_MAGIC))
114 112 return gfs2_meta_check_ii(sdp, bh, "magic number", function,
115 113 file, line);