xfs
[Top] [All Lists]

Re: [PATCH v8 2/5] xfs: Add pquota fields where gquota is used.

To: Jeff Liu <jeff.liu@xxxxxxxxxx>
Subject: Re: [PATCH v8 2/5] xfs: Add pquota fields where gquota is used.
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Fri, 17 May 2013 13:01:26 +1000
Cc: Chandra Seetharaman <sekharan@xxxxxxxxxx>, xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <51906528.3030307@xxxxxxxxxx>
References: <1368220889-25188-1-git-send-email-sekharan@xxxxxxxxxx> <1368220889-25188-3-git-send-email-sekharan@xxxxxxxxxx> <51906528.3030307@xxxxxxxxxx>
User-agent: Mutt/1.5.21 (2010-09-15)
On Mon, May 13, 2013 at 11:59:36AM +0800, Jeff Liu wrote:
> Hi,
> 
> > +struct xfs_inode *
> > +xfs_dq_to_quota_inode(struct xfs_dquot *dqp)
> > +{
> > +   if (XFS_QM_ISUDQ(dqp))
> > +           return dqp->q_mount->m_quotainfo->qi_uquotaip;
> > +   if (XFS_QM_ISGDQ(dqp))
> > +           return dqp->q_mount->m_quotainfo->qi_gquotaip;
> > +   ASSERT(XFS_QM_ISPDQ(dqp));
> > +   return dqp->q_mount->m_quotainfo->qi_pquotaip;
> > +}
> Is it better to replace above conditional judgment with 'switch...case'?
> i.e.
> static inline struct xfs_inode *
> xfs_dq_to_qip(struct xfs_dquot *dqp)
> {
>       switch (dqp->dq_flags) {
>       case XFS_DQ_USER:
>               return dqp->q_mount->m_quotainfo->qi_uquotaip;
>       case XFS_DQ_GROUP:
>               return dqp->q_mount->m_quotainfo->qi_gqoutaip;
>       case XFS_DQ_PROJ:
>               return dqp->q_mount->m_quotainfo->qi_pquotaip;
>       }

Doesn't work because dq_flags can have other fields set in it (e.g
XFS_DQ_DIRTY). It would need to be:

        switch (dqp->dq_flags & XFS_DQ_ALLTYPES) {
        ....
        }

Cheers,

Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>