aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/dir.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/gfs2/dir.c')
-rw-r--r--fs/gfs2/dir.c124
1 files changed, 62 insertions, 62 deletions
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index 59d0cbcaecff..2023dc4ea306 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -78,15 +78,15 @@
78#define IS_LEAF 1 /* Hashed (leaf) directory */ 78#define IS_LEAF 1 /* Hashed (leaf) directory */
79#define IS_DINODE 2 /* Linear (stuffed dinode block) directory */ 79#define IS_DINODE 2 /* Linear (stuffed dinode block) directory */
80 80
81#define gfs2_disk_hash2offset(h) (((uint64_t)(h)) >> 1) 81#define gfs2_disk_hash2offset(h) (((u64)(h)) >> 1)
82#define gfs2_dir_offset2hash(p) ((uint32_t)(((uint64_t)(p)) << 1)) 82#define gfs2_dir_offset2hash(p) ((u32)(((u64)(p)) << 1))
83 83
84typedef int (*leaf_call_t) (struct gfs2_inode *dip, 84typedef int (*leaf_call_t) (struct gfs2_inode *dip,
85 uint32_t index, uint32_t len, uint64_t leaf_no, 85 u32 index, u32 len, u64 leaf_no,
86 void *data); 86 void *data);
87 87
88 88
89int gfs2_dir_get_new_buffer(struct gfs2_inode *ip, uint64_t block, 89int gfs2_dir_get_new_buffer(struct gfs2_inode *ip, u64 block,
90 struct buffer_head **bhp) 90 struct buffer_head **bhp)
91{ 91{
92 struct buffer_head *bh; 92 struct buffer_head *bh;
@@ -99,7 +99,7 @@ int gfs2_dir_get_new_buffer(struct gfs2_inode *ip, uint64_t block,
99 return 0; 99 return 0;
100} 100}
101 101
102static int gfs2_dir_get_existing_buffer(struct gfs2_inode *ip, uint64_t block, 102static int gfs2_dir_get_existing_buffer(struct gfs2_inode *ip, u64 block,
103 struct buffer_head **bhp) 103 struct buffer_head **bhp)
104{ 104{
105 struct buffer_head *bh; 105 struct buffer_head *bh;
@@ -151,12 +151,12 @@ static int gfs2_dir_write_stuffed(struct gfs2_inode *ip, const char *buf,
151 * Returns: The number of bytes correctly written or error code 151 * Returns: The number of bytes correctly written or error code
152 */ 152 */
153static int gfs2_dir_write_data(struct gfs2_inode *ip, const char *buf, 153static int gfs2_dir_write_data(struct gfs2_inode *ip, const char *buf,
154 uint64_t offset, unsigned int size) 154 u64 offset, unsigned int size)
155{ 155{
156 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 156 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
157 struct buffer_head *dibh; 157 struct buffer_head *dibh;
158 uint64_t lblock, dblock; 158 u64 lblock, dblock;
159 uint32_t extlen = 0; 159 u32 extlen = 0;
160 unsigned int o; 160 unsigned int o;
161 int copied = 0; 161 int copied = 0;
162 int error = 0; 162 int error = 0;
@@ -271,11 +271,11 @@ static int gfs2_dir_read_stuffed(struct gfs2_inode *ip, char *buf,
271 * Returns: The amount of data actually copied or the error 271 * Returns: The amount of data actually copied or the error
272 */ 272 */
273static int gfs2_dir_read_data(struct gfs2_inode *ip, char *buf, 273static int gfs2_dir_read_data(struct gfs2_inode *ip, char *buf,
274 uint64_t offset, unsigned int size) 274 u64 offset, unsigned int size)
275{ 275{
276 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 276 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
277 uint64_t lblock, dblock; 277 u64 lblock, dblock;
278 uint32_t extlen = 0; 278 u32 extlen = 0;
279 unsigned int o; 279 unsigned int o;
280 int copied = 0; 280 int copied = 0;
281 int error = 0; 281 int error = 0;
@@ -581,7 +581,7 @@ static int dirent_next(struct gfs2_inode *dip, struct buffer_head *bh,
581{ 581{
582 struct gfs2_dirent *tmp, *cur; 582 struct gfs2_dirent *tmp, *cur;
583 char *bh_end; 583 char *bh_end;
584 uint16_t cur_rec_len; 584 u16 cur_rec_len;
585 585
586 cur = *dent; 586 cur = *dent;
587 bh_end = bh->b_data + bh->b_size; 587 bh_end = bh->b_data + bh->b_size;
@@ -630,7 +630,7 @@ static int dirent_next(struct gfs2_inode *dip, struct buffer_head *bh,
630static void dirent_del(struct gfs2_inode *dip, struct buffer_head *bh, 630static void dirent_del(struct gfs2_inode *dip, struct buffer_head *bh,
631 struct gfs2_dirent *prev, struct gfs2_dirent *cur) 631 struct gfs2_dirent *prev, struct gfs2_dirent *cur)
632{ 632{
633 uint16_t cur_rec_len, prev_rec_len; 633 u16 cur_rec_len, prev_rec_len;
634 634
635 if (!cur->de_inum.no_addr) { 635 if (!cur->de_inum.no_addr) {
636 gfs2_consist_inode(dip); 636 gfs2_consist_inode(dip);
@@ -698,7 +698,7 @@ static struct gfs2_dirent *gfs2_dirent_alloc(struct inode *inode,
698 return gfs2_init_dirent(inode, dent, name, bh); 698 return gfs2_init_dirent(inode, dent, name, bh);
699} 699}
700 700
701static int get_leaf(struct gfs2_inode *dip, uint64_t leaf_no, 701static int get_leaf(struct gfs2_inode *dip, u64 leaf_no,
702 struct buffer_head **bhp) 702 struct buffer_head **bhp)
703{ 703{
704 int error; 704 int error;
@@ -721,16 +721,16 @@ static int get_leaf(struct gfs2_inode *dip, uint64_t leaf_no,
721 * Returns: 0 on success, error code otherwise 721 * Returns: 0 on success, error code otherwise
722 */ 722 */
723 723
724static int get_leaf_nr(struct gfs2_inode *dip, uint32_t index, 724static int get_leaf_nr(struct gfs2_inode *dip, u32 index,
725 uint64_t *leaf_out) 725 u64 *leaf_out)
726{ 726{
727 uint64_t leaf_no; 727 u64 leaf_no;
728 int error; 728 int error;
729 729
730 error = gfs2_dir_read_data(dip, (char *)&leaf_no, 730 error = gfs2_dir_read_data(dip, (char *)&leaf_no,
731 index * sizeof(uint64_t), 731 index * sizeof(u64),
732 sizeof(uint64_t)); 732 sizeof(u64));
733 if (error != sizeof(uint64_t)) 733 if (error != sizeof(u64))
734 return (error < 0) ? error : -EIO; 734 return (error < 0) ? error : -EIO;
735 735
736 *leaf_out = be64_to_cpu(leaf_no); 736 *leaf_out = be64_to_cpu(leaf_no);
@@ -738,10 +738,10 @@ static int get_leaf_nr(struct gfs2_inode *dip, uint32_t index,
738 return 0; 738 return 0;
739} 739}
740 740
741static int get_first_leaf(struct gfs2_inode *dip, uint32_t index, 741static int get_first_leaf(struct gfs2_inode *dip, u32 index,
742 struct buffer_head **bh_out) 742 struct buffer_head **bh_out)
743{ 743{
744 uint64_t leaf_no; 744 u64 leaf_no;
745 int error; 745 int error;
746 746
747 error = get_leaf_nr(dip, index, &leaf_no); 747 error = get_leaf_nr(dip, index, &leaf_no);
@@ -847,8 +847,8 @@ static int dir_make_exhash(struct inode *inode)
847 struct buffer_head *bh, *dibh; 847 struct buffer_head *bh, *dibh;
848 struct gfs2_leaf *leaf; 848 struct gfs2_leaf *leaf;
849 int y; 849 int y;
850 uint32_t x; 850 u32 x;
851 uint64_t *lp, bn; 851 u64 *lp, bn;
852 int error; 852 int error;
853 853
854 error = gfs2_meta_inode_buffer(dip, &dibh); 854 error = gfs2_meta_inode_buffer(dip, &dibh);
@@ -904,7 +904,7 @@ static int dir_make_exhash(struct inode *inode)
904 gfs2_trans_add_bh(dip->i_gl, dibh, 1); 904 gfs2_trans_add_bh(dip->i_gl, dibh, 1);
905 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode)); 905 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
906 906
907 lp = (uint64_t *)(dibh->b_data + sizeof(struct gfs2_dinode)); 907 lp = (u64 *)(dibh->b_data + sizeof(struct gfs2_dinode));
908 908
909 for (x = sdp->sd_hash_ptrs; x--; lp++) 909 for (x = sdp->sd_hash_ptrs; x--; lp++)
910 *lp = cpu_to_be64(bn); 910 *lp = cpu_to_be64(bn);
@@ -939,9 +939,9 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
939 struct buffer_head *nbh, *obh, *dibh; 939 struct buffer_head *nbh, *obh, *dibh;
940 struct gfs2_leaf *nleaf, *oleaf; 940 struct gfs2_leaf *nleaf, *oleaf;
941 struct gfs2_dirent *dent = NULL, *prev = NULL, *next = NULL, *new; 941 struct gfs2_dirent *dent = NULL, *prev = NULL, *next = NULL, *new;
942 uint32_t start, len, half_len, divider; 942 u32 start, len, half_len, divider;
943 uint64_t bn, *lp, leaf_no; 943 u64 bn, *lp, leaf_no;
944 uint32_t index; 944 u32 index;
945 int x, moved = 0; 945 int x, moved = 0;
946 int error; 946 int error;
947 947
@@ -985,14 +985,14 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
985 /* Change the pointers. 985 /* Change the pointers.
986 Don't bother distinguishing stuffed from non-stuffed. 986 Don't bother distinguishing stuffed from non-stuffed.
987 This code is complicated enough already. */ 987 This code is complicated enough already. */
988 lp = kmalloc(half_len * sizeof(uint64_t), GFP_NOFS | __GFP_NOFAIL); 988 lp = kmalloc(half_len * sizeof(u64), GFP_NOFS | __GFP_NOFAIL);
989 /* Change the pointers */ 989 /* Change the pointers */
990 for (x = 0; x < half_len; x++) 990 for (x = 0; x < half_len; x++)
991 lp[x] = cpu_to_be64(bn); 991 lp[x] = cpu_to_be64(bn);
992 992
993 error = gfs2_dir_write_data(dip, (char *)lp, start * sizeof(uint64_t), 993 error = gfs2_dir_write_data(dip, (char *)lp, start * sizeof(u64),
994 half_len * sizeof(uint64_t)); 994 half_len * sizeof(u64));
995 if (error != half_len * sizeof(uint64_t)) { 995 if (error != half_len * sizeof(u64)) {
996 if (error >= 0) 996 if (error >= 0)
997 error = -EIO; 997 error = -EIO;
998 goto fail_lpfree; 998 goto fail_lpfree;
@@ -1077,15 +1077,15 @@ static int dir_double_exhash(struct gfs2_inode *dip)
1077{ 1077{
1078 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); 1078 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
1079 struct buffer_head *dibh; 1079 struct buffer_head *dibh;
1080 uint32_t hsize; 1080 u32 hsize;
1081 uint64_t *buf; 1081 u64 *buf;
1082 uint64_t *from, *to; 1082 u64 *from, *to;
1083 uint64_t block; 1083 u64 block;
1084 int x; 1084 int x;
1085 int error = 0; 1085 int error = 0;
1086 1086
1087 hsize = 1 << dip->i_di.di_depth; 1087 hsize = 1 << dip->i_di.di_depth;
1088 if (hsize * sizeof(uint64_t) != dip->i_di.di_size) { 1088 if (hsize * sizeof(u64) != dip->i_di.di_size) {
1089 gfs2_consist_inode(dip); 1089 gfs2_consist_inode(dip);
1090 return -EIO; 1090 return -EIO;
1091 } 1091 }
@@ -1105,7 +1105,7 @@ static int dir_double_exhash(struct gfs2_inode *dip)
1105 } 1105 }
1106 1106
1107 from = buf; 1107 from = buf;
1108 to = (uint64_t *)((char *)buf + sdp->sd_hash_bsize); 1108 to = (u64 *)((char *)buf + sdp->sd_hash_bsize);
1109 1109
1110 for (x = sdp->sd_hash_ptrs; x--; from++) { 1110 for (x = sdp->sd_hash_ptrs; x--; from++) {
1111 *to++ = *from; /* No endianess worries */ 1111 *to++ = *from; /* No endianess worries */
@@ -1153,7 +1153,7 @@ fail:
1153static int compare_dents(const void *a, const void *b) 1153static int compare_dents(const void *a, const void *b)
1154{ 1154{
1155 struct gfs2_dirent *dent_a, *dent_b; 1155 struct gfs2_dirent *dent_a, *dent_b;
1156 uint32_t hash_a, hash_b; 1156 u32 hash_a, hash_b;
1157 int ret = 0; 1157 int ret = 0;
1158 1158
1159 dent_a = *(struct gfs2_dirent **)a; 1159 dent_a = *(struct gfs2_dirent **)a;
@@ -1201,14 +1201,14 @@ static int compare_dents(const void *a, const void *b)
1201 * Returns: errno, >0 on exception from filldir 1201 * Returns: errno, >0 on exception from filldir
1202 */ 1202 */
1203 1203
1204static int do_filldir_main(struct gfs2_inode *dip, uint64_t *offset, 1204static int do_filldir_main(struct gfs2_inode *dip, u64 *offset,
1205 void *opaque, gfs2_filldir_t filldir, 1205 void *opaque, gfs2_filldir_t filldir,
1206 const struct gfs2_dirent **darr, uint32_t entries, 1206 const struct gfs2_dirent **darr, u32 entries,
1207 int *copied) 1207 int *copied)
1208{ 1208{
1209 const struct gfs2_dirent *dent, *dent_next; 1209 const struct gfs2_dirent *dent, *dent_next;
1210 struct gfs2_inum inum; 1210 struct gfs2_inum inum;
1211 uint64_t off, off_next; 1211 u64 off, off_next;
1212 unsigned int x, y; 1212 unsigned int x, y;
1213 int run = 0; 1213 int run = 0;
1214 int error = 0; 1214 int error = 0;
@@ -1346,21 +1346,21 @@ out:
1346 * Returns: errno 1346 * Returns: errno
1347 */ 1347 */
1348 1348
1349static int dir_e_read(struct inode *inode, uint64_t *offset, void *opaque, 1349static int dir_e_read(struct inode *inode, u64 *offset, void *opaque,
1350 gfs2_filldir_t filldir) 1350 gfs2_filldir_t filldir)
1351{ 1351{
1352 struct gfs2_inode *dip = GFS2_I(inode); 1352 struct gfs2_inode *dip = GFS2_I(inode);
1353 struct gfs2_sbd *sdp = GFS2_SB(inode); 1353 struct gfs2_sbd *sdp = GFS2_SB(inode);
1354 uint32_t hsize, len = 0; 1354 u32 hsize, len = 0;
1355 uint32_t ht_offset, lp_offset, ht_offset_cur = -1; 1355 u32 ht_offset, lp_offset, ht_offset_cur = -1;
1356 uint32_t hash, index; 1356 u32 hash, index;
1357 uint64_t *lp; 1357 u64 *lp;
1358 int copied = 0; 1358 int copied = 0;
1359 int error = 0; 1359 int error = 0;
1360 unsigned depth = 0; 1360 unsigned depth = 0;
1361 1361
1362 hsize = 1 << dip->i_di.di_depth; 1362 hsize = 1 << dip->i_di.di_depth;
1363 if (hsize * sizeof(uint64_t) != dip->i_di.di_size) { 1363 if (hsize * sizeof(u64) != dip->i_di.di_size) {
1364 gfs2_consist_inode(dip); 1364 gfs2_consist_inode(dip);
1365 return -EIO; 1365 return -EIO;
1366 } 1366 }
@@ -1378,7 +1378,7 @@ static int dir_e_read(struct inode *inode, uint64_t *offset, void *opaque,
1378 1378
1379 if (ht_offset_cur != ht_offset) { 1379 if (ht_offset_cur != ht_offset) {
1380 error = gfs2_dir_read_data(dip, (char *)lp, 1380 error = gfs2_dir_read_data(dip, (char *)lp,
1381 ht_offset * sizeof(uint64_t), 1381 ht_offset * sizeof(u64),
1382 sdp->sd_hash_bsize); 1382 sdp->sd_hash_bsize);
1383 if (error != sdp->sd_hash_bsize) { 1383 if (error != sdp->sd_hash_bsize) {
1384 if (error >= 0) 1384 if (error >= 0)
@@ -1405,7 +1405,7 @@ out:
1405 return error; 1405 return error;
1406} 1406}
1407 1407
1408int gfs2_dir_read(struct inode *inode, uint64_t *offset, void *opaque, 1408int gfs2_dir_read(struct inode *inode, u64 *offset, void *opaque,
1409 gfs2_filldir_t filldir) 1409 gfs2_filldir_t filldir)
1410{ 1410{
1411 struct gfs2_inode *dip = GFS2_I(inode); 1411 struct gfs2_inode *dip = GFS2_I(inode);
@@ -1725,15 +1725,15 @@ static int foreach_leaf(struct gfs2_inode *dip, leaf_call_t lc, void *data)
1725 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); 1725 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
1726 struct buffer_head *bh; 1726 struct buffer_head *bh;
1727 struct gfs2_leaf *leaf; 1727 struct gfs2_leaf *leaf;
1728 uint32_t hsize, len; 1728 u32 hsize, len;
1729 uint32_t ht_offset, lp_offset, ht_offset_cur = -1; 1729 u32 ht_offset, lp_offset, ht_offset_cur = -1;
1730 uint32_t index = 0; 1730 u32 index = 0;
1731 uint64_t *lp; 1731 u64 *lp;
1732 uint64_t leaf_no; 1732 u64 leaf_no;
1733 int error = 0; 1733 int error = 0;
1734 1734
1735 hsize = 1 << dip->i_di.di_depth; 1735 hsize = 1 << dip->i_di.di_depth;
1736 if (hsize * sizeof(uint64_t) != dip->i_di.di_size) { 1736 if (hsize * sizeof(u64) != dip->i_di.di_size) {
1737 gfs2_consist_inode(dip); 1737 gfs2_consist_inode(dip);
1738 return -EIO; 1738 return -EIO;
1739 } 1739 }
@@ -1748,7 +1748,7 @@ static int foreach_leaf(struct gfs2_inode *dip, leaf_call_t lc, void *data)
1748 1748
1749 if (ht_offset_cur != ht_offset) { 1749 if (ht_offset_cur != ht_offset) {
1750 error = gfs2_dir_read_data(dip, (char *)lp, 1750 error = gfs2_dir_read_data(dip, (char *)lp,
1751 ht_offset * sizeof(uint64_t), 1751 ht_offset * sizeof(u64),
1752 sdp->sd_hash_bsize); 1752 sdp->sd_hash_bsize);
1753 if (error != sdp->sd_hash_bsize) { 1753 if (error != sdp->sd_hash_bsize) {
1754 if (error >= 0) 1754 if (error >= 0)
@@ -1798,17 +1798,17 @@ out:
1798 * Returns: errno 1798 * Returns: errno
1799 */ 1799 */
1800 1800
1801static int leaf_dealloc(struct gfs2_inode *dip, uint32_t index, uint32_t len, 1801static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
1802 uint64_t leaf_no, void *data) 1802 u64 leaf_no, void *data)
1803{ 1803{
1804 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); 1804 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
1805 struct gfs2_leaf *tmp_leaf; 1805 struct gfs2_leaf *tmp_leaf;
1806 struct gfs2_rgrp_list rlist; 1806 struct gfs2_rgrp_list rlist;
1807 struct buffer_head *bh, *dibh; 1807 struct buffer_head *bh, *dibh;
1808 uint64_t blk, nblk; 1808 u64 blk, nblk;
1809 unsigned int rg_blocks = 0, l_blocks = 0; 1809 unsigned int rg_blocks = 0, l_blocks = 0;
1810 char *ht; 1810 char *ht;
1811 unsigned int x, size = len * sizeof(uint64_t); 1811 unsigned int x, size = len * sizeof(u64);
1812 int error; 1812 int error;
1813 1813
1814 memset(&rlist, 0, sizeof(struct gfs2_rgrp_list)); 1814 memset(&rlist, 0, sizeof(struct gfs2_rgrp_list));
@@ -1874,7 +1874,7 @@ static int leaf_dealloc(struct gfs2_inode *dip, uint32_t index, uint32_t len,
1874 dip->i_di.di_blocks--; 1874 dip->i_di.di_blocks--;
1875 } 1875 }
1876 1876
1877 error = gfs2_dir_write_data(dip, ht, index * sizeof(uint64_t), size); 1877 error = gfs2_dir_write_data(dip, ht, index * sizeof(u64), size);
1878 if (error != size) { 1878 if (error != size) {
1879 if (error >= 0) 1879 if (error >= 0)
1880 error = -EIO; 1880 error = -EIO;