aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2008-11-03 08:59:19 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2009-01-05 02:38:56 -0500
commitad6203f2b46c2217f74b2e88299640eef5889e72 (patch)
tree24197a5bc7ffac80071d2375ff46947cabe9b365 /fs/gfs2
parentbcf0b5b348a1f49c2c878ffdb78e68c930baabb8 (diff)
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>
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/dir.c20
-rw-r--r--fs/gfs2/incore.h3
-rw-r--r--fs/gfs2/inode.c10
-rw-r--r--fs/gfs2/ops_inode.c14
4 files changed, 23 insertions, 24 deletions
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index eed040d8ba3a..830cf48184e3 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -858,8 +858,8 @@ static int dir_make_exhash(struct inode *inode)
858 return -ENOSPC; 858 return -ENOSPC;
859 bn = bh->b_blocknr; 859 bn = bh->b_blocknr;
860 860
861 gfs2_assert(sdp, dip->i_di.di_entries < (1 << 16)); 861 gfs2_assert(sdp, dip->i_entries < (1 << 16));
862 leaf->lf_entries = cpu_to_be16(dip->i_di.di_entries); 862 leaf->lf_entries = cpu_to_be16(dip->i_entries);
863 863
864 /* Copy dirents */ 864 /* Copy dirents */
865 865
@@ -1426,7 +1426,7 @@ int gfs2_dir_read(struct inode *inode, u64 *offset, void *opaque,
1426 int copied = 0; 1426 int copied = 0;
1427 int error; 1427 int error;
1428 1428
1429 if (!dip->i_di.di_entries) 1429 if (!dip->i_entries)
1430 return 0; 1430 return 0;
1431 1431
1432 if (dip->i_di.di_flags & GFS2_DIF_EXHASH) 1432 if (dip->i_di.di_flags & GFS2_DIF_EXHASH)
@@ -1453,17 +1453,17 @@ int gfs2_dir_read(struct inode *inode, u64 *offset, void *opaque,
1453 error = PTR_ERR(dent); 1453 error = PTR_ERR(dent);
1454 goto out; 1454 goto out;
1455 } 1455 }
1456 if (dip->i_di.di_entries != g.offset) { 1456 if (dip->i_entries != g.offset) {
1457 fs_warn(sdp, "Number of entries corrupt in dir %llu, " 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 (unsigned long long)dip->i_no_addr, 1459 (unsigned long long)dip->i_no_addr,
1460 dip->i_di.di_entries, 1460 dip->i_entries,
1461 g.offset); 1461 g.offset);
1462 error = -EIO; 1462 error = -EIO;
1463 goto out; 1463 goto out;
1464 } 1464 }
1465 error = do_filldir_main(dip, offset, opaque, filldir, darr, 1465 error = do_filldir_main(dip, offset, opaque, filldir, darr,
1466 dip->i_di.di_entries, &copied); 1466 dip->i_entries, &copied);
1467out: 1467out:
1468 kfree(darr); 1468 kfree(darr);
1469 } 1469 }
@@ -1621,7 +1621,7 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name,
1621 if (error) 1621 if (error)
1622 break; 1622 break;
1623 gfs2_trans_add_bh(ip->i_gl, bh, 1); 1623 gfs2_trans_add_bh(ip->i_gl, bh, 1);
1624 ip->i_di.di_entries++; 1624 ip->i_entries++;
1625 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; 1625 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME;
1626 gfs2_dinode_out(ip, bh->b_data); 1626 gfs2_dinode_out(ip, bh->b_data);
1627 brelse(bh); 1627 brelse(bh);
@@ -1704,10 +1704,10 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *name)
1704 if (error) 1704 if (error)
1705 return error; 1705 return error;
1706 1706
1707 if (!dip->i_di.di_entries) 1707 if (!dip->i_entries)
1708 gfs2_consist_inode(dip); 1708 gfs2_consist_inode(dip);
1709 gfs2_trans_add_bh(dip->i_gl, bh, 1); 1709 gfs2_trans_add_bh(dip->i_gl, bh, 1);
1710 dip->i_di.di_entries--; 1710 dip->i_entries--;
1711 dip->i_inode.i_mtime = dip->i_inode.i_ctime = CURRENT_TIME; 1711 dip->i_inode.i_mtime = dip->i_inode.i_ctime = CURRENT_TIME;
1712 gfs2_dinode_out(dip, bh->b_data); 1712 gfs2_dinode_out(dip, bh->b_data);
1713 brelse(bh); 1713 brelse(bh);
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index 4ff1d7ecd98a..15ca3a75cf12 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -236,8 +236,6 @@ enum {
236struct gfs2_dinode_host { 236struct gfs2_dinode_host {
237 u64 di_size; /* number of bytes in file */ 237 u64 di_size; /* number of bytes in file */
238 u32 di_flags; /* GFS2_DIF_... */ 238 u32 di_flags; /* GFS2_DIF_... */
239 /* These only apply to directories */
240 u32 di_entries; /* The number of entries in the directory */
241 u64 di_eattr; /* extended attribute block number */ 239 u64 di_eattr; /* extended attribute block number */
242}; 240};
243 241
@@ -256,6 +254,7 @@ struct gfs2_inode {
256 struct gfs2_alloc *i_alloc; 254 struct gfs2_alloc *i_alloc;
257 u64 i_goal; /* goal block for allocations */ 255 u64 i_goal; /* goal block for allocations */
258 struct rw_semaphore i_rw_mutex; 256 struct rw_semaphore i_rw_mutex;
257 u32 i_entries;
259 u8 i_height; 258 u8 i_height;
260 u8 i_depth; 259 u8 i_depth;
261}; 260};
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 9d97f699c81a..015d4c007086 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -299,7 +299,7 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
299 if (unlikely(depth > GFS2_DIR_MAX_DEPTH)) 299 if (unlikely(depth > GFS2_DIR_MAX_DEPTH))
300 goto corrupt; 300 goto corrupt;
301 ip->i_depth = (u8)depth; 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 di->di_eattr = be64_to_cpu(str->di_eattr); 304 di->di_eattr = be64_to_cpu(str->di_eattr);
305 if (S_ISREG(ip->i_inode.i_mode)) 305 if (S_ISREG(ip->i_inode.i_mode))
@@ -689,7 +689,7 @@ static int create_ok(struct gfs2_inode *dip, const struct qstr *name,
689 return error; 689 return error;
690 } 690 }
691 691
692 if (dip->i_di.di_entries == (u32)-1) 692 if (dip->i_entries == (u32)-1)
693 return -EFBIG; 693 return -EFBIG;
694 if (S_ISDIR(mode) && dip->i_inode.i_nlink == (u32)-1) 694 if (S_ISDIR(mode) && dip->i_inode.i_nlink == (u32)-1)
695 return -EMLINK; 695 return -EMLINK;
@@ -1067,7 +1067,7 @@ int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name,
1067 struct qstr dotname; 1067 struct qstr dotname;
1068 int error; 1068 int error;
1069 1069
1070 if (ip->i_di.di_entries != 2) { 1070 if (ip->i_entries != 2) {
1071 if (gfs2_consist_inode(ip)) 1071 if (gfs2_consist_inode(ip))
1072 gfs2_dinode_print(ip); 1072 gfs2_dinode_print(ip);
1073 return -EIO; 1073 return -EIO;
@@ -1271,7 +1271,7 @@ void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
1271 !(ip->i_di.di_flags & GFS2_DIF_EXHASH) ? 1271 !(ip->i_di.di_flags & GFS2_DIF_EXHASH) ?
1272 GFS2_FORMAT_DE : 0); 1272 GFS2_FORMAT_DE : 0);
1273 str->di_depth = cpu_to_be16(ip->i_depth); 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 str->di_eattr = cpu_to_be64(di->di_eattr); 1276 str->di_eattr = cpu_to_be64(di->di_eattr);
1277 str->di_atime_nsec = cpu_to_be32(ip->i_inode.i_atime.tv_nsec); 1277 str->di_atime_nsec = cpu_to_be32(ip->i_inode.i_atime.tv_nsec);
@@ -1295,7 +1295,7 @@ void gfs2_dinode_print(const struct gfs2_inode *ip)
1295 printk(KERN_INFO " di_flags = 0x%.8X\n", di->di_flags); 1295 printk(KERN_INFO " di_flags = 0x%.8X\n", di->di_flags);
1296 printk(KERN_INFO " i_height = %u\n", ip->i_height); 1296 printk(KERN_INFO " i_height = %u\n", ip->i_height);
1297 printk(KERN_INFO " i_depth = %u\n", ip->i_depth); 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 printk(KERN_INFO " di_eattr = %llu\n", 1299 printk(KERN_INFO " di_eattr = %llu\n",
1300 (unsigned long long)di->di_eattr); 1300 (unsigned long long)di->di_eattr);
1301} 1301}
diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c
index 98440fef01cf..48468f48d7bf 100644
--- a/fs/gfs2/ops_inode.c
+++ b/fs/gfs2/ops_inode.c
@@ -185,7 +185,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
185 if (!dip->i_inode.i_nlink) 185 if (!dip->i_inode.i_nlink)
186 goto out_gunlock; 186 goto out_gunlock;
187 error = -EFBIG; 187 error = -EFBIG;
188 if (dip->i_di.di_entries == (u32)-1) 188 if (dip->i_entries == (u32)-1)
189 goto out_gunlock; 189 goto out_gunlock;
190 error = -EPERM; 190 error = -EPERM;
191 if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) 191 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
@@ -427,7 +427,7 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)
427 ip->i_inode.i_nlink = 2; 427 ip->i_inode.i_nlink = 2;
428 ip->i_di.di_size = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode); 428 ip->i_di.di_size = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode);
429 ip->i_di.di_flags |= GFS2_DIF_JDATA; 429 ip->i_di.di_flags |= GFS2_DIF_JDATA;
430 ip->i_di.di_entries = 2; 430 ip->i_entries = 2;
431 431
432 error = gfs2_meta_inode_buffer(ip, &dibh); 432 error = gfs2_meta_inode_buffer(ip, &dibh);
433 433
@@ -517,13 +517,13 @@ static int gfs2_rmdir(struct inode *dir, struct dentry *dentry)
517 if (error) 517 if (error)
518 goto out_gunlock; 518 goto out_gunlock;
519 519
520 if (ip->i_di.di_entries < 2) { 520 if (ip->i_entries < 2) {
521 if (gfs2_consist_inode(ip)) 521 if (gfs2_consist_inode(ip))
522 gfs2_dinode_print(ip); 522 gfs2_dinode_print(ip);
523 error = -EIO; 523 error = -EIO;
524 goto out_gunlock; 524 goto out_gunlock;
525 } 525 }
526 if (ip->i_di.di_entries > 2) { 526 if (ip->i_entries > 2) {
527 error = -ENOTEMPTY; 527 error = -ENOTEMPTY;
528 goto out_gunlock; 528 goto out_gunlock;
529 } 529 }
@@ -726,13 +726,13 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
726 goto out_gunlock; 726 goto out_gunlock;
727 727
728 if (S_ISDIR(nip->i_inode.i_mode)) { 728 if (S_ISDIR(nip->i_inode.i_mode)) {
729 if (nip->i_di.di_entries < 2) { 729 if (nip->i_entries < 2) {
730 if (gfs2_consist_inode(nip)) 730 if (gfs2_consist_inode(nip))
731 gfs2_dinode_print(nip); 731 gfs2_dinode_print(nip);
732 error = -EIO; 732 error = -EIO;
733 goto out_gunlock; 733 goto out_gunlock;
734 } 734 }
735 if (nip->i_di.di_entries > 2) { 735 if (nip->i_entries > 2) {
736 error = -ENOTEMPTY; 736 error = -ENOTEMPTY;
737 goto out_gunlock; 737 goto out_gunlock;
738 } 738 }
@@ -758,7 +758,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
758 error = -EINVAL; 758 error = -EINVAL;
759 goto out_gunlock; 759 goto out_gunlock;
760 } 760 }
761 if (ndip->i_di.di_entries == (u32)-1) { 761 if (ndip->i_entries == (u32)-1) {
762 error = -EFBIG; 762 error = -EFBIG;
763 goto out_gunlock; 763 goto out_gunlock;
764 } 764 }