Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH] btrfs: directly wake up cleaner kthread in the BTRFS_IOC_SYNC ioctl
@ 2024-08-07 17:47 fdmanana
  2024-08-07 18:25 ` Boris Burkov
  2024-08-07 22:27 ` Qu Wenruo
  0 siblings, 2 replies; 3+ messages in thread
From: fdmanana @ 2024-08-07 17:47 UTC (permalink / raw)
  To: linux-btrfs

From: Filipe Manana <fdmanana@suse.com>

The BTRFS_IOC_SYNC ioctl wants to wake up the cleaner kthread so that it
does any pending work (subvolume deletion, delayed iputs, etc), however
it is waking up the transaction kthread, which in turn wakes up the
cleaner. Since we don't have any transaction to commit, as any ongoing
transaction was already committed when it called btrfs_sync_fs() and
the goal is just to wake up the cleaner thread, directly wake up the
cleaner instead of the transaction kthread.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/ioctl.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index e0a664b8a46a..ee01cc828883 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -4765,11 +4765,10 @@ long btrfs_ioctl(struct file *file, unsigned int
 			return ret;
 		ret = btrfs_sync_fs(inode->i_sb, 1);
 		/*
-		 * The transaction thread may want to do more work,
-		 * namely it pokes the cleaner kthread that will start
-		 * processing uncleaned subvols.
+		 * There may be work for the cleaner kthread to do (subvolume
+		 * deletion, delayed iputs, defrag inodes, etc), so wake it up.
 		 */
-		wake_up_process(fs_info->transaction_kthread);
+		wake_up_process(fs_info->cleaner_kthread);
 		return ret;
 	}
 	case BTRFS_IOC_START_SYNC:
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: directly wake up cleaner kthread in the BTRFS_IOC_SYNC ioctl
  2024-08-07 17:47 [PATCH] btrfs: directly wake up cleaner kthread in the BTRFS_IOC_SYNC ioctl fdmanana
@ 2024-08-07 18:25 ` Boris Burkov
  2024-08-07 22:27 ` Qu Wenruo
  1 sibling, 0 replies; 3+ messages in thread
From: Boris Burkov @ 2024-08-07 18:25 UTC (permalink / raw)
  To: linux-btrfs, Filipe Manana

On Wed, Aug 07, 2024 at 06:47:50PM +0100, Filipe Manana wrote:
> The BTRFS_IOC_SYNC ioctl wants to wake up the cleaner kthread so that it
> does any pending work (subvolume deletion, delayed iputs, etc), however
> it is waking up the transaction kthread, which in turn wakes up the
> cleaner. Since we don't have any transaction to commit, as any ongoing
> transaction was already committed when it called btrfs_sync_fs() and
> the goal is just to wake up the cleaner thread, directly wake up the
> cleaner instead of the transaction kthread.
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Boris Burkov <boris@bur.io>
> ---
>  fs/btrfs/ioctl.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index e0a664b8a46a..ee01cc828883 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -4765,11 +4765,10 @@ long btrfs_ioctl(struct file *file, unsigned int
>  			return ret;
>  		ret = btrfs_sync_fs(inode->i_sb, 1);
>  		/*
> -		 * The transaction thread may want to do more work,
> -		 * namely it pokes the cleaner kthread that will start
> -		 * processing uncleaned subvols.
> +		 * There may be work for the cleaner kthread to do (subvolume
> +		 * deletion, delayed iputs, defrag inodes, etc), so wake it up.
>  		 */
> -		wake_up_process(fs_info->transaction_kthread);
> +		wake_up_process(fs_info->cleaner_kthread);
>  		return ret;
>  	}
>  	case BTRFS_IOC_START_SYNC:
> -- 
> 2.43.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: directly wake up cleaner kthread in the BTRFS_IOC_SYNC ioctl
  2024-08-07 17:47 [PATCH] btrfs: directly wake up cleaner kthread in the BTRFS_IOC_SYNC ioctl fdmanana
  2024-08-07 18:25 ` Boris Burkov
@ 2024-08-07 22:27 ` Qu Wenruo
  1 sibling, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2024-08-07 22:27 UTC (permalink / raw)
  To: fdmanana, linux-btrfs



在 2024/8/8 03:17, fdmanana@kernel.org 写道:
> From: Filipe Manana <fdmanana@suse.com>
>
> The BTRFS_IOC_SYNC ioctl wants to wake up the cleaner kthread so that it
> does any pending work (subvolume deletion, delayed iputs, etc), however
> it is waking up the transaction kthread, which in turn wakes up the
> cleaner. Since we don't have any transaction to commit, as any ongoing
> transaction was already committed when it called btrfs_sync_fs() and
> the goal is just to wake up the cleaner thread, directly wake up the
> cleaner instead of the transaction kthread.
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu
> ---
>   fs/btrfs/ioctl.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index e0a664b8a46a..ee01cc828883 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -4765,11 +4765,10 @@ long btrfs_ioctl(struct file *file, unsigned int
>   			return ret;
>   		ret = btrfs_sync_fs(inode->i_sb, 1);
>   		/*
> -		 * The transaction thread may want to do more work,
> -		 * namely it pokes the cleaner kthread that will start
> -		 * processing uncleaned subvols.
> +		 * There may be work for the cleaner kthread to do (subvolume
> +		 * deletion, delayed iputs, defrag inodes, etc), so wake it up.
>   		 */
> -		wake_up_process(fs_info->transaction_kthread);
> +		wake_up_process(fs_info->cleaner_kthread);
>   		return ret;
>   	}
>   	case BTRFS_IOC_START_SYNC:

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-07 22:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-07 17:47 [PATCH] btrfs: directly wake up cleaner kthread in the BTRFS_IOC_SYNC ioctl fdmanana
2024-08-07 18:25 ` Boris Burkov
2024-08-07 22:27 ` Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox