diff options
author | Chandra Seetharaman <sekharan@us.ibm.com> | 2012-01-23 12:31:30 -0500 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2012-02-03 11:53:39 -0500 |
commit | 36731410834e08c7d15c3980abd6cc4c563c2e87 (patch) | |
tree | 22823adcd10572766aa37d98bb7f5c3dcc248189 /fs/xfs | |
parent | 6967b964c1012231f338445f20f877e680cd4cb8 (diff) |
Define a new function xfs_inode_dquot()
Define a new function xfs_inode_dquot() that takes a inode pointer
and a disk quota type and returns the quota pointer for the specified
quota type.
This simplifies the xfs_qm_dqget() error path significantly.
Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_dquot.c | 33 | ||||
-rw-r--r-- | fs/xfs/xfs_dquot.h | 13 |
2 files changed, 22 insertions, 24 deletions
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index 4c8b3d2cc96..bf4fe8637f3 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c | |||
@@ -723,7 +723,7 @@ xfs_qm_dqget( | |||
723 | uint flags, /* DQALLOC, DQSUSER, DQREPAIR, DOWARN */ | 723 | uint flags, /* DQALLOC, DQSUSER, DQREPAIR, DOWARN */ |
724 | xfs_dquot_t **O_dqpp) /* OUT : locked incore dquot */ | 724 | xfs_dquot_t **O_dqpp) /* OUT : locked incore dquot */ |
725 | { | 725 | { |
726 | xfs_dquot_t *dqp; | 726 | xfs_dquot_t *dqp, *dqp1; |
727 | xfs_dqhash_t *h; | 727 | xfs_dqhash_t *h; |
728 | uint version; | 728 | uint version; |
729 | int error; | 729 | int error; |
@@ -750,10 +750,7 @@ xfs_qm_dqget( | |||
750 | type == XFS_DQ_GROUP); | 750 | type == XFS_DQ_GROUP); |
751 | if (ip) { | 751 | if (ip) { |
752 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | 752 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
753 | if (type == XFS_DQ_USER) | 753 | ASSERT(xfs_inode_dquot(ip, type) == NULL); |
754 | ASSERT(ip->i_udquot == NULL); | ||
755 | else | ||
756 | ASSERT(ip->i_gdquot == NULL); | ||
757 | } | 754 | } |
758 | #endif | 755 | #endif |
759 | 756 | ||
@@ -819,30 +816,18 @@ restart: | |||
819 | * A dquot could be attached to this inode by now, since | 816 | * A dquot could be attached to this inode by now, since |
820 | * we had dropped the ilock. | 817 | * we had dropped the ilock. |
821 | */ | 818 | */ |
822 | if (type == XFS_DQ_USER) { | 819 | if (xfs_this_quota_on(mp, type)) { |
823 | if (!XFS_IS_UQUOTA_ON(mp)) { | 820 | dqp1 = xfs_inode_dquot(ip, type); |
824 | /* inode stays locked on return */ | 821 | if (dqp1) { |
825 | xfs_qm_dqdestroy(dqp); | ||
826 | return XFS_ERROR(ESRCH); | ||
827 | } | ||
828 | if (ip->i_udquot) { | ||
829 | xfs_qm_dqdestroy(dqp); | 822 | xfs_qm_dqdestroy(dqp); |
830 | dqp = ip->i_udquot; | 823 | dqp = dqp1; |
831 | xfs_dqlock(dqp); | 824 | xfs_dqlock(dqp); |
832 | goto dqret; | 825 | goto dqret; |
833 | } | 826 | } |
834 | } else { | 827 | } else { |
835 | if (!XFS_IS_OQUOTA_ON(mp)) { | 828 | /* inode stays locked on return */ |
836 | /* inode stays locked on return */ | 829 | xfs_qm_dqdestroy(dqp); |
837 | xfs_qm_dqdestroy(dqp); | 830 | return XFS_ERROR(ESRCH); |
838 | return XFS_ERROR(ESRCH); | ||
839 | } | ||
840 | if (ip->i_gdquot) { | ||
841 | xfs_qm_dqdestroy(dqp); | ||
842 | dqp = ip->i_gdquot; | ||
843 | xfs_dqlock(dqp); | ||
844 | goto dqret; | ||
845 | } | ||
846 | } | 831 | } |
847 | } | 832 | } |
848 | 833 | ||
diff --git a/fs/xfs/xfs_dquot.h b/fs/xfs/xfs_dquot.h index 1c48489423e..48a795b141b 100644 --- a/fs/xfs/xfs_dquot.h +++ b/fs/xfs/xfs_dquot.h | |||
@@ -128,6 +128,19 @@ static inline int xfs_this_quota_on(struct xfs_mount *mp, int type) | |||
128 | } | 128 | } |
129 | } | 129 | } |
130 | 130 | ||
131 | static inline xfs_dquot_t *xfs_inode_dquot(struct xfs_inode *ip, int type) | ||
132 | { | ||
133 | switch (type & XFS_DQ_ALLTYPES) { | ||
134 | case XFS_DQ_USER: | ||
135 | return ip->i_udquot; | ||
136 | case XFS_DQ_GROUP: | ||
137 | case XFS_DQ_PROJ: | ||
138 | return ip->i_gdquot; | ||
139 | default: | ||
140 | return NULL; | ||
141 | } | ||
142 | } | ||
143 | |||
131 | #define XFS_DQ_IS_LOCKED(dqp) (mutex_is_locked(&((dqp)->q_qlock))) | 144 | #define XFS_DQ_IS_LOCKED(dqp) (mutex_is_locked(&((dqp)->q_qlock))) |
132 | #define XFS_DQ_IS_DIRTY(dqp) ((dqp)->dq_flags & XFS_DQ_DIRTY) | 145 | #define XFS_DQ_IS_DIRTY(dqp) ((dqp)->dq_flags & XFS_DQ_DIRTY) |
133 | #define XFS_QM_ISUDQ(dqp) ((dqp)->dq_flags & XFS_DQ_USER) | 146 | #define XFS_QM_ISUDQ(dqp) ((dqp)->dq_flags & XFS_DQ_USER) |