| .. | .. |
|---|
| 11 | 11 | #include "xfs_trans_resv.h" |
|---|
| 12 | 12 | #include "xfs_mount.h" |
|---|
| 13 | 13 | #include "xfs_inode.h" |
|---|
| 14 | | -#include "xfs_error.h" |
|---|
| 15 | 14 | #include "xfs_trans.h" |
|---|
| 16 | 15 | #include "xfs_trans_priv.h" |
|---|
| 17 | 16 | #include "xfs_quota.h" |
|---|
| 18 | 17 | #include "xfs_qm.h" |
|---|
| 18 | +#include "xfs_trace.h" |
|---|
| 19 | 19 | |
|---|
| 20 | 20 | STATIC void xfs_trans_alloc_dqinfo(xfs_trans_t *); |
|---|
| 21 | 21 | |
|---|
| .. | .. |
|---|
| 26 | 26 | */ |
|---|
| 27 | 27 | void |
|---|
| 28 | 28 | xfs_trans_dqjoin( |
|---|
| 29 | | - xfs_trans_t *tp, |
|---|
| 30 | | - xfs_dquot_t *dqp) |
|---|
| 29 | + struct xfs_trans *tp, |
|---|
| 30 | + struct xfs_dquot *dqp) |
|---|
| 31 | 31 | { |
|---|
| 32 | | - ASSERT(dqp->q_transp != tp); |
|---|
| 33 | 32 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); |
|---|
| 34 | 33 | ASSERT(dqp->q_logitem.qli_dquot == dqp); |
|---|
| 35 | 34 | |
|---|
| .. | .. |
|---|
| 37 | 36 | * Get a log_item_desc to point at the new item. |
|---|
| 38 | 37 | */ |
|---|
| 39 | 38 | xfs_trans_add_item(tp, &dqp->q_logitem.qli_item); |
|---|
| 40 | | - |
|---|
| 41 | | - /* |
|---|
| 42 | | - * Initialize d_transp so we can later determine if this dquot is |
|---|
| 43 | | - * associated with this transaction. |
|---|
| 44 | | - */ |
|---|
| 45 | | - dqp->q_transp = tp; |
|---|
| 46 | 39 | } |
|---|
| 47 | | - |
|---|
| 48 | 40 | |
|---|
| 49 | 41 | /* |
|---|
| 50 | 42 | * This is called to mark the dquot as needing |
|---|
| .. | .. |
|---|
| 58 | 50 | */ |
|---|
| 59 | 51 | void |
|---|
| 60 | 52 | xfs_trans_log_dquot( |
|---|
| 61 | | - xfs_trans_t *tp, |
|---|
| 62 | | - xfs_dquot_t *dqp) |
|---|
| 53 | + struct xfs_trans *tp, |
|---|
| 54 | + struct xfs_dquot *dqp) |
|---|
| 63 | 55 | { |
|---|
| 64 | | - ASSERT(dqp->q_transp == tp); |
|---|
| 65 | 56 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); |
|---|
| 57 | + |
|---|
| 58 | + /* Upgrade the dquot to bigtime format if possible. */ |
|---|
| 59 | + if (dqp->q_id != 0 && |
|---|
| 60 | + xfs_sb_version_hasbigtime(&tp->t_mountp->m_sb) && |
|---|
| 61 | + !(dqp->q_type & XFS_DQTYPE_BIGTIME)) |
|---|
| 62 | + dqp->q_type |= XFS_DQTYPE_BIGTIME; |
|---|
| 66 | 63 | |
|---|
| 67 | 64 | tp->t_flags |= XFS_TRANS_DIRTY; |
|---|
| 68 | 65 | set_bit(XFS_LI_DIRTY, &dqp->q_logitem.qli_item.li_flags); |
|---|
| .. | .. |
|---|
| 74 | 71 | */ |
|---|
| 75 | 72 | void |
|---|
| 76 | 73 | xfs_trans_dup_dqinfo( |
|---|
| 77 | | - xfs_trans_t *otp, |
|---|
| 78 | | - xfs_trans_t *ntp) |
|---|
| 74 | + struct xfs_trans *otp, |
|---|
| 75 | + struct xfs_trans *ntp) |
|---|
| 79 | 76 | { |
|---|
| 80 | | - xfs_dqtrx_t *oq, *nq; |
|---|
| 81 | | - int i, j; |
|---|
| 82 | | - xfs_dqtrx_t *oqa, *nqa; |
|---|
| 83 | | - ulong blk_res_used; |
|---|
| 77 | + struct xfs_dqtrx *oq, *nq; |
|---|
| 78 | + int i, j; |
|---|
| 79 | + struct xfs_dqtrx *oqa, *nqa; |
|---|
| 80 | + uint64_t blk_res_used; |
|---|
| 84 | 81 | |
|---|
| 85 | 82 | if (!otp->t_dqinfo) |
|---|
| 86 | 83 | return; |
|---|
| .. | .. |
|---|
| 137 | 134 | xfs_trans_t *tp, |
|---|
| 138 | 135 | xfs_inode_t *ip, |
|---|
| 139 | 136 | uint field, |
|---|
| 140 | | - long delta) |
|---|
| 137 | + int64_t delta) |
|---|
| 141 | 138 | { |
|---|
| 142 | 139 | xfs_mount_t *mp = tp->t_mountp; |
|---|
| 143 | 140 | |
|---|
| .. | .. |
|---|
| 165 | 162 | int i; |
|---|
| 166 | 163 | struct xfs_dqtrx *qa; |
|---|
| 167 | 164 | |
|---|
| 168 | | - if (XFS_QM_ISUDQ(dqp)) |
|---|
| 165 | + switch (xfs_dquot_type(dqp)) { |
|---|
| 166 | + case XFS_DQTYPE_USER: |
|---|
| 169 | 167 | qa = tp->t_dqinfo->dqs[XFS_QM_TRANS_USR]; |
|---|
| 170 | | - else if (XFS_QM_ISGDQ(dqp)) |
|---|
| 168 | + break; |
|---|
| 169 | + case XFS_DQTYPE_GROUP: |
|---|
| 171 | 170 | qa = tp->t_dqinfo->dqs[XFS_QM_TRANS_GRP]; |
|---|
| 172 | | - else if (XFS_QM_ISPDQ(dqp)) |
|---|
| 171 | + break; |
|---|
| 172 | + case XFS_DQTYPE_PROJ: |
|---|
| 173 | 173 | qa = tp->t_dqinfo->dqs[XFS_QM_TRANS_PRJ]; |
|---|
| 174 | | - else |
|---|
| 174 | + break; |
|---|
| 175 | + default: |
|---|
| 175 | 176 | return NULL; |
|---|
| 177 | + } |
|---|
| 176 | 178 | |
|---|
| 177 | 179 | for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) { |
|---|
| 178 | 180 | if (qa[i].qt_dquot == NULL || |
|---|
| .. | .. |
|---|
| 191 | 193 | */ |
|---|
| 192 | 194 | void |
|---|
| 193 | 195 | xfs_trans_mod_dquot( |
|---|
| 194 | | - xfs_trans_t *tp, |
|---|
| 195 | | - xfs_dquot_t *dqp, |
|---|
| 196 | | - uint field, |
|---|
| 197 | | - long delta) |
|---|
| 196 | + struct xfs_trans *tp, |
|---|
| 197 | + struct xfs_dquot *dqp, |
|---|
| 198 | + uint field, |
|---|
| 199 | + int64_t delta) |
|---|
| 198 | 200 | { |
|---|
| 199 | | - xfs_dqtrx_t *qtrx; |
|---|
| 201 | + struct xfs_dqtrx *qtrx; |
|---|
| 200 | 202 | |
|---|
| 201 | 203 | ASSERT(tp); |
|---|
| 202 | 204 | ASSERT(XFS_IS_QUOTA_RUNNING(tp->t_mountp)); |
|---|
| .. | .. |
|---|
| 213 | 215 | if (qtrx->qt_dquot == NULL) |
|---|
| 214 | 216 | qtrx->qt_dquot = dqp; |
|---|
| 215 | 217 | |
|---|
| 218 | + if (delta) { |
|---|
| 219 | + trace_xfs_trans_mod_dquot_before(qtrx); |
|---|
| 220 | + trace_xfs_trans_mod_dquot(tp, dqp, field, delta); |
|---|
| 221 | + } |
|---|
| 222 | + |
|---|
| 216 | 223 | switch (field) { |
|---|
| 217 | | - |
|---|
| 218 | | - /* |
|---|
| 219 | | - * regular disk blk reservation |
|---|
| 220 | | - */ |
|---|
| 221 | | - case XFS_TRANS_DQ_RES_BLKS: |
|---|
| 222 | | - qtrx->qt_blk_res += (ulong)delta; |
|---|
| 224 | + /* regular disk blk reservation */ |
|---|
| 225 | + case XFS_TRANS_DQ_RES_BLKS: |
|---|
| 226 | + qtrx->qt_blk_res += delta; |
|---|
| 223 | 227 | break; |
|---|
| 224 | 228 | |
|---|
| 225 | | - /* |
|---|
| 226 | | - * inode reservation |
|---|
| 227 | | - */ |
|---|
| 228 | | - case XFS_TRANS_DQ_RES_INOS: |
|---|
| 229 | | - qtrx->qt_ino_res += (ulong)delta; |
|---|
| 229 | + /* inode reservation */ |
|---|
| 230 | + case XFS_TRANS_DQ_RES_INOS: |
|---|
| 231 | + qtrx->qt_ino_res += delta; |
|---|
| 230 | 232 | break; |
|---|
| 231 | 233 | |
|---|
| 232 | | - /* |
|---|
| 233 | | - * disk blocks used. |
|---|
| 234 | | - */ |
|---|
| 235 | | - case XFS_TRANS_DQ_BCOUNT: |
|---|
| 234 | + /* disk blocks used. */ |
|---|
| 235 | + case XFS_TRANS_DQ_BCOUNT: |
|---|
| 236 | 236 | qtrx->qt_bcount_delta += delta; |
|---|
| 237 | 237 | break; |
|---|
| 238 | 238 | |
|---|
| 239 | | - case XFS_TRANS_DQ_DELBCOUNT: |
|---|
| 239 | + case XFS_TRANS_DQ_DELBCOUNT: |
|---|
| 240 | 240 | qtrx->qt_delbcnt_delta += delta; |
|---|
| 241 | 241 | break; |
|---|
| 242 | 242 | |
|---|
| 243 | | - /* |
|---|
| 244 | | - * Inode Count |
|---|
| 245 | | - */ |
|---|
| 246 | | - case XFS_TRANS_DQ_ICOUNT: |
|---|
| 243 | + /* Inode Count */ |
|---|
| 244 | + case XFS_TRANS_DQ_ICOUNT: |
|---|
| 247 | 245 | if (qtrx->qt_ino_res && delta > 0) { |
|---|
| 248 | | - qtrx->qt_ino_res_used += (ulong)delta; |
|---|
| 246 | + qtrx->qt_ino_res_used += delta; |
|---|
| 249 | 247 | ASSERT(qtrx->qt_ino_res >= qtrx->qt_ino_res_used); |
|---|
| 250 | 248 | } |
|---|
| 251 | 249 | qtrx->qt_icount_delta += delta; |
|---|
| 252 | 250 | break; |
|---|
| 253 | 251 | |
|---|
| 254 | | - /* |
|---|
| 255 | | - * rtblk reservation |
|---|
| 256 | | - */ |
|---|
| 257 | | - case XFS_TRANS_DQ_RES_RTBLKS: |
|---|
| 258 | | - qtrx->qt_rtblk_res += (ulong)delta; |
|---|
| 252 | + /* rtblk reservation */ |
|---|
| 253 | + case XFS_TRANS_DQ_RES_RTBLKS: |
|---|
| 254 | + qtrx->qt_rtblk_res += delta; |
|---|
| 259 | 255 | break; |
|---|
| 260 | 256 | |
|---|
| 261 | | - /* |
|---|
| 262 | | - * rtblk count |
|---|
| 263 | | - */ |
|---|
| 264 | | - case XFS_TRANS_DQ_RTBCOUNT: |
|---|
| 257 | + /* rtblk count */ |
|---|
| 258 | + case XFS_TRANS_DQ_RTBCOUNT: |
|---|
| 265 | 259 | if (qtrx->qt_rtblk_res && delta > 0) { |
|---|
| 266 | | - qtrx->qt_rtblk_res_used += (ulong)delta; |
|---|
| 260 | + qtrx->qt_rtblk_res_used += delta; |
|---|
| 267 | 261 | ASSERT(qtrx->qt_rtblk_res >= qtrx->qt_rtblk_res_used); |
|---|
| 268 | 262 | } |
|---|
| 269 | 263 | qtrx->qt_rtbcount_delta += delta; |
|---|
| 270 | 264 | break; |
|---|
| 271 | 265 | |
|---|
| 272 | | - case XFS_TRANS_DQ_DELRTBCOUNT: |
|---|
| 266 | + case XFS_TRANS_DQ_DELRTBCOUNT: |
|---|
| 273 | 267 | qtrx->qt_delrtb_delta += delta; |
|---|
| 274 | 268 | break; |
|---|
| 275 | 269 | |
|---|
| 276 | | - default: |
|---|
| 270 | + default: |
|---|
| 277 | 271 | ASSERT(0); |
|---|
| 278 | 272 | } |
|---|
| 273 | + |
|---|
| 274 | + if (delta) |
|---|
| 275 | + trace_xfs_trans_mod_dquot_after(qtrx); |
|---|
| 276 | + |
|---|
| 279 | 277 | tp->t_flags |= XFS_TRANS_DQ_DIRTY; |
|---|
| 280 | 278 | } |
|---|
| 281 | 279 | |
|---|
| .. | .. |
|---|
| 288 | 286 | */ |
|---|
| 289 | 287 | STATIC void |
|---|
| 290 | 288 | xfs_trans_dqlockedjoin( |
|---|
| 291 | | - xfs_trans_t *tp, |
|---|
| 292 | | - xfs_dqtrx_t *q) |
|---|
| 289 | + struct xfs_trans *tp, |
|---|
| 290 | + struct xfs_dqtrx *q) |
|---|
| 293 | 291 | { |
|---|
| 294 | 292 | ASSERT(q[0].qt_dquot != NULL); |
|---|
| 295 | 293 | if (q[1].qt_dquot == NULL) { |
|---|
| .. | .. |
|---|
| 303 | 301 | } |
|---|
| 304 | 302 | } |
|---|
| 305 | 303 | |
|---|
| 304 | +/* Apply dqtrx changes to the quota reservation counters. */ |
|---|
| 305 | +static inline void |
|---|
| 306 | +xfs_apply_quota_reservation_deltas( |
|---|
| 307 | + struct xfs_dquot_res *res, |
|---|
| 308 | + uint64_t reserved, |
|---|
| 309 | + int64_t res_used, |
|---|
| 310 | + int64_t count_delta) |
|---|
| 311 | +{ |
|---|
| 312 | + if (reserved != 0) { |
|---|
| 313 | + /* |
|---|
| 314 | + * Subtle math here: If reserved > res_used (the normal case), |
|---|
| 315 | + * we're simply subtracting the unused transaction quota |
|---|
| 316 | + * reservation from the dquot reservation. |
|---|
| 317 | + * |
|---|
| 318 | + * If, however, res_used > reserved, then we have allocated |
|---|
| 319 | + * more quota blocks than were reserved for the transaction. |
|---|
| 320 | + * We must add that excess to the dquot reservation since it |
|---|
| 321 | + * tracks (usage + resv) and by definition we didn't reserve |
|---|
| 322 | + * that excess. |
|---|
| 323 | + */ |
|---|
| 324 | + res->reserved -= abs(reserved - res_used); |
|---|
| 325 | + } else if (count_delta != 0) { |
|---|
| 326 | + /* |
|---|
| 327 | + * These blks were never reserved, either inside a transaction |
|---|
| 328 | + * or outside one (in a delayed allocation). Also, this isn't |
|---|
| 329 | + * always a negative number since we sometimes deliberately |
|---|
| 330 | + * skip quota reservations. |
|---|
| 331 | + */ |
|---|
| 332 | + res->reserved += count_delta; |
|---|
| 333 | + } |
|---|
| 334 | +} |
|---|
| 306 | 335 | |
|---|
| 307 | 336 | /* |
|---|
| 308 | 337 | * Called by xfs_trans_commit() and similar in spirit to |
|---|
| .. | .. |
|---|
| 319 | 348 | int i, j; |
|---|
| 320 | 349 | struct xfs_dquot *dqp; |
|---|
| 321 | 350 | struct xfs_dqtrx *qtrx, *qa; |
|---|
| 322 | | - struct xfs_disk_dquot *d; |
|---|
| 323 | | - long totalbdelta; |
|---|
| 324 | | - long totalrtbdelta; |
|---|
| 351 | + int64_t totalbdelta; |
|---|
| 352 | + int64_t totalrtbdelta; |
|---|
| 325 | 353 | |
|---|
| 326 | 354 | if (!(tp->t_flags & XFS_TRANS_DQ_DIRTY)) |
|---|
| 327 | 355 | return; |
|---|
| .. | .. |
|---|
| 338 | 366 | xfs_trans_dqlockedjoin(tp, qa); |
|---|
| 339 | 367 | |
|---|
| 340 | 368 | for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) { |
|---|
| 369 | + uint64_t blk_res_used; |
|---|
| 370 | + |
|---|
| 341 | 371 | qtrx = &qa[i]; |
|---|
| 342 | 372 | /* |
|---|
| 343 | 373 | * The array of dquots is filled |
|---|
| .. | .. |
|---|
| 347 | 377 | break; |
|---|
| 348 | 378 | |
|---|
| 349 | 379 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); |
|---|
| 350 | | - ASSERT(dqp->q_transp == tp); |
|---|
| 351 | 380 | |
|---|
| 352 | 381 | /* |
|---|
| 353 | 382 | * adjust the actual number of blocks used |
|---|
| 354 | 383 | */ |
|---|
| 355 | | - d = &dqp->q_core; |
|---|
| 356 | 384 | |
|---|
| 357 | 385 | /* |
|---|
| 358 | 386 | * The issue here is - sometimes we don't make a blkquota |
|---|
| .. | .. |
|---|
| 371 | 399 | qtrx->qt_delbcnt_delta; |
|---|
| 372 | 400 | totalrtbdelta = qtrx->qt_rtbcount_delta + |
|---|
| 373 | 401 | qtrx->qt_delrtb_delta; |
|---|
| 402 | + |
|---|
| 403 | + if (totalbdelta != 0 || totalrtbdelta != 0 || |
|---|
| 404 | + qtrx->qt_icount_delta != 0) { |
|---|
| 405 | + trace_xfs_trans_apply_dquot_deltas_before(dqp); |
|---|
| 406 | + trace_xfs_trans_apply_dquot_deltas(qtrx); |
|---|
| 407 | + } |
|---|
| 408 | + |
|---|
| 374 | 409 | #ifdef DEBUG |
|---|
| 375 | 410 | if (totalbdelta < 0) |
|---|
| 376 | | - ASSERT(be64_to_cpu(d->d_bcount) >= |
|---|
| 377 | | - -totalbdelta); |
|---|
| 411 | + ASSERT(dqp->q_blk.count >= -totalbdelta); |
|---|
| 378 | 412 | |
|---|
| 379 | 413 | if (totalrtbdelta < 0) |
|---|
| 380 | | - ASSERT(be64_to_cpu(d->d_rtbcount) >= |
|---|
| 381 | | - -totalrtbdelta); |
|---|
| 414 | + ASSERT(dqp->q_rtb.count >= -totalrtbdelta); |
|---|
| 382 | 415 | |
|---|
| 383 | 416 | if (qtrx->qt_icount_delta < 0) |
|---|
| 384 | | - ASSERT(be64_to_cpu(d->d_icount) >= |
|---|
| 385 | | - -qtrx->qt_icount_delta); |
|---|
| 417 | + ASSERT(dqp->q_ino.count >= -qtrx->qt_icount_delta); |
|---|
| 386 | 418 | #endif |
|---|
| 387 | 419 | if (totalbdelta) |
|---|
| 388 | | - be64_add_cpu(&d->d_bcount, (xfs_qcnt_t)totalbdelta); |
|---|
| 420 | + dqp->q_blk.count += totalbdelta; |
|---|
| 389 | 421 | |
|---|
| 390 | 422 | if (qtrx->qt_icount_delta) |
|---|
| 391 | | - be64_add_cpu(&d->d_icount, (xfs_qcnt_t)qtrx->qt_icount_delta); |
|---|
| 423 | + dqp->q_ino.count += qtrx->qt_icount_delta; |
|---|
| 392 | 424 | |
|---|
| 393 | 425 | if (totalrtbdelta) |
|---|
| 394 | | - be64_add_cpu(&d->d_rtbcount, (xfs_qcnt_t)totalrtbdelta); |
|---|
| 426 | + dqp->q_rtb.count += totalrtbdelta; |
|---|
| 427 | + |
|---|
| 428 | + if (totalbdelta != 0 || totalrtbdelta != 0 || |
|---|
| 429 | + qtrx->qt_icount_delta != 0) |
|---|
| 430 | + trace_xfs_trans_apply_dquot_deltas_after(dqp); |
|---|
| 395 | 431 | |
|---|
| 396 | 432 | /* |
|---|
| 397 | 433 | * Get any default limits in use. |
|---|
| 398 | 434 | * Start/reset the timer(s) if needed. |
|---|
| 399 | 435 | */ |
|---|
| 400 | | - if (d->d_id) { |
|---|
| 401 | | - xfs_qm_adjust_dqlimits(tp->t_mountp, dqp); |
|---|
| 402 | | - xfs_qm_adjust_dqtimers(tp->t_mountp, d); |
|---|
| 436 | + if (dqp->q_id) { |
|---|
| 437 | + xfs_qm_adjust_dqlimits(dqp); |
|---|
| 438 | + xfs_qm_adjust_dqtimers(dqp); |
|---|
| 403 | 439 | } |
|---|
| 404 | 440 | |
|---|
| 405 | | - dqp->dq_flags |= XFS_DQ_DIRTY; |
|---|
| 441 | + dqp->q_flags |= XFS_DQFLAG_DIRTY; |
|---|
| 406 | 442 | /* |
|---|
| 407 | 443 | * add this to the list of items to get logged |
|---|
| 408 | 444 | */ |
|---|
| .. | .. |
|---|
| 412 | 448 | * In case of delayed allocations, there's no |
|---|
| 413 | 449 | * reservation that a transaction structure knows of. |
|---|
| 414 | 450 | */ |
|---|
| 415 | | - if (qtrx->qt_blk_res != 0) { |
|---|
| 416 | | - ulong blk_res_used = 0; |
|---|
| 451 | + blk_res_used = max_t(int64_t, 0, qtrx->qt_bcount_delta); |
|---|
| 452 | + xfs_apply_quota_reservation_deltas(&dqp->q_blk, |
|---|
| 453 | + qtrx->qt_blk_res, blk_res_used, |
|---|
| 454 | + qtrx->qt_bcount_delta); |
|---|
| 417 | 455 | |
|---|
| 418 | | - if (qtrx->qt_bcount_delta > 0) |
|---|
| 419 | | - blk_res_used = qtrx->qt_bcount_delta; |
|---|
| 420 | | - |
|---|
| 421 | | - if (qtrx->qt_blk_res != blk_res_used) { |
|---|
| 422 | | - if (qtrx->qt_blk_res > blk_res_used) |
|---|
| 423 | | - dqp->q_res_bcount -= (xfs_qcnt_t) |
|---|
| 424 | | - (qtrx->qt_blk_res - |
|---|
| 425 | | - blk_res_used); |
|---|
| 426 | | - else |
|---|
| 427 | | - dqp->q_res_bcount -= (xfs_qcnt_t) |
|---|
| 428 | | - (blk_res_used - |
|---|
| 429 | | - qtrx->qt_blk_res); |
|---|
| 430 | | - } |
|---|
| 431 | | - } else { |
|---|
| 432 | | - /* |
|---|
| 433 | | - * These blks were never reserved, either inside |
|---|
| 434 | | - * a transaction or outside one (in a delayed |
|---|
| 435 | | - * allocation). Also, this isn't always a |
|---|
| 436 | | - * negative number since we sometimes |
|---|
| 437 | | - * deliberately skip quota reservations. |
|---|
| 438 | | - */ |
|---|
| 439 | | - if (qtrx->qt_bcount_delta) { |
|---|
| 440 | | - dqp->q_res_bcount += |
|---|
| 441 | | - (xfs_qcnt_t)qtrx->qt_bcount_delta; |
|---|
| 442 | | - } |
|---|
| 443 | | - } |
|---|
| 444 | 456 | /* |
|---|
| 445 | 457 | * Adjust the RT reservation. |
|---|
| 446 | 458 | */ |
|---|
| 447 | | - if (qtrx->qt_rtblk_res != 0) { |
|---|
| 448 | | - if (qtrx->qt_rtblk_res != qtrx->qt_rtblk_res_used) { |
|---|
| 449 | | - if (qtrx->qt_rtblk_res > |
|---|
| 450 | | - qtrx->qt_rtblk_res_used) |
|---|
| 451 | | - dqp->q_res_rtbcount -= (xfs_qcnt_t) |
|---|
| 452 | | - (qtrx->qt_rtblk_res - |
|---|
| 453 | | - qtrx->qt_rtblk_res_used); |
|---|
| 454 | | - else |
|---|
| 455 | | - dqp->q_res_rtbcount -= (xfs_qcnt_t) |
|---|
| 456 | | - (qtrx->qt_rtblk_res_used - |
|---|
| 457 | | - qtrx->qt_rtblk_res); |
|---|
| 458 | | - } |
|---|
| 459 | | - } else { |
|---|
| 460 | | - if (qtrx->qt_rtbcount_delta) |
|---|
| 461 | | - dqp->q_res_rtbcount += |
|---|
| 462 | | - (xfs_qcnt_t)qtrx->qt_rtbcount_delta; |
|---|
| 463 | | - } |
|---|
| 459 | + xfs_apply_quota_reservation_deltas(&dqp->q_rtb, |
|---|
| 460 | + qtrx->qt_rtblk_res, |
|---|
| 461 | + qtrx->qt_rtblk_res_used, |
|---|
| 462 | + qtrx->qt_rtbcount_delta); |
|---|
| 464 | 463 | |
|---|
| 465 | 464 | /* |
|---|
| 466 | 465 | * Adjust the inode reservation. |
|---|
| 467 | 466 | */ |
|---|
| 468 | | - if (qtrx->qt_ino_res != 0) { |
|---|
| 469 | | - ASSERT(qtrx->qt_ino_res >= |
|---|
| 470 | | - qtrx->qt_ino_res_used); |
|---|
| 471 | | - if (qtrx->qt_ino_res > qtrx->qt_ino_res_used) |
|---|
| 472 | | - dqp->q_res_icount -= (xfs_qcnt_t) |
|---|
| 473 | | - (qtrx->qt_ino_res - |
|---|
| 474 | | - qtrx->qt_ino_res_used); |
|---|
| 475 | | - } else { |
|---|
| 476 | | - if (qtrx->qt_icount_delta) |
|---|
| 477 | | - dqp->q_res_icount += |
|---|
| 478 | | - (xfs_qcnt_t)qtrx->qt_icount_delta; |
|---|
| 479 | | - } |
|---|
| 467 | + ASSERT(qtrx->qt_ino_res >= qtrx->qt_ino_res_used); |
|---|
| 468 | + xfs_apply_quota_reservation_deltas(&dqp->q_ino, |
|---|
| 469 | + qtrx->qt_ino_res, |
|---|
| 470 | + qtrx->qt_ino_res_used, |
|---|
| 471 | + qtrx->qt_icount_delta); |
|---|
| 480 | 472 | |
|---|
| 481 | | - ASSERT(dqp->q_res_bcount >= |
|---|
| 482 | | - be64_to_cpu(dqp->q_core.d_bcount)); |
|---|
| 483 | | - ASSERT(dqp->q_res_icount >= |
|---|
| 484 | | - be64_to_cpu(dqp->q_core.d_icount)); |
|---|
| 485 | | - ASSERT(dqp->q_res_rtbcount >= |
|---|
| 486 | | - be64_to_cpu(dqp->q_core.d_rtbcount)); |
|---|
| 473 | + ASSERT(dqp->q_blk.reserved >= dqp->q_blk.count); |
|---|
| 474 | + ASSERT(dqp->q_ino.reserved >= dqp->q_ino.count); |
|---|
| 475 | + ASSERT(dqp->q_rtb.reserved >= dqp->q_rtb.count); |
|---|
| 487 | 476 | } |
|---|
| 488 | 477 | } |
|---|
| 489 | 478 | } |
|---|
| .. | .. |
|---|
| 497 | 486 | */ |
|---|
| 498 | 487 | void |
|---|
| 499 | 488 | xfs_trans_unreserve_and_mod_dquots( |
|---|
| 500 | | - xfs_trans_t *tp) |
|---|
| 489 | + struct xfs_trans *tp) |
|---|
| 501 | 490 | { |
|---|
| 502 | 491 | int i, j; |
|---|
| 503 | | - xfs_dquot_t *dqp; |
|---|
| 504 | | - xfs_dqtrx_t *qtrx, *qa; |
|---|
| 505 | | - bool locked; |
|---|
| 492 | + struct xfs_dquot *dqp; |
|---|
| 493 | + struct xfs_dqtrx *qtrx, *qa; |
|---|
| 494 | + bool locked; |
|---|
| 506 | 495 | |
|---|
| 507 | 496 | if (!tp->t_dqinfo || !(tp->t_flags & XFS_TRANS_DQ_DIRTY)) |
|---|
| 508 | 497 | return; |
|---|
| .. | .. |
|---|
| 527 | 516 | if (qtrx->qt_blk_res) { |
|---|
| 528 | 517 | xfs_dqlock(dqp); |
|---|
| 529 | 518 | locked = true; |
|---|
| 530 | | - dqp->q_res_bcount -= |
|---|
| 519 | + dqp->q_blk.reserved -= |
|---|
| 531 | 520 | (xfs_qcnt_t)qtrx->qt_blk_res; |
|---|
| 532 | 521 | } |
|---|
| 533 | 522 | if (qtrx->qt_ino_res) { |
|---|
| .. | .. |
|---|
| 535 | 524 | xfs_dqlock(dqp); |
|---|
| 536 | 525 | locked = true; |
|---|
| 537 | 526 | } |
|---|
| 538 | | - dqp->q_res_icount -= |
|---|
| 527 | + dqp->q_ino.reserved -= |
|---|
| 539 | 528 | (xfs_qcnt_t)qtrx->qt_ino_res; |
|---|
| 540 | 529 | } |
|---|
| 541 | 530 | |
|---|
| .. | .. |
|---|
| 544 | 533 | xfs_dqlock(dqp); |
|---|
| 545 | 534 | locked = true; |
|---|
| 546 | 535 | } |
|---|
| 547 | | - dqp->q_res_rtbcount -= |
|---|
| 536 | + dqp->q_rtb.reserved -= |
|---|
| 548 | 537 | (xfs_qcnt_t)qtrx->qt_rtblk_res; |
|---|
| 549 | 538 | } |
|---|
| 550 | 539 | if (locked) |
|---|
| .. | .. |
|---|
| 560 | 549 | struct xfs_dquot *dqp, |
|---|
| 561 | 550 | int type) |
|---|
| 562 | 551 | { |
|---|
| 563 | | - enum quota_type qtype; |
|---|
| 552 | + enum quota_type qtype; |
|---|
| 564 | 553 | |
|---|
| 565 | | - if (dqp->dq_flags & XFS_DQ_PROJ) |
|---|
| 554 | + switch (xfs_dquot_type(dqp)) { |
|---|
| 555 | + case XFS_DQTYPE_PROJ: |
|---|
| 566 | 556 | qtype = PRJQUOTA; |
|---|
| 567 | | - else if (dqp->dq_flags & XFS_DQ_USER) |
|---|
| 557 | + break; |
|---|
| 558 | + case XFS_DQTYPE_USER: |
|---|
| 568 | 559 | qtype = USRQUOTA; |
|---|
| 569 | | - else |
|---|
| 560 | + break; |
|---|
| 561 | + case XFS_DQTYPE_GROUP: |
|---|
| 570 | 562 | qtype = GRPQUOTA; |
|---|
| 563 | + break; |
|---|
| 564 | + default: |
|---|
| 565 | + return; |
|---|
| 566 | + } |
|---|
| 571 | 567 | |
|---|
| 572 | | - quota_send_warning(make_kqid(&init_user_ns, qtype, |
|---|
| 573 | | - be32_to_cpu(dqp->q_core.d_id)), |
|---|
| 568 | + quota_send_warning(make_kqid(&init_user_ns, qtype, dqp->q_id), |
|---|
| 574 | 569 | mp->m_super->s_dev, type); |
|---|
| 570 | +} |
|---|
| 571 | + |
|---|
| 572 | +/* |
|---|
| 573 | + * Decide if we can make an additional reservation against a quota resource. |
|---|
| 574 | + * Returns an inode QUOTA_NL_ warning code and whether or not it's fatal. |
|---|
| 575 | + * |
|---|
| 576 | + * Note that we assume that the numeric difference between the inode and block |
|---|
| 577 | + * warning codes will always be 3 since it's userspace ABI now, and will never |
|---|
| 578 | + * decrease the quota reservation, so the *BELOW messages are irrelevant. |
|---|
| 579 | + */ |
|---|
| 580 | +static inline int |
|---|
| 581 | +xfs_dqresv_check( |
|---|
| 582 | + struct xfs_dquot_res *res, |
|---|
| 583 | + struct xfs_quota_limits *qlim, |
|---|
| 584 | + int64_t delta, |
|---|
| 585 | + bool *fatal) |
|---|
| 586 | +{ |
|---|
| 587 | + xfs_qcnt_t hardlimit = res->hardlimit; |
|---|
| 588 | + xfs_qcnt_t softlimit = res->softlimit; |
|---|
| 589 | + xfs_qcnt_t total_count = res->reserved + delta; |
|---|
| 590 | + |
|---|
| 591 | + BUILD_BUG_ON(QUOTA_NL_BHARDWARN != QUOTA_NL_IHARDWARN + 3); |
|---|
| 592 | + BUILD_BUG_ON(QUOTA_NL_BSOFTLONGWARN != QUOTA_NL_ISOFTLONGWARN + 3); |
|---|
| 593 | + BUILD_BUG_ON(QUOTA_NL_BSOFTWARN != QUOTA_NL_ISOFTWARN + 3); |
|---|
| 594 | + |
|---|
| 595 | + *fatal = false; |
|---|
| 596 | + if (delta <= 0) |
|---|
| 597 | + return QUOTA_NL_NOWARN; |
|---|
| 598 | + |
|---|
| 599 | + if (!hardlimit) |
|---|
| 600 | + hardlimit = qlim->hard; |
|---|
| 601 | + if (!softlimit) |
|---|
| 602 | + softlimit = qlim->soft; |
|---|
| 603 | + |
|---|
| 604 | + if (hardlimit && total_count > hardlimit) { |
|---|
| 605 | + *fatal = true; |
|---|
| 606 | + return QUOTA_NL_IHARDWARN; |
|---|
| 607 | + } |
|---|
| 608 | + |
|---|
| 609 | + if (softlimit && total_count > softlimit) { |
|---|
| 610 | + time64_t now = ktime_get_real_seconds(); |
|---|
| 611 | + |
|---|
| 612 | + if ((res->timer != 0 && now > res->timer) || |
|---|
| 613 | + (res->warnings != 0 && res->warnings >= qlim->warn)) { |
|---|
| 614 | + *fatal = true; |
|---|
| 615 | + return QUOTA_NL_ISOFTLONGWARN; |
|---|
| 616 | + } |
|---|
| 617 | + |
|---|
| 618 | + return QUOTA_NL_ISOFTWARN; |
|---|
| 619 | + } |
|---|
| 620 | + |
|---|
| 621 | + return QUOTA_NL_NOWARN; |
|---|
| 575 | 622 | } |
|---|
| 576 | 623 | |
|---|
| 577 | 624 | /* |
|---|
| .. | .. |
|---|
| 582 | 629 | */ |
|---|
| 583 | 630 | STATIC int |
|---|
| 584 | 631 | xfs_trans_dqresv( |
|---|
| 585 | | - xfs_trans_t *tp, |
|---|
| 586 | | - xfs_mount_t *mp, |
|---|
| 587 | | - xfs_dquot_t *dqp, |
|---|
| 588 | | - long nblks, |
|---|
| 589 | | - long ninos, |
|---|
| 590 | | - uint flags) |
|---|
| 632 | + struct xfs_trans *tp, |
|---|
| 633 | + struct xfs_mount *mp, |
|---|
| 634 | + struct xfs_dquot *dqp, |
|---|
| 635 | + int64_t nblks, |
|---|
| 636 | + long ninos, |
|---|
| 637 | + uint flags) |
|---|
| 591 | 638 | { |
|---|
| 592 | | - xfs_qcnt_t hardlimit; |
|---|
| 593 | | - xfs_qcnt_t softlimit; |
|---|
| 594 | | - time_t timer; |
|---|
| 595 | | - xfs_qwarncnt_t warns; |
|---|
| 596 | | - xfs_qwarncnt_t warnlimit; |
|---|
| 597 | | - xfs_qcnt_t total_count; |
|---|
| 598 | | - xfs_qcnt_t *resbcountp; |
|---|
| 599 | | - xfs_quotainfo_t *q = mp->m_quotainfo; |
|---|
| 639 | + struct xfs_quotainfo *q = mp->m_quotainfo; |
|---|
| 600 | 640 | struct xfs_def_quota *defq; |
|---|
| 601 | | - |
|---|
| 641 | + struct xfs_dquot_res *blkres; |
|---|
| 642 | + struct xfs_quota_limits *qlim; |
|---|
| 602 | 643 | |
|---|
| 603 | 644 | xfs_dqlock(dqp); |
|---|
| 604 | 645 | |
|---|
| 605 | | - defq = xfs_get_defquota(dqp, q); |
|---|
| 646 | + defq = xfs_get_defquota(q, xfs_dquot_type(dqp)); |
|---|
| 606 | 647 | |
|---|
| 607 | 648 | if (flags & XFS_TRANS_DQ_RES_BLKS) { |
|---|
| 608 | | - hardlimit = be64_to_cpu(dqp->q_core.d_blk_hardlimit); |
|---|
| 609 | | - if (!hardlimit) |
|---|
| 610 | | - hardlimit = defq->bhardlimit; |
|---|
| 611 | | - softlimit = be64_to_cpu(dqp->q_core.d_blk_softlimit); |
|---|
| 612 | | - if (!softlimit) |
|---|
| 613 | | - softlimit = defq->bsoftlimit; |
|---|
| 614 | | - timer = be32_to_cpu(dqp->q_core.d_btimer); |
|---|
| 615 | | - warns = be16_to_cpu(dqp->q_core.d_bwarns); |
|---|
| 616 | | - warnlimit = dqp->q_mount->m_quotainfo->qi_bwarnlimit; |
|---|
| 617 | | - resbcountp = &dqp->q_res_bcount; |
|---|
| 649 | + blkres = &dqp->q_blk; |
|---|
| 650 | + qlim = &defq->blk; |
|---|
| 618 | 651 | } else { |
|---|
| 619 | | - ASSERT(flags & XFS_TRANS_DQ_RES_RTBLKS); |
|---|
| 620 | | - hardlimit = be64_to_cpu(dqp->q_core.d_rtb_hardlimit); |
|---|
| 621 | | - if (!hardlimit) |
|---|
| 622 | | - hardlimit = defq->rtbhardlimit; |
|---|
| 623 | | - softlimit = be64_to_cpu(dqp->q_core.d_rtb_softlimit); |
|---|
| 624 | | - if (!softlimit) |
|---|
| 625 | | - softlimit = defq->rtbsoftlimit; |
|---|
| 626 | | - timer = be32_to_cpu(dqp->q_core.d_rtbtimer); |
|---|
| 627 | | - warns = be16_to_cpu(dqp->q_core.d_rtbwarns); |
|---|
| 628 | | - warnlimit = dqp->q_mount->m_quotainfo->qi_rtbwarnlimit; |
|---|
| 629 | | - resbcountp = &dqp->q_res_rtbcount; |
|---|
| 652 | + blkres = &dqp->q_rtb; |
|---|
| 653 | + qlim = &defq->rtb; |
|---|
| 630 | 654 | } |
|---|
| 631 | 655 | |
|---|
| 632 | | - if ((flags & XFS_QMOPT_FORCE_RES) == 0 && |
|---|
| 633 | | - dqp->q_core.d_id && |
|---|
| 634 | | - ((XFS_IS_UQUOTA_ENFORCED(dqp->q_mount) && XFS_QM_ISUDQ(dqp)) || |
|---|
| 635 | | - (XFS_IS_GQUOTA_ENFORCED(dqp->q_mount) && XFS_QM_ISGDQ(dqp)) || |
|---|
| 636 | | - (XFS_IS_PQUOTA_ENFORCED(dqp->q_mount) && XFS_QM_ISPDQ(dqp)))) { |
|---|
| 637 | | - if (nblks > 0) { |
|---|
| 656 | + if ((flags & XFS_QMOPT_FORCE_RES) == 0 && dqp->q_id && |
|---|
| 657 | + xfs_dquot_is_enforced(dqp)) { |
|---|
| 658 | + int quota_nl; |
|---|
| 659 | + bool fatal; |
|---|
| 660 | + |
|---|
| 661 | + /* |
|---|
| 662 | + * dquot is locked already. See if we'd go over the hardlimit |
|---|
| 663 | + * or exceed the timelimit if we'd reserve resources. |
|---|
| 664 | + */ |
|---|
| 665 | + quota_nl = xfs_dqresv_check(blkres, qlim, nblks, &fatal); |
|---|
| 666 | + if (quota_nl != QUOTA_NL_NOWARN) { |
|---|
| 638 | 667 | /* |
|---|
| 639 | | - * dquot is locked already. See if we'd go over the |
|---|
| 640 | | - * hardlimit or exceed the timelimit if we allocate |
|---|
| 641 | | - * nblks. |
|---|
| 668 | + * Quota block warning codes are 3 more than the inode |
|---|
| 669 | + * codes, which we check above. |
|---|
| 642 | 670 | */ |
|---|
| 643 | | - total_count = *resbcountp + nblks; |
|---|
| 644 | | - if (hardlimit && total_count > hardlimit) { |
|---|
| 645 | | - xfs_quota_warn(mp, dqp, QUOTA_NL_BHARDWARN); |
|---|
| 671 | + xfs_quota_warn(mp, dqp, quota_nl + 3); |
|---|
| 672 | + if (fatal) |
|---|
| 646 | 673 | goto error_return; |
|---|
| 647 | | - } |
|---|
| 648 | | - if (softlimit && total_count > softlimit) { |
|---|
| 649 | | - if ((timer != 0 && get_seconds() > timer) || |
|---|
| 650 | | - (warns != 0 && warns >= warnlimit)) { |
|---|
| 651 | | - xfs_quota_warn(mp, dqp, |
|---|
| 652 | | - QUOTA_NL_BSOFTLONGWARN); |
|---|
| 653 | | - goto error_return; |
|---|
| 654 | | - } |
|---|
| 655 | | - |
|---|
| 656 | | - xfs_quota_warn(mp, dqp, QUOTA_NL_BSOFTWARN); |
|---|
| 657 | | - } |
|---|
| 658 | 674 | } |
|---|
| 659 | | - if (ninos > 0) { |
|---|
| 660 | | - total_count = dqp->q_res_icount + ninos; |
|---|
| 661 | | - timer = be32_to_cpu(dqp->q_core.d_itimer); |
|---|
| 662 | | - warns = be16_to_cpu(dqp->q_core.d_iwarns); |
|---|
| 663 | | - warnlimit = dqp->q_mount->m_quotainfo->qi_iwarnlimit; |
|---|
| 664 | | - hardlimit = be64_to_cpu(dqp->q_core.d_ino_hardlimit); |
|---|
| 665 | | - if (!hardlimit) |
|---|
| 666 | | - hardlimit = defq->ihardlimit; |
|---|
| 667 | | - softlimit = be64_to_cpu(dqp->q_core.d_ino_softlimit); |
|---|
| 668 | | - if (!softlimit) |
|---|
| 669 | | - softlimit = defq->isoftlimit; |
|---|
| 670 | 675 | |
|---|
| 671 | | - if (hardlimit && total_count > hardlimit) { |
|---|
| 672 | | - xfs_quota_warn(mp, dqp, QUOTA_NL_IHARDWARN); |
|---|
| 676 | + quota_nl = xfs_dqresv_check(&dqp->q_ino, &defq->ino, ninos, |
|---|
| 677 | + &fatal); |
|---|
| 678 | + if (quota_nl != QUOTA_NL_NOWARN) { |
|---|
| 679 | + xfs_quota_warn(mp, dqp, quota_nl); |
|---|
| 680 | + if (fatal) |
|---|
| 673 | 681 | goto error_return; |
|---|
| 674 | | - } |
|---|
| 675 | | - if (softlimit && total_count > softlimit) { |
|---|
| 676 | | - if ((timer != 0 && get_seconds() > timer) || |
|---|
| 677 | | - (warns != 0 && warns >= warnlimit)) { |
|---|
| 678 | | - xfs_quota_warn(mp, dqp, |
|---|
| 679 | | - QUOTA_NL_ISOFTLONGWARN); |
|---|
| 680 | | - goto error_return; |
|---|
| 681 | | - } |
|---|
| 682 | | - xfs_quota_warn(mp, dqp, QUOTA_NL_ISOFTWARN); |
|---|
| 683 | | - } |
|---|
| 684 | 682 | } |
|---|
| 685 | 683 | } |
|---|
| 686 | 684 | |
|---|
| 687 | 685 | /* |
|---|
| 688 | 686 | * Change the reservation, but not the actual usage. |
|---|
| 689 | | - * Note that q_res_bcount = q_core.d_bcount + resv |
|---|
| 687 | + * Note that q_blk.reserved = q_blk.count + resv |
|---|
| 690 | 688 | */ |
|---|
| 691 | | - (*resbcountp) += (xfs_qcnt_t)nblks; |
|---|
| 692 | | - if (ninos != 0) |
|---|
| 693 | | - dqp->q_res_icount += (xfs_qcnt_t)ninos; |
|---|
| 689 | + blkres->reserved += (xfs_qcnt_t)nblks; |
|---|
| 690 | + dqp->q_ino.reserved += (xfs_qcnt_t)ninos; |
|---|
| 694 | 691 | |
|---|
| 695 | 692 | /* |
|---|
| 696 | 693 | * note the reservation amt in the trans struct too, |
|---|
| .. | .. |
|---|
| 711 | 708 | XFS_TRANS_DQ_RES_INOS, |
|---|
| 712 | 709 | ninos); |
|---|
| 713 | 710 | } |
|---|
| 714 | | - ASSERT(dqp->q_res_bcount >= be64_to_cpu(dqp->q_core.d_bcount)); |
|---|
| 715 | | - ASSERT(dqp->q_res_rtbcount >= be64_to_cpu(dqp->q_core.d_rtbcount)); |
|---|
| 716 | | - ASSERT(dqp->q_res_icount >= be64_to_cpu(dqp->q_core.d_icount)); |
|---|
| 711 | + ASSERT(dqp->q_blk.reserved >= dqp->q_blk.count); |
|---|
| 712 | + ASSERT(dqp->q_rtb.reserved >= dqp->q_rtb.count); |
|---|
| 713 | + ASSERT(dqp->q_ino.reserved >= dqp->q_ino.count); |
|---|
| 717 | 714 | |
|---|
| 718 | 715 | xfs_dqunlock(dqp); |
|---|
| 719 | 716 | return 0; |
|---|
| 720 | 717 | |
|---|
| 721 | 718 | error_return: |
|---|
| 722 | 719 | xfs_dqunlock(dqp); |
|---|
| 723 | | - if (flags & XFS_QMOPT_ENOSPC) |
|---|
| 720 | + if (xfs_dquot_type(dqp) == XFS_DQTYPE_PROJ) |
|---|
| 724 | 721 | return -ENOSPC; |
|---|
| 725 | 722 | return -EDQUOT; |
|---|
| 726 | 723 | } |
|---|
| .. | .. |
|---|
| 745 | 742 | struct xfs_dquot *udqp, |
|---|
| 746 | 743 | struct xfs_dquot *gdqp, |
|---|
| 747 | 744 | struct xfs_dquot *pdqp, |
|---|
| 748 | | - long nblks, |
|---|
| 745 | + int64_t nblks, |
|---|
| 749 | 746 | long ninos, |
|---|
| 750 | 747 | uint flags) |
|---|
| 751 | 748 | { |
|---|
| .. | .. |
|---|
| 760 | 757 | ASSERT(flags & XFS_QMOPT_RESBLK_MASK); |
|---|
| 761 | 758 | |
|---|
| 762 | 759 | if (udqp) { |
|---|
| 763 | | - error = xfs_trans_dqresv(tp, mp, udqp, nblks, ninos, |
|---|
| 764 | | - (flags & ~XFS_QMOPT_ENOSPC)); |
|---|
| 760 | + error = xfs_trans_dqresv(tp, mp, udqp, nblks, ninos, flags); |
|---|
| 765 | 761 | if (error) |
|---|
| 766 | 762 | return error; |
|---|
| 767 | 763 | } |
|---|
| .. | .. |
|---|
| 804 | 800 | xfs_trans_reserve_quota_nblks( |
|---|
| 805 | 801 | struct xfs_trans *tp, |
|---|
| 806 | 802 | struct xfs_inode *ip, |
|---|
| 807 | | - long nblks, |
|---|
| 803 | + int64_t nblks, |
|---|
| 808 | 804 | long ninos, |
|---|
| 809 | 805 | uint flags) |
|---|
| 810 | 806 | { |
|---|
| .. | .. |
|---|
| 812 | 808 | |
|---|
| 813 | 809 | if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) |
|---|
| 814 | 810 | return 0; |
|---|
| 815 | | - if (XFS_IS_PQUOTA_ON(mp)) |
|---|
| 816 | | - flags |= XFS_QMOPT_ENOSPC; |
|---|
| 817 | 811 | |
|---|
| 818 | 812 | ASSERT(!xfs_is_quota_inode(&mp->m_sb, ip->i_ino)); |
|---|
| 819 | 813 | |
|---|
| 820 | 814 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
|---|
| 821 | | - ASSERT((flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) == |
|---|
| 822 | | - XFS_TRANS_DQ_RES_RTBLKS || |
|---|
| 823 | | - (flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) == |
|---|
| 824 | | - XFS_TRANS_DQ_RES_BLKS); |
|---|
| 815 | + ASSERT((flags & ~(XFS_QMOPT_FORCE_RES)) == XFS_TRANS_DQ_RES_RTBLKS || |
|---|
| 816 | + (flags & ~(XFS_QMOPT_FORCE_RES)) == XFS_TRANS_DQ_RES_BLKS); |
|---|
| 825 | 817 | |
|---|
| 826 | 818 | /* |
|---|
| 827 | 819 | * Reserve nblks against these dquots, with trans as the mediator. |
|---|
| .. | .. |
|---|
| 835 | 827 | /* |
|---|
| 836 | 828 | * This routine is called to allocate a quotaoff log item. |
|---|
| 837 | 829 | */ |
|---|
| 838 | | -xfs_qoff_logitem_t * |
|---|
| 830 | +struct xfs_qoff_logitem * |
|---|
| 839 | 831 | xfs_trans_get_qoff_item( |
|---|
| 840 | | - xfs_trans_t *tp, |
|---|
| 841 | | - xfs_qoff_logitem_t *startqoff, |
|---|
| 832 | + struct xfs_trans *tp, |
|---|
| 833 | + struct xfs_qoff_logitem *startqoff, |
|---|
| 842 | 834 | uint flags) |
|---|
| 843 | 835 | { |
|---|
| 844 | | - xfs_qoff_logitem_t *q; |
|---|
| 836 | + struct xfs_qoff_logitem *q; |
|---|
| 845 | 837 | |
|---|
| 846 | 838 | ASSERT(tp != NULL); |
|---|
| 847 | 839 | |
|---|
| .. | .. |
|---|
| 863 | 855 | */ |
|---|
| 864 | 856 | void |
|---|
| 865 | 857 | xfs_trans_log_quotaoff_item( |
|---|
| 866 | | - xfs_trans_t *tp, |
|---|
| 867 | | - xfs_qoff_logitem_t *qlp) |
|---|
| 858 | + struct xfs_trans *tp, |
|---|
| 859 | + struct xfs_qoff_logitem *qlp) |
|---|
| 868 | 860 | { |
|---|
| 869 | 861 | tp->t_flags |= XFS_TRANS_DIRTY; |
|---|
| 870 | 862 | set_bit(XFS_LI_DIRTY, &qlp->qql_item.li_flags); |
|---|
| .. | .. |
|---|
| 874 | 866 | xfs_trans_alloc_dqinfo( |
|---|
| 875 | 867 | xfs_trans_t *tp) |
|---|
| 876 | 868 | { |
|---|
| 877 | | - tp->t_dqinfo = kmem_zone_zalloc(xfs_qm_dqtrxzone, KM_SLEEP); |
|---|
| 869 | + tp->t_dqinfo = kmem_cache_zalloc(xfs_qm_dqtrxzone, |
|---|
| 870 | + GFP_KERNEL | __GFP_NOFAIL); |
|---|
| 878 | 871 | } |
|---|
| 879 | 872 | |
|---|
| 880 | 873 | void |
|---|
| .. | .. |
|---|
| 883 | 876 | { |
|---|
| 884 | 877 | if (!tp->t_dqinfo) |
|---|
| 885 | 878 | return; |
|---|
| 886 | | - kmem_zone_free(xfs_qm_dqtrxzone, tp->t_dqinfo); |
|---|
| 879 | + kmem_cache_free(xfs_qm_dqtrxzone, tp->t_dqinfo); |
|---|
| 887 | 880 | tp->t_dqinfo = NULL; |
|---|
| 888 | 881 | } |
|---|