Skip to content

Commit 5407e24

Browse files
AstralBobswhiteho
authored andcommitted
GFS2: Fold quota data into the reservations struct
This patch moves the ancillary quota data structures into the block reservations structure. This saves GFS2 some time and effort in allocating and deallocating the qadata structure. Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
1 parent 0a305e4 commit 5407e24

12 files changed

Lines changed: 56 additions & 186 deletions

File tree

‎fs/gfs2/aops.c‎

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,6 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
614614
unsigned int data_blocks = 0, ind_blocks = 0, rblocks;
615615
int alloc_required;
616616
int error = 0;
617-
struct gfs2_qadata *qa = NULL;
618617
pgoff_t index = pos >> PAGE_CACHE_SHIFT;
619618
unsigned from = pos & (PAGE_CACHE_SIZE - 1);
620619
struct page *page;
@@ -638,15 +637,9 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
638637
gfs2_write_calc_reserv(ip, len, &data_blocks, &ind_blocks);
639638

640639
if (alloc_required) {
641-
qa = gfs2_qadata_get(ip);
642-
if (!qa) {
643-
error = -ENOMEM;
644-
goto out_unlock;
645-
}
646-
647640
error = gfs2_quota_lock_check(ip);
648641
if (error)
649-
goto out_alloc_put;
642+
goto out_unlock;
650643

651644
error = gfs2_inplace_reserve(ip, data_blocks + ind_blocks);
652645
if (error)
@@ -708,8 +701,6 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
708701
gfs2_inplace_release(ip);
709702
out_qunlock:
710703
gfs2_quota_unlock(ip);
711-
out_alloc_put:
712-
gfs2_qadata_put(ip);
713704
}
714705
out_unlock:
715706
if (&ip->i_inode == sdp->sd_rindex) {
@@ -846,7 +837,6 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping,
846837
struct gfs2_sbd *sdp = GFS2_SB(inode);
847838
struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
848839
struct buffer_head *dibh;
849-
struct gfs2_qadata *qa = ip->i_qadata;
850840
unsigned int from = pos & (PAGE_CACHE_SIZE - 1);
851841
unsigned int to = from + len;
852842
int ret;
@@ -880,10 +870,8 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping,
880870
gfs2_trans_end(sdp);
881871
if (gfs2_mb_reserved(ip))
882872
gfs2_inplace_release(ip);
883-
if (qa) {
873+
if (ip->i_res->rs_qa_qd_num)
884874
gfs2_quota_unlock(ip);
885-
gfs2_qadata_put(ip);
886-
}
887875
if (inode == sdp->sd_rindex) {
888876
gfs2_glock_dq(&m_ip->i_gh);
889877
gfs2_holder_uninit(&m_ip->i_gh);

‎fs/gfs2/bmap.c‎

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,12 +1045,13 @@ static int trunc_dealloc(struct gfs2_inode *ip, u64 size)
10451045
lblock = (size - 1) >> sdp->sd_sb.sb_bsize_shift;
10461046

10471047
find_metapath(sdp, lblock, &mp, ip->i_height);
1048-
if (!gfs2_qadata_get(ip))
1049-
return -ENOMEM;
1048+
error = gfs2_rindex_update(sdp);
1049+
if (error)
1050+
return error;
10501051

10511052
error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
10521053
if (error)
1053-
goto out;
1054+
return error;
10541055

10551056
while (height--) {
10561057
struct strip_mine sm;
@@ -1064,8 +1065,6 @@ static int trunc_dealloc(struct gfs2_inode *ip, u64 size)
10641065

10651066
gfs2_quota_unhold(ip);
10661067

1067-
out:
1068-
gfs2_qadata_put(ip);
10691068
return error;
10701069
}
10711070

@@ -1167,19 +1166,14 @@ static int do_grow(struct inode *inode, u64 size)
11671166
struct gfs2_inode *ip = GFS2_I(inode);
11681167
struct gfs2_sbd *sdp = GFS2_SB(inode);
11691168
struct buffer_head *dibh;
1170-
struct gfs2_qadata *qa = NULL;
11711169
int error;
11721170
int unstuff = 0;
11731171

11741172
if (gfs2_is_stuffed(ip) &&
11751173
(size > (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)))) {
1176-
qa = gfs2_qadata_get(ip);
1177-
if (qa == NULL)
1178-
return -ENOMEM;
1179-
11801174
error = gfs2_quota_lock_check(ip);
11811175
if (error)
1182-
goto do_grow_alloc_put;
1176+
return error;
11831177

11841178
error = gfs2_inplace_reserve(ip, 1);
11851179
if (error)
@@ -1214,8 +1208,6 @@ static int do_grow(struct inode *inode, u64 size)
12141208
gfs2_inplace_release(ip);
12151209
do_grow_qunlock:
12161210
gfs2_quota_unlock(ip);
1217-
do_grow_alloc_put:
1218-
gfs2_qadata_put(ip);
12191211
}
12201212
return error;
12211213
}

‎fs/gfs2/dir.c‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,14 +1854,9 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
18541854
if (!ht)
18551855
return -ENOMEM;
18561856

1857-
if (!gfs2_qadata_get(dip)) {
1858-
error = -ENOMEM;
1859-
goto out;
1860-
}
1861-
18621857
error = gfs2_quota_hold(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
18631858
if (error)
1864-
goto out_put;
1859+
goto out;
18651860

18661861
/* Count the number of leaves */
18671862
bh = leaf_bh;
@@ -1942,8 +1937,6 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
19421937
out_rlist:
19431938
gfs2_rlist_free(&rlist);
19441939
gfs2_quota_unhold(dip);
1945-
out_put:
1946-
gfs2_qadata_put(dip);
19471940
out:
19481941
kfree(ht);
19491942
return error;

‎fs/gfs2/file.c‎

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,6 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
366366
u64 pos = page->index << PAGE_CACHE_SHIFT;
367367
unsigned int data_blocks, ind_blocks, rblocks;
368368
struct gfs2_holder gh;
369-
struct gfs2_qadata *qa;
370369
loff_t size;
371370
int ret;
372371

@@ -397,14 +396,13 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
397396
goto out_unlock;
398397
}
399398

400-
ret = -ENOMEM;
401-
qa = gfs2_qadata_get(ip);
402-
if (qa == NULL)
399+
ret = gfs2_rindex_update(sdp);
400+
if (ret)
403401
goto out_unlock;
404402

405403
ret = gfs2_quota_lock_check(ip);
406404
if (ret)
407-
goto out_alloc_put;
405+
goto out_unlock;
408406
gfs2_write_calc_reserv(ip, PAGE_CACHE_SIZE, &data_blocks, &ind_blocks);
409407
ret = gfs2_inplace_reserve(ip, data_blocks + ind_blocks);
410408
if (ret)
@@ -451,8 +449,6 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
451449
gfs2_inplace_release(ip);
452450
out_quota_unlock:
453451
gfs2_quota_unlock(ip);
454-
out_alloc_put:
455-
gfs2_qadata_put(ip);
456452
out_unlock:
457453
gfs2_glock_dq(&gh);
458454
out:
@@ -764,7 +760,6 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
764760
struct gfs2_inode *ip = GFS2_I(inode);
765761
unsigned int data_blocks = 0, ind_blocks = 0, rblocks;
766762
loff_t bytes, max_bytes;
767-
struct gfs2_qadata *qa;
768763
int error;
769764
const loff_t pos = offset;
770765
const loff_t count = len;
@@ -804,15 +799,13 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
804799
offset += bytes;
805800
continue;
806801
}
807-
qa = gfs2_qadata_get(ip);
808-
if (!qa) {
809-
error = -ENOMEM;
802+
error = gfs2_rindex_update(sdp);
803+
if (error)
810804
goto out_unlock;
811-
}
812805

813806
error = gfs2_quota_lock_check(ip);
814807
if (error)
815-
goto out_alloc_put;
808+
goto out_unlock;
816809

817810
retry:
818811
gfs2_write_calc_reserv(ip, bytes, &data_blocks, &ind_blocks);
@@ -852,7 +845,6 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
852845
offset += max_bytes;
853846
gfs2_inplace_release(ip);
854847
gfs2_quota_unlock(ip);
855-
gfs2_qadata_put(ip);
856848
}
857849

858850
if (error == 0)
@@ -863,8 +855,6 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
863855
gfs2_inplace_release(ip);
864856
out_qunlock:
865857
gfs2_quota_unlock(ip);
866-
out_alloc_put:
867-
gfs2_qadata_put(ip);
868858
out_unlock:
869859
gfs2_glock_dq(&ip->i_gh);
870860
out_uninit:

‎fs/gfs2/incore.h‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -289,16 +289,14 @@ struct gfs2_glock {
289289

290290
#define GFS2_MIN_LVB_SIZE 32 /* Min size of LVB that gfs2 supports */
291291

292-
struct gfs2_qadata { /* quota allocation data */
293-
/* Quota stuff */
294-
struct gfs2_quota_data *qa_qd[2*MAXQUOTAS];
295-
struct gfs2_holder qa_qd_ghs[2*MAXQUOTAS];
296-
unsigned int qa_qd_num;
297-
};
298-
299292
struct gfs2_blkreserv {
300293
u32 rs_requested; /* Filled in by caller of gfs2_inplace_reserve() */
301294
struct gfs2_holder rs_rgd_gh; /* Filled in by gfs2_inplace_reserve() */
295+
296+
/* ancillary quota stuff */
297+
struct gfs2_quota_data *rs_qa_qd[2 * MAXQUOTAS];
298+
struct gfs2_holder rs_qa_qd_ghs[2 * MAXQUOTAS];
299+
unsigned int rs_qa_qd_num;
302300
};
303301

304302
enum {
@@ -319,7 +317,6 @@ struct gfs2_inode {
319317
struct gfs2_glock *i_gl; /* Move into i_gh? */
320318
struct gfs2_holder i_iopen_gh;
321319
struct gfs2_holder i_gh; /* for prepare/commit_write only */
322-
struct gfs2_qadata *i_qadata; /* quota allocation data */
323320
struct gfs2_blkreserv *i_res; /* resource group block reservation */
324321
struct gfs2_rgrpd *i_rgd;
325322
u64 i_goal; /* goal block for allocations */

‎fs/gfs2/inode.c‎

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -521,12 +521,10 @@ static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
521521
int error;
522522

523523
munge_mode_uid_gid(dip, &mode, &uid, &gid);
524-
if (!gfs2_qadata_get(dip))
525-
return -ENOMEM;
526524

527525
error = gfs2_quota_lock(dip, uid, gid);
528526
if (error)
529-
goto out;
527+
return error;
530528

531529
error = gfs2_quota_check(dip, uid, gid);
532530
if (error)
@@ -542,24 +540,17 @@ static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
542540

543541
out_quota:
544542
gfs2_quota_unlock(dip);
545-
out:
546-
gfs2_qadata_put(dip);
547543
return error;
548544
}
549545

550546
static int link_dinode(struct gfs2_inode *dip, const struct qstr *name,
551547
struct gfs2_inode *ip)
552548
{
553549
struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
554-
struct gfs2_qadata *qa;
555550
int alloc_required;
556551
struct buffer_head *dibh;
557552
int error;
558553

559-
qa = gfs2_qadata_get(dip);
560-
if (!qa)
561-
return -ENOMEM;
562-
563554
error = gfs2_quota_lock(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
564555
if (error)
565556
goto fail;
@@ -611,7 +602,6 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name,
611602
gfs2_quota_unlock(dip);
612603

613604
fail:
614-
gfs2_qadata_put(dip);
615605
return error;
616606
}
617607

@@ -734,7 +724,6 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
734724
if (gfs2_mb_reserved(dip))
735725
gfs2_inplace_release(dip);
736726
gfs2_quota_unlock(dip);
737-
gfs2_qadata_put(dip);
738727
mark_inode_dirty(inode);
739728
gfs2_glock_dq_uninit_m(2, ghs);
740729
d_instantiate(dentry, inode);
@@ -883,16 +872,9 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
883872
error = 0;
884873

885874
if (alloc_required) {
886-
struct gfs2_qadata *qa = gfs2_qadata_get(dip);
887-
888-
if (!qa) {
889-
error = -ENOMEM;
890-
goto out_gunlock;
891-
}
892-
893875
error = gfs2_quota_lock_check(dip);
894876
if (error)
895-
goto out_alloc;
877+
goto out_gunlock;
896878

897879
error = gfs2_inplace_reserve(dip, sdp->sd_max_dirres);
898880
if (error)
@@ -935,9 +917,6 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
935917
out_gunlock_q:
936918
if (alloc_required)
937919
gfs2_quota_unlock(dip);
938-
out_alloc:
939-
if (alloc_required)
940-
gfs2_qadata_put(dip);
941920
out_gunlock:
942921
gfs2_glock_dq(ghs + 1);
943922
out_child:
@@ -1374,16 +1353,9 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
13741353
goto out_gunlock;
13751354

13761355
if (alloc_required) {
1377-
struct gfs2_qadata *qa = gfs2_qadata_get(ndip);
1378-
1379-
if (!qa) {
1380-
error = -ENOMEM;
1381-
goto out_gunlock;
1382-
}
1383-
13841356
error = gfs2_quota_lock_check(ndip);
13851357
if (error)
1386-
goto out_alloc;
1358+
goto out_gunlock;
13871359

13881360
error = gfs2_inplace_reserve(ndip, sdp->sd_max_dirres);
13891361
if (error)
@@ -1444,9 +1416,6 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
14441416
out_gunlock_q:
14451417
if (alloc_required)
14461418
gfs2_quota_unlock(ndip);
1447-
out_alloc:
1448-
if (alloc_required)
1449-
gfs2_qadata_put(ndip);
14501419
out_gunlock:
14511420
while (x--) {
14521421
gfs2_glock_dq(ghs + x);
@@ -1607,12 +1576,9 @@ static int setattr_chown(struct inode *inode, struct iattr *attr)
16071576
if (!(attr->ia_valid & ATTR_GID) || ogid == ngid)
16081577
ogid = ngid = NO_QUOTA_CHANGE;
16091578

1610-
if (!gfs2_qadata_get(ip))
1611-
return -ENOMEM;
1612-
16131579
error = gfs2_quota_lock(ip, nuid, ngid);
16141580
if (error)
1615-
goto out_alloc;
1581+
return error;
16161582

16171583
if (ouid != NO_QUOTA_CHANGE || ogid != NO_QUOTA_CHANGE) {
16181584
error = gfs2_quota_check(ip, nuid, ngid);
@@ -1638,8 +1604,6 @@ static int setattr_chown(struct inode *inode, struct iattr *attr)
16381604
gfs2_trans_end(sdp);
16391605
out_gunlock_q:
16401606
gfs2_quota_unlock(ip);
1641-
out_alloc:
1642-
gfs2_qadata_put(ip);
16431607
return error;
16441608
}
16451609

‎fs/gfs2/main.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ static void gfs2_init_inode_once(void *foo)
4343
inode_init_once(&ip->i_inode);
4444
init_rwsem(&ip->i_rw_mutex);
4545
INIT_LIST_HEAD(&ip->i_trunc_list);
46-
ip->i_qadata = NULL;
4746
ip->i_res = NULL;
4847
ip->i_hash_cache = NULL;
4948
}

0 commit comments

Comments
 (0)