[v2,2/3] btrfs-progs: fi defrag: do not exit if defrag range ioctl is unsupported
diff mbox

Message ID 20171128091450.21789-2-suy.fnst@cn.fujitsu.com
State New
Headers show

Commit Message

Su Yue Nov. 28, 2017, 9:14 a.m. UTC
If ioctl of defrag range is unsupported, defrag will exit
immediately.

Since caller can handle the error, let cmd_filesystem_defrag()
break the loop and return error instead of calling exit(1).

Suggested-by: David Sterba <dsterba@suse.com>
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
---
Changelog:
v2:	Separate the patch from commit 6e991b9161fa ("btrfs-progs: fi
	defrag: clean up duplicate code if find errors").
---
 cmds-filesystem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Sterba Nov. 28, 2017, 3:57 p.m. UTC | #1
On Tue, Nov 28, 2017 at 05:14:49PM +0800, Su Yue wrote:
> If ioctl of defrag range is unsupported, defrag will exit
> immediately.
> 
> Since caller can handle the error, let cmd_filesystem_defrag()
> break the loop and return error instead of calling exit(1).
> 
> Suggested-by: David Sterba <dsterba@suse.com>
> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
> ---
> Changelog:
> v2:	Separate the patch from commit 6e991b9161fa ("btrfs-progs: fi
> 	defrag: clean up duplicate code if find errors").
> ---
>  cmds-filesystem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/cmds-filesystem.c b/cmds-filesystem.c
> index 17d399d58adf..3931333f76c6 100644
> --- a/cmds-filesystem.c
> +++ b/cmds-filesystem.c
> @@ -1050,7 +1050,7 @@ static int cmd_filesystem_defrag(int argc, char **argv)
>  			ret = nftw(argv[i], defrag_callback, 10,
>  						FTW_MOUNT | FTW_PHYS);
>  			if (ret == ENOTTY)
> -				exit(1);
> +				break;

And we still need to call close_file_or_dir.

>  			/* errors are handled in the callback */
>  			ret = 0;
>  		} else {
> -- 
> 2.15.0
> 
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index 17d399d58adf..3931333f76c6 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -1050,7 +1050,7 @@  static int cmd_filesystem_defrag(int argc, char **argv)
 			ret = nftw(argv[i], defrag_callback, 10,
 						FTW_MOUNT | FTW_PHYS);
 			if (ret == ENOTTY)
-				exit(1);
+				break;
 			/* errors are handled in the callback */
 			ret = 0;
 		} else {