btrfs: don't hold CPU for too long when defragging a file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Qu Wenruo <wqu@xxxxxxxx>

commit ea0eba69a2a8125229b1b6011644598039bc53aa upstream.

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@xxxxxxxxxxxxxxx # 5.16
Link: https://lore.kernel.org/linux-btrfs/10e51417-2203-f0a4-2021-86c8511cc367@xxxxxxx
Signed-off-by: Qu Wenruo <wqu@xxxxxxxx>
Reviewed-by: David Sterba <dsterba@xxxxxxxx>
Signed-off-by: David Sterba <dsterba@xxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 fs/btrfs/ioctl.c |    1 +
 1 file changed, 1 insertion(+)

--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1603,6 +1603,7 @@ int btrfs_defrag_file(struct inode *inod
 			ret = 0;
 			break;
 		}
+		cond_resched();
 	}
 
 	if (ra_allocated)


Patches currently in stable-queue which might be from wqu@xxxxxxxx are

queue-5.16/btrfs-don-t-hold-cpu-for-too-long-when-defragging-a-file.patch
queue-5.16/btrfs-defrag-don-t-try-to-defrag-extents-which-are-under-writeback.patch



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux