GFS2: Fold quota data into the reservations struct
A message that is not in the archive (sent off-list or not yet received): e6331abc-7dfe-4ab1-a141-d7d0f809e37e@zmail12.collab.prod.int.phx2.redhat.com
PATCH 1/1 GFS2: Fold quota data into the reservations struct
Hi,
Several patches ago, we split the qadata structure from the reservations structure. Now that the previous patch lengthened the lifespan of that structure, we can safely fold the qadata structure back into it again. That saves GFS2 the work and time to allocate and deallocate the qadata structure, since we know quota work is normally only needed when allocations are done.
Regards,
Bob Peterson
Red Hat GFS
--
Author: Bob Peterson <[email protected]> Date: Thu Apr 12 12:11:25 2012 -0500
GFS2: Fold quota data into the reservations struct
This patch moves the ancillary quota data structures into the block reservations structure. This saves GFS2 a lot of time and effort in allocating and deallocating the qadata structure.
--- fs/gfs2/aops.c | 16 +------------ fs/gfs2/bmap.c | 18 ++++----------- fs/gfs2/dir.c | 9 +------- fs/gfs2/file.c | 22 +------------------ fs/gfs2/incore.h | 15 +++++-------- fs/gfs2/inode.c | 44 +++------------------------------------ fs/gfs2/main.c | 1 - fs/gfs2/quota.c | 59 +++++++++++++++++++++++++++-------------------------- fs/gfs2/rgrp.c | 19 ----------------- fs/gfs2/rgrp.h | 8 ------- fs/gfs2/super.c | 9 +------- fs/gfs2/xattr.c | 24 +-------------------- 12 files changed, 53 insertions(+), 191 deletions(-)
fs/gfs2/aops.c +2 -14
@@ -615,7 +615,6 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,unsigned int data_blocks =0 , ind_blocks =0 , rblocks;int alloc_required;int error =0 ; -struct gfs2_qadata *qa =NULL ;pgoff_t index = pos >>PAGE_CACHE_SHIFT ;unsigned from = pos & (PAGE_CACHE_SIZE -1 );struct page *page;
@@ -639,15 +638,9 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,gfs2_write_calc_reserv (ip, len, &data_blocks, &ind_blocks);if (alloc_required) { - qa =gfs2_qadata_get (ip); -if (!qa) { - error = -ENOMEM ; - goto out_unlock; - } - error =gfs2_quota_lock_check (ip);if (error) - goto out_alloc_put; + goto out_unlock; error =gfs2_inplace_reserve (ip, data_blocks + ind_blocks);if (error)
@@ -709,8 +702,6 @@ out_trans_fail:gfs2_inplace_release (ip); out_qunlock:gfs2_quota_unlock (ip); -out_alloc_put: -gfs2_qadata_put (ip); } out_unlock:if (&ip->i_inode == sdp->sd_rindex) {
@@ -847,7 +838,6 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping,struct gfs2_sbd *sdp =GFS2_SB (inode);struct gfs2_inode *m_ip =GFS2_I (sdp->sd_statfs_inode);struct buffer_head *dibh; -struct gfs2_qadata *qa = ip->i_qadata;unsigned int from = pos & (PAGE_CACHE_SIZE -1 );unsigned int to = from + len;int ret;
@@ -881,10 +871,8 @@ failed:gfs2_trans_end (sdp);if (gfs2_mb_reserved (ip))gfs2_inplace_release (ip); -if (qa) { +if (ip->i_res->rs_qa_qd_num)gfs2_quota_unlock (ip); -gfs2_qadata_put (ip); - }if (inode == sdp->sd_rindex) {gfs2_glock_dq (&m_ip->i_gh);gfs2_holder_uninit (&m_ip->i_gh);
fs/gfs2/bmap.c +5 -13
@@ -1045,12 +1045,13 @@ static int trunc_dealloc(struct gfs2_inode *ip, u64 size) lblock = (size -1 ) >> sdp->sd_sb.sb_bsize_shift;find_metapath (sdp, lblock, &mp, ip->i_height); -if (!gfs2_qadata_get (ip)) -return -ENOMEM ; + error =gfs2_rindex_update (sdp); +if (error) +return error; error =gfs2_quota_hold (ip,NO_QUOTA_CHANGE ,NO_QUOTA_CHANGE );if (error) - goto out; +return error;while (height--) {struct strip_mine sm;
@@ -1064,8 +1065,6 @@ static int trunc_dealloc(struct gfs2_inode *ip, u64 size)gfs2_quota_unhold (ip); -out: -gfs2_qadata_put (ip);return error; }
@@ -1167,19 +1166,14 @@ static int do_grow(struct inode *inode, u64 size)struct gfs2_inode *ip =GFS2_I (inode);struct gfs2_sbd *sdp =GFS2_SB (inode);struct buffer_head *dibh; -struct gfs2_qadata *qa =NULL ;int error;int unstuff =0 ;if (gfs2_is_stuffed (ip) && (size > (sdp->sd_sb.sb_bsize -sizeof (struct gfs2_dinode )))) { - qa =gfs2_qadata_get (ip); -if (qa ==NULL ) -return -ENOMEM ; - error =gfs2_quota_lock_check (ip);if (error) - goto do_grow_alloc_put; +return error; error =gfs2_inplace_reserve (ip,1 );if (error)
@@ -1214,8 +1208,6 @@ do_grow_release:gfs2_inplace_release (ip); do_grow_qunlock:gfs2_quota_unlock (ip); -do_grow_alloc_put: -gfs2_qadata_put (ip); }return error; }
fs/gfs2/dir.c +1 -8
@@ -1854,14 +1854,9 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,if (!ht)return -ENOMEM ; -if (!gfs2_qadata_get (dip)) { - error = -ENOMEM ; - goto out; - } - error =gfs2_quota_hold (dip,NO_QUOTA_CHANGE ,NO_QUOTA_CHANGE );if (error) - goto out_put; + goto out;/* Count the number of leaves */ bh = leaf_bh;
@@ -1942,8 +1937,6 @@ out_rg_gunlock: out_rlist:gfs2_rlist_free (&rlist);gfs2_quota_unhold (dip); -out_put: -gfs2_qadata_put (dip); out:kfree (ht);return error;
fs/gfs2/file.c +2 -20
@@ -366,7 +366,6 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)u64 pos = page->index <<PAGE_CACHE_SHIFT ;unsigned int data_blocks, ind_blocks, rblocks;struct gfs2_holder gh; -struct gfs2_qadata *qa;loff_t size;int ret;
@@ -397,14 +396,9 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) goto out_unlock; } - ret = -ENOMEM ; - qa =gfs2_qadata_get (ip); -if (qa ==NULL ) - goto out_unlock; - ret =gfs2_quota_lock_check (ip);if (ret) - goto out_alloc_put; + goto out_unlock;gfs2_write_calc_reserv (ip,PAGE_CACHE_SIZE , &data_blocks, &ind_blocks); ret =gfs2_inplace_reserve (ip, data_blocks + ind_blocks);if (ret)
@@ -451,8 +445,6 @@ out_trans_fail:gfs2_inplace_release (ip); out_quota_unlock:gfs2_quota_unlock (ip); -out_alloc_put: -gfs2_qadata_put (ip); out_unlock:gfs2_glock_dq (&gh); out:
@@ -766,7 +758,6 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,struct gfs2_inode *ip =GFS2_I (inode);unsigned int data_blocks =0 , ind_blocks =0 , rblocks;loff_t bytes, max_bytes; -struct gfs2_qadata *qa;int error;const loff_t pos = offset;const loff_t count = len;
@@ -802,15 +793,9 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset, offset += bytes;continue ; } - qa =gfs2_qadata_get (ip); -if (!qa) { - error = -ENOMEM ; - goto out_unlock; - } - error =gfs2_quota_lock_check (ip);if (error) - goto out_alloc_put; + goto out_unlock; retry:gfs2_write_calc_reserv (ip, bytes, &data_blocks, &ind_blocks);
@@ -850,7 +835,6 @@ retry: offset += max_bytes;gfs2_inplace_release (ip);gfs2_quota_unlock (ip); -gfs2_qadata_put (ip); }if (error ==0 )
@@ -861,8 +845,6 @@ out_trans_fail:gfs2_inplace_release (ip); out_qunlock:gfs2_quota_unlock (ip); -out_alloc_put: -gfs2_qadata_put (ip); out_unlock:gfs2_glock_dq (&ip->i_gh); out_uninit:
fs/gfs2/incore.h +6 -9
@@ -299,16 +299,14 @@ struct gfs2_glock {#define GFS2_MIN_LVB_SIZE 32/* Min size of LVB that gfs2 supports */ -struct gfs2_qadata {/* quota allocation data */ -/* Quota stuff */ -struct gfs2_quota_data *qa_qd[2 *MAXQUOTAS ]; -struct gfs2_holder qa_qd_ghs[2 *MAXQUOTAS ]; -unsigned int qa_qd_num; -}; -struct gfs2_blkreserv {u32 rs_requested;/* Filled in by caller of gfs2_inplace_reserve() */ struct gfs2_holder rs_rgd_gh;/* Filled in by gfs2_inplace_reserve() */ + +/* ancillary quota stuff */ +struct gfs2_quota_data *rs_qa_qd[2 *MAXQUOTAS ]; +struct gfs2_holder rs_qa_qd_ghs[2 *MAXQUOTAS ]; +unsigned int rs_qa_qd_num; };enum {
@@ -329,8 +327,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;/* resource group block reservation */ +struct gfs2_blkreserv *i_res;/* rgrp multi-block reservation */ struct gfs2_rgrpd *i_rgd;u64 i_goal;/* goal block for allocations */ struct rw_semaphore i_rw_mutex;
fs/gfs2/inode.c +4 -40
123 lines not on this page · raw message
fs/gfs2/main.c +0 -1
@@ -43,7 +43,6 @@ 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 ; }
fs/gfs2/quota.c +30 -29
164 lines not on this page · raw message
fs/gfs2/rgrp.c +0 -19
@@ -1010,25 +1010,6 @@ out: }/** -* gfs2_qadata_get - get the struct gfs2_qadata structure for an inode -* @ip: the incore GFS2 inode structure -* -* Returns: the struct gfs2_qadata -*/ - -struct gfs2_qadata *gfs2_qadata_get (struct gfs2_inode *ip) -{ -struct gfs2_sbd *sdp =GFS2_SB (&ip->i_inode); -int error; -BUG_ON (ip->i_qadata !=NULL ); - ip->i_qadata =kzalloc (sizeof (struct gfs2_qadata ),GFP_NOFS ); - error =gfs2_rindex_update (sdp); -if (error) -fs_warn (sdp,"rindex update returns %d\n" , error); -return ip->i_qadata; -} - -/** * try_rgrp_fit - See if a given reservation will fit in a given RG * @rgd: the RG data * @ip: the inode
fs/gfs2/rgrp.h +0 -8
@@ -29,14 +29,6 @@ extern void gfs2_free_clones(struct gfs2_rgrpd *rgd);extern int gfs2_rgrp_go_lock (struct gfs2_holder *gh);extern void gfs2_rgrp_go_unlock (struct gfs2_holder *gh); -extern struct gfs2_qadata *gfs2_qadata_get (struct gfs2_inode *ip); -static inline void gfs2_qadata_put (struct gfs2_inode *ip) -{ -BUG_ON (ip->i_qadata ==NULL ); -kfree (ip->i_qadata); - ip->i_qadata =NULL ; -} -extern int gfs2_inplace_reserve (struct gfs2_inode *ip,u32 requested);extern void gfs2_inplace_release (struct gfs2_inode *ip);
fs/gfs2/super.c +1 -8
@@ -1399,7 +1399,6 @@ static void gfs2_final_release_pages(struct gfs2_inode *ip)static int gfs2_dinode_dealloc (struct gfs2_inode *ip) {struct gfs2_sbd *sdp =GFS2_SB (&ip->i_inode); -struct gfs2_qadata *qa;struct gfs2_rgrpd *rgd;struct gfs2_holder gh;int error;
@@ -1409,13 +1408,9 @@ static int gfs2_dinode_dealloc(struct gfs2_inode *ip)return -EIO ; } - qa =gfs2_qadata_get (ip); -if (!qa) -return -ENOMEM ; - error =gfs2_quota_hold (ip,NO_QUOTA_CHANGE ,NO_QUOTA_CHANGE );if (error) - goto out; +return error; rgd =gfs2_blk2rgrpd (sdp, ip->i_no_addr,1 );if (!rgd) {
@@ -1443,8 +1438,6 @@ out_rg_gunlock:gfs2_glock_dq_uninit (&gh); out_qs:gfs2_quota_unhold (ip); -out: -gfs2_qadata_put (ip);return error; }
fs/gfs2/xattr.c +2 -22
@@ -325,13 +325,8 @@ static int ea_remove_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,struct gfs2_ea_header *ea, struct gfs2_ea_header *prev, int leave) { - struct gfs2_qadata *qa; int error; - qa =gfs2_qadata_get (ip); -if (!qa) -return -ENOMEM ; - error =gfs2_quota_hold (ip,NO_QUOTA_CHANGE ,NO_QUOTA_CHANGE );if (error) goto out_alloc;
@@ -340,7 +335,6 @@ static int ea_remove_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,gfs2_quota_unhold (ip); out_alloc: -gfs2_qadata_put (ip);return error; }
@@ -713,17 +707,12 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er,unsigned int blks, ea_skeleton_call_t skeleton_call, void *private) { - struct gfs2_qadata *qa; struct buffer_head *dibh;int error; - qa =gfs2_qadata_get (ip); -if (!qa) -return -ENOMEM ; - error =gfs2_quota_lock_check (ip);if (error) - goto out; +return error; error =gfs2_inplace_reserve (ip, blks);if (error)
@@ -753,8 +742,6 @@ out_ipres:gfs2_inplace_release (ip); out_gunlock_q:gfs2_quota_unlock (ip); -out: -gfs2_qadata_put (ip);return error; }
@@ -1494,16 +1481,11 @@ out_gunlock:int gfs2_ea_dealloc (struct gfs2_inode *ip) { -struct gfs2_qadata *qa;int error; - qa =gfs2_qadata_get (ip); -if (!qa) -return -ENOMEM ; - error =gfs2_quota_hold (ip,NO_QUOTA_CHANGE ,NO_QUOTA_CHANGE );if (error) - goto out_alloc; +return error; error =ea_foreach (ip, ea_dealloc_unstuffed,NULL );if (error)
@@ -1519,8 +1501,6 @@ int gfs2_ea_dealloc(struct gfs2_inode *ip) out_quota:gfs2_quota_unhold (ip); -out_alloc: -gfs2_qadata_put (ip);return error; }
PATCH 1/1 GFS2: Fold quota data into the reservations struct
Hi,
Quoted 24 lines · Bob Peterson
Hi,
Several patches ago, we split the qadata structure from the reservations structure. Now that the previous patch lengthened the lifespan of that structure, we can safely fold the qadata structure back into it again. That saves GFS2 the work and time to allocate and deallocate the qadata structure, since we know quota work is normally only needed when allocations are done.
Regards,
Bob Peterson
Red Hat GFSSigned-off-by Bob Peterson <[email protected]>--
Author: Bob Peterson <[email protected]> Date: Thu Apr 12 12:11:25 2012 -0500GFS2: Fold quota data into the reservations struct
This patch moves the ancillary quota data structures into the block reservations structure. This saves GFS2 a lot of time and effort in allocating and deallocating the qadata structure.
[snip]
Quoted 17 lines
fs/gfs2/rgrp.c +0
-9@@ -1010,25 +1010,6 @@ out: }/** -* gfs2_qadata_get - get the struct gfs2_qadata structure for an inode -* @ip: the incore GFS2 inode structure -* -* Returns: the struct gfs2_qadata -*/ - -struct gfs2_qadata *gfs2_qadata_get (struct gfs2_inode *ip) -{ -struct gfs2_sbd *sdp =GFS2_SB (&ip->i_inode);
fs/gfs2/rgrp.c out: · line 1031
Quoted 10 lines
fs/gfs2/rgrp.c +0
-10-int error; -BUG_ON (ip->i_qadata !=NULL ); - ip->i_qadata =kzalloc (sizeof (struct gfs2_qadata ),GFP_NOFS ); - error =gfs2_rindex_update (sdp); -if (error) -fs_warn (sdp,"rindex update returns %d\n" , error); -return ip->i_qadata; -} - -/**
Does it matter that we will lose the call to gfs2_rindex_update here?
Otherwise it looks good, but I can't apply until the previous patch is ready,
Steve.