diff options
Diffstat (limited to 'fs/xfs/quota/xfs_dquot.c')
-rw-r--r-- | fs/xfs/quota/xfs_dquot.c | 110 |
1 files changed, 31 insertions, 79 deletions
diff --git a/fs/xfs/quota/xfs_dquot.c b/fs/xfs/quota/xfs_dquot.c index 2f3f2229eaaf..d7c7eea09fc2 100644 --- a/fs/xfs/quota/xfs_dquot.c +++ b/fs/xfs/quota/xfs_dquot.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include "xfs_trans_space.h" | 47 | #include "xfs_trans_space.h" |
48 | #include "xfs_trans_priv.h" | 48 | #include "xfs_trans_priv.h" |
49 | #include "xfs_qm.h" | 49 | #include "xfs_qm.h" |
50 | #include "xfs_trace.h" | ||
50 | 51 | ||
51 | 52 | ||
52 | /* | 53 | /* |
@@ -112,10 +113,7 @@ xfs_qm_dqinit( | |||
112 | init_completion(&dqp->q_flush); | 113 | init_completion(&dqp->q_flush); |
113 | complete(&dqp->q_flush); | 114 | complete(&dqp->q_flush); |
114 | 115 | ||
115 | #ifdef XFS_DQUOT_TRACE | 116 | trace_xfs_dqinit(dqp); |
116 | dqp->q_trace = ktrace_alloc(DQUOT_TRACE_SIZE, KM_NOFS); | ||
117 | xfs_dqtrace_entry(dqp, "DQINIT"); | ||
118 | #endif | ||
119 | } else { | 117 | } else { |
120 | /* | 118 | /* |
121 | * Only the q_core portion was zeroed in dqreclaim_one(). | 119 | * Only the q_core portion was zeroed in dqreclaim_one(). |
@@ -136,10 +134,7 @@ xfs_qm_dqinit( | |||
136 | dqp->q_hash = NULL; | 134 | dqp->q_hash = NULL; |
137 | ASSERT(dqp->dq_flnext == dqp->dq_flprev); | 135 | ASSERT(dqp->dq_flnext == dqp->dq_flprev); |
138 | 136 | ||
139 | #ifdef XFS_DQUOT_TRACE | 137 | trace_xfs_dqreuse(dqp); |
140 | ASSERT(dqp->q_trace); | ||
141 | xfs_dqtrace_entry(dqp, "DQRECLAIMED_INIT"); | ||
142 | #endif | ||
143 | } | 138 | } |
144 | 139 | ||
145 | /* | 140 | /* |
@@ -167,13 +162,8 @@ xfs_qm_dqdestroy( | |||
167 | 162 | ||
168 | mutex_destroy(&dqp->q_qlock); | 163 | mutex_destroy(&dqp->q_qlock); |
169 | sv_destroy(&dqp->q_pinwait); | 164 | sv_destroy(&dqp->q_pinwait); |
170 | |||
171 | #ifdef XFS_DQUOT_TRACE | ||
172 | if (dqp->q_trace) | ||
173 | ktrace_free(dqp->q_trace); | ||
174 | dqp->q_trace = NULL; | ||
175 | #endif | ||
176 | kmem_zone_free(xfs_Gqm->qm_dqzone, dqp); | 165 | kmem_zone_free(xfs_Gqm->qm_dqzone, dqp); |
166 | |||
177 | atomic_dec(&xfs_Gqm->qm_totaldquots); | 167 | atomic_dec(&xfs_Gqm->qm_totaldquots); |
178 | } | 168 | } |
179 | 169 | ||
@@ -195,49 +185,6 @@ xfs_qm_dqinit_core( | |||
195 | d->dd_diskdq.d_flags = type; | 185 | d->dd_diskdq.d_flags = type; |
196 | } | 186 | } |
197 | 187 | ||
198 | |||
199 | #ifdef XFS_DQUOT_TRACE | ||
200 | /* | ||
201 | * Dquot tracing for debugging. | ||
202 | */ | ||
203 | /* ARGSUSED */ | ||
204 | void | ||
205 | __xfs_dqtrace_entry( | ||
206 | xfs_dquot_t *dqp, | ||
207 | char *func, | ||
208 | void *retaddr, | ||
209 | xfs_inode_t *ip) | ||
210 | { | ||
211 | xfs_dquot_t *udqp = NULL; | ||
212 | xfs_ino_t ino = 0; | ||
213 | |||
214 | ASSERT(dqp->q_trace); | ||
215 | if (ip) { | ||
216 | ino = ip->i_ino; | ||
217 | udqp = ip->i_udquot; | ||
218 | } | ||
219 | ktrace_enter(dqp->q_trace, | ||
220 | (void *)(__psint_t)DQUOT_KTRACE_ENTRY, | ||
221 | (void *)func, | ||
222 | (void *)(__psint_t)dqp->q_nrefs, | ||
223 | (void *)(__psint_t)dqp->dq_flags, | ||
224 | (void *)(__psint_t)dqp->q_res_bcount, | ||
225 | (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_bcount), | ||
226 | (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_icount), | ||
227 | (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_blk_hardlimit), | ||
228 | (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_blk_softlimit), | ||
229 | (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_ino_hardlimit), | ||
230 | (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_ino_softlimit), | ||
231 | (void *)(__psint_t)be32_to_cpu(dqp->q_core.d_id), | ||
232 | (void *)(__psint_t)current_pid(), | ||
233 | (void *)(__psint_t)ino, | ||
234 | (void *)(__psint_t)retaddr, | ||
235 | (void *)(__psint_t)udqp); | ||
236 | return; | ||
237 | } | ||
238 | #endif | ||
239 | |||
240 | |||
241 | /* | 188 | /* |
242 | * If default limits are in force, push them into the dquot now. | 189 | * If default limits are in force, push them into the dquot now. |
243 | * We overwrite the dquot limits only if they are zero and this | 190 | * We overwrite the dquot limits only if they are zero and this |
@@ -425,7 +372,8 @@ xfs_qm_dqalloc( | |||
425 | xfs_trans_t *tp = *tpp; | 372 | xfs_trans_t *tp = *tpp; |
426 | 373 | ||
427 | ASSERT(tp != NULL); | 374 | ASSERT(tp != NULL); |
428 | xfs_dqtrace_entry(dqp, "DQALLOC"); | 375 | |
376 | trace_xfs_dqalloc(dqp); | ||
429 | 377 | ||
430 | /* | 378 | /* |
431 | * Initialize the bmap freelist prior to calling bmapi code. | 379 | * Initialize the bmap freelist prior to calling bmapi code. |
@@ -612,7 +560,8 @@ xfs_qm_dqtobp( | |||
612 | * (in which case we already have the buf). | 560 | * (in which case we already have the buf). |
613 | */ | 561 | */ |
614 | if (! newdquot) { | 562 | if (! newdquot) { |
615 | xfs_dqtrace_entry(dqp, "DQTOBP READBUF"); | 563 | trace_xfs_dqtobp_read(dqp); |
564 | |||
616 | if ((error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, | 565 | if ((error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, |
617 | dqp->q_blkno, | 566 | dqp->q_blkno, |
618 | XFS_QI_DQCHUNKLEN(mp), | 567 | XFS_QI_DQCHUNKLEN(mp), |
@@ -670,11 +619,12 @@ xfs_qm_dqread( | |||
670 | 619 | ||
671 | ASSERT(tpp); | 620 | ASSERT(tpp); |
672 | 621 | ||
622 | trace_xfs_dqread(dqp); | ||
623 | |||
673 | /* | 624 | /* |
674 | * get a pointer to the on-disk dquot and the buffer containing it | 625 | * get a pointer to the on-disk dquot and the buffer containing it |
675 | * dqp already knows its own type (GROUP/USER). | 626 | * dqp already knows its own type (GROUP/USER). |
676 | */ | 627 | */ |
677 | xfs_dqtrace_entry(dqp, "DQREAD"); | ||
678 | if ((error = xfs_qm_dqtobp(tpp, dqp, &ddqp, &bp, flags))) { | 628 | if ((error = xfs_qm_dqtobp(tpp, dqp, &ddqp, &bp, flags))) { |
679 | return (error); | 629 | return (error); |
680 | } | 630 | } |
@@ -763,7 +713,7 @@ xfs_qm_idtodq( | |||
763 | * or if the dquot didn't exist on disk and we ask to | 713 | * or if the dquot didn't exist on disk and we ask to |
764 | * allocate (ENOENT). | 714 | * allocate (ENOENT). |
765 | */ | 715 | */ |
766 | xfs_dqtrace_entry(dqp, "DQREAD FAIL"); | 716 | trace_xfs_dqread_fail(dqp); |
767 | cancelflags |= XFS_TRANS_ABORT; | 717 | cancelflags |= XFS_TRANS_ABORT; |
768 | goto error0; | 718 | goto error0; |
769 | } | 719 | } |
@@ -817,7 +767,8 @@ xfs_qm_dqlookup( | |||
817 | * id can't be modified without the hashlock anyway. | 767 | * id can't be modified without the hashlock anyway. |
818 | */ | 768 | */ |
819 | if (be32_to_cpu(dqp->q_core.d_id) == id && dqp->q_mount == mp) { | 769 | if (be32_to_cpu(dqp->q_core.d_id) == id && dqp->q_mount == mp) { |
820 | xfs_dqtrace_entry(dqp, "DQFOUND BY LOOKUP"); | 770 | trace_xfs_dqlookup_found(dqp); |
771 | |||
821 | /* | 772 | /* |
822 | * All in core dquots must be on the dqlist of mp | 773 | * All in core dquots must be on the dqlist of mp |
823 | */ | 774 | */ |
@@ -827,7 +778,7 @@ xfs_qm_dqlookup( | |||
827 | if (dqp->q_nrefs == 0) { | 778 | if (dqp->q_nrefs == 0) { |
828 | ASSERT (XFS_DQ_IS_ON_FREELIST(dqp)); | 779 | ASSERT (XFS_DQ_IS_ON_FREELIST(dqp)); |
829 | if (! xfs_qm_freelist_lock_nowait(xfs_Gqm)) { | 780 | if (! xfs_qm_freelist_lock_nowait(xfs_Gqm)) { |
830 | xfs_dqtrace_entry(dqp, "DQLOOKUP: WANT"); | 781 | trace_xfs_dqlookup_want(dqp); |
831 | 782 | ||
832 | /* | 783 | /* |
833 | * We may have raced with dqreclaim_one() | 784 | * We may have raced with dqreclaim_one() |
@@ -857,8 +808,7 @@ xfs_qm_dqlookup( | |||
857 | /* | 808 | /* |
858 | * take it off the freelist | 809 | * take it off the freelist |
859 | */ | 810 | */ |
860 | xfs_dqtrace_entry(dqp, | 811 | trace_xfs_dqlookup_freelist(dqp); |
861 | "DQLOOKUP: TAKEOFF FL"); | ||
862 | XQM_FREELIST_REMOVE(dqp); | 812 | XQM_FREELIST_REMOVE(dqp); |
863 | /* xfs_qm_freelist_print(&(xfs_Gqm-> | 813 | /* xfs_qm_freelist_print(&(xfs_Gqm-> |
864 | qm_dqfreelist), | 814 | qm_dqfreelist), |
@@ -878,8 +828,7 @@ xfs_qm_dqlookup( | |||
878 | */ | 828 | */ |
879 | ASSERT(mutex_is_locked(&qh->qh_lock)); | 829 | ASSERT(mutex_is_locked(&qh->qh_lock)); |
880 | if (dqp->HL_PREVP != &qh->qh_next) { | 830 | if (dqp->HL_PREVP != &qh->qh_next) { |
881 | xfs_dqtrace_entry(dqp, | 831 | trace_xfs_dqlookup_move(dqp); |
882 | "DQLOOKUP: HASH MOVETOFRONT"); | ||
883 | if ((d = dqp->HL_NEXT)) | 832 | if ((d = dqp->HL_NEXT)) |
884 | d->HL_PREVP = dqp->HL_PREVP; | 833 | d->HL_PREVP = dqp->HL_PREVP; |
885 | *(dqp->HL_PREVP) = d; | 834 | *(dqp->HL_PREVP) = d; |
@@ -889,7 +838,7 @@ xfs_qm_dqlookup( | |||
889 | dqp->HL_PREVP = &qh->qh_next; | 838 | dqp->HL_PREVP = &qh->qh_next; |
890 | qh->qh_next = dqp; | 839 | qh->qh_next = dqp; |
891 | } | 840 | } |
892 | xfs_dqtrace_entry(dqp, "LOOKUP END"); | 841 | trace_xfs_dqlookup_done(dqp); |
893 | *O_dqpp = dqp; | 842 | *O_dqpp = dqp; |
894 | ASSERT(mutex_is_locked(&qh->qh_lock)); | 843 | ASSERT(mutex_is_locked(&qh->qh_lock)); |
895 | return (0); | 844 | return (0); |
@@ -971,7 +920,7 @@ xfs_qm_dqget( | |||
971 | ASSERT(*O_dqpp); | 920 | ASSERT(*O_dqpp); |
972 | ASSERT(XFS_DQ_IS_LOCKED(*O_dqpp)); | 921 | ASSERT(XFS_DQ_IS_LOCKED(*O_dqpp)); |
973 | mutex_unlock(&h->qh_lock); | 922 | mutex_unlock(&h->qh_lock); |
974 | xfs_dqtrace_entry(*O_dqpp, "DQGET DONE (FROM CACHE)"); | 923 | trace_xfs_dqget_hit(*O_dqpp); |
975 | return (0); /* success */ | 924 | return (0); /* success */ |
976 | } | 925 | } |
977 | XQM_STATS_INC(xqmstats.xs_qm_dqcachemisses); | 926 | XQM_STATS_INC(xqmstats.xs_qm_dqcachemisses); |
@@ -1104,7 +1053,7 @@ xfs_qm_dqget( | |||
1104 | mutex_unlock(&h->qh_lock); | 1053 | mutex_unlock(&h->qh_lock); |
1105 | dqret: | 1054 | dqret: |
1106 | ASSERT((ip == NULL) || xfs_isilocked(ip, XFS_ILOCK_EXCL)); | 1055 | ASSERT((ip == NULL) || xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
1107 | xfs_dqtrace_entry(dqp, "DQGET DONE"); | 1056 | trace_xfs_dqget_miss(dqp); |
1108 | *O_dqpp = dqp; | 1057 | *O_dqpp = dqp; |
1109 | return (0); | 1058 | return (0); |
1110 | } | 1059 | } |
@@ -1124,7 +1073,8 @@ xfs_qm_dqput( | |||
1124 | 1073 | ||
1125 | ASSERT(dqp->q_nrefs > 0); | 1074 | ASSERT(dqp->q_nrefs > 0); |
1126 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); | 1075 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); |
1127 | xfs_dqtrace_entry(dqp, "DQPUT"); | 1076 | |
1077 | trace_xfs_dqput(dqp); | ||
1128 | 1078 | ||
1129 | if (dqp->q_nrefs != 1) { | 1079 | if (dqp->q_nrefs != 1) { |
1130 | dqp->q_nrefs--; | 1080 | dqp->q_nrefs--; |
@@ -1137,7 +1087,7 @@ xfs_qm_dqput( | |||
1137 | * in the right order; but try to get it out-of-order first | 1087 | * in the right order; but try to get it out-of-order first |
1138 | */ | 1088 | */ |
1139 | if (! xfs_qm_freelist_lock_nowait(xfs_Gqm)) { | 1089 | if (! xfs_qm_freelist_lock_nowait(xfs_Gqm)) { |
1140 | xfs_dqtrace_entry(dqp, "DQPUT: FLLOCK-WAIT"); | 1090 | trace_xfs_dqput_wait(dqp); |
1141 | xfs_dqunlock(dqp); | 1091 | xfs_dqunlock(dqp); |
1142 | xfs_qm_freelist_lock(xfs_Gqm); | 1092 | xfs_qm_freelist_lock(xfs_Gqm); |
1143 | xfs_dqlock(dqp); | 1093 | xfs_dqlock(dqp); |
@@ -1148,7 +1098,8 @@ xfs_qm_dqput( | |||
1148 | 1098 | ||
1149 | /* We can't depend on nrefs being == 1 here */ | 1099 | /* We can't depend on nrefs being == 1 here */ |
1150 | if (--dqp->q_nrefs == 0) { | 1100 | if (--dqp->q_nrefs == 0) { |
1151 | xfs_dqtrace_entry(dqp, "DQPUT: ON FREELIST"); | 1101 | trace_xfs_dqput_free(dqp); |
1102 | |||
1152 | /* | 1103 | /* |
1153 | * insert at end of the freelist. | 1104 | * insert at end of the freelist. |
1154 | */ | 1105 | */ |
@@ -1196,7 +1147,7 @@ xfs_qm_dqrele( | |||
1196 | if (!dqp) | 1147 | if (!dqp) |
1197 | return; | 1148 | return; |
1198 | 1149 | ||
1199 | xfs_dqtrace_entry(dqp, "DQRELE"); | 1150 | trace_xfs_dqrele(dqp); |
1200 | 1151 | ||
1201 | xfs_dqlock(dqp); | 1152 | xfs_dqlock(dqp); |
1202 | /* | 1153 | /* |
@@ -1229,7 +1180,7 @@ xfs_qm_dqflush( | |||
1229 | 1180 | ||
1230 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); | 1181 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); |
1231 | ASSERT(!completion_done(&dqp->q_flush)); | 1182 | ASSERT(!completion_done(&dqp->q_flush)); |
1232 | xfs_dqtrace_entry(dqp, "DQFLUSH"); | 1183 | trace_xfs_dqflush(dqp); |
1233 | 1184 | ||
1234 | /* | 1185 | /* |
1235 | * If not dirty, or it's pinned and we are not supposed to | 1186 | * If not dirty, or it's pinned and we are not supposed to |
@@ -1259,7 +1210,6 @@ xfs_qm_dqflush( | |||
1259 | * the ondisk-dquot has already been allocated for. | 1210 | * the ondisk-dquot has already been allocated for. |
1260 | */ | 1211 | */ |
1261 | if ((error = xfs_qm_dqtobp(NULL, dqp, &ddqp, &bp, XFS_QMOPT_DOWARN))) { | 1212 | if ((error = xfs_qm_dqtobp(NULL, dqp, &ddqp, &bp, XFS_QMOPT_DOWARN))) { |
1262 | xfs_dqtrace_entry(dqp, "DQTOBP FAIL"); | ||
1263 | ASSERT(error != ENOENT); | 1213 | ASSERT(error != ENOENT); |
1264 | /* | 1214 | /* |
1265 | * Quotas could have gotten turned off (ESRCH) | 1215 | * Quotas could have gotten turned off (ESRCH) |
@@ -1297,7 +1247,7 @@ xfs_qm_dqflush( | |||
1297 | * get stuck waiting in the write for too long. | 1247 | * get stuck waiting in the write for too long. |
1298 | */ | 1248 | */ |
1299 | if (XFS_BUF_ISPINNED(bp)) { | 1249 | if (XFS_BUF_ISPINNED(bp)) { |
1300 | xfs_dqtrace_entry(dqp, "DQFLUSH LOG FORCE"); | 1250 | trace_xfs_dqflush_force(dqp); |
1301 | xfs_log_force(mp, (xfs_lsn_t)0, XFS_LOG_FORCE); | 1251 | xfs_log_force(mp, (xfs_lsn_t)0, XFS_LOG_FORCE); |
1302 | } | 1252 | } |
1303 | 1253 | ||
@@ -1308,7 +1258,9 @@ xfs_qm_dqflush( | |||
1308 | } else { | 1258 | } else { |
1309 | error = xfs_bwrite(mp, bp); | 1259 | error = xfs_bwrite(mp, bp); |
1310 | } | 1260 | } |
1311 | xfs_dqtrace_entry(dqp, "DQFLUSH END"); | 1261 | |
1262 | trace_xfs_dqflush_done(dqp); | ||
1263 | |||
1312 | /* | 1264 | /* |
1313 | * dqp is still locked, but caller is free to unlock it now. | 1265 | * dqp is still locked, but caller is free to unlock it now. |
1314 | */ | 1266 | */ |
@@ -1483,7 +1435,7 @@ xfs_qm_dqpurge( | |||
1483 | */ | 1435 | */ |
1484 | if (XFS_DQ_IS_DIRTY(dqp)) { | 1436 | if (XFS_DQ_IS_DIRTY(dqp)) { |
1485 | int error; | 1437 | int error; |
1486 | xfs_dqtrace_entry(dqp, "DQPURGE ->DQFLUSH: DQDIRTY"); | 1438 | |
1487 | /* dqflush unlocks dqflock */ | 1439 | /* dqflush unlocks dqflock */ |
1488 | /* | 1440 | /* |
1489 | * Given that dqpurge is a very rare occurrence, it is OK | 1441 | * Given that dqpurge is a very rare occurrence, it is OK |