提交 ad6203f2 编写于 作者: S Steven Whitehouse

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: NSteven Whitehouse <swhiteho@redhat.com>
上级 bcf0b5b3
...@@ -858,8 +858,8 @@ static int dir_make_exhash(struct inode *inode) ...@@ -858,8 +858,8 @@ static int dir_make_exhash(struct inode *inode)
return -ENOSPC; return -ENOSPC;
bn = bh->b_blocknr; bn = bh->b_blocknr;
gfs2_assert(sdp, dip->i_di.di_entries < (1 << 16)); gfs2_assert(sdp, dip->i_entries < (1 << 16));
leaf->lf_entries = cpu_to_be16(dip->i_di.di_entries); leaf->lf_entries = cpu_to_be16(dip->i_entries);
/* Copy dirents */ /* Copy dirents */
...@@ -1426,7 +1426,7 @@ int gfs2_dir_read(struct inode *inode, u64 *offset, void *opaque, ...@@ -1426,7 +1426,7 @@ int gfs2_dir_read(struct inode *inode, u64 *offset, void *opaque,
int copied = 0; int copied = 0;
int error; int error;
if (!dip->i_di.di_entries) if (!dip->i_entries)
return 0; return 0;
if (dip->i_di.di_flags & GFS2_DIF_EXHASH) 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,17 +1453,17 @@ int gfs2_dir_read(struct inode *inode, u64 *offset, void *opaque,
error = PTR_ERR(dent); error = PTR_ERR(dent);
goto out; goto out;
} }
if (dip->i_di.di_entries != g.offset) { if (dip->i_entries != g.offset) {
fs_warn(sdp, "Number of entries corrupt in dir %llu, " fs_warn(sdp, "Number of entries corrupt in dir %llu, "
"ip->i_di.di_entries (%u) != g.offset (%u)\n", "ip->i_entries (%u) != g.offset (%u)\n",
(unsigned long long)dip->i_no_addr, (unsigned long long)dip->i_no_addr,
dip->i_di.di_entries, dip->i_entries,
g.offset); g.offset);
error = -EIO; error = -EIO;
goto out; goto out;
} }
error = do_filldir_main(dip, offset, opaque, filldir, darr, error = do_filldir_main(dip, offset, opaque, filldir, darr,
dip->i_di.di_entries, &copied); dip->i_entries, &copied);
out: out:
kfree(darr); kfree(darr);
} }
...@@ -1621,7 +1621,7 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name, ...@@ -1621,7 +1621,7 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name,
if (error) if (error)
break; break;
gfs2_trans_add_bh(ip->i_gl, bh, 1); gfs2_trans_add_bh(ip->i_gl, bh, 1);
ip->i_di.di_entries++; ip->i_entries++;
ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME;
gfs2_dinode_out(ip, bh->b_data); gfs2_dinode_out(ip, bh->b_data);
brelse(bh); brelse(bh);
...@@ -1704,10 +1704,10 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *name) ...@@ -1704,10 +1704,10 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *name)
if (error) if (error)
return error; return error;
if (!dip->i_di.di_entries) if (!dip->i_entries)
gfs2_consist_inode(dip); gfs2_consist_inode(dip);
gfs2_trans_add_bh(dip->i_gl, bh, 1); gfs2_trans_add_bh(dip->i_gl, bh, 1);
dip->i_di.di_entries--; dip->i_entries--;
dip->i_inode.i_mtime = dip->i_inode.i_ctime = CURRENT_TIME; dip->i_inode.i_mtime = dip->i_inode.i_ctime = CURRENT_TIME;
gfs2_dinode_out(dip, bh->b_data); gfs2_dinode_out(dip, bh->b_data);
brelse(bh); brelse(bh);
......
...@@ -236,8 +236,6 @@ enum { ...@@ -236,8 +236,6 @@ enum {
struct gfs2_dinode_host { struct gfs2_dinode_host {
u64 di_size; /* number of bytes in file */ u64 di_size; /* number of bytes in file */
u32 di_flags; /* GFS2_DIF_... */ u32 di_flags; /* GFS2_DIF_... */
/* These only apply to directories */
u32 di_entries; /* The number of entries in the directory */
u64 di_eattr; /* extended attribute block number */ u64 di_eattr; /* extended attribute block number */
}; };
...@@ -256,6 +254,7 @@ struct gfs2_inode { ...@@ -256,6 +254,7 @@ struct gfs2_inode {
struct gfs2_alloc *i_alloc; struct gfs2_alloc *i_alloc;
u64 i_goal; /* goal block for allocations */ u64 i_goal; /* goal block for allocations */
struct rw_semaphore i_rw_mutex; struct rw_semaphore i_rw_mutex;
u32 i_entries;
u8 i_height; u8 i_height;
u8 i_depth; u8 i_depth;
}; };
......
...@@ -299,7 +299,7 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf) ...@@ -299,7 +299,7 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
if (unlikely(depth > GFS2_DIR_MAX_DEPTH)) if (unlikely(depth > GFS2_DIR_MAX_DEPTH))
goto corrupt; goto corrupt;
ip->i_depth = (u8)depth; ip->i_depth = (u8)depth;
di->di_entries = be32_to_cpu(str->di_entries); ip->i_entries = be32_to_cpu(str->di_entries);
di->di_eattr = be64_to_cpu(str->di_eattr); di->di_eattr = be64_to_cpu(str->di_eattr);
if (S_ISREG(ip->i_inode.i_mode)) 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,7 +689,7 @@ static int create_ok(struct gfs2_inode *dip, const struct qstr *name,
return error; return error;
} }
if (dip->i_di.di_entries == (u32)-1) if (dip->i_entries == (u32)-1)
return -EFBIG; return -EFBIG;
if (S_ISDIR(mode) && dip->i_inode.i_nlink == (u32)-1) if (S_ISDIR(mode) && dip->i_inode.i_nlink == (u32)-1)
return -EMLINK; return -EMLINK;
...@@ -1067,7 +1067,7 @@ int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name, ...@@ -1067,7 +1067,7 @@ int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name,
struct qstr dotname; struct qstr dotname;
int error; int error;
if (ip->i_di.di_entries != 2) { if (ip->i_entries != 2) {
if (gfs2_consist_inode(ip)) if (gfs2_consist_inode(ip))
gfs2_dinode_print(ip); gfs2_dinode_print(ip);
return -EIO; return -EIO;
...@@ -1271,7 +1271,7 @@ void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf) ...@@ -1271,7 +1271,7 @@ void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
!(ip->i_di.di_flags & GFS2_DIF_EXHASH) ? !(ip->i_di.di_flags & GFS2_DIF_EXHASH) ?
GFS2_FORMAT_DE : 0); GFS2_FORMAT_DE : 0);
str->di_depth = cpu_to_be16(ip->i_depth); str->di_depth = cpu_to_be16(ip->i_depth);
str->di_entries = cpu_to_be32(di->di_entries); str->di_entries = cpu_to_be32(ip->i_entries);
str->di_eattr = cpu_to_be64(di->di_eattr); str->di_eattr = cpu_to_be64(di->di_eattr);
str->di_atime_nsec = cpu_to_be32(ip->i_inode.i_atime.tv_nsec); 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,7 +1295,7 @@ void gfs2_dinode_print(const struct gfs2_inode *ip)
printk(KERN_INFO " di_flags = 0x%.8X\n", di->di_flags); printk(KERN_INFO " di_flags = 0x%.8X\n", di->di_flags);
printk(KERN_INFO " i_height = %u\n", ip->i_height); printk(KERN_INFO " i_height = %u\n", ip->i_height);
printk(KERN_INFO " i_depth = %u\n", ip->i_depth); printk(KERN_INFO " i_depth = %u\n", ip->i_depth);
printk(KERN_INFO " di_entries = %u\n", di->di_entries); printk(KERN_INFO " i_entries = %u\n", ip->i_entries);
printk(KERN_INFO " di_eattr = %llu\n", printk(KERN_INFO " di_eattr = %llu\n",
(unsigned long long)di->di_eattr); (unsigned long long)di->di_eattr);
} }
......
...@@ -185,7 +185,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir, ...@@ -185,7 +185,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
if (!dip->i_inode.i_nlink) if (!dip->i_inode.i_nlink)
goto out_gunlock; goto out_gunlock;
error = -EFBIG; error = -EFBIG;
if (dip->i_di.di_entries == (u32)-1) if (dip->i_entries == (u32)-1)
goto out_gunlock; goto out_gunlock;
error = -EPERM; error = -EPERM;
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
...@@ -427,7 +427,7 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode) ...@@ -427,7 +427,7 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)
ip->i_inode.i_nlink = 2; ip->i_inode.i_nlink = 2;
ip->i_di.di_size = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode); ip->i_di.di_size = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode);
ip->i_di.di_flags |= GFS2_DIF_JDATA; ip->i_di.di_flags |= GFS2_DIF_JDATA;
ip->i_di.di_entries = 2; ip->i_entries = 2;
error = gfs2_meta_inode_buffer(ip, &dibh); error = gfs2_meta_inode_buffer(ip, &dibh);
...@@ -517,13 +517,13 @@ static int gfs2_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -517,13 +517,13 @@ static int gfs2_rmdir(struct inode *dir, struct dentry *dentry)
if (error) if (error)
goto out_gunlock; goto out_gunlock;
if (ip->i_di.di_entries < 2) { if (ip->i_entries < 2) {
if (gfs2_consist_inode(ip)) if (gfs2_consist_inode(ip))
gfs2_dinode_print(ip); gfs2_dinode_print(ip);
error = -EIO; error = -EIO;
goto out_gunlock; goto out_gunlock;
} }
if (ip->i_di.di_entries > 2) { if (ip->i_entries > 2) {
error = -ENOTEMPTY; error = -ENOTEMPTY;
goto out_gunlock; goto out_gunlock;
} }
...@@ -726,13 +726,13 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, ...@@ -726,13 +726,13 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
goto out_gunlock; goto out_gunlock;
if (S_ISDIR(nip->i_inode.i_mode)) { if (S_ISDIR(nip->i_inode.i_mode)) {
if (nip->i_di.di_entries < 2) { if (nip->i_entries < 2) {
if (gfs2_consist_inode(nip)) if (gfs2_consist_inode(nip))
gfs2_dinode_print(nip); gfs2_dinode_print(nip);
error = -EIO; error = -EIO;
goto out_gunlock; goto out_gunlock;
} }
if (nip->i_di.di_entries > 2) { if (nip->i_entries > 2) {
error = -ENOTEMPTY; error = -ENOTEMPTY;
goto out_gunlock; goto out_gunlock;
} }
...@@ -758,7 +758,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, ...@@ -758,7 +758,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
error = -EINVAL; error = -EINVAL;
goto out_gunlock; goto out_gunlock;
} }
if (ndip->i_di.di_entries == (u32)-1) { if (ndip->i_entries == (u32)-1) {
error = -EFBIG; error = -EFBIG;
goto out_gunlock; goto out_gunlock;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册