Skip to content

Commit 8bfadd8

Browse files
Christoph Hellwigdjwong
Christoph Hellwig
authored andcommitted
xfs: replace xfs_qm_get_rtblks with a direct call to xfs_bmap_count_leaves
Use the existing functionality instead of directly poking into the extent list. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent e17a5c6 commit 8bfadd8

File tree

1 file changed

+12
-32
lines changed

1 file changed

+12
-32
lines changed

fs/xfs/xfs_qm.c

+12-32
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "xfs_error.h"
3232
#include "xfs_bmap.h"
3333
#include "xfs_bmap_btree.h"
34+
#include "xfs_bmap_util.h"
3435
#include "xfs_trans.h"
3536
#include "xfs_trans_space.h"
3637
#include "xfs_qm.h"
@@ -1120,31 +1121,6 @@ xfs_qm_quotacheck_dqadjust(
11201121
return 0;
11211122
}
11221123

1123-
STATIC int
1124-
xfs_qm_get_rtblks(
1125-
xfs_inode_t *ip,
1126-
xfs_qcnt_t *O_rtblks)
1127-
{
1128-
xfs_filblks_t rtblks; /* total rt blks */
1129-
xfs_extnum_t idx; /* extent record index */
1130-
xfs_ifork_t *ifp; /* inode fork pointer */
1131-
xfs_extnum_t nextents; /* number of extent entries */
1132-
int error;
1133-
1134-
ASSERT(XFS_IS_REALTIME_INODE(ip));
1135-
ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
1136-
if (!(ifp->if_flags & XFS_IFEXTENTS)) {
1137-
if ((error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK)))
1138-
return error;
1139-
}
1140-
rtblks = 0;
1141-
nextents = xfs_iext_count(ifp);
1142-
for (idx = 0; idx < nextents; idx++)
1143-
rtblks += xfs_bmbt_get_blockcount(xfs_iext_get_ext(ifp, idx));
1144-
*O_rtblks = (xfs_qcnt_t)rtblks;
1145-
return 0;
1146-
}
1147-
11481124
/*
11491125
* callback routine supplied to bulkstat(). Given an inumber, find its
11501126
* dquots and update them to account for resources taken by that inode.
@@ -1160,7 +1136,8 @@ xfs_qm_dqusage_adjust(
11601136
int *res) /* result code value */
11611137
{
11621138
xfs_inode_t *ip;
1163-
xfs_qcnt_t nblks, rtblks = 0;
1139+
xfs_qcnt_t nblks;
1140+
xfs_filblks_t rtblks = 0; /* total rt blks */
11641141
int error;
11651142

11661143
ASSERT(XFS_IS_QUOTA_RUNNING(mp));
@@ -1190,12 +1167,15 @@ xfs_qm_dqusage_adjust(
11901167
ASSERT(ip->i_delayed_blks == 0);
11911168

11921169
if (XFS_IS_REALTIME_INODE(ip)) {
1193-
/*
1194-
* Walk thru the extent list and count the realtime blocks.
1195-
*/
1196-
error = xfs_qm_get_rtblks(ip, &rtblks);
1197-
if (error)
1198-
goto error0;
1170+
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
1171+
1172+
if (!(ifp->if_flags & XFS_IFEXTENTS)) {
1173+
error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK);
1174+
if (error)
1175+
goto error0;
1176+
}
1177+
1178+
xfs_bmap_count_leaves(ifp, &rtblks);
11991179
}
12001180

12011181
nblks = (xfs_qcnt_t)ip->i_d.di_nblocks - rtblks;

0 commit comments

Comments
 (0)