Re: PATCH] xfs: use roundup_pow_of_two in xlog_write_log_records

From: Wang Jianchao
Date: Tue Sep 12 2023 - 03:18:22 EST


xlog_find_verify_cycle() has similar issue.
It will be covered in new version patch.

On 2023/9/12 14:17, Wang Jianchao wrote:
>
> In our production environment, we find that mounting a 500M and
> clean /boot needs ~6 seconds sometimes. The one cause is that
> xlog_write_log_records() uses ffs 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. As xlog_write_log_records() has handled bigger
> buffer very well, we can use roundup_pow_of_two instead of ffs to
> decide buffer size.
>
> Signed-off-by: Wang Jianchao <jianchwa@xxxxxxxxxxx>
> ---
> fs/xfs/xfs_log_recover.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
> index 82c81d20459d..9368fefe1d0a 100644
> --- a/fs/xfs/xfs_log_recover.c
> +++ b/fs/xfs/xfs_log_recover.c
> @@ -1528,7 +1528,7 @@ xlog_write_log_records(
> * a smaller size. We need to be able to write at least a
> * log sector, or we're out of luck.
> */
> - bufblks = 1 << ffs(blocks);
> + bufblks = roundup_pow_of_two(blocks);
> while (bufblks > log->l_logBBsize)
> bufblks >>= 1;
> while (!(buffer = xlog_alloc_buffer(log, bufblks))) {