Commit 2933f925 authored by Steven Whitehouse's avatar Steven Whitehouse
Browse files

[GFS2] Shrink gfs2_inode (4) - di_uid/di_gid



Remove duplicate di_uid/di_gid fields in favour of using
inode->i_uid/inode->i_gid instead. This saves 8 bytes.
Signed-off-by: default avatarSteven Whitehouse <swhiteho@redhat.com>
parent b60623c2
......@@ -74,7 +74,7 @@ int gfs2_acl_validate_remove(struct gfs2_inode *ip, int access)
{
if (!GFS2_SB(&ip->i_inode)->sd_args.ar_posix_acl)
return -EOPNOTSUPP;
if (current->fsuid != ip->i_di.di_uid && !capable(CAP_FOWNER))
if (current->fsuid != ip->i_inode.i_uid && !capable(CAP_FOWNER))
return -EPERM;
if (S_ISLNK(ip->i_inode.i_mode))
return -EOPNOTSUPP;
......
......@@ -819,7 +819,7 @@ static int do_grow(struct gfs2_inode *ip, u64 size)
if (error)
goto out;
error = gfs2_quota_check(ip, ip->i_di.di_uid, ip->i_di.di_gid);
error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid);
if (error)
goto out_gunlock_q;
......
......@@ -687,7 +687,7 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er,
if (error)
goto out;
error = gfs2_quota_check(ip, ip->i_di.di_uid, ip->i_di.di_gid);
error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid);
if (error)
goto out_gunlock_q;
......
......@@ -52,8 +52,6 @@ void gfs2_inode_attr_in(struct gfs2_inode *ip)
inode->i_ino = ip->i_num.no_addr;
inode->i_nlink = di->di_nlink;
inode->i_uid = di->di_uid;
inode->i_gid = di->di_gid;
i_size_write(inode, di->di_size);
inode->i_atime.tv_sec = di->di_atime;
inode->i_mtime.tv_sec = di->di_mtime;
......@@ -87,8 +85,6 @@ void gfs2_inode_attr_out(struct gfs2_inode *ip)
{
struct inode *inode = &ip->i_inode;
struct gfs2_dinode_host *di = &ip->i_di;
di->di_uid = inode->i_uid;
di->di_gid = inode->i_gid;
di->di_atime = inode->i_atime.tv_sec;
di->di_mtime = inode->i_mtime.tv_sec;
di->di_ctime = inode->i_ctime.tv_sec;
......@@ -216,8 +212,8 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
break;
};
di->di_uid = be32_to_cpu(str->di_uid);
di->di_gid = be32_to_cpu(str->di_gid);
ip->i_inode.i_uid = be32_to_cpu(str->di_uid);
ip->i_inode.i_gid = be32_to_cpu(str->di_gid);
di->di_nlink = be32_to_cpu(str->di_nlink);
di->di_size = be64_to_cpu(str->di_size);
di->di_blocks = be64_to_cpu(str->di_blocks);
......@@ -616,19 +612,19 @@ static void munge_mode_uid_gid(struct gfs2_inode *dip, unsigned int *mode,
unsigned int *uid, unsigned int *gid)
{
if (GFS2_SB(&dip->i_inode)->sd_args.ar_suiddir &&
(dip->i_inode.i_mode & S_ISUID) && dip->i_di.di_uid) {
(dip->i_inode.i_mode & S_ISUID) && dip->i_inode.i_uid) {
if (S_ISDIR(*mode))
*mode |= S_ISUID;
else if (dip->i_di.di_uid != current->fsuid)
else if (dip->i_inode.i_uid != current->fsuid)
*mode &= ~07111;
*uid = dip->i_di.di_uid;
*uid = dip->i_inode.i_uid;
} else
*uid = current->fsuid;
if (dip->i_inode.i_mode & S_ISGID) {
if (S_ISDIR(*mode))
*mode |= S_ISGID;
*gid = dip->i_di.di_gid;
*gid = dip->i_inode.i_gid;
} else
*gid = current->fsgid;
}
......@@ -783,8 +779,7 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name,
if (alloc_required < 0)
goto fail;
if (alloc_required) {
error = gfs2_quota_check(dip, dip->i_di.di_uid,
dip->i_di.di_gid);
error = gfs2_quota_check(dip, dip->i_inode.i_uid, dip->i_inode.i_gid);
if (error)
goto fail_quota_locks;
......@@ -1050,8 +1045,8 @@ int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,
return -EPERM;
if ((dip->i_inode.i_mode & S_ISVTX) &&
dip->i_di.di_uid != current->fsuid &&
ip->i_di.di_uid != current->fsuid && !capable(CAP_FOWNER))
dip->i_inode.i_uid != current->fsuid &&
ip->i_inode.i_uid != current->fsuid && !capable(CAP_FOWNER))
return -EPERM;
if (IS_APPEND(&dip->i_inode))
......
......@@ -162,8 +162,8 @@ void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
gfs2_inum_out(&ip->i_num, &str->di_num);
str->di_mode = cpu_to_be32(ip->i_inode.i_mode);
str->di_uid = cpu_to_be32(di->di_uid);
str->di_gid = cpu_to_be32(di->di_gid);
str->di_uid = cpu_to_be32(ip->i_inode.i_uid);
str->di_gid = cpu_to_be32(ip->i_inode.i_gid);
str->di_nlink = cpu_to_be32(di->di_nlink);
str->di_size = cpu_to_be64(di->di_size);
str->di_blocks = cpu_to_be64(di->di_blocks);
......@@ -191,8 +191,6 @@ void gfs2_dinode_print(const struct gfs2_inode *ip)
gfs2_inum_print(&ip->i_num);
pv(di, di_uid, "%u");
pv(di, di_gid, "%u");
pv(di, di_nlink, "%u");
printk(KERN_INFO " di_size = %llu\n", (unsigned long long)di->di_size);
printk(KERN_INFO " di_blocks = %llu\n", (unsigned long long)di->di_blocks);
......
......@@ -386,7 +386,7 @@ static int gfs2_prepare_write(struct file *file, struct page *page,
if (error)
goto out_alloc_put;
error = gfs2_quota_check(ip, ip->i_di.di_uid, ip->i_di.di_gid);
error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid);
if (error)
goto out_qunlock;
......
......@@ -196,8 +196,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
if (error)
goto out_alloc;
error = gfs2_quota_check(dip, dip->i_di.di_uid,
dip->i_di.di_gid);
error = gfs2_quota_check(dip, dip->i_inode.i_uid, dip->i_inode.i_gid);
if (error)
goto out_gunlock_q;
......@@ -673,8 +672,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
if (error)
goto out_alloc;
error = gfs2_quota_check(ndip, ndip->i_di.di_uid,
ndip->i_di.di_gid);
error = gfs2_quota_check(ndip, ndip->i_inode.i_uid, ndip->i_inode.i_gid);
if (error)
goto out_gunlock_q;
......@@ -885,8 +883,8 @@ static int setattr_chown(struct inode *inode, struct iattr *attr)
u32 ouid, ogid, nuid, ngid;
int error;
ouid = ip->i_di.di_uid;
ogid = ip->i_di.di_gid;
ouid = inode->i_uid;
ogid = inode->i_gid;
nuid = attr->ia_uid;
ngid = attr->ia_gid;
......
......@@ -76,7 +76,7 @@ static int alloc_page_backing(struct gfs2_inode *ip, struct page *page)
if (error)
goto out;
error = gfs2_quota_check(ip, ip->i_di.di_uid, ip->i_di.di_gid);
error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid);
if (error)
goto out_gunlock_q;
......
......@@ -452,19 +452,19 @@ int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid)
if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF)
return 0;
error = qdsb_get(sdp, QUOTA_USER, ip->i_di.di_uid, CREATE, qd);
error = qdsb_get(sdp, QUOTA_USER, ip->i_inode.i_uid, CREATE, qd);
if (error)
goto out;
al->al_qd_num++;
qd++;
error = qdsb_get(sdp, QUOTA_GROUP, ip->i_di.di_gid, CREATE, qd);
error = qdsb_get(sdp, QUOTA_GROUP, ip->i_inode.i_gid, CREATE, qd);
if (error)
goto out;
al->al_qd_num++;
qd++;
if (uid != NO_QUOTA_CHANGE && uid != ip->i_di.di_uid) {
if (uid != NO_QUOTA_CHANGE && uid != ip->i_inode.i_uid) {
error = qdsb_get(sdp, QUOTA_USER, uid, CREATE, qd);
if (error)
goto out;
......@@ -472,7 +472,7 @@ int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid)
qd++;
}
if (gid != NO_QUOTA_CHANGE && gid != ip->i_di.di_gid) {
if (gid != NO_QUOTA_CHANGE && gid != ip->i_inode.i_gid) {
error = qdsb_get(sdp, QUOTA_GROUP, gid, CREATE, qd);
if (error)
goto out;
......
......@@ -1217,7 +1217,7 @@ u64 gfs2_alloc_data(struct gfs2_inode *ip)
al->al_alloced++;
gfs2_statfs_change(sdp, 0, -1, 0);
gfs2_quota_change(ip, +1, ip->i_di.di_uid, ip->i_di.di_gid);
gfs2_quota_change(ip, +1, ip->i_inode.i_uid, ip->i_inode.i_gid);
spin_lock(&sdp->sd_rindex_spin);
rgd->rd_free_clone--;
......@@ -1261,7 +1261,7 @@ u64 gfs2_alloc_meta(struct gfs2_inode *ip)
al->al_alloced++;
gfs2_statfs_change(sdp, 0, -1, 0);
gfs2_quota_change(ip, +1, ip->i_di.di_uid, ip->i_di.di_gid);
gfs2_quota_change(ip, +1, ip->i_inode.i_uid, ip->i_inode.i_gid);
gfs2_trans_add_unrevoke(sdp, block);
spin_lock(&sdp->sd_rindex_spin);
......@@ -1337,8 +1337,7 @@ void gfs2_free_data(struct gfs2_inode *ip, u64 bstart, u32 blen)
gfs2_trans_add_rg(rgd);
gfs2_statfs_change(sdp, 0, +blen, 0);
gfs2_quota_change(ip, -(s64)blen,
ip->i_di.di_uid, ip->i_di.di_gid);
gfs2_quota_change(ip, -(s64)blen, ip->i_inode.i_uid, ip->i_inode.i_gid);
}
/**
......@@ -1366,7 +1365,7 @@ void gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen)
gfs2_trans_add_rg(rgd);
gfs2_statfs_change(sdp, 0, +blen, 0);
gfs2_quota_change(ip, -(s64)blen, ip->i_di.di_uid, ip->i_di.di_gid);
gfs2_quota_change(ip, -(s64)blen, ip->i_inode.i_uid, ip->i_inode.i_gid);
gfs2_meta_wipe(ip, bstart, blen);
}
......@@ -1411,7 +1410,7 @@ static void gfs2_free_uninit_di(struct gfs2_rgrpd *rgd, u64 blkno)
void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip)
{
gfs2_free_uninit_di(rgd, ip->i_num.no_addr);
gfs2_quota_change(ip, -1, ip->i_di.di_uid, ip->i_di.di_gid);
gfs2_quota_change(ip, -1, ip->i_inode.i_uid, ip->i_inode.i_gid);
gfs2_meta_wipe(ip, ip->i_num.no_addr, 1);
}
......
......@@ -322,8 +322,6 @@ struct gfs2_dinode {
};
struct gfs2_dinode_host {
__u32 di_uid; /* owner's user id */
__u32 di_gid; /* owner's group id */
__u32 di_nlink; /* number of links to this file */
__u64 di_size; /* number of bytes in file */
__u64 di_blocks; /* number of blocks in file */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment