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.c103
1 files changed, 55 insertions, 48 deletions
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index 459498cac93b..0fdcb7713cd9 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -131,8 +131,8 @@ static int gfs2_dir_write_stuffed(struct gfs2_inode *ip, const char *buf,
131 memcpy(dibh->b_data + offset + sizeof(struct gfs2_dinode), buf, size); 131 memcpy(dibh->b_data + offset + sizeof(struct gfs2_dinode), buf, size);
132 if (ip->i_di.di_size < offset + size) 132 if (ip->i_di.di_size < offset + size)
133 ip->i_di.di_size = offset + size; 133 ip->i_di.di_size = offset + size;
134 ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds(); 134 ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds();
135 gfs2_dinode_out(&ip->i_di, dibh->b_data); 135 gfs2_dinode_out(ip, dibh->b_data);
136 136
137 brelse(dibh); 137 brelse(dibh);
138 138
@@ -184,7 +184,7 @@ static int gfs2_dir_write_data(struct gfs2_inode *ip, const char *buf,
184 while (copied < size) { 184 while (copied < size) {
185 unsigned int amount; 185 unsigned int amount;
186 struct buffer_head *bh; 186 struct buffer_head *bh;
187 int new; 187 int new = 0;
188 188
189 amount = size - copied; 189 amount = size - copied;
190 if (amount > sdp->sd_sb.sb_bsize - o) 190 if (amount > sdp->sd_sb.sb_bsize - o)
@@ -212,8 +212,6 @@ static int gfs2_dir_write_data(struct gfs2_inode *ip, const char *buf,
212 gfs2_trans_add_bh(ip->i_gl, bh, 1); 212 gfs2_trans_add_bh(ip->i_gl, bh, 1);
213 memcpy(bh->b_data + o, buf, amount); 213 memcpy(bh->b_data + o, buf, amount);
214 brelse(bh); 214 brelse(bh);
215 if (error)
216 goto fail;
217 215
218 buf += amount; 216 buf += amount;
219 copied += amount; 217 copied += amount;
@@ -231,10 +229,10 @@ out:
231 229
232 if (ip->i_di.di_size < offset + copied) 230 if (ip->i_di.di_size < offset + copied)
233 ip->i_di.di_size = offset + copied; 231 ip->i_di.di_size = offset + copied;
234 ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds(); 232 ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds();
235 233
236 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 234 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
237 gfs2_dinode_out(&ip->i_di, dibh->b_data); 235 gfs2_dinode_out(ip, dibh->b_data);
238 brelse(dibh); 236 brelse(dibh);
239 237
240 return copied; 238 return copied;
@@ -317,8 +315,7 @@ static int gfs2_dir_read_data(struct gfs2_inode *ip, char *buf, u64 offset,
317 if (!ra) 315 if (!ra)
318 extlen = 1; 316 extlen = 1;
319 bh = gfs2_meta_ra(ip->i_gl, dblock, extlen); 317 bh = gfs2_meta_ra(ip->i_gl, dblock, extlen);
320 } 318 } else {
321 if (!bh) {
322 error = gfs2_meta_read(ip->i_gl, dblock, DIO_WAIT, &bh); 319 error = gfs2_meta_read(ip->i_gl, dblock, DIO_WAIT, &bh);
323 if (error) 320 if (error)
324 goto fail; 321 goto fail;
@@ -332,7 +329,6 @@ static int gfs2_dir_read_data(struct gfs2_inode *ip, char *buf, u64 offset,
332 extlen--; 329 extlen--;
333 memcpy(buf, bh->b_data + o, amount); 330 memcpy(buf, bh->b_data + o, amount);
334 brelse(bh); 331 brelse(bh);
335 bh = NULL;
336 buf += amount; 332 buf += amount;
337 copied += amount; 333 copied += amount;
338 lblock++; 334 lblock++;
@@ -344,10 +340,15 @@ fail:
344 return (copied) ? copied : error; 340 return (copied) ? copied : error;
345} 341}
346 342
343static inline int gfs2_dirent_sentinel(const struct gfs2_dirent *dent)
344{
345 return dent->de_inum.no_addr == 0 || dent->de_inum.no_formal_ino == 0;
346}
347
347static inline int __gfs2_dirent_find(const struct gfs2_dirent *dent, 348static inline int __gfs2_dirent_find(const struct gfs2_dirent *dent,
348 const struct qstr *name, int ret) 349 const struct qstr *name, int ret)
349{ 350{
350 if (dent->de_inum.no_addr != 0 && 351 if (!gfs2_dirent_sentinel(dent) &&
351 be32_to_cpu(dent->de_hash) == name->hash && 352 be32_to_cpu(dent->de_hash) == name->hash &&
352 be16_to_cpu(dent->de_name_len) == name->len && 353 be16_to_cpu(dent->de_name_len) == name->len &&
353 memcmp(dent+1, name->name, name->len) == 0) 354 memcmp(dent+1, name->name, name->len) == 0)
@@ -392,7 +393,7 @@ static int gfs2_dirent_find_space(const struct gfs2_dirent *dent,
392 unsigned actual = GFS2_DIRENT_SIZE(be16_to_cpu(dent->de_name_len)); 393 unsigned actual = GFS2_DIRENT_SIZE(be16_to_cpu(dent->de_name_len));
393 unsigned totlen = be16_to_cpu(dent->de_rec_len); 394 unsigned totlen = be16_to_cpu(dent->de_rec_len);
394 395
395 if (!dent->de_inum.no_addr) 396 if (gfs2_dirent_sentinel(dent))
396 actual = GFS2_DIRENT_SIZE(0); 397 actual = GFS2_DIRENT_SIZE(0);
397 if (totlen - actual >= required) 398 if (totlen - actual >= required)
398 return 1; 399 return 1;
@@ -409,7 +410,7 @@ static int gfs2_dirent_gather(const struct gfs2_dirent *dent,
409 void *opaque) 410 void *opaque)
410{ 411{
411 struct dirent_gather *g = opaque; 412 struct dirent_gather *g = opaque;
412 if (dent->de_inum.no_addr) { 413 if (!gfs2_dirent_sentinel(dent)) {
413 g->pdent[g->offset++] = dent; 414 g->pdent[g->offset++] = dent;
414 } 415 }
415 return 0; 416 return 0;
@@ -437,10 +438,10 @@ static int gfs2_check_dirent(struct gfs2_dirent *dent, unsigned int offset,
437 if (unlikely(offset + size > len)) 438 if (unlikely(offset + size > len))
438 goto error; 439 goto error;
439 msg = "zero inode number"; 440 msg = "zero inode number";
440 if (unlikely(!first && !dent->de_inum.no_addr)) 441 if (unlikely(!first && gfs2_dirent_sentinel(dent)))
441 goto error; 442 goto error;
442 msg = "name length is greater than space in dirent"; 443 msg = "name length is greater than space in dirent";
443 if (dent->de_inum.no_addr && 444 if (!gfs2_dirent_sentinel(dent) &&
444 unlikely(sizeof(struct gfs2_dirent)+be16_to_cpu(dent->de_name_len) > 445 unlikely(sizeof(struct gfs2_dirent)+be16_to_cpu(dent->de_name_len) >
445 size)) 446 size))
446 goto error; 447 goto error;
@@ -602,7 +603,7 @@ static int dirent_next(struct gfs2_inode *dip, struct buffer_head *bh,
602 return ret; 603 return ret;
603 604
604 /* Only the first dent could ever have de_inum.no_addr == 0 */ 605 /* Only the first dent could ever have de_inum.no_addr == 0 */
605 if (!tmp->de_inum.no_addr) { 606 if (gfs2_dirent_sentinel(tmp)) {
606 gfs2_consist_inode(dip); 607 gfs2_consist_inode(dip);
607 return -EIO; 608 return -EIO;
608 } 609 }
@@ -625,7 +626,7 @@ static void dirent_del(struct gfs2_inode *dip, struct buffer_head *bh,
625{ 626{
626 u16 cur_rec_len, prev_rec_len; 627 u16 cur_rec_len, prev_rec_len;
627 628
628 if (!cur->de_inum.no_addr) { 629 if (gfs2_dirent_sentinel(cur)) {
629 gfs2_consist_inode(dip); 630 gfs2_consist_inode(dip);
630 return; 631 return;
631 } 632 }
@@ -637,7 +638,8 @@ static void dirent_del(struct gfs2_inode *dip, struct buffer_head *bh,
637 out the inode number and return. */ 638 out the inode number and return. */
638 639
639 if (!prev) { 640 if (!prev) {
640 cur->de_inum.no_addr = 0; /* No endianess worries */ 641 cur->de_inum.no_addr = 0;
642 cur->de_inum.no_formal_ino = 0;
641 return; 643 return;
642 } 644 }
643 645
@@ -668,7 +670,7 @@ static struct gfs2_dirent *gfs2_init_dirent(struct inode *inode,
668 struct gfs2_dirent *ndent; 670 struct gfs2_dirent *ndent;
669 unsigned offset = 0, totlen; 671 unsigned offset = 0, totlen;
670 672
671 if (dent->de_inum.no_addr) 673 if (!gfs2_dirent_sentinel(dent))
672 offset = GFS2_DIRENT_SIZE(be16_to_cpu(dent->de_name_len)); 674 offset = GFS2_DIRENT_SIZE(be16_to_cpu(dent->de_name_len));
673 totlen = be16_to_cpu(dent->de_rec_len); 675 totlen = be16_to_cpu(dent->de_rec_len);
674 BUG_ON(offset + name->len > totlen); 676 BUG_ON(offset + name->len > totlen);
@@ -717,12 +719,12 @@ static int get_leaf(struct gfs2_inode *dip, u64 leaf_no,
717static int get_leaf_nr(struct gfs2_inode *dip, u32 index, 719static int get_leaf_nr(struct gfs2_inode *dip, u32 index,
718 u64 *leaf_out) 720 u64 *leaf_out)
719{ 721{
720 u64 leaf_no; 722 __be64 leaf_no;
721 int error; 723 int error;
722 724
723 error = gfs2_dir_read_data(dip, (char *)&leaf_no, 725 error = gfs2_dir_read_data(dip, (char *)&leaf_no,
724 index * sizeof(u64), 726 index * sizeof(__be64),
725 sizeof(u64), 0); 727 sizeof(__be64), 0);
726 if (error != sizeof(u64)) 728 if (error != sizeof(u64))
727 return (error < 0) ? error : -EIO; 729 return (error < 0) ? error : -EIO;
728 730
@@ -815,7 +817,7 @@ static struct gfs2_leaf *new_leaf(struct inode *inode, struct buffer_head **pbh,
815 leaf = (struct gfs2_leaf *)bh->b_data; 817 leaf = (struct gfs2_leaf *)bh->b_data;
816 leaf->lf_depth = cpu_to_be16(depth); 818 leaf->lf_depth = cpu_to_be16(depth);
817 leaf->lf_entries = 0; 819 leaf->lf_entries = 0;
818 leaf->lf_dirent_format = cpu_to_be16(GFS2_FORMAT_DE); 820 leaf->lf_dirent_format = cpu_to_be32(GFS2_FORMAT_DE);
819 leaf->lf_next = 0; 821 leaf->lf_next = 0;
820 memset(leaf->lf_reserved, 0, sizeof(leaf->lf_reserved)); 822 memset(leaf->lf_reserved, 0, sizeof(leaf->lf_reserved));
821 dent = (struct gfs2_dirent *)(leaf+1); 823 dent = (struct gfs2_dirent *)(leaf+1);
@@ -841,7 +843,8 @@ static int dir_make_exhash(struct inode *inode)
841 struct gfs2_leaf *leaf; 843 struct gfs2_leaf *leaf;
842 int y; 844 int y;
843 u32 x; 845 u32 x;
844 u64 *lp, bn; 846 __be64 *lp;
847 u64 bn;
845 int error; 848 int error;
846 849
847 error = gfs2_meta_inode_buffer(dip, &dibh); 850 error = gfs2_meta_inode_buffer(dip, &dibh);
@@ -897,20 +900,20 @@ static int dir_make_exhash(struct inode *inode)
897 gfs2_trans_add_bh(dip->i_gl, dibh, 1); 900 gfs2_trans_add_bh(dip->i_gl, dibh, 1);
898 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode)); 901 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
899 902
900 lp = (u64 *)(dibh->b_data + sizeof(struct gfs2_dinode)); 903 lp = (__be64 *)(dibh->b_data + sizeof(struct gfs2_dinode));
901 904
902 for (x = sdp->sd_hash_ptrs; x--; lp++) 905 for (x = sdp->sd_hash_ptrs; x--; lp++)
903 *lp = cpu_to_be64(bn); 906 *lp = cpu_to_be64(bn);
904 907
905 dip->i_di.di_size = sdp->sd_sb.sb_bsize / 2; 908 dip->i_di.di_size = sdp->sd_sb.sb_bsize / 2;
906 dip->i_di.di_blocks++; 909 dip->i_di.di_blocks++;
910 gfs2_set_inode_blocks(&dip->i_inode);
907 dip->i_di.di_flags |= GFS2_DIF_EXHASH; 911 dip->i_di.di_flags |= GFS2_DIF_EXHASH;
908 dip->i_di.di_payload_format = 0;
909 912
910 for (x = sdp->sd_hash_ptrs, y = -1; x; x >>= 1, y++) ; 913 for (x = sdp->sd_hash_ptrs, y = -1; x; x >>= 1, y++) ;
911 dip->i_di.di_depth = y; 914 dip->i_di.di_depth = y;
912 915
913 gfs2_dinode_out(&dip->i_di, dibh->b_data); 916 gfs2_dinode_out(dip, dibh->b_data);
914 917
915 brelse(dibh); 918 brelse(dibh);
916 919
@@ -933,7 +936,8 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
933 struct gfs2_leaf *nleaf, *oleaf; 936 struct gfs2_leaf *nleaf, *oleaf;
934 struct gfs2_dirent *dent = NULL, *prev = NULL, *next = NULL, *new; 937 struct gfs2_dirent *dent = NULL, *prev = NULL, *next = NULL, *new;
935 u32 start, len, half_len, divider; 938 u32 start, len, half_len, divider;
936 u64 bn, *lp, leaf_no; 939 u64 bn, leaf_no;
940 __be64 *lp;
937 u32 index; 941 u32 index;
938 int x, moved = 0; 942 int x, moved = 0;
939 int error; 943 int error;
@@ -978,7 +982,7 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
978 /* Change the pointers. 982 /* Change the pointers.
979 Don't bother distinguishing stuffed from non-stuffed. 983 Don't bother distinguishing stuffed from non-stuffed.
980 This code is complicated enough already. */ 984 This code is complicated enough already. */
981 lp = kmalloc(half_len * sizeof(u64), GFP_NOFS | __GFP_NOFAIL); 985 lp = kmalloc(half_len * sizeof(__be64), GFP_NOFS | __GFP_NOFAIL);
982 /* Change the pointers */ 986 /* Change the pointers */
983 for (x = 0; x < half_len; x++) 987 for (x = 0; x < half_len; x++)
984 lp[x] = cpu_to_be64(bn); 988 lp[x] = cpu_to_be64(bn);
@@ -1004,7 +1008,7 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
1004 if (dirent_next(dip, obh, &next)) 1008 if (dirent_next(dip, obh, &next))
1005 next = NULL; 1009 next = NULL;
1006 1010
1007 if (dent->de_inum.no_addr && 1011 if (!gfs2_dirent_sentinel(dent) &&
1008 be32_to_cpu(dent->de_hash) < divider) { 1012 be32_to_cpu(dent->de_hash) < divider) {
1009 struct qstr str; 1013 struct qstr str;
1010 str.name = (char*)(dent+1); 1014 str.name = (char*)(dent+1);
@@ -1041,7 +1045,8 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
1041 error = gfs2_meta_inode_buffer(dip, &dibh); 1045 error = gfs2_meta_inode_buffer(dip, &dibh);
1042 if (!gfs2_assert_withdraw(GFS2_SB(&dip->i_inode), !error)) { 1046 if (!gfs2_assert_withdraw(GFS2_SB(&dip->i_inode), !error)) {
1043 dip->i_di.di_blocks++; 1047 dip->i_di.di_blocks++;
1044 gfs2_dinode_out(&dip->i_di, dibh->b_data); 1048 gfs2_set_inode_blocks(&dip->i_inode);
1049 gfs2_dinode_out(dip, dibh->b_data);
1045 brelse(dibh); 1050 brelse(dibh);
1046 } 1051 }
1047 1052
@@ -1121,7 +1126,7 @@ static int dir_double_exhash(struct gfs2_inode *dip)
1121 error = gfs2_meta_inode_buffer(dip, &dibh); 1126 error = gfs2_meta_inode_buffer(dip, &dibh);
1122 if (!gfs2_assert_withdraw(sdp, !error)) { 1127 if (!gfs2_assert_withdraw(sdp, !error)) {
1123 dip->i_di.di_depth++; 1128 dip->i_di.di_depth++;
1124 gfs2_dinode_out(&dip->i_di, dibh->b_data); 1129 gfs2_dinode_out(dip, dibh->b_data);
1125 brelse(dibh); 1130 brelse(dibh);
1126 } 1131 }
1127 1132
@@ -1198,7 +1203,7 @@ static int do_filldir_main(struct gfs2_inode *dip, u64 *offset,
1198 int *copied) 1203 int *copied)
1199{ 1204{
1200 const struct gfs2_dirent *dent, *dent_next; 1205 const struct gfs2_dirent *dent, *dent_next;
1201 struct gfs2_inum inum; 1206 struct gfs2_inum_host inum;
1202 u64 off, off_next; 1207 u64 off, off_next;
1203 unsigned int x, y; 1208 unsigned int x, y;
1204 int run = 0; 1209 int run = 0;
@@ -1345,7 +1350,7 @@ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque,
1345 u32 hsize, len = 0; 1350 u32 hsize, len = 0;
1346 u32 ht_offset, lp_offset, ht_offset_cur = -1; 1351 u32 ht_offset, lp_offset, ht_offset_cur = -1;
1347 u32 hash, index; 1352 u32 hash, index;
1348 u64 *lp; 1353 __be64 *lp;
1349 int copied = 0; 1354 int copied = 0;
1350 int error = 0; 1355 int error = 0;
1351 unsigned depth = 0; 1356 unsigned depth = 0;
@@ -1369,7 +1374,7 @@ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque,
1369 1374
1370 if (ht_offset_cur != ht_offset) { 1375 if (ht_offset_cur != ht_offset) {
1371 error = gfs2_dir_read_data(dip, (char *)lp, 1376 error = gfs2_dir_read_data(dip, (char *)lp,
1372 ht_offset * sizeof(u64), 1377 ht_offset * sizeof(__be64),
1373 sdp->sd_hash_bsize, 1); 1378 sdp->sd_hash_bsize, 1);
1374 if (error != sdp->sd_hash_bsize) { 1379 if (error != sdp->sd_hash_bsize) {
1375 if (error >= 0) 1380 if (error >= 0)
@@ -1460,7 +1465,7 @@ out:
1460 */ 1465 */
1461 1466
1462int gfs2_dir_search(struct inode *dir, const struct qstr *name, 1467int gfs2_dir_search(struct inode *dir, const struct qstr *name,
1463 struct gfs2_inum *inum, unsigned int *type) 1468 struct gfs2_inum_host *inum, unsigned int *type)
1464{ 1469{
1465 struct buffer_head *bh; 1470 struct buffer_head *bh;
1466 struct gfs2_dirent *dent; 1471 struct gfs2_dirent *dent;
@@ -1519,7 +1524,8 @@ static int dir_new_leaf(struct inode *inode, const struct qstr *name)
1519 return error; 1524 return error;
1520 gfs2_trans_add_bh(ip->i_gl, bh, 1); 1525 gfs2_trans_add_bh(ip->i_gl, bh, 1);
1521 ip->i_di.di_blocks++; 1526 ip->i_di.di_blocks++;
1522 gfs2_dinode_out(&ip->i_di, bh->b_data); 1527 gfs2_set_inode_blocks(&ip->i_inode);
1528 gfs2_dinode_out(ip, bh->b_data);
1523 brelse(bh); 1529 brelse(bh);
1524 return 0; 1530 return 0;
1525} 1531}
@@ -1535,7 +1541,7 @@ static int dir_new_leaf(struct inode *inode, const struct qstr *name)
1535 */ 1541 */
1536 1542
1537int gfs2_dir_add(struct inode *inode, const struct qstr *name, 1543int gfs2_dir_add(struct inode *inode, const struct qstr *name,
1538 const struct gfs2_inum *inum, unsigned type) 1544 const struct gfs2_inum_host *inum, unsigned type)
1539{ 1545{
1540 struct gfs2_inode *ip = GFS2_I(inode); 1546 struct gfs2_inode *ip = GFS2_I(inode);
1541 struct buffer_head *bh; 1547 struct buffer_head *bh;
@@ -1562,8 +1568,8 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name,
1562 break; 1568 break;
1563 gfs2_trans_add_bh(ip->i_gl, bh, 1); 1569 gfs2_trans_add_bh(ip->i_gl, bh, 1);
1564 ip->i_di.di_entries++; 1570 ip->i_di.di_entries++;
1565 ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds(); 1571 ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds();
1566 gfs2_dinode_out(&ip->i_di, bh->b_data); 1572 gfs2_dinode_out(ip, bh->b_data);
1567 brelse(bh); 1573 brelse(bh);
1568 error = 0; 1574 error = 0;
1569 break; 1575 break;
@@ -1648,8 +1654,8 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *name)
1648 gfs2_consist_inode(dip); 1654 gfs2_consist_inode(dip);
1649 gfs2_trans_add_bh(dip->i_gl, bh, 1); 1655 gfs2_trans_add_bh(dip->i_gl, bh, 1);
1650 dip->i_di.di_entries--; 1656 dip->i_di.di_entries--;
1651 dip->i_di.di_mtime = dip->i_di.di_ctime = get_seconds(); 1657 dip->i_inode.i_mtime.tv_sec = dip->i_inode.i_ctime.tv_sec = get_seconds();
1652 gfs2_dinode_out(&dip->i_di, bh->b_data); 1658 gfs2_dinode_out(dip, bh->b_data);
1653 brelse(bh); 1659 brelse(bh);
1654 mark_inode_dirty(&dip->i_inode); 1660 mark_inode_dirty(&dip->i_inode);
1655 1661
@@ -1670,7 +1676,7 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *name)
1670 */ 1676 */
1671 1677
1672int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename, 1678int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename,
1673 struct gfs2_inum *inum, unsigned int new_type) 1679 struct gfs2_inum_host *inum, unsigned int new_type)
1674{ 1680{
1675 struct buffer_head *bh; 1681 struct buffer_head *bh;
1676 struct gfs2_dirent *dent; 1682 struct gfs2_dirent *dent;
@@ -1696,8 +1702,8 @@ int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename,
1696 gfs2_trans_add_bh(dip->i_gl, bh, 1); 1702 gfs2_trans_add_bh(dip->i_gl, bh, 1);
1697 } 1703 }
1698 1704
1699 dip->i_di.di_mtime = dip->i_di.di_ctime = get_seconds(); 1705 dip->i_inode.i_mtime.tv_sec = dip->i_inode.i_ctime.tv_sec = get_seconds();
1700 gfs2_dinode_out(&dip->i_di, bh->b_data); 1706 gfs2_dinode_out(dip, bh->b_data);
1701 brelse(bh); 1707 brelse(bh);
1702 return 0; 1708 return 0;
1703} 1709}
@@ -1719,7 +1725,7 @@ static int foreach_leaf(struct gfs2_inode *dip, leaf_call_t lc, void *data)
1719 u32 hsize, len; 1725 u32 hsize, len;
1720 u32 ht_offset, lp_offset, ht_offset_cur = -1; 1726 u32 ht_offset, lp_offset, ht_offset_cur = -1;
1721 u32 index = 0; 1727 u32 index = 0;
1722 u64 *lp; 1728 __be64 *lp;
1723 u64 leaf_no; 1729 u64 leaf_no;
1724 int error = 0; 1730 int error = 0;
1725 1731
@@ -1739,7 +1745,7 @@ static int foreach_leaf(struct gfs2_inode *dip, leaf_call_t lc, void *data)
1739 1745
1740 if (ht_offset_cur != ht_offset) { 1746 if (ht_offset_cur != ht_offset) {
1741 error = gfs2_dir_read_data(dip, (char *)lp, 1747 error = gfs2_dir_read_data(dip, (char *)lp,
1742 ht_offset * sizeof(u64), 1748 ht_offset * sizeof(__be64),
1743 sdp->sd_hash_bsize, 1); 1749 sdp->sd_hash_bsize, 1);
1744 if (error != sdp->sd_hash_bsize) { 1750 if (error != sdp->sd_hash_bsize) {
1745 if (error >= 0) 1751 if (error >= 0)
@@ -1863,6 +1869,7 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
1863 if (!dip->i_di.di_blocks) 1869 if (!dip->i_di.di_blocks)
1864 gfs2_consist_inode(dip); 1870 gfs2_consist_inode(dip);
1865 dip->i_di.di_blocks--; 1871 dip->i_di.di_blocks--;
1872 gfs2_set_inode_blocks(&dip->i_inode);
1866 } 1873 }
1867 1874
1868 error = gfs2_dir_write_data(dip, ht, index * sizeof(u64), size); 1875 error = gfs2_dir_write_data(dip, ht, index * sizeof(u64), size);
@@ -1877,7 +1884,7 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
1877 goto out_end_trans; 1884 goto out_end_trans;
1878 1885
1879 gfs2_trans_add_bh(dip->i_gl, dibh, 1); 1886 gfs2_trans_add_bh(dip->i_gl, dibh, 1);
1880 gfs2_dinode_out(&dip->i_di, dibh->b_data); 1887 gfs2_dinode_out(dip, dibh->b_data);
1881 brelse(dibh); 1888 brelse(dibh);
1882 1889
1883out_end_trans: 1890out_end_trans: