aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/quota.c
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 /fs/gfs2/quota.c
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>
Diffstat (limited to 'fs/gfs2/quota.c')
-rw-r--r--fs/gfs2/quota.c59
1 files changed, 30 insertions, 29 deletions
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))) {