aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_trans_dquot.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_trans_dquot.c')
-rw-r--r--fs/xfs/xfs_trans_dquot.c87
1 files changed, 37 insertions, 50 deletions
diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
index fec75d023703..3ba64d540168 100644
--- a/fs/xfs/xfs_trans_dquot.c
+++ b/fs/xfs/xfs_trans_dquot.c
@@ -103,8 +103,6 @@ xfs_trans_dup_dqinfo(
103 return; 103 return;
104 104
105 xfs_trans_alloc_dqinfo(ntp); 105 xfs_trans_alloc_dqinfo(ntp);
106 oqa = otp->t_dqinfo->dqa_usrdquots;
107 nqa = ntp->t_dqinfo->dqa_usrdquots;
108 106
109 /* 107 /*
110 * Because the quota blk reservation is carried forward, 108 * Because the quota blk reservation is carried forward,
@@ -113,7 +111,9 @@ xfs_trans_dup_dqinfo(
113 if(otp->t_flags & XFS_TRANS_DQ_DIRTY) 111 if(otp->t_flags & XFS_TRANS_DQ_DIRTY)
114 ntp->t_flags |= XFS_TRANS_DQ_DIRTY; 112 ntp->t_flags |= XFS_TRANS_DQ_DIRTY;
115 113
116 for (j = 0; j < 2; j++) { 114 for (j = 0; j < XFS_QM_TRANS_DQTYPES; j++) {
115 oqa = otp->t_dqinfo->dqs[j];
116 nqa = ntp->t_dqinfo->dqs[j];
117 for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) { 117 for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) {
118 if (oqa[i].qt_dquot == NULL) 118 if (oqa[i].qt_dquot == NULL)
119 break; 119 break;
@@ -138,8 +138,6 @@ xfs_trans_dup_dqinfo(
138 oq->qt_ino_res = oq->qt_ino_res_used; 138 oq->qt_ino_res = oq->qt_ino_res_used;
139 139
140 } 140 }
141 oqa = otp->t_dqinfo->dqa_grpdquots;
142 nqa = ntp->t_dqinfo->dqa_grpdquots;
143 } 141 }
144} 142}
145 143
@@ -157,8 +155,7 @@ xfs_trans_mod_dquot_byino(
157 155
158 if (!XFS_IS_QUOTA_RUNNING(mp) || 156 if (!XFS_IS_QUOTA_RUNNING(mp) ||
159 !XFS_IS_QUOTA_ON(mp) || 157 !XFS_IS_QUOTA_ON(mp) ||
160 ip->i_ino == mp->m_sb.sb_uquotino || 158 xfs_is_quota_inode(&mp->m_sb, ip->i_ino))
161 ip->i_ino == mp->m_sb.sb_gquotino)
162 return; 159 return;
163 160
164 if (tp->t_dqinfo == NULL) 161 if (tp->t_dqinfo == NULL)
@@ -170,16 +167,18 @@ xfs_trans_mod_dquot_byino(
170 (void) xfs_trans_mod_dquot(tp, ip->i_gdquot, field, delta); 167 (void) xfs_trans_mod_dquot(tp, ip->i_gdquot, field, delta);
171} 168}
172 169
173STATIC xfs_dqtrx_t * 170STATIC struct xfs_dqtrx *
174xfs_trans_get_dqtrx( 171xfs_trans_get_dqtrx(
175 xfs_trans_t *tp, 172 struct xfs_trans *tp,
176 xfs_dquot_t *dqp) 173 struct xfs_dquot *dqp)
177{ 174{
178 int i; 175 int i;
179 xfs_dqtrx_t *qa; 176 struct xfs_dqtrx *qa;
180 177
181 qa = XFS_QM_ISUDQ(dqp) ? 178 if (XFS_QM_ISUDQ(dqp))
182 tp->t_dqinfo->dqa_usrdquots : tp->t_dqinfo->dqa_grpdquots; 179 qa = tp->t_dqinfo->dqs[XFS_QM_TRANS_USR];
180 else
181 qa = tp->t_dqinfo->dqs[XFS_QM_TRANS_GRP];
183 182
184 for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) { 183 for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) {
185 if (qa[i].qt_dquot == NULL || 184 if (qa[i].qt_dquot == NULL ||
@@ -339,12 +338,10 @@ xfs_trans_apply_dquot_deltas(
339 return; 338 return;
340 339
341 ASSERT(tp->t_dqinfo); 340 ASSERT(tp->t_dqinfo);
342 qa = tp->t_dqinfo->dqa_usrdquots; 341 for (j = 0; j < XFS_QM_TRANS_DQTYPES; j++) {
343 for (j = 0; j < 2; j++) { 342 qa = tp->t_dqinfo->dqs[j];
344 if (qa[0].qt_dquot == NULL) { 343 if (qa[0].qt_dquot == NULL)
345 qa = tp->t_dqinfo->dqa_grpdquots;
346 continue; 344 continue;
347 }
348 345
349 /* 346 /*
350 * Lock all of the dquots and join them to the transaction. 347 * Lock all of the dquots and join them to the transaction.
@@ -495,10 +492,6 @@ xfs_trans_apply_dquot_deltas(
495 ASSERT(dqp->q_res_rtbcount >= 492 ASSERT(dqp->q_res_rtbcount >=
496 be64_to_cpu(dqp->q_core.d_rtbcount)); 493 be64_to_cpu(dqp->q_core.d_rtbcount));
497 } 494 }
498 /*
499 * Do the group quotas next
500 */
501 qa = tp->t_dqinfo->dqa_grpdquots;
502 } 495 }
503} 496}
504 497
@@ -521,9 +514,9 @@ xfs_trans_unreserve_and_mod_dquots(
521 if (!tp->t_dqinfo || !(tp->t_flags & XFS_TRANS_DQ_DIRTY)) 514 if (!tp->t_dqinfo || !(tp->t_flags & XFS_TRANS_DQ_DIRTY))
522 return; 515 return;
523 516
524 qa = tp->t_dqinfo->dqa_usrdquots; 517 for (j = 0; j < XFS_QM_TRANS_DQTYPES; j++) {
518 qa = tp->t_dqinfo->dqs[j];
525 519
526 for (j = 0; j < 2; j++) {
527 for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) { 520 for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) {
528 qtrx = &qa[i]; 521 qtrx = &qa[i];
529 /* 522 /*
@@ -565,7 +558,6 @@ xfs_trans_unreserve_and_mod_dquots(
565 xfs_dqunlock(dqp); 558 xfs_dqunlock(dqp);
566 559
567 } 560 }
568 qa = tp->t_dqinfo->dqa_grpdquots;
569 } 561 }
570} 562}
571 563
@@ -640,8 +632,8 @@ xfs_trans_dqresv(
640 if ((flags & XFS_QMOPT_FORCE_RES) == 0 && 632 if ((flags & XFS_QMOPT_FORCE_RES) == 0 &&
641 dqp->q_core.d_id && 633 dqp->q_core.d_id &&
642 ((XFS_IS_UQUOTA_ENFORCED(dqp->q_mount) && XFS_QM_ISUDQ(dqp)) || 634 ((XFS_IS_UQUOTA_ENFORCED(dqp->q_mount) && XFS_QM_ISUDQ(dqp)) ||
643 (XFS_IS_OQUOTA_ENFORCED(dqp->q_mount) && 635 (XFS_IS_GQUOTA_ENFORCED(dqp->q_mount) && XFS_QM_ISGDQ(dqp)) ||
644 (XFS_QM_ISPDQ(dqp) || XFS_QM_ISGDQ(dqp))))) { 636 (XFS_IS_PQUOTA_ENFORCED(dqp->q_mount) && XFS_QM_ISPDQ(dqp)))) {
645 if (nblks > 0) { 637 if (nblks > 0) {
646 /* 638 /*
647 * dquot is locked already. See if we'd go over the 639 * dquot is locked already. See if we'd go over the
@@ -748,15 +740,15 @@ error_return:
748 */ 740 */
749int 741int
750xfs_trans_reserve_quota_bydquots( 742xfs_trans_reserve_quota_bydquots(
751 xfs_trans_t *tp, 743 struct xfs_trans *tp,
752 xfs_mount_t *mp, 744 struct xfs_mount *mp,
753 xfs_dquot_t *udqp, 745 struct xfs_dquot *udqp,
754 xfs_dquot_t *gdqp, 746 struct xfs_dquot *gdqp,
755 long nblks, 747 long nblks,
756 long ninos, 748 long ninos,
757 uint flags) 749 uint flags)
758{ 750{
759 int resvd = 0, error; 751 int error;
760 752
761 if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) 753 if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp))
762 return 0; 754 return 0;
@@ -771,28 +763,24 @@ xfs_trans_reserve_quota_bydquots(
771 (flags & ~XFS_QMOPT_ENOSPC)); 763 (flags & ~XFS_QMOPT_ENOSPC));
772 if (error) 764 if (error)
773 return error; 765 return error;
774 resvd = 1;
775 } 766 }
776 767
777 if (gdqp) { 768 if (gdqp) {
778 error = xfs_trans_dqresv(tp, mp, gdqp, nblks, ninos, flags); 769 error = xfs_trans_dqresv(tp, mp, gdqp, nblks, ninos, flags);
779 if (error) { 770 if (error)
780 /* 771 goto unwind_usr;
781 * can't do it, so backout previous reservation
782 */
783 if (resvd) {
784 flags |= XFS_QMOPT_FORCE_RES;
785 xfs_trans_dqresv(tp, mp, udqp,
786 -nblks, -ninos, flags);
787 }
788 return error;
789 }
790 } 772 }
791 773
792 /* 774 /*
793 * Didn't change anything critical, so, no need to log 775 * Didn't change anything critical, so, no need to log
794 */ 776 */
795 return 0; 777 return 0;
778
779unwind_usr:
780 flags |= XFS_QMOPT_FORCE_RES;
781 if (udqp)
782 xfs_trans_dqresv(tp, mp, udqp, -nblks, -ninos, flags);
783 return error;
796} 784}
797 785
798 786
@@ -816,8 +804,7 @@ xfs_trans_reserve_quota_nblks(
816 if (XFS_IS_PQUOTA_ON(mp)) 804 if (XFS_IS_PQUOTA_ON(mp))
817 flags |= XFS_QMOPT_ENOSPC; 805 flags |= XFS_QMOPT_ENOSPC;
818 806
819 ASSERT(ip->i_ino != mp->m_sb.sb_uquotino); 807 ASSERT(!xfs_is_quota_inode(&mp->m_sb, ip->i_ino));
820 ASSERT(ip->i_ino != mp->m_sb.sb_gquotino);
821 808
822 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); 809 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
823 ASSERT((flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) == 810 ASSERT((flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) ==