diff mbox series

[3/2] xfs_io: copy_file_range length is a size_t

Message ID 20181203002036.GB6311@dastard (mailing list archive)
State Accepted
Headers show
Series xfs_io: additions for testing copy_range | expand

Commit Message

Dave Chinner Dec. 3, 2018, 12:20 a.m. UTC
From: Dave Chinner <dchinner@redhat.com>

copy_file_range() takes a size_t as it's length, not a "long long".
Therefore we need to be able to pass sizes larger than 8EB to it
to be able to test the interface fully and that requires copy_range
to accept all values except an explicit error value of "-1LL".

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 io/copy_file_range.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Jan Tulak Dec. 3, 2018, 10:08 a.m. UTC | #1
On Mon, Dec 3, 2018 at 1:20 AM Dave Chinner <david@fromorbit.com> wrote:
>
> From: Dave Chinner <dchinner@redhat.com>
>
> copy_file_range() takes a size_t as it's length, not a "long long".
> Therefore we need to be able to pass sizes larger than 8EB to it
> to be able to test the interface fully and that requires copy_range
> to accept all values except an explicit error value of "-1LL".
>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>

Reviewed-by: Jan Tulak <jtulak@redhat.com>

> ---
>  io/copy_file_range.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/io/copy_file_range.c b/io/copy_file_range.c
> index f118a3bfd506..4e2969c9ca47 100644
> --- a/io/copy_file_range.c
> +++ b/io/copy_file_range.c
> @@ -34,7 +34,7 @@ copy_range_help(void)
>   * glibc buffered copy fallback.
>   */
>  static loff_t
> -copy_file_range_cmd(int fd, long long *src, long long *dst, long long len)
> +copy_file_range_cmd(int fd, long long *src, long long *dst, size_t len)
>  {
>         loff_t ret;
>
> @@ -78,7 +78,7 @@ copy_range_f(int argc, char **argv)
>  {
>         long long src = 0;
>         long long dst = 0;
> -       long long len = 0;
> +       size_t len = 0;
>         int opt;
>         int ret;
>         int fd;
> @@ -104,7 +104,7 @@ copy_range_f(int argc, char **argv)
>                         break;
>                 case 'l':
>                         len = cvtnum(fsblocksize, fssectsize, optarg);
> -                       if (len < 0) {
> +                       if (len == -1LL) {
>                                 printf(_("invalid length -- %s\n"), optarg);
>                                 return 0;
>                         }
>
Darrick J. Wong Dec. 3, 2018, 4:27 p.m. UTC | #2
On Mon, Dec 03, 2018 at 11:20:36AM +1100, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> copy_file_range() takes a size_t as it's length, not a "long long".
> Therefore we need to be able to pass sizes larger than 8EB to it
> to be able to test the interface fully and that requires copy_range
> to accept all values except an explicit error value of "-1LL".
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  io/copy_file_range.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/io/copy_file_range.c b/io/copy_file_range.c
> index f118a3bfd506..4e2969c9ca47 100644
> --- a/io/copy_file_range.c
> +++ b/io/copy_file_range.c
> @@ -34,7 +34,7 @@ copy_range_help(void)
>   * glibc buffered copy fallback.
>   */
>  static loff_t
> -copy_file_range_cmd(int fd, long long *src, long long *dst, long long len)
> +copy_file_range_cmd(int fd, long long *src, long long *dst, size_t len)
>  {
>  	loff_t ret;
>  
> @@ -78,7 +78,7 @@ copy_range_f(int argc, char **argv)
>  {
>  	long long src = 0;
>  	long long dst = 0;
> -	long long len = 0;
> +	size_t len = 0;
>  	int opt;
>  	int ret;
>  	int fd;
> @@ -104,7 +104,7 @@ copy_range_f(int argc, char **argv)
>  			break;
>  		case 'l':
>  			len = cvtnum(fsblocksize, fssectsize, optarg);
> -			if (len < 0) {
> +			if (len == -1LL) {
>  				printf(_("invalid length -- %s\n"), optarg);
>  				return 0;
>  			}
>
diff mbox series

Patch

diff --git a/io/copy_file_range.c b/io/copy_file_range.c
index f118a3bfd506..4e2969c9ca47 100644
--- a/io/copy_file_range.c
+++ b/io/copy_file_range.c
@@ -34,7 +34,7 @@  copy_range_help(void)
  * glibc buffered copy fallback.
  */
 static loff_t
-copy_file_range_cmd(int fd, long long *src, long long *dst, long long len)
+copy_file_range_cmd(int fd, long long *src, long long *dst, size_t len)
 {
 	loff_t ret;
 
@@ -78,7 +78,7 @@  copy_range_f(int argc, char **argv)
 {
 	long long src = 0;
 	long long dst = 0;
-	long long len = 0;
+	size_t len = 0;
 	int opt;
 	int ret;
 	int fd;
@@ -104,7 +104,7 @@  copy_range_f(int argc, char **argv)
 			break;
 		case 'l':
 			len = cvtnum(fsblocksize, fssectsize, optarg);
-			if (len < 0) {
+			if (len == -1LL) {
 				printf(_("invalid length -- %s\n"), optarg);
 				return 0;
 			}