Commit ad6203f2b46c2217f74b2e88299640eef5889e72

Authored by Steven Whitehouse
1 parent bcf0b5b348

GFS2: Move "entries" into "proper" inode

This moves the directory entry count into the proper inode.
Potentially we could get this to share the space used by
something else in the future, but this is one more step
on the way to removing the gfs2_dinode_host structure.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>

Showing 4 changed files with 23 additions and 24 deletions Side-by-side Diff

... ... @@ -858,8 +858,8 @@
858 858 return -ENOSPC;
859 859 bn = bh->b_blocknr;
860 860  
861   - gfs2_assert(sdp, dip->i_di.di_entries < (1 << 16));
862   - leaf->lf_entries = cpu_to_be16(dip->i_di.di_entries);
  861 + gfs2_assert(sdp, dip->i_entries < (1 << 16));
  862 + leaf->lf_entries = cpu_to_be16(dip->i_entries);
863 863  
864 864 /* Copy dirents */
865 865  
... ... @@ -1426,7 +1426,7 @@
1426 1426 int copied = 0;
1427 1427 int error;
1428 1428  
1429   - if (!dip->i_di.di_entries)
  1429 + if (!dip->i_entries)
1430 1430 return 0;
1431 1431  
1432 1432 if (dip->i_di.di_flags & GFS2_DIF_EXHASH)
1433 1433  
1434 1434  
1435 1435  
... ... @@ -1453,17 +1453,17 @@
1453 1453 error = PTR_ERR(dent);
1454 1454 goto out;
1455 1455 }
1456   - if (dip->i_di.di_entries != g.offset) {
  1456 + if (dip->i_entries != g.offset) {
1457 1457 fs_warn(sdp, "Number of entries corrupt in dir %llu, "
1458   - "ip->i_di.di_entries (%u) != g.offset (%u)\n",
  1458 + "ip->i_entries (%u) != g.offset (%u)\n",
1459 1459 (unsigned long long)dip->i_no_addr,
1460   - dip->i_di.di_entries,
  1460 + dip->i_entries,
1461 1461 g.offset);
1462 1462 error = -EIO;
1463 1463 goto out;
1464 1464 }
1465 1465 error = do_filldir_main(dip, offset, opaque, filldir, darr,
1466   - dip->i_di.di_entries, &copied);
  1466 + dip->i_entries, &copied);
1467 1467 out:
1468 1468 kfree(darr);
1469 1469 }
... ... @@ -1621,7 +1621,7 @@
1621 1621 if (error)
1622 1622 break;
1623 1623 gfs2_trans_add_bh(ip->i_gl, bh, 1);
1624   - ip->i_di.di_entries++;
  1624 + ip->i_entries++;
1625 1625 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME;
1626 1626 gfs2_dinode_out(ip, bh->b_data);
1627 1627 brelse(bh);
1628 1628  
... ... @@ -1704,10 +1704,10 @@
1704 1704 if (error)
1705 1705 return error;
1706 1706  
1707   - if (!dip->i_di.di_entries)
  1707 + if (!dip->i_entries)
1708 1708 gfs2_consist_inode(dip);
1709 1709 gfs2_trans_add_bh(dip->i_gl, bh, 1);
1710   - dip->i_di.di_entries--;
  1710 + dip->i_entries--;
1711 1711 dip->i_inode.i_mtime = dip->i_inode.i_ctime = CURRENT_TIME;
1712 1712 gfs2_dinode_out(dip, bh->b_data);
1713 1713 brelse(bh);
... ... @@ -236,8 +236,6 @@
236 236 struct gfs2_dinode_host {
237 237 u64 di_size; /* number of bytes in file */
238 238 u32 di_flags; /* GFS2_DIF_... */
239   - /* These only apply to directories */
240   - u32 di_entries; /* The number of entries in the directory */
241 239 u64 di_eattr; /* extended attribute block number */
242 240 };
243 241  
... ... @@ -256,6 +254,7 @@
256 254 struct gfs2_alloc *i_alloc;
257 255 u64 i_goal; /* goal block for allocations */
258 256 struct rw_semaphore i_rw_mutex;
  257 + u32 i_entries;
259 258 u8 i_height;
260 259 u8 i_depth;
261 260 };
... ... @@ -299,7 +299,7 @@
299 299 if (unlikely(depth > GFS2_DIR_MAX_DEPTH))
300 300 goto corrupt;
301 301 ip->i_depth = (u8)depth;
302   - di->di_entries = be32_to_cpu(str->di_entries);
  302 + ip->i_entries = be32_to_cpu(str->di_entries);
303 303  
304 304 di->di_eattr = be64_to_cpu(str->di_eattr);
305 305 if (S_ISREG(ip->i_inode.i_mode))
... ... @@ -689,7 +689,7 @@
689 689 return error;
690 690 }
691 691  
692   - if (dip->i_di.di_entries == (u32)-1)
  692 + if (dip->i_entries == (u32)-1)
693 693 return -EFBIG;
694 694 if (S_ISDIR(mode) && dip->i_inode.i_nlink == (u32)-1)
695 695 return -EMLINK;
... ... @@ -1067,7 +1067,7 @@
1067 1067 struct qstr dotname;
1068 1068 int error;
1069 1069  
1070   - if (ip->i_di.di_entries != 2) {
  1070 + if (ip->i_entries != 2) {
1071 1071 if (gfs2_consist_inode(ip))
1072 1072 gfs2_dinode_print(ip);
1073 1073 return -EIO;
... ... @@ -1271,7 +1271,7 @@
1271 1271 !(ip->i_di.di_flags & GFS2_DIF_EXHASH) ?
1272 1272 GFS2_FORMAT_DE : 0);
1273 1273 str->di_depth = cpu_to_be16(ip->i_depth);
1274   - str->di_entries = cpu_to_be32(di->di_entries);
  1274 + str->di_entries = cpu_to_be32(ip->i_entries);
1275 1275  
1276 1276 str->di_eattr = cpu_to_be64(di->di_eattr);
1277 1277 str->di_atime_nsec = cpu_to_be32(ip->i_inode.i_atime.tv_nsec);
... ... @@ -1295,7 +1295,7 @@
1295 1295 printk(KERN_INFO " di_flags = 0x%.8X\n", di->di_flags);
1296 1296 printk(KERN_INFO " i_height = %u\n", ip->i_height);
1297 1297 printk(KERN_INFO " i_depth = %u\n", ip->i_depth);
1298   - printk(KERN_INFO " di_entries = %u\n", di->di_entries);
  1298 + printk(KERN_INFO " i_entries = %u\n", ip->i_entries);
1299 1299 printk(KERN_INFO " di_eattr = %llu\n",
1300 1300 (unsigned long long)di->di_eattr);
1301 1301 }
... ... @@ -185,7 +185,7 @@
185 185 if (!dip->i_inode.i_nlink)
186 186 goto out_gunlock;
187 187 error = -EFBIG;
188   - if (dip->i_di.di_entries == (u32)-1)
  188 + if (dip->i_entries == (u32)-1)
189 189 goto out_gunlock;
190 190 error = -EPERM;
191 191 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
... ... @@ -427,7 +427,7 @@
427 427 ip->i_inode.i_nlink = 2;
428 428 ip->i_di.di_size = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode);
429 429 ip->i_di.di_flags |= GFS2_DIF_JDATA;
430   - ip->i_di.di_entries = 2;
  430 + ip->i_entries = 2;
431 431  
432 432 error = gfs2_meta_inode_buffer(ip, &dibh);
433 433  
434 434  
... ... @@ -517,13 +517,13 @@
517 517 if (error)
518 518 goto out_gunlock;
519 519  
520   - if (ip->i_di.di_entries < 2) {
  520 + if (ip->i_entries < 2) {
521 521 if (gfs2_consist_inode(ip))
522 522 gfs2_dinode_print(ip);
523 523 error = -EIO;
524 524 goto out_gunlock;
525 525 }
526   - if (ip->i_di.di_entries > 2) {
  526 + if (ip->i_entries > 2) {
527 527 error = -ENOTEMPTY;
528 528 goto out_gunlock;
529 529 }
530 530  
... ... @@ -726,13 +726,13 @@
726 726 goto out_gunlock;
727 727  
728 728 if (S_ISDIR(nip->i_inode.i_mode)) {
729   - if (nip->i_di.di_entries < 2) {
  729 + if (nip->i_entries < 2) {
730 730 if (gfs2_consist_inode(nip))
731 731 gfs2_dinode_print(nip);
732 732 error = -EIO;
733 733 goto out_gunlock;
734 734 }
735   - if (nip->i_di.di_entries > 2) {
  735 + if (nip->i_entries > 2) {
736 736 error = -ENOTEMPTY;
737 737 goto out_gunlock;
738 738 }
... ... @@ -758,7 +758,7 @@
758 758 error = -EINVAL;
759 759 goto out_gunlock;
760 760 }
761   - if (ndip->i_di.di_entries == (u32)-1) {
  761 + if (ndip->i_entries == (u32)-1) {
762 762 error = -EFBIG;
763 763 goto out_gunlock;
764 764 }