|
Jan Kara |
d59b12 |
From c44245b3d5435f533ca8346ece65918f84c057f9 Mon Sep 17 00:00:00 2001
|
|
Jan Kara |
d59b12 |
From: Omar Sandoval <osandov@fb.com>
|
|
Jan Kara |
d59b12 |
Date: Fri, 11 Aug 2017 09:00:06 -0700
|
|
Jan Kara |
d59b12 |
Subject: [PATCH] xfs: fix inobt inode allocation search optimization
|
|
Jan Kara |
d59b12 |
Git-commit: c44245b3d5435f533ca8346ece65918f84c057f9
|
|
Jan Kara |
d59b12 |
Patch-mainline: v4.13-rc6
|
|
Jan Kara |
d59b12 |
References: bsc#1052766
|
|
Jan Kara |
d59b12 |
|
|
Jan Kara |
d59b12 |
When we try to allocate a free inode by searching the inobt, we try to
|
|
Jan Kara |
d59b12 |
find the inode nearest the parent inode by searching chunks both left
|
|
Jan Kara |
d59b12 |
and right of the chunk containing the parent. As an optimization, we
|
|
Jan Kara |
d59b12 |
cache the leftmost and rightmost records that we previously searched; if
|
|
Jan Kara |
d59b12 |
we do another allocation with the same parent inode, we'll pick up the
|
|
Jan Kara |
d59b12 |
search where it last left off.
|
|
Jan Kara |
d59b12 |
|
|
Jan Kara |
d59b12 |
There's a bug in the case where we found a free inode to the left of the
|
|
Jan Kara |
d59b12 |
parent's chunk: we need to update the cached left and right records, but
|
|
Jan Kara |
d59b12 |
because we already reassigned the right record to point to the left, we
|
|
Jan Kara |
d59b12 |
end up assigning the left record to both the cached left and right
|
|
Jan Kara |
d59b12 |
records.
|
|
Jan Kara |
d59b12 |
|
|
Jan Kara |
d59b12 |
This isn't a correctness problem strictly, but it can result in the next
|
|
Jan Kara |
d59b12 |
allocation rechecking chunks unnecessarily or allocating inodes further
|
|
Jan Kara |
d59b12 |
away from the parent than it needs to. Fix it by swapping the record
|
|
Jan Kara |
d59b12 |
pointer after we update the cached left and right records.
|
|
Jan Kara |
d59b12 |
|
|
Jan Kara |
d59b12 |
Fixes: bd169565993b ("xfs: speed up free inode search")
|
|
Jan Kara |
d59b12 |
Signed-off-by: Omar Sandoval <osandov@fb.com>
|
|
Jan Kara |
d59b12 |
Reviewed-by: Christoph Hellwig <hch@lst.de>
|
|
Jan Kara |
d59b12 |
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
|
|
Jan Kara |
d59b12 |
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
|
|
Jan Kara |
d59b12 |
Acked-by: Jan Kara <jack@suse.cz>
|
|
Jan Kara |
d59b12 |
|
|
Jan Kara |
d59b12 |
---
|
|
Jan Kara |
d59b12 |
fs/xfs/libxfs/xfs_ialloc.c | 2 +-
|
|
Jan Kara |
d59b12 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
Jan Kara |
d59b12 |
|
|
Jan Kara |
d59b12 |
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
|
|
Jan Kara |
d59b12 |
index ffd5a15d1bb6..abf5beaae907 100644
|
|
Jan Kara |
d59b12 |
--- a/fs/xfs/libxfs/xfs_ialloc.c
|
|
Jan Kara |
d59b12 |
+++ b/fs/xfs/libxfs/xfs_ialloc.c
|
|
Jan Kara |
d59b12 |
@@ -1246,13 +1246,13 @@ xfs_dialloc_ag_inobt(
|
|
Jan Kara |
d59b12 |
|
|
Jan Kara |
d59b12 |
/* free inodes to the left? */
|
|
Jan Kara |
d59b12 |
if (useleft && trec.ir_freecount) {
|
|
Jan Kara |
d59b12 |
- rec = trec;
|
|
Jan Kara |
d59b12 |
xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
|
|
Jan Kara |
d59b12 |
cur = tcur;
|
|
Jan Kara |
d59b12 |
|
|
Jan Kara |
d59b12 |
pag->pagl_leftrec = trec.ir_startino;
|
|
Jan Kara |
d59b12 |
pag->pagl_rightrec = rec.ir_startino;
|
|
Jan Kara |
d59b12 |
pag->pagl_pagino = pagino;
|
|
Jan Kara |
d59b12 |
+ rec = trec;
|
|
Jan Kara |
d59b12 |
goto alloc_inode;
|
|
Jan Kara |
d59b12 |
}
|
|
Jan Kara |
d59b12 |
|
|
Jan Kara |
d59b12 |
--
|
|
Jan Kara |
d59b12 |
2.12.3
|
|
Jan Kara |
d59b12 |
|