From: Greg KH <gregkh@linuxfoundation.org>
To: Qu Wenruo <wqu@suse.com>
Cc: stable@vger.kernel.org, linux-btrfs@vger.kernel.org,
David Sterba <dsterba@suse.com>
Subject: Re: [PATCH for v5.15 1/2] btrfs: don't hold CPU for too long when defragging a file
Date: Thu, 17 Feb 2022 20:01:06 +0100 [thread overview]
Message-ID: <Yg6bcq2stNcvDLOv@kroah.com> (raw)
In-Reply-To: <67dd6f0e69c59a8554d7a2977939f94221af00c1.1644994950.git.wqu@suse.com>
On Wed, Feb 16, 2022 at 03:09:07PM +0800, Qu Wenruo wrote:
> commit 2d192fc4c1abeb0d04d1c8cd54405ff4a0b0255b upstream.
This commit is already in 5.15.22.
>
> There is a user report about "btrfs filesystem defrag" causing 120s
> timeout problem.
>
> For btrfs_defrag_file() it will iterate all file extents if called from
> defrag ioctl, thus it can take a long time.
>
> There is no reason not to release the CPU during such a long operation.
>
> Add cond_resched() after defragged one cluster.
>
> CC: stable@vger.kernel.org # 5.15
> Link: https://lore.kernel.org/linux-btrfs/10e51417-2203-f0a4-2021-86c8511cc367@gmx.com
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> Reviewed-by: David Sterba <dsterba@suse.com>
> Signed-off-by: David Sterba <dsterba@suse.com>
> ---
> fs/btrfs/ioctl.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 6a863b3f6de0..38a1b68c7851 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -1581,6 +1581,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
> last_len = 0;
> }
> }
> + cond_resched();
> }
>
> ret = defrag_count;
> --
> 2.35.1
>
The original commit looks nothing like this commit at all. Are you sure
you got this correct?
confused,
greg k-h
next prev parent reply other threads:[~2022-02-17 19:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-16 7:09 [PATCH for v5.15 0/2] Defrag fixes for v5.15 Qu Wenruo
2022-02-16 7:09 ` [PATCH for v5.15 1/2] btrfs: don't hold CPU for too long when defragging a file Qu Wenruo
2022-02-17 19:01 ` Greg KH [this message]
2022-02-17 19:41 ` Holger Hoffstätte
2022-02-17 19:48 ` Greg KH
2022-02-18 0:06 ` Qu Wenruo
2022-02-16 7:09 ` [PATCH for v5.15 2/2] btrfs: defrag: use the same cluster size for defrag ioctl and autodefrag Qu Wenruo
2022-02-16 12:37 ` David Sterba
2022-02-16 12:49 ` Qu Wenruo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Yg6bcq2stNcvDLOv@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=wqu@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).