aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Sandoval <osandov@fb.com>2017-09-15 08:32:48 -0500
committerEric Sandeen <sandeen@redhat.com>2017-09-15 08:32:48 -0500
commitef54efb5bcbb9e125ded561dc20710450bb301c7 (patch)
tree96fa4b7ae64901f3b4a3bf713e7bbd8324aa113f
parent15a8bccc9403c0ab1dbe869aa3afce7be9e1dd49 (diff)
downloadxfsprogs-dev-ef54efb5bcbb9e125ded561dc20710450bb301c7.tar.gz
xfs: fix inobt inode allocation search optimizationlibxfs-4.13-sync
Source kernel commit: c44245b3d5435f533ca8346ece65918f84c057f9 When we try to allocate a free inode by searching the inobt, we try to find the inode nearest the parent inode by searching chunks both left and right of the chunk containing the parent. As an optimization, we cache the leftmost and rightmost records that we previously searched; if we do another allocation with the same parent inode, we'll pick up the search where it last left off. There's a bug in the case where we found a free inode to the left of the parent's chunk: we need to update the cached left and right records, but because we already reassigned the right record to point to the left, we end up assigning the left record to both the cached left and right records. This isn't a correctness problem strictly, but it can result in the next allocation rechecking chunks unnecessarily or allocating inodes further away from the parent than it needs to. Fix it by swapping the record pointer after we update the cached left and right records. Fixes: bd169565993b ("xfs: speed up free inode search") Signed-off-by: Omar Sandoval <osandov@fb.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-rw-r--r--libxfs/xfs_ialloc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c
index b7f5a30f93..13a4446bf6 100644
--- a/libxfs/xfs_ialloc.c
+++ b/libxfs/xfs_ialloc.c
@@ -1240,13 +1240,13 @@ xfs_dialloc_ag_inobt(
/* free inodes to the left? */
if (useleft && trec.ir_freecount) {
- rec = trec;
xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
cur = tcur;
pag->pagl_leftrec = trec.ir_startino;
pag->pagl_rightrec = rec.ir_startino;
pag->pagl_pagino = pagino;
+ rec = trec;
goto alloc_inode;
}