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>
This commit is contained in:
parent
6967b964c1
commit
3673141083
2 changed files with 22 additions and 24 deletions
|
@ -723,7 +723,7 @@ xfs_qm_dqget(
|
||||||
uint flags, /* DQALLOC, DQSUSER, DQREPAIR, DOWARN */
|
uint flags, /* DQALLOC, DQSUSER, DQREPAIR, DOWARN */
|
||||||
xfs_dquot_t **O_dqpp) /* OUT : locked incore dquot */
|
xfs_dquot_t **O_dqpp) /* OUT : locked incore dquot */
|
||||||
{
|
{
|
||||||
xfs_dquot_t *dqp;
|
xfs_dquot_t *dqp, *dqp1;
|
||||||
xfs_dqhash_t *h;
|
xfs_dqhash_t *h;
|
||||||
uint version;
|
uint version;
|
||||||
int error;
|
int error;
|
||||||
|
@ -750,10 +750,7 @@ xfs_qm_dqget(
|
||||||
type == XFS_DQ_GROUP);
|
type == XFS_DQ_GROUP);
|
||||||
if (ip) {
|
if (ip) {
|
||||||
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
|
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
|
||||||
if (type == XFS_DQ_USER)
|
ASSERT(xfs_inode_dquot(ip, type) == NULL);
|
||||||
ASSERT(ip->i_udquot == NULL);
|
|
||||||
else
|
|
||||||
ASSERT(ip->i_gdquot == NULL);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -819,31 +816,19 @@ restart:
|
||||||
* A dquot could be attached to this inode by now, since
|
* A dquot could be attached to this inode by now, since
|
||||||
* we had dropped the ilock.
|
* we had dropped the ilock.
|
||||||
*/
|
*/
|
||||||
if (type == XFS_DQ_USER) {
|
if (xfs_this_quota_on(mp, type)) {
|
||||||
if (!XFS_IS_UQUOTA_ON(mp)) {
|
dqp1 = xfs_inode_dquot(ip, type);
|
||||||
/* inode stays locked on return */
|
if (dqp1) {
|
||||||
xfs_qm_dqdestroy(dqp);
|
xfs_qm_dqdestroy(dqp);
|
||||||
return XFS_ERROR(ESRCH);
|
dqp = dqp1;
|
||||||
}
|
|
||||||
if (ip->i_udquot) {
|
|
||||||
xfs_qm_dqdestroy(dqp);
|
|
||||||
dqp = ip->i_udquot;
|
|
||||||
xfs_dqlock(dqp);
|
xfs_dqlock(dqp);
|
||||||
goto dqret;
|
goto dqret;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!XFS_IS_OQUOTA_ON(mp)) {
|
|
||||||
/* inode stays locked on return */
|
/* inode stays locked on return */
|
||||||
xfs_qm_dqdestroy(dqp);
|
xfs_qm_dqdestroy(dqp);
|
||||||
return XFS_ERROR(ESRCH);
|
return XFS_ERROR(ESRCH);
|
||||||
}
|
}
|
||||||
if (ip->i_gdquot) {
|
|
||||||
xfs_qm_dqdestroy(dqp);
|
|
||||||
dqp = ip->i_gdquot;
|
|
||||||
xfs_dqlock(dqp);
|
|
||||||
goto dqret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -128,6 +128,19 @@ static inline int xfs_this_quota_on(struct xfs_mount *mp, int type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline xfs_dquot_t *xfs_inode_dquot(struct xfs_inode *ip, int type)
|
||||||
|
{
|
||||||
|
switch (type & XFS_DQ_ALLTYPES) {
|
||||||
|
case XFS_DQ_USER:
|
||||||
|
return ip->i_udquot;
|
||||||
|
case XFS_DQ_GROUP:
|
||||||
|
case XFS_DQ_PROJ:
|
||||||
|
return ip->i_gdquot;
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#define XFS_DQ_IS_LOCKED(dqp) (mutex_is_locked(&((dqp)->q_qlock)))
|
#define XFS_DQ_IS_LOCKED(dqp) (mutex_is_locked(&((dqp)->q_qlock)))
|
||||||
#define XFS_DQ_IS_DIRTY(dqp) ((dqp)->dq_flags & XFS_DQ_DIRTY)
|
#define XFS_DQ_IS_DIRTY(dqp) ((dqp)->dq_flags & XFS_DQ_DIRTY)
|
||||||
#define XFS_QM_ISUDQ(dqp) ((dqp)->dq_flags & XFS_DQ_USER)
|
#define XFS_QM_ISUDQ(dqp) ((dqp)->dq_flags & XFS_DQ_USER)
|
||||||
|
|
Loading…
Add table
Reference in a new issue