Skip to content

Commit 8b010ac

Browse files
Wang JianchaoChandan Babu R
authored andcommitted
xfs: use roundup_pow_of_two instead of ffs during xlog_find_tail
In our production environment, we find that mounting a 500M /boot which is umount cleanly needs ~6s. One cause is that ffs() is used by xlog_write_log_records() to decide the buffer size. It can cause a lot of small IO easily when xlog_clear_stale_blocks() needs to wrap around the end of log area and log head block is not power of two. Things are similar in xlog_find_verify_cycle(). The code is able to handed bigger buffer very well, we can use roundup_pow_of_two() to replace ffs() directly to avoid small and sychronous IOs. Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Wang Jianchao <wangjc136@midea.com> Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
1 parent 1155b12 commit 8b010ac

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/xfs/xfs_log_recover.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ xlog_find_verify_cycle(
329329
* try a smaller size. We need to be able to read at least
330330
* a log sector, or we're out of luck.
331331
*/
332-
bufblks = 1 << ffs(nbblks);
332+
bufblks = roundup_pow_of_two(nbblks);
333333
while (bufblks > log->l_logBBsize)
334334
bufblks >>= 1;
335335
while (!(buffer = xlog_alloc_buffer(log, bufblks))) {
@@ -1528,7 +1528,7 @@ xlog_write_log_records(
15281528
* a smaller size. We need to be able to write at least a
15291529
* log sector, or we're out of luck.
15301530
*/
1531-
bufblks = 1 << ffs(blocks);
1531+
bufblks = roundup_pow_of_two(blocks);
15321532
while (bufblks > log->l_logBBsize)
15331533
bufblks >>= 1;
15341534
while (!(buffer = xlog_alloc_buffer(log, bufblks))) {

0 commit comments

Comments
 (0)