提交 97e7ade5 编写于 作者: C Christoph Hellwig 提交者: Ben Myers

xfs: kill xfs_qm_idtodq

This function doesn't help the code flow, so merge the dquot allocation and
transaction handling into xfs_qm_dqread.
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NDave Chinner <dchinner@redhat.com>
Signed-off-by: NBen Myers <bpm@sgi.com>
上级 49d35a5c
...@@ -550,36 +550,62 @@ xfs_qm_dqtobp( ...@@ -550,36 +550,62 @@ xfs_qm_dqtobp(
* Read in the ondisk dquot using dqtobp() then copy it to an incore version, * Read in the ondisk dquot using dqtobp() then copy it to an incore version,
* and release the buffer immediately. * and release the buffer immediately.
* *
* If XFS_QMOPT_DQALLOC is set, allocate a dquot on disk if it needed.
*/ */
/* ARGSUSED */
STATIC int STATIC int
xfs_qm_dqread( xfs_qm_dqread(
xfs_trans_t **tpp, struct xfs_mount *mp,
xfs_dqid_t id, xfs_dqid_t id,
xfs_dquot_t *dqp, /* dquot to get filled in */ uint type,
uint flags) uint flags,
struct xfs_dquot **O_dqpp)
{ {
xfs_disk_dquot_t *ddqp; struct xfs_dquot *dqp;
xfs_buf_t *bp; struct xfs_disk_dquot *ddqp;
int error; struct xfs_buf *bp;
xfs_trans_t *tp; struct xfs_trans *tp = NULL;
int error;
int cancelflags = 0;
ASSERT(tpp); dqp = xfs_qm_dqinit(mp, id, type);
trace_xfs_dqread(dqp); trace_xfs_dqread(dqp);
if (flags & XFS_QMOPT_DQALLOC) {
tp = xfs_trans_alloc(mp, XFS_TRANS_QM_DQALLOC);
error = xfs_trans_reserve(tp, XFS_QM_DQALLOC_SPACE_RES(mp),
XFS_WRITE_LOG_RES(mp) +
/*
* Round the chunklen up to the next multiple
* of 128 (buf log item chunk size)).
*/
BBTOB(mp->m_quotainfo->qi_dqchunklen) - 1 + 128,
0,
XFS_TRANS_PERM_LOG_RES,
XFS_WRITE_LOG_COUNT);
if (error)
goto error1;
cancelflags = XFS_TRANS_RELEASE_LOG_RES;
}
/* /*
* get a pointer to the on-disk dquot and the buffer containing it * get a pointer to the on-disk dquot and the buffer containing it
* dqp already knows its own type (GROUP/USER). * dqp already knows its own type (GROUP/USER).
*/ */
if ((error = xfs_qm_dqtobp(tpp, dqp, &ddqp, &bp, flags))) { error = xfs_qm_dqtobp(&tp, dqp, &ddqp, &bp, flags);
return (error); if (error) {
/*
* This can happen if quotas got turned off (ESRCH),
* or if the dquot didn't exist on disk and we ask to
* allocate (ENOENT).
*/
trace_xfs_dqread_fail(dqp);
cancelflags |= XFS_TRANS_ABORT;
goto error1;
} }
tp = *tpp;
/* copy everything from disk dquot to the incore dquot */ /* copy everything from disk dquot to the incore dquot */
memcpy(&dqp->q_core, ddqp, sizeof(xfs_disk_dquot_t)); memcpy(&dqp->q_core, ddqp, sizeof(xfs_disk_dquot_t));
ASSERT(be32_to_cpu(dqp->q_core.d_id) == id);
xfs_qm_dquot_logitem_init(dqp); xfs_qm_dquot_logitem_init(dqp);
/* /*
...@@ -608,77 +634,22 @@ xfs_qm_dqread( ...@@ -608,77 +634,22 @@ xfs_qm_dqread(
ASSERT(xfs_buf_islocked(bp)); ASSERT(xfs_buf_islocked(bp));
xfs_trans_brelse(tp, bp); xfs_trans_brelse(tp, bp);
return (error);
}
/*
* allocate an incore dquot from the kernel heap,
* and fill its core with quota information kept on disk.
* If XFS_QMOPT_DQALLOC is set, it'll allocate a dquot on disk
* if it wasn't already allocated.
*/
STATIC int
xfs_qm_idtodq(
xfs_mount_t *mp,
xfs_dqid_t id, /* gid or uid, depending on type */
uint type, /* UDQUOT or GDQUOT */
uint flags, /* DQALLOC, DQREPAIR */
xfs_dquot_t **O_dqpp)/* OUT : incore dquot, not locked */
{
xfs_dquot_t *dqp;
int error;
xfs_trans_t *tp;
int cancelflags=0;
dqp = xfs_qm_dqinit(mp, id, type);
tp = NULL;
if (flags & XFS_QMOPT_DQALLOC) {
tp = xfs_trans_alloc(mp, XFS_TRANS_QM_DQALLOC);
error = xfs_trans_reserve(tp, XFS_QM_DQALLOC_SPACE_RES(mp),
XFS_WRITE_LOG_RES(mp) +
BBTOB(mp->m_quotainfo->qi_dqchunklen) - 1 +
128,
0,
XFS_TRANS_PERM_LOG_RES,
XFS_WRITE_LOG_COUNT);
if (error) {
cancelflags = 0;
goto error0;
}
cancelflags = XFS_TRANS_RELEASE_LOG_RES;
}
/*
* Read it from disk; xfs_dqread() takes care of
* all the necessary initialization of dquot's fields (locks, etc)
*/
if ((error = xfs_qm_dqread(&tp, id, dqp, flags))) {
/*
* This can happen if quotas got turned off (ESRCH),
* or if the dquot didn't exist on disk and we ask to
* allocate (ENOENT).
*/
trace_xfs_dqread_fail(dqp);
cancelflags |= XFS_TRANS_ABORT;
goto error0;
}
if (tp) { if (tp) {
if ((error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES))) error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES);
goto error1; if (error)
goto error0;
} }
*O_dqpp = dqp; *O_dqpp = dqp;
return (0); return error;
error0: error1:
ASSERT(error);
if (tp) if (tp)
xfs_trans_cancel(tp, cancelflags); xfs_trans_cancel(tp, cancelflags);
error1: error0:
xfs_qm_dqdestroy(dqp); xfs_qm_dqdestroy(dqp);
*O_dqpp = NULL; *O_dqpp = NULL;
return (error); return error;
} }
/* /*
...@@ -832,19 +803,11 @@ xfs_qm_dqget( ...@@ -832,19 +803,11 @@ xfs_qm_dqget(
version = h->qh_version; version = h->qh_version;
mutex_unlock(&h->qh_lock); mutex_unlock(&h->qh_lock);
/* error = xfs_qm_dqread(mp, id, type, flags, &dqp);
* Allocate the dquot on the kernel heap, and read the ondisk if (error) {
* portion off the disk. Also, do all the necessary initialization
* This can return ENOENT if dquot didn't exist on disk and we didn't
* ask it to allocate; ESRCH if quotas got turned off suddenly.
*/
if ((error = xfs_qm_idtodq(mp, id, type,
flags & (XFS_QMOPT_DQALLOC|XFS_QMOPT_DQREPAIR|
XFS_QMOPT_DOWARN),
&dqp))) {
if (ip) if (ip)
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
return (error); return error;
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册