linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] btrfs: return EAGAIN when receiving a pending signal in the defrag loops
@ 2020-11-18  4:02 xiakaixu1987
  2020-11-18  9:53 ` Anand Jain
  2020-11-23 19:17 ` David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: xiakaixu1987 @ 2020-11-18  4:02 UTC (permalink / raw)
  To: clm, josef, dsterba; +Cc: linux-btrfs, linux-kernel, Kaixu Xia

From: Kaixu Xia <kaixuxia@tencent.com>

The variable ret is overwritten by the following variable defrag_count.
Actually the code should return EAGAIN when receiving a pending signal
in the defrag loops.

Reported-by: Tosk Robot <tencent_os_robot@tencent.com>
Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
---
v2
 -return EAGAIN instead of remove the EAGAIN error.

 fs/btrfs/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 69a384145dc6..6f13db6d30bd 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1519,7 +1519,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
 		if (btrfs_defrag_cancelled(fs_info)) {
 			btrfs_debug(fs_info, "defrag_file cancelled");
 			ret = -EAGAIN;
-			break;
+			goto out_ra;
 		}
 
 		if (!should_defrag_range(inode, (u64)i << PAGE_SHIFT,
-- 
2.20.0


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

* Re: [PATCH v2] btrfs: return EAGAIN when receiving a pending signal in the defrag loops
  2020-11-18  4:02 [PATCH v2] btrfs: return EAGAIN when receiving a pending signal in the defrag loops xiakaixu1987
@ 2020-11-18  9:53 ` Anand Jain
  2020-11-23 19:17 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: Anand Jain @ 2020-11-18  9:53 UTC (permalink / raw)
  To: xiakaixu1987, clm, josef, dsterba; +Cc: linux-btrfs, linux-kernel, Kaixu Xia

On 18/11/20 12:02 pm, xiakaixu1987@gmail.com wrote:
> From: Kaixu Xia <kaixuxia@tencent.com>
> 
> The variable ret is overwritten by the following variable defrag_count.
> Actually the code should return EAGAIN when receiving a pending signal
> in the defrag loops.
> 
> Reported-by: Tosk Robot <tencent_os_robot@tencent.com>
> Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
> ---
> v2
>   -return EAGAIN instead of remove the EAGAIN error.

  Sorry I might have missed in v1. Why was EAGAIN needed here?
  Return of defrag_count rather makes sense to me as of now.

Thanks, Anand

> 
>   fs/btrfs/ioctl.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 69a384145dc6..6f13db6d30bd 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -1519,7 +1519,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
>   		if (btrfs_defrag_cancelled(fs_info)) {
>   			btrfs_debug(fs_info, "defrag_file cancelled");
>   			ret = -EAGAIN;
> -			break;
> +			goto out_ra;
>   		}
>   
>   		if (!should_defrag_range(inode, (u64)i << PAGE_SHIFT,
> 


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

* Re: [PATCH v2] btrfs: return EAGAIN when receiving a pending signal in the defrag loops
  2020-11-18  4:02 [PATCH v2] btrfs: return EAGAIN when receiving a pending signal in the defrag loops xiakaixu1987
  2020-11-18  9:53 ` Anand Jain
@ 2020-11-23 19:17 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2020-11-23 19:17 UTC (permalink / raw)
  To: xiakaixu1987; +Cc: clm, josef, dsterba, linux-btrfs, linux-kernel, Kaixu Xia

On Wed, Nov 18, 2020 at 12:02:36PM +0800, xiakaixu1987@gmail.com wrote:
> From: Kaixu Xia <kaixuxia@tencent.com>
> 
> The variable ret is overwritten by the following variable defrag_count.
> Actually the code should return EAGAIN when receiving a pending signal
> in the defrag loops.

This lacks explanation why is EAGAIN supposed to be the right return
value. This is about semantics of the FITRIM ioctl, changing that would
affect userspace applications.

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

end of thread, other threads:[~2020-11-23 19:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-18  4:02 [PATCH v2] btrfs: return EAGAIN when receiving a pending signal in the defrag loops xiakaixu1987
2020-11-18  9:53 ` Anand Jain
2020-11-23 19:17 ` David Sterba

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