xfs: refactor incore dquot initialization functions
Create two incore dquot initialization functions that will help us to disentangle dqget and dqread. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
0fcef1270f
commit
617cd5c12c
@ -499,26 +499,14 @@ xfs_qm_dqtobp(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Allocate and initialize everything we need for an incore dquot. */
|
||||||
/*
|
STATIC struct xfs_dquot *
|
||||||
* Read in the ondisk dquot using dqtobp() then copy it to an incore version,
|
xfs_dquot_alloc(
|
||||||
* and release the buffer immediately.
|
|
||||||
*
|
|
||||||
* If XFS_QMOPT_DQALLOC is set, allocate a dquot on disk if it needed.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
xfs_qm_dqread(
|
|
||||||
struct xfs_mount *mp,
|
struct xfs_mount *mp,
|
||||||
xfs_dqid_t id,
|
xfs_dqid_t id,
|
||||||
uint type,
|
uint type)
|
||||||
uint flags,
|
|
||||||
struct xfs_dquot **O_dqpp)
|
|
||||||
{
|
{
|
||||||
struct xfs_dquot *dqp;
|
struct xfs_dquot *dqp;
|
||||||
struct xfs_disk_dquot *ddqp;
|
|
||||||
struct xfs_buf *bp;
|
|
||||||
struct xfs_trans *tp = NULL;
|
|
||||||
int error;
|
|
||||||
|
|
||||||
dqp = kmem_zone_zalloc(xfs_qm_dqzone, KM_SLEEP);
|
dqp = kmem_zone_zalloc(xfs_qm_dqzone, KM_SLEEP);
|
||||||
|
|
||||||
@ -556,8 +544,54 @@ xfs_qm_dqread(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
XFS_STATS_INC(mp, xs_qm_dquot);
|
xfs_qm_dquot_logitem_init(dqp);
|
||||||
|
|
||||||
|
XFS_STATS_INC(mp, xs_qm_dquot);
|
||||||
|
return dqp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Copy the in-core quota fields in from the on-disk buffer. */
|
||||||
|
STATIC void
|
||||||
|
xfs_dquot_from_disk(
|
||||||
|
struct xfs_dquot *dqp,
|
||||||
|
struct xfs_disk_dquot *ddqp)
|
||||||
|
{
|
||||||
|
/* copy everything from disk dquot to the incore dquot */
|
||||||
|
memcpy(&dqp->q_core, ddqp, sizeof(xfs_disk_dquot_t));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reservation counters are defined as reservation plus current usage
|
||||||
|
* to avoid having to add every time.
|
||||||
|
*/
|
||||||
|
dqp->q_res_bcount = be64_to_cpu(ddqp->d_bcount);
|
||||||
|
dqp->q_res_icount = be64_to_cpu(ddqp->d_icount);
|
||||||
|
dqp->q_res_rtbcount = be64_to_cpu(ddqp->d_rtbcount);
|
||||||
|
|
||||||
|
/* initialize the dquot speculative prealloc thresholds */
|
||||||
|
xfs_dquot_set_prealloc_limits(dqp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Read in the ondisk dquot using dqtobp() then copy it to an incore version,
|
||||||
|
* and release the buffer immediately.
|
||||||
|
*
|
||||||
|
* If XFS_QMOPT_DQALLOC is set, allocate a dquot on disk if it needed.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
xfs_qm_dqread(
|
||||||
|
struct xfs_mount *mp,
|
||||||
|
xfs_dqid_t id,
|
||||||
|
uint type,
|
||||||
|
uint flags,
|
||||||
|
struct xfs_dquot **O_dqpp)
|
||||||
|
{
|
||||||
|
struct xfs_dquot *dqp;
|
||||||
|
struct xfs_disk_dquot *ddqp;
|
||||||
|
struct xfs_buf *bp;
|
||||||
|
struct xfs_trans *tp = NULL;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
dqp = xfs_dquot_alloc(mp, id, type);
|
||||||
trace_xfs_dqread(dqp);
|
trace_xfs_dqread(dqp);
|
||||||
|
|
||||||
if (flags & XFS_QMOPT_DQALLOC) {
|
if (flags & XFS_QMOPT_DQALLOC) {
|
||||||
@ -582,20 +616,7 @@ xfs_qm_dqread(
|
|||||||
goto error1;
|
goto error1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy everything from disk dquot to the incore dquot */
|
xfs_dquot_from_disk(dqp, ddqp);
|
||||||
memcpy(&dqp->q_core, ddqp, sizeof(xfs_disk_dquot_t));
|
|
||||||
xfs_qm_dquot_logitem_init(dqp);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Reservation counters are defined as reservation plus current usage
|
|
||||||
* to avoid having to add every time.
|
|
||||||
*/
|
|
||||||
dqp->q_res_bcount = be64_to_cpu(ddqp->d_bcount);
|
|
||||||
dqp->q_res_icount = be64_to_cpu(ddqp->d_icount);
|
|
||||||
dqp->q_res_rtbcount = be64_to_cpu(ddqp->d_rtbcount);
|
|
||||||
|
|
||||||
/* initialize the dquot speculative prealloc thresholds */
|
|
||||||
xfs_dquot_set_prealloc_limits(dqp);
|
|
||||||
|
|
||||||
/* Mark the buf so that this will stay incore a little longer */
|
/* Mark the buf so that this will stay incore a little longer */
|
||||||
xfs_buf_set_ref(bp, XFS_DQUOT_REF);
|
xfs_buf_set_ref(bp, XFS_DQUOT_REF);
|
||||||
|
Loading…
Reference in New Issue
Block a user