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

Jeff Liu
2013-05-17T05:40:27Z

On 05/17/2013 11:01 AM, Dave Chinner wrote:
> 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) {
> ....
> }
Ah, yep. thanks for the teaching. :)

Thanks,
-Jeff