Skip to content

Commit bf5066e

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: fold xfs_qm_dqattach_one into xfs_qm_dqget_inode
xfs_qm_dqattach_one is a thin wrapper around xfs_qm_dqget_inode. Move the extra asserts into xfs_qm_dqget_inode, drop the unneeded q_qlock roundtrip and merge the two functions. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org>
1 parent d0f93c0 commit bf5066e

2 files changed

Lines changed: 9 additions & 40 deletions

File tree

fs/xfs/xfs_dquot.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ xfs_qm_dqget_inode(
994994
struct xfs_inode *ip,
995995
xfs_dqtype_t type,
996996
bool can_alloc,
997-
struct xfs_dquot **O_dqpp)
997+
struct xfs_dquot **dqpp)
998998
{
999999
struct xfs_mount *mp = ip->i_mount;
10001000
struct xfs_quotainfo *qi = mp->m_quotainfo;
@@ -1003,6 +1003,9 @@ xfs_qm_dqget_inode(
10031003
xfs_dqid_t id;
10041004
int error;
10051005

1006+
ASSERT(!*dqpp);
1007+
xfs_assert_ilocked(ip, XFS_ILOCK_EXCL);
1008+
10061009
error = xfs_qm_dqget_checks(mp, type);
10071010
if (error)
10081011
return error;
@@ -1068,8 +1071,8 @@ xfs_qm_dqget_inode(
10681071
xfs_assert_ilocked(ip, XFS_ILOCK_EXCL);
10691072
trace_xfs_dqget_miss(dqp);
10701073
found:
1071-
*O_dqpp = dqp;
1072-
mutex_lock(&dqp->q_qlock);
1074+
trace_xfs_dqattach_get(dqp);
1075+
*dqpp = dqp;
10731076
return 0;
10741077
}
10751078

fs/xfs/xfs_qm.c

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -287,40 +287,6 @@ xfs_qm_unmount_quotas(
287287
xfs_qm_destroy_quotainos(mp->m_quotainfo);
288288
}
289289

290-
STATIC int
291-
xfs_qm_dqattach_one(
292-
struct xfs_inode *ip,
293-
xfs_dqtype_t type,
294-
bool doalloc,
295-
struct xfs_dquot **IO_idqpp)
296-
{
297-
struct xfs_dquot *dqp;
298-
int error;
299-
300-
ASSERT(!*IO_idqpp);
301-
xfs_assert_ilocked(ip, XFS_ILOCK_EXCL);
302-
303-
/*
304-
* Find the dquot from somewhere. This bumps the reference count of
305-
* dquot and returns it locked. This can return ENOENT if dquot didn't
306-
* exist on disk and we didn't ask it to allocate; ESRCH if quotas got
307-
* turned off suddenly.
308-
*/
309-
error = xfs_qm_dqget_inode(ip, type, doalloc, &dqp);
310-
if (error)
311-
return error;
312-
313-
trace_xfs_dqattach_get(dqp);
314-
315-
/*
316-
* dqget may have dropped and re-acquired the ilock, but it guarantees
317-
* that the dquot returned is the one that should go in the inode.
318-
*/
319-
*IO_idqpp = dqp;
320-
mutex_unlock(&dqp->q_qlock);
321-
return 0;
322-
}
323-
324290
static bool
325291
xfs_qm_need_dqattach(
326292
struct xfs_inode *ip)
@@ -360,23 +326,23 @@ xfs_qm_dqattach_locked(
360326
ASSERT(!xfs_is_metadir_inode(ip));
361327

362328
if (XFS_IS_UQUOTA_ON(mp) && !ip->i_udquot) {
363-
error = xfs_qm_dqattach_one(ip, XFS_DQTYPE_USER,
329+
error = xfs_qm_dqget_inode(ip, XFS_DQTYPE_USER,
364330
doalloc, &ip->i_udquot);
365331
if (error)
366332
goto done;
367333
ASSERT(ip->i_udquot);
368334
}
369335

370336
if (XFS_IS_GQUOTA_ON(mp) && !ip->i_gdquot) {
371-
error = xfs_qm_dqattach_one(ip, XFS_DQTYPE_GROUP,
337+
error = xfs_qm_dqget_inode(ip, XFS_DQTYPE_GROUP,
372338
doalloc, &ip->i_gdquot);
373339
if (error)
374340
goto done;
375341
ASSERT(ip->i_gdquot);
376342
}
377343

378344
if (XFS_IS_PQUOTA_ON(mp) && !ip->i_pdquot) {
379-
error = xfs_qm_dqattach_one(ip, XFS_DQTYPE_PROJ,
345+
error = xfs_qm_dqget_inode(ip, XFS_DQTYPE_PROJ,
380346
doalloc, &ip->i_pdquot);
381347
if (error)
382348
goto done;

0 commit comments

Comments
 (0)