Commit c51df733 authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: stop using q_core.d_id in the quota code

Add a dquot id field to the incore dquot, and use that instead of the
one in qcore.  This eliminates a bunch of endian conversions and will
eventually allow us to remove qcore entirely.

We also rearrange the start of xfs_dquot to remove padding holes, saving
8 bytes.
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarChandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarAllison Collins <allison.henderson@oracle.com>
parent 0b0fa1d1
...@@ -92,7 +92,6 @@ xchk_quota_item( ...@@ -92,7 +92,6 @@ xchk_quota_item(
unsigned long long icount; unsigned long long icount;
unsigned long long rcount; unsigned long long rcount;
xfs_ino_t fs_icount; xfs_ino_t fs_icount;
xfs_dqid_t id = be32_to_cpu(d->d_id);
int error = 0; int error = 0;
if (xchk_should_terminate(sc, &error)) if (xchk_should_terminate(sc, &error))
...@@ -102,11 +101,11 @@ xchk_quota_item( ...@@ -102,11 +101,11 @@ xchk_quota_item(
* Except for the root dquot, the actual dquot we got must either have * Except for the root dquot, the actual dquot we got must either have
* the same or higher id as we saw before. * the same or higher id as we saw before.
*/ */
offset = id / qi->qi_dqperchunk; offset = dq->q_id / qi->qi_dqperchunk;
if (id && id <= sqi->last_id) if (dq->q_id && dq->q_id <= sqi->last_id)
xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, offset); xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, offset);
sqi->last_id = id; sqi->last_id = dq->q_id;
/* Did we get the dquot type we wanted? */ /* Did we get the dquot type we wanted? */
if (dqtype != (d->d_flags & XFS_DQ_ALLTYPES)) if (dqtype != (d->d_flags & XFS_DQ_ALLTYPES))
...@@ -175,13 +174,19 @@ xchk_quota_item( ...@@ -175,13 +174,19 @@ xchk_quota_item(
* lower limit than the actual usage. However, we flag it for * lower limit than the actual usage. However, we flag it for
* admin review. * admin review.
*/ */
if (id != 0 && bhard != 0 && bcount > bhard) if (dq->q_id == 0)
goto out;
if (bhard != 0 && bcount > bhard)
xchk_fblock_set_warning(sc, XFS_DATA_FORK, offset); xchk_fblock_set_warning(sc, XFS_DATA_FORK, offset);
if (id != 0 && ihard != 0 && icount > ihard)
if (ihard != 0 && icount > ihard)
xchk_fblock_set_warning(sc, XFS_DATA_FORK, offset); xchk_fblock_set_warning(sc, XFS_DATA_FORK, offset);
if (id != 0 && rhard != 0 && rcount > rhard)
if (rhard != 0 && rcount > rhard)
xchk_fblock_set_warning(sc, XFS_DATA_FORK, offset); xchk_fblock_set_warning(sc, XFS_DATA_FORK, offset);
out:
if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
return -EFSCORRUPTED; return -EFSCORRUPTED;
......
...@@ -75,7 +75,7 @@ xfs_qm_adjust_dqlimits( ...@@ -75,7 +75,7 @@ xfs_qm_adjust_dqlimits(
struct xfs_def_quota *defq; struct xfs_def_quota *defq;
int prealloc = 0; int prealloc = 0;
ASSERT(d->d_id); ASSERT(dq->q_id);
defq = xfs_get_defquota(q, xfs_dquot_type(dq)); defq = xfs_get_defquota(q, xfs_dquot_type(dq));
if (defq->bsoftlimit && !d->d_blk_softlimit) { if (defq->bsoftlimit && !d->d_blk_softlimit) {
...@@ -121,7 +121,7 @@ xfs_qm_adjust_dqtimers( ...@@ -121,7 +121,7 @@ xfs_qm_adjust_dqtimers(
struct xfs_disk_dquot *d = &dq->q_core; struct xfs_disk_dquot *d = &dq->q_core;
struct xfs_def_quota *defq; struct xfs_def_quota *defq;
ASSERT(d->d_id); ASSERT(dq->q_id);
defq = xfs_get_defquota(qi, xfs_dquot_type(dq)); defq = xfs_get_defquota(qi, xfs_dquot_type(dq));
#ifdef DEBUG #ifdef DEBUG
...@@ -366,7 +366,7 @@ xfs_dquot_disk_alloc( ...@@ -366,7 +366,7 @@ xfs_dquot_disk_alloc(
* Make a chunk of dquots out of this buffer and log * Make a chunk of dquots out of this buffer and log
* the entire thing. * the entire thing.
*/ */
xfs_qm_init_dquot_blk(tp, mp, be32_to_cpu(dqp->q_core.d_id), xfs_qm_init_dquot_blk(tp, mp, dqp->q_id,
dqp->dq_flags & XFS_DQ_ALLTYPES, bp); dqp->dq_flags & XFS_DQ_ALLTYPES, bp);
xfs_buf_set_ref(bp, XFS_DQUOT_REF); xfs_buf_set_ref(bp, XFS_DQUOT_REF);
...@@ -479,7 +479,7 @@ xfs_dquot_alloc( ...@@ -479,7 +479,7 @@ xfs_dquot_alloc(
dqp = kmem_zone_zalloc(xfs_qm_dqzone, 0); dqp = kmem_zone_zalloc(xfs_qm_dqzone, 0);
dqp->dq_flags = type; dqp->dq_flags = type;
dqp->q_core.d_id = cpu_to_be32(id); dqp->q_id = id;
dqp->q_mount = mp; dqp->q_mount = mp;
INIT_LIST_HEAD(&dqp->q_lru); INIT_LIST_HEAD(&dqp->q_lru);
mutex_init(&dqp->q_qlock); mutex_init(&dqp->q_qlock);
...@@ -537,10 +537,10 @@ xfs_dquot_from_disk( ...@@ -537,10 +537,10 @@ xfs_dquot_from_disk(
* Everything else was checked by the dquot buffer verifier. * Everything else was checked by the dquot buffer verifier.
*/ */
if ((ddqp->d_flags & XFS_DQ_ALLTYPES) != dqp->dq_flags || if ((ddqp->d_flags & XFS_DQ_ALLTYPES) != dqp->dq_flags ||
ddqp->d_id != dqp->q_core.d_id) { be32_to_cpu(ddqp->d_id) != dqp->q_id) {
xfs_alert_tag(bp->b_mount, XFS_PTAG_VERIFIER_ERROR, xfs_alert_tag(bp->b_mount, XFS_PTAG_VERIFIER_ERROR,
"Metadata corruption detected at %pS, quota %u", "Metadata corruption detected at %pS, quota %u",
__this_address, be32_to_cpu(dqp->q_core.d_id)); __this_address, dqp->q_id);
xfs_alert(bp->b_mount, "Unmount and run xfs_repair"); xfs_alert(bp->b_mount, "Unmount and run xfs_repair");
return -EFSCORRUPTED; return -EFSCORRUPTED;
} }
...@@ -1187,11 +1187,10 @@ xfs_qm_dqflush( ...@@ -1187,11 +1187,10 @@ xfs_qm_dqflush(
ddqp = &dqb->dd_diskdq; ddqp = &dqb->dd_diskdq;
/* sanity check the in-core structure before we flush */ /* sanity check the in-core structure before we flush */
fa = xfs_dquot_verify(mp, &dqp->q_core, be32_to_cpu(dqp->q_core.d_id), fa = xfs_dquot_verify(mp, &dqp->q_core, dqp->q_id, 0);
0);
if (fa) { if (fa) {
xfs_alert(mp, "corrupt dquot ID 0x%x in memory at %pS", xfs_alert(mp, "corrupt dquot ID 0x%x in memory at %pS",
be32_to_cpu(dqp->q_core.d_id), fa); dqp->q_id, fa);
xfs_buf_relse(bp); xfs_buf_relse(bp);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_abort; goto out_abort;
...@@ -1200,7 +1199,7 @@ xfs_qm_dqflush( ...@@ -1200,7 +1199,7 @@ xfs_qm_dqflush(
fa = xfs_qm_dqflush_check(dqp); fa = xfs_qm_dqflush_check(dqp);
if (fa) { if (fa) {
xfs_alert(mp, "corrupt dquot ID 0x%x in memory at %pS", xfs_alert(mp, "corrupt dquot ID 0x%x in memory at %pS",
be32_to_cpu(dqp->q_core.d_id), fa); dqp->q_id, fa);
xfs_buf_relse(bp); xfs_buf_relse(bp);
error = -EFSCORRUPTED; error = -EFSCORRUPTED;
goto out_abort; goto out_abort;
...@@ -1273,8 +1272,7 @@ xfs_dqlock2( ...@@ -1273,8 +1272,7 @@ xfs_dqlock2(
{ {
if (d1 && d2) { if (d1 && d2) {
ASSERT(d1 != d2); ASSERT(d1 != d2);
if (be32_to_cpu(d1->q_core.d_id) > if (d1->q_id > d2->q_id) {
be32_to_cpu(d2->q_core.d_id)) {
mutex_lock(&d2->q_qlock); mutex_lock(&d2->q_qlock);
mutex_lock_nested(&d1->q_qlock, XFS_QLOCK_NESTED); mutex_lock_nested(&d1->q_qlock, XFS_QLOCK_NESTED);
} else { } else {
...@@ -1342,9 +1340,8 @@ xfs_qm_dqiterate( ...@@ -1342,9 +1340,8 @@ xfs_qm_dqiterate(
return error; return error;
error = iter_fn(dq, dqtype, priv); error = iter_fn(dq, dqtype, priv);
id = be32_to_cpu(dq->q_core.d_id); id = dq->q_id;
xfs_qm_dqput(dq); xfs_qm_dqput(dq);
id++;
} while (error == 0 && id != 0); } while (error == 0 && id != 0);
return error; return error;
......
...@@ -35,9 +35,10 @@ struct xfs_dquot { ...@@ -35,9 +35,10 @@ struct xfs_dquot {
struct xfs_mount *q_mount; struct xfs_mount *q_mount;
uint8_t dq_flags; uint8_t dq_flags;
uint16_t q_flags; uint16_t q_flags;
xfs_dqid_t q_id;
uint q_nrefs; uint q_nrefs;
xfs_daddr_t q_blkno;
int q_bufoffset; int q_bufoffset;
xfs_daddr_t q_blkno;
xfs_fileoff_t q_fileoffset; xfs_fileoff_t q_fileoffset;
struct xfs_disk_dquot q_core; struct xfs_disk_dquot q_core;
......
...@@ -53,7 +53,7 @@ xfs_qm_dquot_logitem_format( ...@@ -53,7 +53,7 @@ xfs_qm_dquot_logitem_format(
qlf = xlog_prepare_iovec(lv, &vecp, XLOG_REG_TYPE_QFORMAT); qlf = xlog_prepare_iovec(lv, &vecp, XLOG_REG_TYPE_QFORMAT);
qlf->qlf_type = XFS_LI_DQUOT; qlf->qlf_type = XFS_LI_DQUOT;
qlf->qlf_size = 2; qlf->qlf_size = 2;
qlf->qlf_id = be32_to_cpu(qlip->qli_dquot->q_core.d_id); qlf->qlf_id = qlip->qli_dquot->q_id;
qlf->qlf_blkno = qlip->qli_dquot->q_blkno; qlf->qlf_blkno = qlip->qli_dquot->q_blkno;
qlf->qlf_len = 1; qlf->qlf_len = 1;
qlf->qlf_boffset = qlip->qli_dquot->q_bufoffset; qlf->qlf_boffset = qlip->qli_dquot->q_bufoffset;
......
...@@ -79,7 +79,7 @@ xfs_qm_dquot_walk( ...@@ -79,7 +79,7 @@ xfs_qm_dquot_walk(
for (i = 0; i < nr_found; i++) { for (i = 0; i < nr_found; i++) {
struct xfs_dquot *dqp = batch[i]; struct xfs_dquot *dqp = batch[i];
next_index = be32_to_cpu(dqp->q_core.d_id) + 1; next_index = dqp->q_id + 1;
error = execute(batch[i], data); error = execute(batch[i], data);
if (error == -EAGAIN) { if (error == -EAGAIN) {
...@@ -161,8 +161,7 @@ xfs_qm_dqpurge( ...@@ -161,8 +161,7 @@ xfs_qm_dqpurge(
xfs_dqfunlock(dqp); xfs_dqfunlock(dqp);
xfs_dqunlock(dqp); xfs_dqunlock(dqp);
radix_tree_delete(xfs_dquot_tree(qi, dqp->q_core.d_flags), radix_tree_delete(xfs_dquot_tree(qi, dqp->q_core.d_flags), dqp->q_id);
be32_to_cpu(dqp->q_core.d_id));
qi->qi_dquots--; qi->qi_dquots--;
/* /*
...@@ -1108,7 +1107,7 @@ xfs_qm_quotacheck_dqadjust( ...@@ -1108,7 +1107,7 @@ xfs_qm_quotacheck_dqadjust(
* *
* There are no timers for the default values set in the root dquot. * There are no timers for the default values set in the root dquot.
*/ */
if (dqp->q_core.d_id) { if (dqp->q_id) {
xfs_qm_adjust_dqlimits(mp, dqp); xfs_qm_adjust_dqlimits(mp, dqp);
xfs_qm_adjust_dqtimers(mp, dqp); xfs_qm_adjust_dqtimers(mp, dqp);
} }
...@@ -1594,8 +1593,7 @@ xfs_qm_dqfree_one( ...@@ -1594,8 +1593,7 @@ xfs_qm_dqfree_one(
struct xfs_quotainfo *qi = mp->m_quotainfo; struct xfs_quotainfo *qi = mp->m_quotainfo;
mutex_lock(&qi->qi_tree_lock); mutex_lock(&qi->qi_tree_lock);
radix_tree_delete(xfs_dquot_tree(qi, dqp->q_core.d_flags), radix_tree_delete(xfs_dquot_tree(qi, dqp->q_core.d_flags), dqp->q_id);
be32_to_cpu(dqp->q_core.d_id));
qi->qi_dquots--; qi->qi_dquots--;
mutex_unlock(&qi->qi_tree_lock); mutex_unlock(&qi->qi_tree_lock);
...@@ -1819,7 +1817,7 @@ xfs_qm_vop_chown_reserve( ...@@ -1819,7 +1817,7 @@ xfs_qm_vop_chown_reserve(
XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS; XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS;
if (XFS_IS_UQUOTA_ON(mp) && udqp && if (XFS_IS_UQUOTA_ON(mp) && udqp &&
i_uid_read(VFS_I(ip)) != be32_to_cpu(udqp->q_core.d_id)) { i_uid_read(VFS_I(ip)) != udqp->q_id) {
udq_delblks = udqp; udq_delblks = udqp;
/* /*
* If there are delayed allocation blocks, then we have to * If there are delayed allocation blocks, then we have to
...@@ -1832,7 +1830,7 @@ xfs_qm_vop_chown_reserve( ...@@ -1832,7 +1830,7 @@ xfs_qm_vop_chown_reserve(
} }
} }
if (XFS_IS_GQUOTA_ON(ip->i_mount) && gdqp && if (XFS_IS_GQUOTA_ON(ip->i_mount) && gdqp &&
i_gid_read(VFS_I(ip)) != be32_to_cpu(gdqp->q_core.d_id)) { i_gid_read(VFS_I(ip)) != gdqp->q_id) {
gdq_delblks = gdqp; gdq_delblks = gdqp;
if (delblks) { if (delblks) {
ASSERT(ip->i_gdquot); ASSERT(ip->i_gdquot);
...@@ -1841,7 +1839,7 @@ xfs_qm_vop_chown_reserve( ...@@ -1841,7 +1839,7 @@ xfs_qm_vop_chown_reserve(
} }
if (XFS_IS_PQUOTA_ON(ip->i_mount) && pdqp && if (XFS_IS_PQUOTA_ON(ip->i_mount) && pdqp &&
ip->i_d.di_projid != be32_to_cpu(pdqp->q_core.d_id)) { ip->i_d.di_projid != pdqp->q_id) {
pdq_delblks = pdqp; pdq_delblks = pdqp;
if (delblks) { if (delblks) {
ASSERT(ip->i_pdquot); ASSERT(ip->i_pdquot);
...@@ -1925,21 +1923,21 @@ xfs_qm_vop_create_dqattach( ...@@ -1925,21 +1923,21 @@ xfs_qm_vop_create_dqattach(
if (udqp && XFS_IS_UQUOTA_ON(mp)) { if (udqp && XFS_IS_UQUOTA_ON(mp)) {
ASSERT(ip->i_udquot == NULL); ASSERT(ip->i_udquot == NULL);
ASSERT(i_uid_read(VFS_I(ip)) == be32_to_cpu(udqp->q_core.d_id)); ASSERT(i_uid_read(VFS_I(ip)) == udqp->q_id);
ip->i_udquot = xfs_qm_dqhold(udqp); ip->i_udquot = xfs_qm_dqhold(udqp);
xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1); xfs_trans_mod_dquot(tp, udqp, XFS_TRANS_DQ_ICOUNT, 1);
} }
if (gdqp && XFS_IS_GQUOTA_ON(mp)) { if (gdqp && XFS_IS_GQUOTA_ON(mp)) {
ASSERT(ip->i_gdquot == NULL); ASSERT(ip->i_gdquot == NULL);
ASSERT(i_gid_read(VFS_I(ip)) == be32_to_cpu(gdqp->q_core.d_id)); ASSERT(i_gid_read(VFS_I(ip)) == gdqp->q_id);
ip->i_gdquot = xfs_qm_dqhold(gdqp); ip->i_gdquot = xfs_qm_dqhold(gdqp);
xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1); xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1);
} }
if (pdqp && XFS_IS_PQUOTA_ON(mp)) { if (pdqp && XFS_IS_PQUOTA_ON(mp)) {
ASSERT(ip->i_pdquot == NULL); ASSERT(ip->i_pdquot == NULL);
ASSERT(ip->i_d.di_projid == be32_to_cpu(pdqp->q_core.d_id)); ASSERT(ip->i_d.di_projid == pdqp->q_id);
ip->i_pdquot = xfs_qm_dqhold(pdqp); ip->i_pdquot = xfs_qm_dqhold(pdqp);
xfs_trans_mod_dquot(tp, pdqp, XFS_TRANS_DQ_ICOUNT, 1); xfs_trans_mod_dquot(tp, pdqp, XFS_TRANS_DQ_ICOUNT, 1);
......
...@@ -659,7 +659,7 @@ xfs_qm_scall_getquota_fill_qc( ...@@ -659,7 +659,7 @@ xfs_qm_scall_getquota_fill_qc(
if (((XFS_IS_UQUOTA_ENFORCED(mp) && type == XFS_DQ_USER) || if (((XFS_IS_UQUOTA_ENFORCED(mp) && type == XFS_DQ_USER) ||
(XFS_IS_GQUOTA_ENFORCED(mp) && type == XFS_DQ_GROUP) || (XFS_IS_GQUOTA_ENFORCED(mp) && type == XFS_DQ_GROUP) ||
(XFS_IS_PQUOTA_ENFORCED(mp) && type == XFS_DQ_PROJ)) && (XFS_IS_PQUOTA_ENFORCED(mp) && type == XFS_DQ_PROJ)) &&
dqp->q_core.d_id != 0) { dqp->q_id != 0) {
if ((dst->d_space > dst->d_spc_softlimit) && if ((dst->d_space > dst->d_spc_softlimit) &&
(dst->d_spc_softlimit > 0)) { (dst->d_spc_softlimit > 0)) {
ASSERT(dst->d_spc_timer != 0); ASSERT(dst->d_spc_timer != 0);
...@@ -726,7 +726,7 @@ xfs_qm_scall_getquota_next( ...@@ -726,7 +726,7 @@ xfs_qm_scall_getquota_next(
return error; return error;
/* Fill in the ID we actually read from disk */ /* Fill in the ID we actually read from disk */
*id = be32_to_cpu(dqp->q_core.d_id); *id = dqp->q_id;
xfs_qm_scall_getquota_fill_qc(mp, type, dqp, dst); xfs_qm_scall_getquota_fill_qc(mp, type, dqp, dst);
......
...@@ -876,7 +876,7 @@ DECLARE_EVENT_CLASS(xfs_dquot_class, ...@@ -876,7 +876,7 @@ DECLARE_EVENT_CLASS(xfs_dquot_class,
), \ ), \
TP_fast_assign( TP_fast_assign(
__entry->dev = dqp->q_mount->m_super->s_dev; __entry->dev = dqp->q_mount->m_super->s_dev;
__entry->id = be32_to_cpu(dqp->q_core.d_id); __entry->id = dqp->q_id;
__entry->flags = dqp->dq_flags | dqp->q_flags; __entry->flags = dqp->dq_flags | dqp->q_flags;
__entry->nrefs = dqp->q_nrefs; __entry->nrefs = dqp->q_nrefs;
__entry->res_bcount = dqp->q_res_bcount; __entry->res_bcount = dqp->q_res_bcount;
......
...@@ -386,7 +386,7 @@ xfs_trans_apply_dquot_deltas( ...@@ -386,7 +386,7 @@ xfs_trans_apply_dquot_deltas(
* Get any default limits in use. * Get any default limits in use.
* Start/reset the timer(s) if needed. * Start/reset the timer(s) if needed.
*/ */
if (d->d_id) { if (dqp->q_id) {
xfs_qm_adjust_dqlimits(tp->t_mountp, dqp); xfs_qm_adjust_dqlimits(tp->t_mountp, dqp);
xfs_qm_adjust_dqtimers(tp->t_mountp, dqp); xfs_qm_adjust_dqtimers(tp->t_mountp, dqp);
} }
...@@ -558,8 +558,7 @@ xfs_quota_warn( ...@@ -558,8 +558,7 @@ xfs_quota_warn(
else else
qtype = GRPQUOTA; qtype = GRPQUOTA;
quota_send_warning(make_kqid(&init_user_ns, qtype, quota_send_warning(make_kqid(&init_user_ns, qtype, dqp->q_id),
be32_to_cpu(dqp->q_core.d_id)),
mp->m_super->s_dev, type); mp->m_super->s_dev, type);
} }
...@@ -618,8 +617,7 @@ xfs_trans_dqresv( ...@@ -618,8 +617,7 @@ xfs_trans_dqresv(
resbcountp = &dqp->q_res_rtbcount; resbcountp = &dqp->q_res_rtbcount;
} }
if ((flags & XFS_QMOPT_FORCE_RES) == 0 && if ((flags & XFS_QMOPT_FORCE_RES) == 0 && dqp->q_id &&
dqp->q_core.d_id &&
((XFS_IS_UQUOTA_ENFORCED(dqp->q_mount) && XFS_QM_ISUDQ(dqp)) || ((XFS_IS_UQUOTA_ENFORCED(dqp->q_mount) && XFS_QM_ISUDQ(dqp)) ||
(XFS_IS_GQUOTA_ENFORCED(dqp->q_mount) && XFS_QM_ISGDQ(dqp)) || (XFS_IS_GQUOTA_ENFORCED(dqp->q_mount) && XFS_QM_ISGDQ(dqp)) ||
(XFS_IS_PQUOTA_ENFORCED(dqp->q_mount) && XFS_QM_ISPDQ(dqp)))) { (XFS_IS_PQUOTA_ENFORCED(dqp->q_mount) && XFS_QM_ISPDQ(dqp)))) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment