mirror of https://gitee.com/openkylin/linux.git
xfs: rewrite xfs_dq_get_next_id using xfs_iext_lookup_extent
This goes straight to a single lookup in the extent list and avoids a roundtrip through two layers that don't add any value for the simple quoata file that just has data or holes and no page cache, delayed allocation, unwritten extent or COW fork (which btw, doesn't seem to be handled by the existing SEEK HOLE/DATA code). Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
This commit is contained in:
parent
d04c241c66
commit
bda250dbaf
|
@ -701,21 +701,18 @@ xfs_qm_dqread(
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
xfs_dq_get_next_id(
|
xfs_dq_get_next_id(
|
||||||
xfs_mount_t *mp,
|
struct xfs_mount *mp,
|
||||||
uint type,
|
uint type,
|
||||||
xfs_dqid_t *id,
|
xfs_dqid_t *id)
|
||||||
loff_t eof)
|
|
||||||
{
|
{
|
||||||
struct xfs_inode *quotip;
|
struct xfs_inode *quotip = xfs_quota_inode(mp, type);
|
||||||
|
xfs_dqid_t next_id = *id + 1; /* simple advance */
|
||||||
|
uint lock_flags;
|
||||||
|
struct xfs_bmbt_irec got;
|
||||||
|
xfs_extnum_t idx;
|
||||||
xfs_fsblock_t start;
|
xfs_fsblock_t start;
|
||||||
loff_t offset;
|
|
||||||
uint lock;
|
|
||||||
xfs_dqid_t next_id;
|
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
/* Simple advance */
|
|
||||||
next_id = *id + 1;
|
|
||||||
|
|
||||||
/* If we'd wrap past the max ID, stop */
|
/* If we'd wrap past the max ID, stop */
|
||||||
if (next_id < *id)
|
if (next_id < *id)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
@ -729,23 +726,20 @@ xfs_dq_get_next_id(
|
||||||
/* Nope, next_id is now past the current chunk, so find the next one */
|
/* Nope, next_id is now past the current chunk, so find the next one */
|
||||||
start = (xfs_fsblock_t)next_id / mp->m_quotainfo->qi_dqperchunk;
|
start = (xfs_fsblock_t)next_id / mp->m_quotainfo->qi_dqperchunk;
|
||||||
|
|
||||||
quotip = xfs_quota_inode(mp, type);
|
lock_flags = xfs_ilock_data_map_shared(quotip);
|
||||||
lock = xfs_ilock_data_map_shared(quotip);
|
if (!(quotip->i_df.if_flags & XFS_IFEXTENTS)) {
|
||||||
|
error = xfs_iread_extents(NULL, quotip, XFS_DATA_FORK);
|
||||||
offset = __xfs_seek_hole_data(VFS_I(quotip), XFS_FSB_TO_B(mp, start),
|
|
||||||
eof, SEEK_DATA);
|
|
||||||
if (offset < 0)
|
|
||||||
error = offset;
|
|
||||||
|
|
||||||
xfs_iunlock(quotip, lock);
|
|
||||||
|
|
||||||
/* -ENXIO is essentially "no more data" */
|
|
||||||
if (error)
|
if (error)
|
||||||
return (error == -ENXIO ? -ENOENT: error);
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
/* Convert next data offset back to a quota id */
|
if (xfs_iext_lookup_extent(quotip, "ip->i_df, start, &idx, &got))
|
||||||
*id = XFS_B_TO_FSB(mp, offset) * mp->m_quotainfo->qi_dqperchunk;
|
*id = got.br_startoff * mp->m_quotainfo->qi_dqperchunk;
|
||||||
return 0;
|
else
|
||||||
|
error = -ENOENT;
|
||||||
|
xfs_iunlock(quotip, lock_flags);
|
||||||
|
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -768,7 +762,6 @@ xfs_qm_dqget(
|
||||||
struct xfs_quotainfo *qi = mp->m_quotainfo;
|
struct xfs_quotainfo *qi = mp->m_quotainfo;
|
||||||
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;
|
||||||
loff_t eof = 0;
|
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
ASSERT(XFS_IS_QUOTA_RUNNING(mp));
|
ASSERT(XFS_IS_QUOTA_RUNNING(mp));
|
||||||
|
@ -796,21 +789,6 @@ xfs_qm_dqget(
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Get the end of the quota file if we need it */
|
|
||||||
if (flags & XFS_QMOPT_DQNEXT) {
|
|
||||||
struct xfs_inode *quotip;
|
|
||||||
xfs_fileoff_t last;
|
|
||||||
uint lock_mode;
|
|
||||||
|
|
||||||
quotip = xfs_quota_inode(mp, type);
|
|
||||||
lock_mode = xfs_ilock_data_map_shared(quotip);
|
|
||||||
error = xfs_bmap_last_offset(quotip, &last, XFS_DATA_FORK);
|
|
||||||
xfs_iunlock(quotip, lock_mode);
|
|
||||||
if (error)
|
|
||||||
return error;
|
|
||||||
eof = XFS_FSB_TO_B(mp, last);
|
|
||||||
}
|
|
||||||
|
|
||||||
restart:
|
restart:
|
||||||
mutex_lock(&qi->qi_tree_lock);
|
mutex_lock(&qi->qi_tree_lock);
|
||||||
dqp = radix_tree_lookup(tree, id);
|
dqp = radix_tree_lookup(tree, id);
|
||||||
|
@ -829,7 +807,7 @@ xfs_qm_dqget(
|
||||||
if (XFS_IS_DQUOT_UNINITIALIZED(dqp)) {
|
if (XFS_IS_DQUOT_UNINITIALIZED(dqp)) {
|
||||||
xfs_dqunlock(dqp);
|
xfs_dqunlock(dqp);
|
||||||
mutex_unlock(&qi->qi_tree_lock);
|
mutex_unlock(&qi->qi_tree_lock);
|
||||||
error = xfs_dq_get_next_id(mp, type, &id, eof);
|
error = xfs_dq_get_next_id(mp, type, &id);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
goto restart;
|
goto restart;
|
||||||
|
@ -864,7 +842,7 @@ xfs_qm_dqget(
|
||||||
|
|
||||||
/* If we are asked to find next active id, keep looking */
|
/* If we are asked to find next active id, keep looking */
|
||||||
if (error == -ENOENT && (flags & XFS_QMOPT_DQNEXT)) {
|
if (error == -ENOENT && (flags & XFS_QMOPT_DQNEXT)) {
|
||||||
error = xfs_dq_get_next_id(mp, type, &id, eof);
|
error = xfs_dq_get_next_id(mp, type, &id);
|
||||||
if (!error)
|
if (!error)
|
||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
|
@ -923,7 +901,7 @@ xfs_qm_dqget(
|
||||||
if (flags & XFS_QMOPT_DQNEXT) {
|
if (flags & XFS_QMOPT_DQNEXT) {
|
||||||
if (XFS_IS_DQUOT_UNINITIALIZED(dqp)) {
|
if (XFS_IS_DQUOT_UNINITIALIZED(dqp)) {
|
||||||
xfs_qm_dqput(dqp);
|
xfs_qm_dqput(dqp);
|
||||||
error = xfs_dq_get_next_id(mp, type, &id, eof);
|
error = xfs_dq_get_next_id(mp, type, &id);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
goto restart;
|
goto restart;
|
||||||
|
|
Loading…
Reference in New Issue