mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-08 14:13:53 +00:00
xfs: fetch dquots directly during quotacheck
Quotacheck only runs during mount, which means that there are no other processes in the system that could be doing chown or chproj. Therefore there's no potential for racing to attach dquots to the inode so we can drop all the ILOCK and race detection bits from quotacheck. 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
4882c19d2a
commit
0fcef1270f
@ -1056,16 +1056,17 @@ xfs_qm_dqiterate(
|
|||||||
STATIC int
|
STATIC int
|
||||||
xfs_qm_quotacheck_dqadjust(
|
xfs_qm_quotacheck_dqadjust(
|
||||||
struct xfs_inode *ip,
|
struct xfs_inode *ip,
|
||||||
xfs_dqid_t id,
|
|
||||||
uint type,
|
uint type,
|
||||||
xfs_qcnt_t nblks,
|
xfs_qcnt_t nblks,
|
||||||
xfs_qcnt_t rtblks)
|
xfs_qcnt_t rtblks)
|
||||||
{
|
{
|
||||||
struct xfs_mount *mp = ip->i_mount;
|
struct xfs_mount *mp = ip->i_mount;
|
||||||
struct xfs_dquot *dqp;
|
struct xfs_dquot *dqp;
|
||||||
|
xfs_dqid_t id;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = xfs_qm_dqget_inode(ip, type, true, &dqp);
|
id = xfs_qm_id_for_quotatype(ip, type);
|
||||||
|
error = xfs_qm_dqget(mp, id, type, XFS_QMOPT_DQALLOC, &dqp);
|
||||||
if (error) {
|
if (error) {
|
||||||
/*
|
/*
|
||||||
* Shouldn't be able to turn off quotas here.
|
* Shouldn't be able to turn off quotas here.
|
||||||
@ -1138,13 +1139,10 @@ xfs_qm_dqusage_adjust(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We don't _need_ to take the ilock EXCL. However, the xfs_qm_dqget
|
* We don't _need_ to take the ilock EXCL here because quotacheck runs
|
||||||
* interface expects the inode to be exclusively locked because that's
|
* at mount time and therefore nobody will be racing chown/chproj.
|
||||||
* the case in all other instances. It's OK that we do this because
|
|
||||||
* quotacheck is done only at mount time.
|
|
||||||
*/
|
*/
|
||||||
error = xfs_iget(mp, NULL, ino, XFS_IGET_DONTCACHE, XFS_ILOCK_EXCL,
|
error = xfs_iget(mp, NULL, ino, XFS_IGET_DONTCACHE, 0, &ip);
|
||||||
&ip);
|
|
||||||
if (error) {
|
if (error) {
|
||||||
*res = BULKSTAT_RV_NOTHING;
|
*res = BULKSTAT_RV_NOTHING;
|
||||||
return error;
|
return error;
|
||||||
@ -1179,33 +1177,31 @@ xfs_qm_dqusage_adjust(
|
|||||||
* and quotaoffs don't race. (Quotachecks happen at mount time only).
|
* and quotaoffs don't race. (Quotachecks happen at mount time only).
|
||||||
*/
|
*/
|
||||||
if (XFS_IS_UQUOTA_ON(mp)) {
|
if (XFS_IS_UQUOTA_ON(mp)) {
|
||||||
error = xfs_qm_quotacheck_dqadjust(ip, ip->i_d.di_uid,
|
error = xfs_qm_quotacheck_dqadjust(ip, XFS_DQ_USER, nblks,
|
||||||
XFS_DQ_USER, nblks, rtblks);
|
rtblks);
|
||||||
if (error)
|
if (error)
|
||||||
goto error0;
|
goto error0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (XFS_IS_GQUOTA_ON(mp)) {
|
if (XFS_IS_GQUOTA_ON(mp)) {
|
||||||
error = xfs_qm_quotacheck_dqadjust(ip, ip->i_d.di_gid,
|
error = xfs_qm_quotacheck_dqadjust(ip, XFS_DQ_GROUP, nblks,
|
||||||
XFS_DQ_GROUP, nblks, rtblks);
|
rtblks);
|
||||||
if (error)
|
if (error)
|
||||||
goto error0;
|
goto error0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (XFS_IS_PQUOTA_ON(mp)) {
|
if (XFS_IS_PQUOTA_ON(mp)) {
|
||||||
error = xfs_qm_quotacheck_dqadjust(ip, xfs_get_projid(ip),
|
error = xfs_qm_quotacheck_dqadjust(ip, XFS_DQ_PROJ, nblks,
|
||||||
XFS_DQ_PROJ, nblks, rtblks);
|
rtblks);
|
||||||
if (error)
|
if (error)
|
||||||
goto error0;
|
goto error0;
|
||||||
}
|
}
|
||||||
|
|
||||||
xfs_iunlock(ip, XFS_ILOCK_EXCL);
|
|
||||||
IRELE(ip);
|
IRELE(ip);
|
||||||
*res = BULKSTAT_RV_DIDONE;
|
*res = BULKSTAT_RV_DIDONE;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error0:
|
error0:
|
||||||
xfs_iunlock(ip, XFS_ILOCK_EXCL);
|
|
||||||
IRELE(ip);
|
IRELE(ip);
|
||||||
*res = BULKSTAT_RV_GIVEUP;
|
*res = BULKSTAT_RV_GIVEUP;
|
||||||
return error;
|
return error;
|
||||||
|
Loading…
Reference in New Issue
Block a user