Skip to content

Commit

Permalink
GFS2: Extract quota data from reservations structure (revert 5407e24)
Browse files Browse the repository at this point in the history
This patch basically reverts the majority of patch 5407e24.
That patch eliminated the gfs2_qadata structure in favor of just
using the reservations structure. The problem with doing that is that
it increases the size of the reservations structure. That is not an
issue until it comes time to fold the reservations structure into the
inode in memory so we know it's always there. By separating out the
quota structure again, we aren't punishing the non-quota users by
making all the inodes bigger, requiring more slab space. This patch
creates a new slab area to allocate the quota stuff so it's managed
a little more sanely.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
  • Loading branch information
Bob Peterson committed Nov 24, 2015
1 parent 39b0555 commit b54e9a0
Show file tree
Hide file tree
Showing 13 changed files with 125 additions and 63 deletions.
2 changes: 1 addition & 1 deletion fs/gfs2/aops.c
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping,
failed:
gfs2_trans_end(sdp);
gfs2_inplace_release(ip);
if (ip->i_res->rs_qa_qd_num)
if (ip->i_qadata && ip->i_qadata->qa_qd_num)
gfs2_quota_unlock(ip);
if (inode == sdp->sd_rindex) {
gfs2_glock_dq(&m_ip->i_gh);
Expand Down
2 changes: 1 addition & 1 deletion fs/gfs2/bmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,7 @@ int gfs2_setattr_size(struct inode *inode, u64 newsize)

inode_dio_wait(inode);

ret = gfs2_rs_alloc(ip);
ret = gfs2_rsqa_alloc(ip);
if (ret)
goto out;

Expand Down
10 changes: 5 additions & 5 deletions fs/gfs2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
if (ret)
goto out;

ret = gfs2_rs_alloc(ip);
ret = gfs2_rsqa_alloc(ip);
if (ret)
goto out_write_access;

Expand Down Expand Up @@ -623,7 +623,7 @@ static int gfs2_release(struct inode *inode, struct file *file)
if (!(file->f_mode & FMODE_WRITE))
return 0;

gfs2_rs_delete(ip, &inode->i_writecount);
gfs2_rsqa_delete(ip, &inode->i_writecount);
return 0;
}

Expand Down Expand Up @@ -703,7 +703,7 @@ static ssize_t gfs2_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
struct gfs2_inode *ip = GFS2_I(file_inode(file));
int ret;

ret = gfs2_rs_alloc(ip);
ret = gfs2_rsqa_alloc(ip);
if (ret)
return ret;

Expand Down Expand Up @@ -938,7 +938,7 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset, loff_t le
if (ret)
goto out_unlock;

ret = gfs2_rs_alloc(ip);
ret = gfs2_rsqa_alloc(ip);
if (ret)
goto out_putw;

Expand All @@ -962,7 +962,7 @@ static ssize_t gfs2_file_splice_write(struct pipe_inode_info *pipe,
int error;
struct gfs2_inode *ip = GFS2_I(out->f_mapping->host);

error = gfs2_rs_alloc(ip);
error = gfs2_rsqa_alloc(ip);
if (error)
return (ssize_t)error;

Expand Down
13 changes: 8 additions & 5 deletions fs/gfs2/incore.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@ struct gfs2_holder {
/* Number of quota types we support */
#define GFS2_MAXQUOTAS 2

struct gfs2_qadata { /* quota allocation data */
/* Quota stuff */
struct gfs2_quota_data *qa_qd[2 * GFS2_MAXQUOTAS];
struct gfs2_holder qa_qd_ghs[2 * GFS2_MAXQUOTAS];
unsigned int qa_qd_num;
};

/* Resource group multi-block reservation, in order of appearance:
Step 1. Function prepares to write, allocates a mb, sets the size hint.
Expand All @@ -288,11 +295,6 @@ struct gfs2_blkreserv {
struct gfs2_rbm rs_rbm; /* Start of reservation */
u32 rs_free; /* how many blocks are still free */
u64 rs_inum; /* Inode number for reservation */

/* ancillary quota stuff */
struct gfs2_quota_data *rs_qa_qd[2 * GFS2_MAXQUOTAS];
struct gfs2_holder rs_qa_qd_ghs[2 * GFS2_MAXQUOTAS];
unsigned int rs_qa_qd_num;
};

/*
Expand Down Expand Up @@ -391,6 +393,7 @@ struct gfs2_inode {
struct gfs2_glock *i_gl; /* Move into i_gh? */
struct gfs2_holder i_iopen_gh;
struct gfs2_holder i_gh; /* for prepare/commit_write only */
struct gfs2_qadata *i_qadata; /* quota allocation data */
struct gfs2_blkreserv *i_res; /* rgrp multi-block reservation */
struct gfs2_rgrpd *i_rgd;
u64 i_goal; /* goal block for allocations */
Expand Down
18 changes: 9 additions & 9 deletions fs/gfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
if (!name->len || name->len > GFS2_FNAMESIZE)
return -ENAMETOOLONG;

error = gfs2_rs_alloc(dip);
error = gfs2_rsqa_alloc(dip);
if (error)
return error;

Expand Down Expand Up @@ -653,7 +653,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
goto fail_free_vfs_inode;

ip = GFS2_I(inode);
error = gfs2_rs_alloc(ip);
error = gfs2_rsqa_alloc(ip);
if (error)
goto fail_free_acls;

Expand Down Expand Up @@ -781,7 +781,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
fail_free_inode:
if (ip->i_gl)
gfs2_glock_put(ip->i_gl);
gfs2_rs_delete(ip, NULL);
gfs2_rsqa_delete(ip, NULL);
fail_free_acls:
if (default_acl)
posix_acl_release(default_acl);
Expand Down Expand Up @@ -903,7 +903,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
if (S_ISDIR(inode->i_mode))
return -EPERM;

error = gfs2_rs_alloc(dip);
error = gfs2_rsqa_alloc(dip);
if (error)
return error;

Expand Down Expand Up @@ -1376,7 +1376,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
if (error)
return error;

error = gfs2_rs_alloc(ndip);
error = gfs2_rsqa_alloc(ndip);
if (error)
return error;

Expand Down Expand Up @@ -1863,7 +1863,7 @@ static int setattr_chown(struct inode *inode, struct iattr *attr)
if (error)
return error;

error = gfs2_rs_alloc(ip);
error = gfs2_rsqa_alloc(ip);
if (error)
goto out;

Expand Down Expand Up @@ -1925,7 +1925,7 @@ static int gfs2_setattr(struct dentry *dentry, struct iattr *attr)
struct gfs2_holder i_gh;
int error;

error = gfs2_rs_alloc(ip);
error = gfs2_rsqa_alloc(ip);
if (error)
return error;

Expand Down Expand Up @@ -2007,7 +2007,7 @@ static int gfs2_setxattr(struct dentry *dentry, const char *name,
gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
ret = gfs2_glock_nq(&gh);
if (ret == 0) {
ret = gfs2_rs_alloc(ip);
ret = gfs2_rsqa_alloc(ip);
if (ret == 0)
ret = generic_setxattr(dentry, name, data, size, flags);
gfs2_glock_dq(&gh);
Expand Down Expand Up @@ -2048,7 +2048,7 @@ static int gfs2_removexattr(struct dentry *dentry, const char *name)
gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
ret = gfs2_glock_nq(&gh);
if (ret == 0) {
ret = gfs2_rs_alloc(ip);
ret = gfs2_rsqa_alloc(ip);
if (ret == 0)
ret = generic_removexattr(dentry, name);
gfs2_glock_dq(&gh);
Expand Down
11 changes: 11 additions & 0 deletions fs/gfs2/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ static void gfs2_init_inode_once(void *foo)
inode_init_once(&ip->i_inode);
init_rwsem(&ip->i_rw_mutex);
INIT_LIST_HEAD(&ip->i_trunc_list);
ip->i_qadata = NULL;
ip->i_res = NULL;
ip->i_hash_cache = NULL;
}
Expand Down Expand Up @@ -135,6 +136,12 @@ static int __init init_gfs2_fs(void)
if (!gfs2_quotad_cachep)
goto fail;

gfs2_qadata_cachep = kmem_cache_create("gfs2_qadata",
sizeof(struct gfs2_qadata),
0, 0, NULL);
if (!gfs2_qadata_cachep)
goto fail;

gfs2_rsrv_cachep = kmem_cache_create("gfs2_mblk",
sizeof(struct gfs2_blkreserv),
0, 0, NULL);
Expand Down Expand Up @@ -196,6 +203,9 @@ static int __init init_gfs2_fs(void)
if (gfs2_rsrv_cachep)
kmem_cache_destroy(gfs2_rsrv_cachep);

if (gfs2_qadata_cachep)
kmem_cache_destroy(gfs2_qadata_cachep);

if (gfs2_quotad_cachep)
kmem_cache_destroy(gfs2_quotad_cachep);

Expand Down Expand Up @@ -239,6 +249,7 @@ static void __exit exit_gfs2_fs(void)

mempool_destroy(gfs2_page_pool);
kmem_cache_destroy(gfs2_rsrv_cachep);
kmem_cache_destroy(gfs2_qadata_cachep);
kmem_cache_destroy(gfs2_quotad_cachep);
kmem_cache_destroy(gfs2_rgrpd_cachep);
kmem_cache_destroy(gfs2_bufdata_cachep);
Expand Down
Loading

0 comments on commit b54e9a0

Please sign in to comment.