aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Peterson <rpeterso@redhat.com>2012-05-18 09:28:23 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2012-06-06 06:20:22 -0400
commit5407e24229408d7586ee451a384fc13e4a2332be (patch)
tree7534b0d0fc69de50b6156ec4e384a71acf01dea1
parent0a305e496059a113f93bdd3ad27a5aaa917fe34d (diff)
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>
-rw-r--r--fs/gfs2/aops.c16
-rw-r--r--fs/gfs2/bmap.c18
-rw-r--r--fs/gfs2/dir.c9
-rw-r--r--fs/gfs2/file.c22
-rw-r--r--fs/gfs2/incore.h13
-rw-r--r--fs/gfs2/inode.c44
-rw-r--r--fs/gfs2/main.c1
-rw-r--r--fs/gfs2/quota.c59
-rw-r--r--fs/gfs2/rgrp.c19
-rw-r--r--fs/gfs2/rgrp.h8
-rw-r--r--fs/gfs2/super.c9
-rw-r--r--fs/gfs2/xattr.c24
12 files changed, 56 insertions, 186 deletions
diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index aba77b5720bc..d6526347d386 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -614,7 +614,6 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
614 unsigned int data_blocks = 0, ind_blocks = 0, rblocks; 614 unsigned int data_blocks = 0, ind_blocks = 0, rblocks;
615 int alloc_required; 615 int alloc_required;
616 int error = 0; 616 int error = 0;
617 struct gfs2_qadata *qa = NULL;
618 pgoff_t index = pos >> PAGE_CACHE_SHIFT; 617 pgoff_t index = pos >> PAGE_CACHE_SHIFT;
619 unsigned from = pos & (PAGE_CACHE_SIZE - 1); 618 unsigned from = pos & (PAGE_CACHE_SIZE - 1);
620 struct page *page; 619 struct page *page;
@@ -638,15 +637,9 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
638 gfs2_write_calc_reserv(ip, len, &data_blocks, &ind_blocks); 637 gfs2_write_calc_reserv(ip, len, &data_blocks, &ind_blocks);
639 638
640 if (alloc_required) { 639 if (alloc_required) {
641 qa = gfs2_qadata_get(ip);
642 if (!qa) {
643 error = -ENOMEM;
644 goto out_unlock;
645 }
646
647 error = gfs2_quota_lock_check(ip); 640 error = gfs2_quota_lock_check(ip);
648 if (error) 641 if (error)
649 goto out_alloc_put; 642 goto out_unlock;
650 643
651 error = gfs2_inplace_reserve(ip, data_blocks + ind_blocks); 644 error = gfs2_inplace_reserve(ip, data_blocks + ind_blocks);
652 if (error) 645 if (error)
@@ -708,8 +701,6 @@ out_trans_fail:
708 gfs2_inplace_release(ip); 701 gfs2_inplace_release(ip);
709out_qunlock: 702out_qunlock:
710 gfs2_quota_unlock(ip); 703 gfs2_quota_unlock(ip);
711out_alloc_put:
712 gfs2_qadata_put(ip);
713 } 704 }
714out_unlock: 705out_unlock:
715 if (&ip->i_inode == sdp->sd_rindex) { 706 if (&ip->i_inode == sdp->sd_rindex) {
@@ -846,7 +837,6 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping,
846 struct gfs2_sbd *sdp = GFS2_SB(inode); 837 struct gfs2_sbd *sdp = GFS2_SB(inode);
847 struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode); 838 struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
848 struct buffer_head *dibh; 839 struct buffer_head *dibh;
849 struct gfs2_qadata *qa = ip->i_qadata;
850 unsigned int from = pos & (PAGE_CACHE_SIZE - 1); 840 unsigned int from = pos & (PAGE_CACHE_SIZE - 1);
851 unsigned int to = from + len; 841 unsigned int to = from + len;
852 int ret; 842 int ret;
@@ -880,10 +870,8 @@ failed:
880 gfs2_trans_end(sdp); 870 gfs2_trans_end(sdp);
881 if (gfs2_mb_reserved(ip)) 871 if (gfs2_mb_reserved(ip))
882 gfs2_inplace_release(ip); 872 gfs2_inplace_release(ip);
883 if (qa) { 873 if (ip->i_res->rs_qa_qd_num)
884 gfs2_quota_unlock(ip); 874 gfs2_quota_unlock(ip);
885 gfs2_qadata_put(ip);
886 }
887 if (inode == sdp->sd_rindex) { 875 if (inode == sdp->sd_rindex) {
888 gfs2_glock_dq(&m_ip->i_gh); 876 gfs2_glock_dq(&m_ip->i_gh);
889 gfs2_holder_uninit(&m_ip->i_gh); 877 gfs2_holder_uninit(&m_ip->i_gh);
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index dab54099dd98..6d957a86482b 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -1045,12 +1045,13 @@ static int trunc_dealloc(struct gfs2_inode *ip, u64 size)
1045 lblock = (size - 1) >> sdp->sd_sb.sb_bsize_shift; 1045 lblock = (size - 1) >> sdp->sd_sb.sb_bsize_shift;
1046 1046
1047 find_metapath(sdp, lblock, &mp, ip->i_height); 1047 find_metapath(sdp, lblock, &mp, ip->i_height);
1048 if (!gfs2_qadata_get(ip)) 1048 error = gfs2_rindex_update(sdp);
1049 return -ENOMEM; 1049 if (error)
1050 return error;
1050 1051
1051 error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); 1052 error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
1052 if (error) 1053 if (error)
1053 goto out; 1054 return error;
1054 1055
1055 while (height--) { 1056 while (height--) {
1056 struct strip_mine sm; 1057 struct strip_mine sm;
@@ -1064,8 +1065,6 @@ static int trunc_dealloc(struct gfs2_inode *ip, u64 size)
1064 1065
1065 gfs2_quota_unhold(ip); 1066 gfs2_quota_unhold(ip);
1066 1067
1067out:
1068 gfs2_qadata_put(ip);
1069 return error; 1068 return error;
1070} 1069}
1071 1070
@@ -1167,19 +1166,14 @@ static int do_grow(struct inode *inode, u64 size)
1167 struct gfs2_inode *ip = GFS2_I(inode); 1166 struct gfs2_inode *ip = GFS2_I(inode);
1168 struct gfs2_sbd *sdp = GFS2_SB(inode); 1167 struct gfs2_sbd *sdp = GFS2_SB(inode);
1169 struct buffer_head *dibh; 1168 struct buffer_head *dibh;
1170 struct gfs2_qadata *qa = NULL;
1171 int error; 1169 int error;
1172 int unstuff = 0; 1170 int unstuff = 0;
1173 1171
1174 if (gfs2_is_stuffed(ip) && 1172 if (gfs2_is_stuffed(ip) &&
1175 (size > (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)))) { 1173 (size > (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)))) {
1176 qa = gfs2_qadata_get(ip);
1177 if (qa == NULL)
1178 return -ENOMEM;
1179
1180 error = gfs2_quota_lock_check(ip); 1174 error = gfs2_quota_lock_check(ip);
1181 if (error) 1175 if (error)
1182 goto do_grow_alloc_put; 1176 return error;
1183 1177
1184 error = gfs2_inplace_reserve(ip, 1); 1178 error = gfs2_inplace_reserve(ip, 1);
1185 if (error) 1179 if (error)
@@ -1214,8 +1208,6 @@ do_grow_release:
1214 gfs2_inplace_release(ip); 1208 gfs2_inplace_release(ip);
1215do_grow_qunlock: 1209do_grow_qunlock:
1216 gfs2_quota_unlock(ip); 1210 gfs2_quota_unlock(ip);
1217do_grow_alloc_put:
1218 gfs2_qadata_put(ip);
1219 } 1211 }
1220 return error; 1212 return error;
1221} 1213}
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index 8aaeb07a07b5..259b088cfc4c 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -1854,14 +1854,9 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
1854 if (!ht) 1854 if (!ht)
1855 return -ENOMEM; 1855 return -ENOMEM;
1856 1856
1857 if (!gfs2_qadata_get(dip)) {
1858 error = -ENOMEM;
1859 goto out;
1860 }
1861
1862 error = gfs2_quota_hold(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); 1857 error = gfs2_quota_hold(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
1863 if (error) 1858 if (error)
1864 goto out_put; 1859 goto out;
1865 1860
1866 /* Count the number of leaves */ 1861 /* Count the number of leaves */
1867 bh = leaf_bh; 1862 bh = leaf_bh;
@@ -1942,8 +1937,6 @@ out_rg_gunlock:
1942out_rlist: 1937out_rlist:
1943 gfs2_rlist_free(&rlist); 1938 gfs2_rlist_free(&rlist);
1944 gfs2_quota_unhold(dip); 1939 gfs2_quota_unhold(dip);
1945out_put:
1946 gfs2_qadata_put(dip);
1947out: 1940out:
1948 kfree(ht); 1941 kfree(ht);
1949 return error; 1942 return error;
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 37906174d417..26e2905070ed 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -366,7 +366,6 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
366 u64 pos = page->index << PAGE_CACHE_SHIFT; 366 u64 pos = page->index << PAGE_CACHE_SHIFT;
367 unsigned int data_blocks, ind_blocks, rblocks; 367 unsigned int data_blocks, ind_blocks, rblocks;
368 struct gfs2_holder gh; 368 struct gfs2_holder gh;
369 struct gfs2_qadata *qa;
370 loff_t size; 369 loff_t size;
371 int ret; 370 int ret;
372 371
@@ -397,14 +396,13 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
397 goto out_unlock; 396 goto out_unlock;
398 } 397 }
399 398
400 ret = -ENOMEM; 399 ret = gfs2_rindex_update(sdp);
401 qa = gfs2_qadata_get(ip); 400 if (ret)
402 if (qa == NULL)
403 goto out_unlock; 401 goto out_unlock;
404 402
405 ret = gfs2_quota_lock_check(ip); 403 ret = gfs2_quota_lock_check(ip);
406 if (ret) 404 if (ret)
407 goto out_alloc_put; 405 goto out_unlock;
408 gfs2_write_calc_reserv(ip, PAGE_CACHE_SIZE, &data_blocks, &ind_blocks); 406 gfs2_write_calc_reserv(ip, PAGE_CACHE_SIZE, &data_blocks, &ind_blocks);
409 ret = gfs2_inplace_reserve(ip, data_blocks + ind_blocks); 407 ret = gfs2_inplace_reserve(ip, data_blocks + ind_blocks);
410 if (ret) 408 if (ret)
@@ -451,8 +449,6 @@ out_trans_fail:
451 gfs2_inplace_release(ip); 449 gfs2_inplace_release(ip);
452out_quota_unlock: 450out_quota_unlock:
453 gfs2_quota_unlock(ip); 451 gfs2_quota_unlock(ip);
454out_alloc_put:
455 gfs2_qadata_put(ip);
456out_unlock: 452out_unlock:
457 gfs2_glock_dq(&gh); 453 gfs2_glock_dq(&gh);
458out: 454out:
@@ -764,7 +760,6 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
764 struct gfs2_inode *ip = GFS2_I(inode); 760 struct gfs2_inode *ip = GFS2_I(inode);
765 unsigned int data_blocks = 0, ind_blocks = 0, rblocks; 761 unsigned int data_blocks = 0, ind_blocks = 0, rblocks;
766 loff_t bytes, max_bytes; 762 loff_t bytes, max_bytes;
767 struct gfs2_qadata *qa;
768 int error; 763 int error;
769 const loff_t pos = offset; 764 const loff_t pos = offset;
770 const loff_t count = len; 765 const loff_t count = len;
@@ -804,15 +799,13 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
804 offset += bytes; 799 offset += bytes;
805 continue; 800 continue;
806 } 801 }
807 qa = gfs2_qadata_get(ip); 802 error = gfs2_rindex_update(sdp);
808 if (!qa) { 803 if (error)
809 error = -ENOMEM;
810 goto out_unlock; 804 goto out_unlock;
811 }
812 805
813 error = gfs2_quota_lock_check(ip); 806 error = gfs2_quota_lock_check(ip);
814 if (error) 807 if (error)
815 goto out_alloc_put; 808 goto out_unlock;
816 809
817retry: 810retry:
818 gfs2_write_calc_reserv(ip, bytes, &data_blocks, &ind_blocks); 811 gfs2_write_calc_reserv(ip, bytes, &data_blocks, &ind_blocks);
@@ -852,7 +845,6 @@ retry:
852 offset += max_bytes; 845 offset += max_bytes;
853 gfs2_inplace_release(ip); 846 gfs2_inplace_release(ip);
854 gfs2_quota_unlock(ip); 847 gfs2_quota_unlock(ip);
855 gfs2_qadata_put(ip);
856 } 848 }
857 849
858 if (error == 0) 850 if (error == 0)
@@ -863,8 +855,6 @@ out_trans_fail:
863 gfs2_inplace_release(ip); 855 gfs2_inplace_release(ip);
864out_qunlock: 856out_qunlock:
865 gfs2_quota_unlock(ip); 857 gfs2_quota_unlock(ip);
866out_alloc_put:
867 gfs2_qadata_put(ip);
868out_unlock: 858out_unlock:
869 gfs2_glock_dq(&ip->i_gh); 859 gfs2_glock_dq(&ip->i_gh);
870out_uninit: 860out_uninit:
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index 67fd6beffece..5cda51a3e3bd 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -289,16 +289,14 @@ struct gfs2_glock {
289 289
290#define GFS2_MIN_LVB_SIZE 32 /* Min size of LVB that gfs2 supports */ 290#define GFS2_MIN_LVB_SIZE 32 /* Min size of LVB that gfs2 supports */
291 291
292struct 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
299struct gfs2_blkreserv { 292struct gfs2_blkreserv {
300 u32 rs_requested; /* Filled in by caller of gfs2_inplace_reserve() */ 293 u32 rs_requested; /* Filled in by caller of gfs2_inplace_reserve() */
301 struct gfs2_holder rs_rgd_gh; /* Filled in by gfs2_inplace_reserve() */ 294 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;
302}; 300};
303 301
304enum { 302enum {
@@ -319,7 +317,6 @@ struct gfs2_inode {
319 struct gfs2_glock *i_gl; /* Move into i_gh? */ 317 struct gfs2_glock *i_gl; /* Move into i_gh? */
320 struct gfs2_holder i_iopen_gh; 318 struct gfs2_holder i_iopen_gh;
321 struct gfs2_holder i_gh; /* for prepare/commit_write only */ 319 struct gfs2_holder i_gh; /* for prepare/commit_write only */
322 struct gfs2_qadata *i_qadata; /* quota allocation data */
323 struct gfs2_blkreserv *i_res; /* resource group block reservation */ 320 struct gfs2_blkreserv *i_res; /* resource group block reservation */
324 struct gfs2_rgrpd *i_rgd; 321 struct gfs2_rgrpd *i_rgd;
325 u64 i_goal; /* goal block for allocations */ 322 u64 i_goal; /* goal block for allocations */
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 2a1b4b5a648c..2b035e0959b2 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -521,12 +521,10 @@ static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
521 int error; 521 int error;
522 522
523 munge_mode_uid_gid(dip, &mode, &uid, &gid); 523 munge_mode_uid_gid(dip, &mode, &uid, &gid);
524 if (!gfs2_qadata_get(dip))
525 return -ENOMEM;
526 524
527 error = gfs2_quota_lock(dip, uid, gid); 525 error = gfs2_quota_lock(dip, uid, gid);
528 if (error) 526 if (error)
529 goto out; 527 return error;
530 528
531 error = gfs2_quota_check(dip, uid, gid); 529 error = gfs2_quota_check(dip, uid, gid);
532 if (error) 530 if (error)
@@ -542,8 +540,6 @@ static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
542 540
543out_quota: 541out_quota:
544 gfs2_quota_unlock(dip); 542 gfs2_quota_unlock(dip);
545out:
546 gfs2_qadata_put(dip);
547 return error; 543 return error;
548} 544}
549 545
@@ -551,15 +547,10 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name,
551 struct gfs2_inode *ip) 547 struct gfs2_inode *ip)
552{ 548{
553 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); 549 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
554 struct gfs2_qadata *qa;
555 int alloc_required; 550 int alloc_required;
556 struct buffer_head *dibh; 551 struct buffer_head *dibh;
557 int error; 552 int error;
558 553
559 qa = gfs2_qadata_get(dip);
560 if (!qa)
561 return -ENOMEM;
562
563 error = gfs2_quota_lock(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); 554 error = gfs2_quota_lock(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
564 if (error) 555 if (error)
565 goto fail; 556 goto fail;
@@ -611,7 +602,6 @@ fail_quota_locks:
611 gfs2_quota_unlock(dip); 602 gfs2_quota_unlock(dip);
612 603
613fail: 604fail:
614 gfs2_qadata_put(dip);
615 return error; 605 return error;
616} 606}
617 607
@@ -734,7 +724,6 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
734 if (gfs2_mb_reserved(dip)) 724 if (gfs2_mb_reserved(dip))
735 gfs2_inplace_release(dip); 725 gfs2_inplace_release(dip);
736 gfs2_quota_unlock(dip); 726 gfs2_quota_unlock(dip);
737 gfs2_qadata_put(dip);
738 mark_inode_dirty(inode); 727 mark_inode_dirty(inode);
739 gfs2_glock_dq_uninit_m(2, ghs); 728 gfs2_glock_dq_uninit_m(2, ghs);
740 d_instantiate(dentry, inode); 729 d_instantiate(dentry, inode);
@@ -883,16 +872,9 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
883 error = 0; 872 error = 0;
884 873
885 if (alloc_required) { 874 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
893 error = gfs2_quota_lock_check(dip); 875 error = gfs2_quota_lock_check(dip);
894 if (error) 876 if (error)
895 goto out_alloc; 877 goto out_gunlock;
896 878
897 error = gfs2_inplace_reserve(dip, sdp->sd_max_dirres); 879 error = gfs2_inplace_reserve(dip, sdp->sd_max_dirres);
898 if (error) 880 if (error)
@@ -935,9 +917,6 @@ out_ipres:
935out_gunlock_q: 917out_gunlock_q:
936 if (alloc_required) 918 if (alloc_required)
937 gfs2_quota_unlock(dip); 919 gfs2_quota_unlock(dip);
938out_alloc:
939 if (alloc_required)
940 gfs2_qadata_put(dip);
941out_gunlock: 920out_gunlock:
942 gfs2_glock_dq(ghs + 1); 921 gfs2_glock_dq(ghs + 1);
943out_child: 922out_child:
@@ -1374,16 +1353,9 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
1374 goto out_gunlock; 1353 goto out_gunlock;
1375 1354
1376 if (alloc_required) { 1355 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
1384 error = gfs2_quota_lock_check(ndip); 1356 error = gfs2_quota_lock_check(ndip);
1385 if (error) 1357 if (error)
1386 goto out_alloc; 1358 goto out_gunlock;
1387 1359
1388 error = gfs2_inplace_reserve(ndip, sdp->sd_max_dirres); 1360 error = gfs2_inplace_reserve(ndip, sdp->sd_max_dirres);
1389 if (error) 1361 if (error)
@@ -1444,9 +1416,6 @@ out_ipreserv:
1444out_gunlock_q: 1416out_gunlock_q:
1445 if (alloc_required) 1417 if (alloc_required)
1446 gfs2_quota_unlock(ndip); 1418 gfs2_quota_unlock(ndip);
1447out_alloc:
1448 if (alloc_required)
1449 gfs2_qadata_put(ndip);
1450out_gunlock: 1419out_gunlock:
1451 while (x--) { 1420 while (x--) {
1452 gfs2_glock_dq(ghs + x); 1421 gfs2_glock_dq(ghs + x);
@@ -1607,12 +1576,9 @@ static int setattr_chown(struct inode *inode, struct iattr *attr)
1607 if (!(attr->ia_valid & ATTR_GID) || ogid == ngid) 1576 if (!(attr->ia_valid & ATTR_GID) || ogid == ngid)
1608 ogid = ngid = NO_QUOTA_CHANGE; 1577 ogid = ngid = NO_QUOTA_CHANGE;
1609 1578
1610 if (!gfs2_qadata_get(ip))
1611 return -ENOMEM;
1612
1613 error = gfs2_quota_lock(ip, nuid, ngid); 1579 error = gfs2_quota_lock(ip, nuid, ngid);
1614 if (error) 1580 if (error)
1615 goto out_alloc; 1581 return error;
1616 1582
1617 if (ouid != NO_QUOTA_CHANGE || ogid != NO_QUOTA_CHANGE) { 1583 if (ouid != NO_QUOTA_CHANGE || ogid != NO_QUOTA_CHANGE) {
1618 error = gfs2_quota_check(ip, nuid, ngid); 1584 error = gfs2_quota_check(ip, nuid, ngid);
@@ -1638,8 +1604,6 @@ out_end_trans:
1638 gfs2_trans_end(sdp); 1604 gfs2_trans_end(sdp);
1639out_gunlock_q: 1605out_gunlock_q:
1640 gfs2_quota_unlock(ip); 1606 gfs2_quota_unlock(ip);
1641out_alloc:
1642 gfs2_qadata_put(ip);
1643 return error; 1607 return error;
1644} 1608}
1645 1609
diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c
index 6cdb0f2a1b09..e04d0e09ee7b 100644
--- a/fs/gfs2/main.c
+++ b/fs/gfs2/main.c
@@ -43,7 +43,6 @@ static void gfs2_init_inode_once(void *foo)
43 inode_init_once(&ip->i_inode); 43 inode_init_once(&ip->i_inode);
44 init_rwsem(&ip->i_rw_mutex); 44 init_rwsem(&ip->i_rw_mutex);
45 INIT_LIST_HEAD(&ip->i_trunc_list); 45 INIT_LIST_HEAD(&ip->i_trunc_list);
46 ip->i_qadata = NULL;
47 ip->i_res = NULL; 46 ip->i_res = NULL;
48 ip->i_hash_cache = NULL; 47 ip->i_hash_cache = NULL;
49} 48}
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index 197cc2dade7f..7d1ede7b66fc 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -494,11 +494,15 @@ static void qdsb_put(struct gfs2_quota_data *qd)
494int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid) 494int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid)
495{ 495{
496 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 496 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
497 struct gfs2_qadata *qa = ip->i_qadata; 497 struct gfs2_quota_data **qd;
498 struct gfs2_quota_data **qd = qa->qa_qd;
499 int error; 498 int error;
500 499
501 if (gfs2_assert_warn(sdp, !qa->qa_qd_num) || 500 if (ip->i_res == NULL)
501 gfs2_rs_alloc(ip);
502
503 qd = ip->i_res->rs_qa_qd;
504
505 if (gfs2_assert_warn(sdp, !ip->i_res->rs_qa_qd_num) ||
502 gfs2_assert_warn(sdp, !test_bit(GIF_QD_LOCKED, &ip->i_flags))) 506 gfs2_assert_warn(sdp, !test_bit(GIF_QD_LOCKED, &ip->i_flags)))
503 return -EIO; 507 return -EIO;
504 508
@@ -508,20 +512,20 @@ int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid)
508 error = qdsb_get(sdp, QUOTA_USER, ip->i_inode.i_uid, qd); 512 error = qdsb_get(sdp, QUOTA_USER, ip->i_inode.i_uid, qd);
509 if (error) 513 if (error)
510 goto out; 514 goto out;
511 qa->qa_qd_num++; 515 ip->i_res->rs_qa_qd_num++;
512 qd++; 516 qd++;
513 517
514 error = qdsb_get(sdp, QUOTA_GROUP, ip->i_inode.i_gid, qd); 518 error = qdsb_get(sdp, QUOTA_GROUP, ip->i_inode.i_gid, qd);
515 if (error) 519 if (error)
516 goto out; 520 goto out;
517 qa->qa_qd_num++; 521 ip->i_res->rs_qa_qd_num++;
518 qd++; 522 qd++;
519 523
520 if (uid != NO_QUOTA_CHANGE && uid != ip->i_inode.i_uid) { 524 if (uid != NO_QUOTA_CHANGE && uid != ip->i_inode.i_uid) {
521 error = qdsb_get(sdp, QUOTA_USER, uid, qd); 525 error = qdsb_get(sdp, QUOTA_USER, uid, qd);
522 if (error) 526 if (error)
523 goto out; 527 goto out;
524 qa->qa_qd_num++; 528 ip->i_res->rs_qa_qd_num++;
525 qd++; 529 qd++;
526 } 530 }
527 531
@@ -529,7 +533,7 @@ int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid)
529 error = qdsb_get(sdp, QUOTA_GROUP, gid, qd); 533 error = qdsb_get(sdp, QUOTA_GROUP, gid, qd);
530 if (error) 534 if (error)
531 goto out; 535 goto out;
532 qa->qa_qd_num++; 536 ip->i_res->rs_qa_qd_num++;
533 qd++; 537 qd++;
534 } 538 }
535 539
@@ -542,16 +546,17 @@ out:
542void gfs2_quota_unhold(struct gfs2_inode *ip) 546void gfs2_quota_unhold(struct gfs2_inode *ip)
543{ 547{
544 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 548 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
545 struct gfs2_qadata *qa = ip->i_qadata;
546 unsigned int x; 549 unsigned int x;
547 550
551 if (ip->i_res == NULL)
552 return;
548 gfs2_assert_warn(sdp, !test_bit(GIF_QD_LOCKED, &ip->i_flags)); 553 gfs2_assert_warn(sdp, !test_bit(GIF_QD_LOCKED, &ip->i_flags));
549 554
550 for (x = 0; x < qa->qa_qd_num; x++) { 555 for (x = 0; x < ip->i_res->rs_qa_qd_num; x++) {
551 qdsb_put(qa->qa_qd[x]); 556 qdsb_put(ip->i_res->rs_qa_qd[x]);
552 qa->qa_qd[x] = NULL; 557 ip->i_res->rs_qa_qd[x] = NULL;
553 } 558 }
554 qa->qa_qd_num = 0; 559 ip->i_res->rs_qa_qd_num = 0;
555} 560}
556 561
557static int sort_qd(const void *a, const void *b) 562static int sort_qd(const void *a, const void *b)
@@ -919,7 +924,6 @@ fail:
919int gfs2_quota_lock(struct gfs2_inode *ip, u32 uid, u32 gid) 924int gfs2_quota_lock(struct gfs2_inode *ip, u32 uid, u32 gid)
920{ 925{
921 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 926 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
922 struct gfs2_qadata *qa = ip->i_qadata;
923 struct gfs2_quota_data *qd; 927 struct gfs2_quota_data *qd;
924 unsigned int x; 928 unsigned int x;
925 int error = 0; 929 int error = 0;
@@ -932,15 +936,15 @@ int gfs2_quota_lock(struct gfs2_inode *ip, u32 uid, u32 gid)
932 sdp->sd_args.ar_quota != GFS2_QUOTA_ON) 936 sdp->sd_args.ar_quota != GFS2_QUOTA_ON)
933 return 0; 937 return 0;
934 938
935 sort(qa->qa_qd, qa->qa_qd_num, sizeof(struct gfs2_quota_data *), 939 sort(ip->i_res->rs_qa_qd, ip->i_res->rs_qa_qd_num,
936 sort_qd, NULL); 940 sizeof(struct gfs2_quota_data *), sort_qd, NULL);
937 941
938 for (x = 0; x < qa->qa_qd_num; x++) { 942 for (x = 0; x < ip->i_res->rs_qa_qd_num; x++) {
939 int force = NO_FORCE; 943 int force = NO_FORCE;
940 qd = qa->qa_qd[x]; 944 qd = ip->i_res->rs_qa_qd[x];
941 if (test_and_clear_bit(QDF_REFRESH, &qd->qd_flags)) 945 if (test_and_clear_bit(QDF_REFRESH, &qd->qd_flags))
942 force = FORCE; 946 force = FORCE;
943 error = do_glock(qd, force, &qa->qa_qd_ghs[x]); 947 error = do_glock(qd, force, &ip->i_res->rs_qa_qd_ghs[x]);
944 if (error) 948 if (error)
945 break; 949 break;
946 } 950 }
@@ -949,7 +953,7 @@ int gfs2_quota_lock(struct gfs2_inode *ip, u32 uid, u32 gid)
949 set_bit(GIF_QD_LOCKED, &ip->i_flags); 953 set_bit(GIF_QD_LOCKED, &ip->i_flags);
950 else { 954 else {
951 while (x--) 955 while (x--)
952 gfs2_glock_dq_uninit(&qa->qa_qd_ghs[x]); 956 gfs2_glock_dq_uninit(&ip->i_res->rs_qa_qd_ghs[x]);
953 gfs2_quota_unhold(ip); 957 gfs2_quota_unhold(ip);
954 } 958 }
955 959
@@ -994,7 +998,6 @@ static int need_sync(struct gfs2_quota_data *qd)
994 998
995void gfs2_quota_unlock(struct gfs2_inode *ip) 999void gfs2_quota_unlock(struct gfs2_inode *ip)
996{ 1000{
997 struct gfs2_qadata *qa = ip->i_qadata;
998 struct gfs2_quota_data *qda[4]; 1001 struct gfs2_quota_data *qda[4];
999 unsigned int count = 0; 1002 unsigned int count = 0;
1000 unsigned int x; 1003 unsigned int x;
@@ -1002,14 +1005,14 @@ void gfs2_quota_unlock(struct gfs2_inode *ip)
1002 if (!test_and_clear_bit(GIF_QD_LOCKED, &ip->i_flags)) 1005 if (!test_and_clear_bit(GIF_QD_LOCKED, &ip->i_flags))
1003 goto out; 1006 goto out;
1004 1007
1005 for (x = 0; x < qa->qa_qd_num; x++) { 1008 for (x = 0; x < ip->i_res->rs_qa_qd_num; x++) {
1006 struct gfs2_quota_data *qd; 1009 struct gfs2_quota_data *qd;
1007 int sync; 1010 int sync;
1008 1011
1009 qd = qa->qa_qd[x]; 1012 qd = ip->i_res->rs_qa_qd[x];
1010 sync = need_sync(qd); 1013 sync = need_sync(qd);
1011 1014
1012 gfs2_glock_dq_uninit(&qa->qa_qd_ghs[x]); 1015 gfs2_glock_dq_uninit(&ip->i_res->rs_qa_qd_ghs[x]);
1013 1016
1014 if (sync && qd_trylock(qd)) 1017 if (sync && qd_trylock(qd))
1015 qda[count++] = qd; 1018 qda[count++] = qd;
@@ -1042,7 +1045,6 @@ static int print_message(struct gfs2_quota_data *qd, char *type)
1042int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid) 1045int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid)
1043{ 1046{
1044 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 1047 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
1045 struct gfs2_qadata *qa = ip->i_qadata;
1046 struct gfs2_quota_data *qd; 1048 struct gfs2_quota_data *qd;
1047 s64 value; 1049 s64 value;
1048 unsigned int x; 1050 unsigned int x;
@@ -1054,8 +1056,8 @@ int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid)
1054 if (sdp->sd_args.ar_quota != GFS2_QUOTA_ON) 1056 if (sdp->sd_args.ar_quota != GFS2_QUOTA_ON)
1055 return 0; 1057 return 0;
1056 1058
1057 for (x = 0; x < qa->qa_qd_num; x++) { 1059 for (x = 0; x < ip->i_res->rs_qa_qd_num; x++) {
1058 qd = qa->qa_qd[x]; 1060 qd = ip->i_res->rs_qa_qd[x];
1059 1061
1060 if (!((qd->qd_id == uid && test_bit(QDF_USER, &qd->qd_flags)) || 1062 if (!((qd->qd_id == uid && test_bit(QDF_USER, &qd->qd_flags)) ||
1061 (qd->qd_id == gid && !test_bit(QDF_USER, &qd->qd_flags)))) 1063 (qd->qd_id == gid && !test_bit(QDF_USER, &qd->qd_flags))))
@@ -1093,7 +1095,6 @@ int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid)
1093void gfs2_quota_change(struct gfs2_inode *ip, s64 change, 1095void gfs2_quota_change(struct gfs2_inode *ip, s64 change,
1094 u32 uid, u32 gid) 1096 u32 uid, u32 gid)
1095{ 1097{
1096 struct gfs2_qadata *qa = ip->i_qadata;
1097 struct gfs2_quota_data *qd; 1098 struct gfs2_quota_data *qd;
1098 unsigned int x; 1099 unsigned int x;
1099 1100
@@ -1102,8 +1103,8 @@ void gfs2_quota_change(struct gfs2_inode *ip, s64 change,
1102 if (ip->i_diskflags & GFS2_DIF_SYSTEM) 1103 if (ip->i_diskflags & GFS2_DIF_SYSTEM)
1103 return; 1104 return;
1104 1105
1105 for (x = 0; x < qa->qa_qd_num; x++) { 1106 for (x = 0; x < ip->i_res->rs_qa_qd_num; x++) {
1106 qd = qa->qa_qd[x]; 1107 qd = ip->i_res->rs_qa_qd[x];
1107 1108
1108 if ((qd->qd_id == uid && test_bit(QDF_USER, &qd->qd_flags)) || 1109 if ((qd->qd_id == uid && test_bit(QDF_USER, &qd->qd_flags)) ||
1109 (qd->qd_id == gid && !test_bit(QDF_USER, &qd->qd_flags))) { 1110 (qd->qd_id == gid && !test_bit(QDF_USER, &qd->qd_flags))) {
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index e944fefbc9a8..9eca6a9cff8f 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -1007,25 +1007,6 @@ out:
1007} 1007}
1008 1008
1009/** 1009/**
1010 * gfs2_qadata_get - get the struct gfs2_qadata structure for an inode
1011 * @ip: the incore GFS2 inode structure
1012 *
1013 * Returns: the struct gfs2_qadata
1014 */
1015
1016struct gfs2_qadata *gfs2_qadata_get(struct gfs2_inode *ip)
1017{
1018 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
1019 int error;
1020 BUG_ON(ip->i_qadata != NULL);
1021 ip->i_qadata = kzalloc(sizeof(struct gfs2_qadata), GFP_NOFS);
1022 error = gfs2_rindex_update(sdp);
1023 if (error)
1024 fs_warn(sdp, "rindex update returns %d\n", error);
1025 return ip->i_qadata;
1026}
1027
1028/**
1029 * try_rgrp_fit - See if a given reservation will fit in a given RG 1010 * try_rgrp_fit - See if a given reservation will fit in a given RG
1030 * @rgd: the RG data 1011 * @rgd: the RG data
1031 * @ip: the inode 1012 * @ip: the inode
diff --git a/fs/gfs2/rgrp.h b/fs/gfs2/rgrp.h
index d9eda5f9ef2a..5d8314dbc899 100644
--- a/fs/gfs2/rgrp.h
+++ b/fs/gfs2/rgrp.h
@@ -29,14 +29,6 @@ extern void gfs2_free_clones(struct gfs2_rgrpd *rgd);
29extern int gfs2_rgrp_go_lock(struct gfs2_holder *gh); 29extern int gfs2_rgrp_go_lock(struct gfs2_holder *gh);
30extern void gfs2_rgrp_go_unlock(struct gfs2_holder *gh); 30extern void gfs2_rgrp_go_unlock(struct gfs2_holder *gh);
31 31
32extern struct gfs2_qadata *gfs2_qadata_get(struct gfs2_inode *ip);
33static inline void gfs2_qadata_put(struct gfs2_inode *ip)
34{
35 BUG_ON(ip->i_qadata == NULL);
36 kfree(ip->i_qadata);
37 ip->i_qadata = NULL;
38}
39
40extern int gfs2_inplace_reserve(struct gfs2_inode *ip, u32 requested); 32extern int gfs2_inplace_reserve(struct gfs2_inode *ip, u32 requested);
41extern void gfs2_inplace_release(struct gfs2_inode *ip); 33extern void gfs2_inplace_release(struct gfs2_inode *ip);
42 34
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 65578df29446..81fc76264ed4 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -1399,7 +1399,6 @@ static void gfs2_final_release_pages(struct gfs2_inode *ip)
1399static int gfs2_dinode_dealloc(struct gfs2_inode *ip) 1399static int gfs2_dinode_dealloc(struct gfs2_inode *ip)
1400{ 1400{
1401 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 1401 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
1402 struct gfs2_qadata *qa;
1403 struct gfs2_rgrpd *rgd; 1402 struct gfs2_rgrpd *rgd;
1404 struct gfs2_holder gh; 1403 struct gfs2_holder gh;
1405 int error; 1404 int error;
@@ -1409,13 +1408,9 @@ static int gfs2_dinode_dealloc(struct gfs2_inode *ip)
1409 return -EIO; 1408 return -EIO;
1410 } 1409 }
1411 1410
1412 qa = gfs2_qadata_get(ip);
1413 if (!qa)
1414 return -ENOMEM;
1415
1416 error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); 1411 error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
1417 if (error) 1412 if (error)
1418 goto out; 1413 return error;
1419 1414
1420 rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr, 1); 1415 rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr, 1);
1421 if (!rgd) { 1416 if (!rgd) {
@@ -1443,8 +1438,6 @@ out_rg_gunlock:
1443 gfs2_glock_dq_uninit(&gh); 1438 gfs2_glock_dq_uninit(&gh);
1444out_qs: 1439out_qs:
1445 gfs2_quota_unhold(ip); 1440 gfs2_quota_unhold(ip);
1446out:
1447 gfs2_qadata_put(ip);
1448 return error; 1441 return error;
1449} 1442}
1450 1443
diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c
index 927f4df874ae..523c0de0d805 100644
--- a/fs/gfs2/xattr.c
+++ b/fs/gfs2/xattr.c
@@ -325,13 +325,8 @@ static int ea_remove_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
325 struct gfs2_ea_header *ea, 325 struct gfs2_ea_header *ea,
326 struct gfs2_ea_header *prev, int leave) 326 struct gfs2_ea_header *prev, int leave)
327{ 327{
328 struct gfs2_qadata *qa;
329 int error; 328 int error;
330 329
331 qa = gfs2_qadata_get(ip);
332 if (!qa)
333 return -ENOMEM;
334
335 error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); 330 error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
336 if (error) 331 if (error)
337 goto out_alloc; 332 goto out_alloc;
@@ -340,7 +335,6 @@ static int ea_remove_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
340 335
341 gfs2_quota_unhold(ip); 336 gfs2_quota_unhold(ip);
342out_alloc: 337out_alloc:
343 gfs2_qadata_put(ip);
344 return error; 338 return error;
345} 339}
346 340
@@ -713,17 +707,12 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er,
713 unsigned int blks, 707 unsigned int blks,
714 ea_skeleton_call_t skeleton_call, void *private) 708 ea_skeleton_call_t skeleton_call, void *private)
715{ 709{
716 struct gfs2_qadata *qa;
717 struct buffer_head *dibh; 710 struct buffer_head *dibh;
718 int error; 711 int error;
719 712
720 qa = gfs2_qadata_get(ip);
721 if (!qa)
722 return -ENOMEM;
723
724 error = gfs2_quota_lock_check(ip); 713 error = gfs2_quota_lock_check(ip);
725 if (error) 714 if (error)
726 goto out; 715 return error;
727 716
728 error = gfs2_inplace_reserve(ip, blks); 717 error = gfs2_inplace_reserve(ip, blks);
729 if (error) 718 if (error)
@@ -753,8 +742,6 @@ out_ipres:
753 gfs2_inplace_release(ip); 742 gfs2_inplace_release(ip);
754out_gunlock_q: 743out_gunlock_q:
755 gfs2_quota_unlock(ip); 744 gfs2_quota_unlock(ip);
756out:
757 gfs2_qadata_put(ip);
758 return error; 745 return error;
759} 746}
760 747
@@ -1494,16 +1481,11 @@ out_gunlock:
1494 1481
1495int gfs2_ea_dealloc(struct gfs2_inode *ip) 1482int gfs2_ea_dealloc(struct gfs2_inode *ip)
1496{ 1483{
1497 struct gfs2_qadata *qa;
1498 int error; 1484 int error;
1499 1485
1500 qa = gfs2_qadata_get(ip);
1501 if (!qa)
1502 return -ENOMEM;
1503
1504 error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); 1486 error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
1505 if (error) 1487 if (error)
1506 goto out_alloc; 1488 return error;
1507 1489
1508 error = ea_foreach(ip, ea_dealloc_unstuffed, NULL); 1490 error = ea_foreach(ip, ea_dealloc_unstuffed, NULL);
1509 if (error) 1491 if (error)
@@ -1519,8 +1501,6 @@ int gfs2_ea_dealloc(struct gfs2_inode *ip)
1519 1501
1520out_quota: 1502out_quota:
1521 gfs2_quota_unhold(ip); 1503 gfs2_quota_unhold(ip);
1522out_alloc:
1523 gfs2_qadata_put(ip);
1524 return error; 1504 return error;
1525} 1505}
1526 1506