Commit 30ab2dcf authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: replace XFS_QMOPT_DQALLOC with a simple boolean

DQALLOC is only ever used with xfs_qm_dqget*, and the only flag that the
_dqget family of functions cares about is DQALLOC.  Therefore, change
it to a boolean 'can alloc?' flag for the dqget interfaces where that
makes sense.
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
parent 114e73cc
...@@ -107,7 +107,6 @@ typedef uint16_t xfs_qwarncnt_t; ...@@ -107,7 +107,6 @@ typedef uint16_t xfs_qwarncnt_t;
* to a single function. None of these XFS_QMOPT_* flags are meant to have * to a single function. None of these XFS_QMOPT_* flags are meant to have
* persistent values (ie. their values can and will change between versions) * persistent values (ie. their values can and will change between versions)
*/ */
#define XFS_QMOPT_DQALLOC 0x0000002 /* alloc dquot ondisk if needed */
#define XFS_QMOPT_UQUOTA 0x0000004 /* user dquot requested */ #define XFS_QMOPT_UQUOTA 0x0000004 /* user dquot requested */
#define XFS_QMOPT_PQUOTA 0x0000008 /* project dquot requested */ #define XFS_QMOPT_PQUOTA 0x0000008 /* project dquot requested */
#define XFS_QMOPT_FORCE_RES 0x0000010 /* ignore quota limits */ #define XFS_QMOPT_FORCE_RES 0x0000010 /* ignore quota limits */
......
...@@ -582,16 +582,15 @@ xfs_qm_dqread_alloc( ...@@ -582,16 +582,15 @@ xfs_qm_dqread_alloc(
/* /*
* 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 @can_alloc is true, fill any
* * holes in the on-disk metadata.
* If XFS_QMOPT_DQALLOC is set, allocate a dquot on disk if it needed.
*/ */
static int static int
xfs_qm_dqread( 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, bool can_alloc,
struct xfs_dquot **dqpp) struct xfs_dquot **dqpp)
{ {
struct xfs_dquot *dqp; struct xfs_dquot *dqp;
...@@ -603,7 +602,7 @@ xfs_qm_dqread( ...@@ -603,7 +602,7 @@ xfs_qm_dqread(
/* Try to read the buffer, allocating if necessary. */ /* Try to read the buffer, allocating if necessary. */
error = xfs_dquot_disk_read(mp, dqp, &bp); error = xfs_dquot_disk_read(mp, dqp, &bp);
if (error == -ENOENT && (flags & XFS_QMOPT_DQALLOC)) if (error == -ENOENT && can_alloc)
error = xfs_qm_dqread_alloc(mp, dqp, &bp); error = xfs_qm_dqread_alloc(mp, dqp, &bp);
if (error) if (error)
goto err; goto err;
...@@ -793,7 +792,7 @@ xfs_qm_dqget( ...@@ -793,7 +792,7 @@ xfs_qm_dqget(
struct xfs_mount *mp, struct xfs_mount *mp,
xfs_dqid_t id, xfs_dqid_t id,
uint type, uint type,
uint flags, /* DQALLOC, DQSUSER, DQREPAIR, DOWARN */ bool can_alloc,
struct xfs_dquot **O_dqpp) struct xfs_dquot **O_dqpp)
{ {
struct xfs_quotainfo *qi = mp->m_quotainfo; struct xfs_quotainfo *qi = mp->m_quotainfo;
...@@ -812,7 +811,7 @@ xfs_qm_dqget( ...@@ -812,7 +811,7 @@ xfs_qm_dqget(
return 0; return 0;
} }
error = xfs_qm_dqread(mp, id, type, flags, &dqp); error = xfs_qm_dqread(mp, id, type, can_alloc, &dqp);
if (error) if (error)
return error; return error;
...@@ -889,16 +888,12 @@ xfs_qm_dqget_inode( ...@@ -889,16 +888,12 @@ xfs_qm_dqget_inode(
struct radix_tree_root *tree = xfs_dquot_tree(qi, type); struct radix_tree_root *tree = xfs_dquot_tree(qi, type);
struct xfs_dquot *dqp; struct xfs_dquot *dqp;
xfs_dqid_t id; xfs_dqid_t id;
uint flags = 0;
int error; int error;
error = xfs_qm_dqget_checks(mp, type); error = xfs_qm_dqget_checks(mp, type);
if (error) if (error)
return error; return error;
if (can_alloc)
flags |= XFS_QMOPT_DQALLOC;
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
ASSERT(xfs_inode_dquot(ip, type) == NULL); ASSERT(xfs_inode_dquot(ip, type) == NULL);
...@@ -919,7 +914,7 @@ xfs_qm_dqget_inode( ...@@ -919,7 +914,7 @@ xfs_qm_dqget_inode(
* we re-acquire the lock. * we re-acquire the lock.
*/ */
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
error = xfs_qm_dqread(mp, id, type, flags, &dqp); error = xfs_qm_dqread(mp, id, type, can_alloc, &dqp);
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
if (error) if (error)
return error; return error;
...@@ -978,7 +973,7 @@ xfs_qm_dqget_next( ...@@ -978,7 +973,7 @@ xfs_qm_dqget_next(
*dqpp = NULL; *dqpp = NULL;
for (; !error; error = xfs_dq_get_next_id(mp, type, &id)) { for (; !error; error = xfs_dq_get_next_id(mp, type, &id)) {
error = xfs_qm_dqget(mp, id, type, 0, &dqp); error = xfs_qm_dqget(mp, id, type, false, &dqp);
if (error == -ENOENT) if (error == -ENOENT)
continue; continue;
else if (error != 0) else if (error != 0)
......
...@@ -170,7 +170,7 @@ extern void xfs_qm_adjust_dqlimits(struct xfs_mount *, ...@@ -170,7 +170,7 @@ extern void xfs_qm_adjust_dqlimits(struct xfs_mount *,
extern xfs_dqid_t xfs_qm_id_for_quotatype(struct xfs_inode *ip, extern xfs_dqid_t xfs_qm_id_for_quotatype(struct xfs_inode *ip,
uint type); uint type);
extern int xfs_qm_dqget(struct xfs_mount *mp, xfs_dqid_t id, extern int xfs_qm_dqget(struct xfs_mount *mp, xfs_dqid_t id,
uint type, uint flags, uint type, bool can_alloc,
struct xfs_dquot **dqpp); struct xfs_dquot **dqpp);
extern int xfs_qm_dqget_inode(struct xfs_inode *ip, uint type, extern int xfs_qm_dqget_inode(struct xfs_inode *ip, uint type,
bool can_alloc, bool can_alloc,
......
...@@ -323,7 +323,7 @@ xfs_qm_need_dqattach( ...@@ -323,7 +323,7 @@ xfs_qm_need_dqattach(
/* /*
* Given a locked inode, attach dquot(s) to it, taking U/G/P-QUOTAON * Given a locked inode, attach dquot(s) to it, taking U/G/P-QUOTAON
* into account. * into account.
* If XFS_QMOPT_DQALLOC, the dquot(s) will be allocated if needed. * If @doalloc is true, the dquot(s) will be allocated if needed.
* Inode may get unlocked and relocked in here, and the caller must deal with * Inode may get unlocked and relocked in here, and the caller must deal with
* the consequences. * the consequences.
*/ */
...@@ -1067,7 +1067,7 @@ xfs_qm_quotacheck_dqadjust( ...@@ -1067,7 +1067,7 @@ xfs_qm_quotacheck_dqadjust(
int error; int error;
id = xfs_qm_id_for_quotatype(ip, type); id = xfs_qm_id_for_quotatype(ip, type);
error = xfs_qm_dqget(mp, id, type, XFS_QMOPT_DQALLOC, &dqp); error = xfs_qm_dqget(mp, id, type, true, &dqp);
if (error) { if (error) {
/* /*
* Shouldn't be able to turn off quotas here. * Shouldn't be able to turn off quotas here.
...@@ -1680,8 +1680,7 @@ xfs_qm_vop_dqalloc( ...@@ -1680,8 +1680,7 @@ xfs_qm_vop_dqalloc(
* holding ilock. * holding ilock.
*/ */
xfs_iunlock(ip, lockflags); xfs_iunlock(ip, lockflags);
error = xfs_qm_dqget(mp, uid, XFS_DQ_USER, error = xfs_qm_dqget(mp, uid, XFS_DQ_USER, true, &uq);
XFS_QMOPT_DQALLOC, &uq);
if (error) { if (error) {
ASSERT(error != -ENOENT); ASSERT(error != -ENOENT);
return error; return error;
...@@ -1704,8 +1703,7 @@ xfs_qm_vop_dqalloc( ...@@ -1704,8 +1703,7 @@ xfs_qm_vop_dqalloc(
if ((flags & XFS_QMOPT_GQUOTA) && XFS_IS_GQUOTA_ON(mp)) { if ((flags & XFS_QMOPT_GQUOTA) && XFS_IS_GQUOTA_ON(mp)) {
if (ip->i_d.di_gid != gid) { if (ip->i_d.di_gid != gid) {
xfs_iunlock(ip, lockflags); xfs_iunlock(ip, lockflags);
error = xfs_qm_dqget(mp, gid, XFS_DQ_GROUP, error = xfs_qm_dqget(mp, gid, XFS_DQ_GROUP, true, &gq);
XFS_QMOPT_DQALLOC, &gq);
if (error) { if (error) {
ASSERT(error != -ENOENT); ASSERT(error != -ENOENT);
goto error_rele; goto error_rele;
...@@ -1722,7 +1720,7 @@ xfs_qm_vop_dqalloc( ...@@ -1722,7 +1720,7 @@ xfs_qm_vop_dqalloc(
if (xfs_get_projid(ip) != prid) { if (xfs_get_projid(ip) != prid) {
xfs_iunlock(ip, lockflags); xfs_iunlock(ip, lockflags);
error = xfs_qm_dqget(mp, (xfs_dqid_t)prid, XFS_DQ_PROJ, error = xfs_qm_dqget(mp, (xfs_dqid_t)prid, XFS_DQ_PROJ,
XFS_QMOPT_DQALLOC, &pq); true, &pq);
if (error) { if (error) {
ASSERT(error != -ENOENT); ASSERT(error != -ENOENT);
goto error_rele; goto error_rele;
......
...@@ -72,7 +72,7 @@ xfs_qm_statvfs( ...@@ -72,7 +72,7 @@ xfs_qm_statvfs(
xfs_mount_t *mp = ip->i_mount; xfs_mount_t *mp = ip->i_mount;
xfs_dquot_t *dqp; xfs_dquot_t *dqp;
if (!xfs_qm_dqget(mp, xfs_get_projid(ip), XFS_DQ_PROJ, 0, &dqp)) { if (!xfs_qm_dqget(mp, xfs_get_projid(ip), XFS_DQ_PROJ, false, &dqp)) {
xfs_fill_statvfs_from_dquot(statp, dqp); xfs_fill_statvfs_from_dquot(statp, dqp);
xfs_qm_dqput(dqp); xfs_qm_dqput(dqp);
} }
......
...@@ -425,7 +425,7 @@ xfs_qm_scall_setqlim( ...@@ -425,7 +425,7 @@ xfs_qm_scall_setqlim(
* a reference to the dquot, so it's safe to do this unlock/lock without * a reference to the dquot, so it's safe to do this unlock/lock without
* it being reclaimed in the mean time. * it being reclaimed in the mean time.
*/ */
error = xfs_qm_dqget(mp, id, type, XFS_QMOPT_DQALLOC, &dqp); error = xfs_qm_dqget(mp, id, type, true, &dqp);
if (error) { if (error) {
ASSERT(error != -ENOENT); ASSERT(error != -ENOENT);
goto out_unlock; goto out_unlock;
...@@ -696,11 +696,10 @@ xfs_qm_scall_getquota( ...@@ -696,11 +696,10 @@ xfs_qm_scall_getquota(
int error; int error;
/* /*
* Try to get the dquot. We don't want it allocated on disk, so * Try to get the dquot. We don't want it allocated on disk, so don't
* we aren't passing the XFS_QMOPT_DOALLOC flag. If it doesn't * set doalloc. If it doesn't exist, we'll get ENOENT back.
* exist, we'll get ENOENT back.
*/ */
error = xfs_qm_dqget(mp, id, type, 0, &dqp); error = xfs_qm_dqget(mp, id, type, false, &dqp);
if (error) if (error)
return error; return error;
......
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