]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: don't hold CPU for too long when defragging a file
authorQu Wenruo <wqu@suse.com>
Sun, 30 Jan 2022 12:53:15 +0000 (20:53 +0800)
committerDavid Sterba <dsterba@suse.com>
Wed, 9 Feb 2022 17:50:56 +0000 (18:50 +0100)
commit7be7c624694009225d278b39c98cd79795318538
treede297c58ae040f5f262d23216357de3b498421fe
parentcc044badcbd2add82a27b6e20bbe91292bcfba1e
btrfs: don't hold CPU for too long when defragging a file

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.16
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