diff options
| author | Christoph Hellwig <hch@infradead.org> | 2010-01-13 17:05:49 -0500 |
|---|---|---|
| committer | Alex Elder <aelder@sgi.com> | 2010-01-21 14:44:22 -0500 |
| commit | 4d1f88d75b00c4d23f4c51305ab5b779a86ef74e (patch) | |
| tree | 9a0aa476c2c285a1557218a14f32f41cd1013f85 | |
| parent | 512dd1abd9539a474f2792eeaf6783c59ad7778a (diff) | |
xfs: clean up error handling in xfs_trans_dqresv
Move the error code selection after the goto label and fold the
xfs_quota_error helper into it.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Alex Elder <aelder@sgi.com>
| -rw-r--r-- | fs/xfs/quota/xfs_trans_dquot.c | 48 |
1 files changed, 17 insertions, 31 deletions
diff --git a/fs/xfs/quota/xfs_trans_dquot.c b/fs/xfs/quota/xfs_trans_dquot.c index 97ac9640be98..b9db6f781cd6 100644 --- a/fs/xfs/quota/xfs_trans_dquot.c +++ b/fs/xfs/quota/xfs_trans_dquot.c | |||
| @@ -589,14 +589,6 @@ xfs_trans_unreserve_and_mod_dquots( | |||
| 589 | } | 589 | } |
| 590 | } | 590 | } |
| 591 | 591 | ||
| 592 | STATIC int | ||
| 593 | xfs_quota_error(uint flags) | ||
| 594 | { | ||
| 595 | if (flags & XFS_QMOPT_ENOSPC) | ||
| 596 | return ENOSPC; | ||
| 597 | return EDQUOT; | ||
| 598 | } | ||
| 599 | |||
| 600 | /* | 592 | /* |
| 601 | * This reserves disk blocks and inodes against a dquot. | 593 | * This reserves disk blocks and inodes against a dquot. |
| 602 | * Flags indicate if the dquot is to be locked here and also | 594 | * Flags indicate if the dquot is to be locked here and also |
| @@ -612,7 +604,6 @@ xfs_trans_dqresv( | |||
| 612 | long ninos, | 604 | long ninos, |
| 613 | uint flags) | 605 | uint flags) |
| 614 | { | 606 | { |
| 615 | int error; | ||
| 616 | xfs_qcnt_t hardlimit; | 607 | xfs_qcnt_t hardlimit; |
| 617 | xfs_qcnt_t softlimit; | 608 | xfs_qcnt_t softlimit; |
| 618 | time_t timer; | 609 | time_t timer; |
| @@ -649,7 +640,6 @@ xfs_trans_dqresv( | |||
| 649 | warnlimit = XFS_QI_RTBWARNLIMIT(dqp->q_mount); | 640 | warnlimit = XFS_QI_RTBWARNLIMIT(dqp->q_mount); |
| 650 | resbcountp = &dqp->q_res_rtbcount; | 641 | resbcountp = &dqp->q_res_rtbcount; |
| 651 | } | 642 | } |
| 652 | error = 0; | ||
| 653 | 643 | ||
| 654 | if ((flags & XFS_QMOPT_FORCE_RES) == 0 && | 644 | if ((flags & XFS_QMOPT_FORCE_RES) == 0 && |
| 655 | dqp->q_core.d_id && | 645 | dqp->q_core.d_id && |
| @@ -667,19 +657,13 @@ xfs_trans_dqresv( | |||
| 667 | * nblks. | 657 | * nblks. |
| 668 | */ | 658 | */ |
| 669 | if (hardlimit > 0ULL && | 659 | if (hardlimit > 0ULL && |
| 670 | (hardlimit <= nblks + *resbcountp)) { | 660 | hardlimit <= nblks + *resbcountp) |
| 671 | error = xfs_quota_error(flags); | ||
| 672 | goto error_return; | 661 | goto error_return; |
| 673 | } | ||
| 674 | |||
| 675 | if (softlimit > 0ULL && | 662 | if (softlimit > 0ULL && |
| 676 | (softlimit <= nblks + *resbcountp)) { | 663 | softlimit <= nblks + *resbcountp && |
| 677 | if ((timer != 0 && get_seconds() > timer) || | 664 | ((timer != 0 && get_seconds() > timer) || |
| 678 | (warns != 0 && warns >= warnlimit)) { | 665 | (warns != 0 && warns >= warnlimit))) |
| 679 | error = xfs_quota_error(flags); | 666 | goto error_return; |
| 680 | goto error_return; | ||
| 681 | } | ||
| 682 | } | ||
| 683 | } | 667 | } |
| 684 | if (ninos > 0) { | 668 | if (ninos > 0) { |
| 685 | count = be64_to_cpu(dqp->q_core.d_icount); | 669 | count = be64_to_cpu(dqp->q_core.d_icount); |
| @@ -692,16 +676,13 @@ xfs_trans_dqresv( | |||
| 692 | softlimit = be64_to_cpu(dqp->q_core.d_ino_softlimit); | 676 | softlimit = be64_to_cpu(dqp->q_core.d_ino_softlimit); |
| 693 | if (!softlimit) | 677 | if (!softlimit) |
| 694 | softlimit = q->qi_isoftlimit; | 678 | softlimit = q->qi_isoftlimit; |
| 695 | if (hardlimit > 0ULL && count >= hardlimit) { | 679 | |
| 696 | error = xfs_quota_error(flags); | 680 | if (hardlimit > 0ULL && count >= hardlimit) |
| 681 | goto error_return; | ||
| 682 | if (softlimit > 0ULL && count >= softlimit && | ||
| 683 | ((timer != 0 && get_seconds() > timer) || | ||
| 684 | (warns != 0 && warns >= warnlimit))) | ||
| 697 | goto error_return; | 685 | goto error_return; |
| 698 | } else if (softlimit > 0ULL && count >= softlimit) { | ||
| 699 | if ((timer != 0 && get_seconds() > timer) || | ||
| 700 | (warns != 0 && warns >= warnlimit)) { | ||
| 701 | error = xfs_quota_error(flags); | ||
| 702 | goto error_return; | ||
| 703 | } | ||
| 704 | } | ||
| 705 | } | 686 | } |
| 706 | } | 687 | } |
| 707 | 688 | ||
| @@ -736,9 +717,14 @@ xfs_trans_dqresv( | |||
| 736 | ASSERT(dqp->q_res_rtbcount >= be64_to_cpu(dqp->q_core.d_rtbcount)); | 717 | ASSERT(dqp->q_res_rtbcount >= be64_to_cpu(dqp->q_core.d_rtbcount)); |
| 737 | ASSERT(dqp->q_res_icount >= be64_to_cpu(dqp->q_core.d_icount)); | 718 | ASSERT(dqp->q_res_icount >= be64_to_cpu(dqp->q_core.d_icount)); |
| 738 | 719 | ||
| 720 | xfs_dqunlock(dqp); | ||
| 721 | return 0; | ||
| 722 | |||
| 739 | error_return: | 723 | error_return: |
| 740 | xfs_dqunlock(dqp); | 724 | xfs_dqunlock(dqp); |
| 741 | return error; | 725 | if (flags & XFS_QMOPT_ENOSPC) |
| 726 | return ENOSPC; | ||
| 727 | return EDQUOT; | ||
| 742 | } | 728 | } |
| 743 | 729 | ||
| 744 | 730 | ||
