All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] restripe.c: Use _FILE_OFFSET_BITS to enable largefile support
@ 2022-11-10 20:45 Khem Raj
  0 siblings, 0 replies; 6+ messages in thread
From: Khem Raj @ 2022-11-10 20:45 UTC (permalink / raw)
  To: linux-raid; +Cc: Khem Raj

Instead of using the lseek64 and friends, its better to enable it via
the feature macro _FILE_OFFSET_BITS = 64 and let the C library deal with
the width of types

Upstream-Status: Pending

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 restripe.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/restripe.c b/restripe.c
index a7a7229..1c03577 100644
--- a/restripe.c
+++ b/restripe.c
@@ -22,6 +22,9 @@
  *    Email: <neilb@suse.de>
  */
 
+/* Enable largefile support */
+#define _FILE_OFFSET_BITS 64
+
 #include "mdadm.h"
 #include <stdint.h>
 
@@ -581,7 +584,7 @@ int save_stripes(int *source, unsigned long long *offsets,
 				       raid_disks, level, layout);
 			if (dnum < 0) abort();
 			if (source[dnum] < 0 ||
-			    lseek64(source[dnum],
+			    lseek(source[dnum],
 				    offsets[dnum] + offset, 0) < 0 ||
 			    read(source[dnum], buf+disk * chunk_size,
 				 chunk_size) != chunk_size) {
@@ -754,8 +757,8 @@ int restore_stripes(int *dest, unsigned long long *offsets,
 					   raid_disks, level, layout);
 			if (src_buf == NULL) {
 				/* read from file */
-				if (lseek64(source, read_offset, 0) !=
-					 (off64_t)read_offset) {
+				if (lseek(source, read_offset, 0) !=
+					 (off_t)read_offset) {
 					rv = -1;
 					goto abort;
 				}
@@ -816,7 +819,7 @@ int restore_stripes(int *dest, unsigned long long *offsets,
 		}
 		for (i=0; i < raid_disks ; i++)
 			if (dest[i] >= 0) {
-				if (lseek64(dest[i],
+				if (lseek(dest[i],
 					 offsets[i]+offset, 0) < 0) {
 					rv = -1;
 					goto abort;
@@ -866,7 +869,7 @@ int test_stripes(int *source, unsigned long long *offsets,
 		int disk;
 
 		for (i = 0 ; i < raid_disks ; i++) {
-			if ((lseek64(source[i], offsets[i]+start, 0) < 0) ||
+			if ((lseek(source[i], offsets[i]+start, 0) < 0) ||
 			    (read(source[i], stripes[i], chunk_size) !=
 			     chunk_size)) {
 				free(q);
-- 
2.38.1


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

* Re: [PATCH] restripe.c: Use _FILE_OFFSET_BITS to enable largefile support
  2024-02-20 16:51 Khem Raj
@ 2024-02-23  8:06 ` Mariusz Tkaczyk
  0 siblings, 0 replies; 6+ messages in thread
From: Mariusz Tkaczyk @ 2024-02-23  8:06 UTC (permalink / raw)
  To: Khem Raj; +Cc: linux-raid

On Tue, 20 Feb 2024 08:51:58 -0800
Khem Raj <raj.khem@gmail.com> wrote:

> Instead of using the lseek64 and friends, its better to enable it via
> the feature macro _FILE_OFFSET_BITS = 64 and let the C library deal with
> the width of types
> 
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
>  restripe.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> --- a/restripe.c
> +++ b/restripe.c
> @@ -22,6 +22,9 @@
>   *    Email: <neilb@suse.de>
>   */
>  
> +/* Enable largefile support */
> +#define _FILE_OFFSET_BITS 64
> +
>  #include "mdadm.h"
>  #include <stdint.h>
>  
> @@ -581,7 +584,7 @@ int save_stripes(int *source, unsigned l
>  				       raid_disks, level, layout);
>  			if (dnum < 0) abort();
>  			if (source[dnum] < 0 ||
> -			    lseek64(source[dnum],
> +			    lseek(source[dnum],
>  				    offsets[dnum] + offset, 0) < 0 ||
>  			    read(source[dnum], buf+disk * chunk_size,
>  				 chunk_size) != chunk_size) {
> @@ -754,8 +757,8 @@ int restore_stripes(int *dest, unsigned
>  					   raid_disks, level, layout);
>  			if (src_buf == NULL) {
>  				/* read from file */
> -				if (lseek64(source, read_offset, 0) !=
> -					 (off64_t)read_offset) {
> +				if (lseek(source, read_offset, 0) !=
> +					 (off_t)read_offset) {
>  					rv = -1;
>  					goto abort;
>  				}
> @@ -816,7 +819,7 @@ int restore_stripes(int *dest, unsigned
>  		}
>  		for (i=0; i < raid_disks ; i++)
>  			if (dest[i] >= 0) {
> -				if (lseek64(dest[i],
> +				if (lseek(dest[i],
>  					 offsets[i]+offset, 0) < 0) {
>  					rv = -1;
>  					goto abort;
> @@ -866,7 +869,7 @@ int test_stripes(int *source, unsigned l
>  		int disk;
>  
>  		for (i = 0 ; i < raid_disks ; i++) {
> -			if ((lseek64(source[i], offsets[i]+start, 0) < 0) ||
> +			if ((lseek(source[i], offsets[i]+start, 0) < 0) ||
>  			    (read(source[i], stripes[i], chunk_size) !=
>  			     chunk_size)) {
>  				free(q);
> --- a/raid6check.c
> +++ b/raid6check.c
> @@ -22,6 +22,9 @@
>   *    Based on "restripe.c" from "mdadm" codebase
>   */
>  
> +/* Enable largefile support */
> +#define _FILE_OFFSET_BITS 64
> +
>  #include "mdadm.h"
>  #include <stdint.h>
>  #include <signal.h>
> @@ -279,9 +282,9 @@ int manual_repair(int chunk_size, int sy
>  	}
>  
>  	int write_res1, write_res2;
> -	off64_t seek_res;
> +	off_t seek_res;
>  
> -	seek_res = lseek64(source[fd1],
> +	seek_res = lseek(source[fd1],
>  			   offsets[fd1] + start * chunk_size, SEEK_SET);
>  	if (seek_res < 0) {
>  		fprintf(stderr, "lseek failed for failed_disk1\n");
> @@ -289,7 +292,7 @@ int manual_repair(int chunk_size, int sy
>  	}
>  	write_res1 = write(source[fd1], blocks[failed_slot1], chunk_size);
>  
> -	seek_res = lseek64(source[fd2],
> +	seek_res = lseek(source[fd2],
>  			   offsets[fd2] + start * chunk_size, SEEK_SET);
>  	if (seek_res < 0) {
>  		fprintf(stderr, "lseek failed for failed_disk2\n");
> @@ -374,7 +377,7 @@ int check_stripes(struct mdinfo *info, i
>  			goto exitCheck;
>  		}
>  		for (i = 0 ; i < raid_disks ; i++) {
> -			off64_t seek_res = lseek64(source[i], offsets[i] +
> start * chunk_size,
> +			off_t seek_res = lseek(source[i], offsets[i] + start
> * chunk_size, SEEK_SET);
>  			if (seek_res < 0) {
>  				fprintf(stderr, "lseek to source %d
> failed\n", i); --- a/swap_super.c
> +++ b/swap_super.c
> @@ -1,3 +1,6 @@
> +/* Enable largefile support */
> +#define _FILE_OFFSET_BITS 64
> +
>  #include <unistd.h>
>  #include <stdlib.h>
>  #include <fcntl.h>
> @@ -16,8 +19,6 @@
>  
>  #define MD_NEW_SIZE_SECTORS(x)		((x & ~(MD_RESERVED_SECTORS -
> 1)) - MD_RESERVED_SECTORS) 
> -extern long long lseek64(int, long long, int);
> -
>  int main(int argc, char *argv[])
>  {
>  	int fd, i;
> @@ -38,8 +39,8 @@ int main(int argc, char *argv[])
>  		exit(1);
>  	}
>  	offset = MD_NEW_SIZE_SECTORS(size) * 512LL;
> -	if (lseek64(fd, offset, 0) < 0LL) {
> -		perror("lseek64");
> +	if (lseek(fd, offset, 0) < 0LL) {
> +		perror("lseek");
>  		exit(1);
>  	}
>  	if (read(fd, super, 4096) != 4096) {
> @@ -68,8 +69,8 @@ int main(int argc, char *argv[])
>  		super[32*4+10*4 +i] = t;
>  	}
>  
> -	if (lseek64(fd, offset, 0) < 0LL) {
> -		perror("lseek64");
> +	if (lseek(fd, offset, 0) < 0LL) {
> +		perror("lseek");
>  		exit(1);
>  	}
>  	if (write(fd, super, 4096) != 4096) {
> 
Hi,

Applying: restripe.c: Use _FILE_OFFSET_BITS to enable largefile support
error: patch failed: raid6check.c:22
error: raid6check.c: patch does not apply
Patch failed at 0001 restripe.c: Use _FILE_OFFSET_BITS to enable largefile
support hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".

I cannot apply this. Please try to rebase it to current master.
Also, I don't see git version signature at the end, perhaps it is broken?

-- 
2.35.3

Thanks,
Mariusz

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

* [PATCH] restripe.c: Use _FILE_OFFSET_BITS to enable largefile support
@ 2024-02-20 16:51 Khem Raj
  2024-02-23  8:06 ` Mariusz Tkaczyk
  0 siblings, 1 reply; 6+ messages in thread
From: Khem Raj @ 2024-02-20 16:51 UTC (permalink / raw)
  To: linux-raid, mariusz.tkaczyk; +Cc: Khem Raj

Instead of using the lseek64 and friends, its better to enable it via
the feature macro _FILE_OFFSET_BITS = 64 and let the C library deal with
the width of types

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 restripe.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

--- a/restripe.c
+++ b/restripe.c
@@ -22,6 +22,9 @@
  *    Email: <neilb@suse.de>
  */
 
+/* Enable largefile support */
+#define _FILE_OFFSET_BITS 64
+
 #include "mdadm.h"
 #include <stdint.h>
 
@@ -581,7 +584,7 @@ int save_stripes(int *source, unsigned l
 				       raid_disks, level, layout);
 			if (dnum < 0) abort();
 			if (source[dnum] < 0 ||
-			    lseek64(source[dnum],
+			    lseek(source[dnum],
 				    offsets[dnum] + offset, 0) < 0 ||
 			    read(source[dnum], buf+disk * chunk_size,
 				 chunk_size) != chunk_size) {
@@ -754,8 +757,8 @@ int restore_stripes(int *dest, unsigned
 					   raid_disks, level, layout);
 			if (src_buf == NULL) {
 				/* read from file */
-				if (lseek64(source, read_offset, 0) !=
-					 (off64_t)read_offset) {
+				if (lseek(source, read_offset, 0) !=
+					 (off_t)read_offset) {
 					rv = -1;
 					goto abort;
 				}
@@ -816,7 +819,7 @@ int restore_stripes(int *dest, unsigned
 		}
 		for (i=0; i < raid_disks ; i++)
 			if (dest[i] >= 0) {
-				if (lseek64(dest[i],
+				if (lseek(dest[i],
 					 offsets[i]+offset, 0) < 0) {
 					rv = -1;
 					goto abort;
@@ -866,7 +869,7 @@ int test_stripes(int *source, unsigned l
 		int disk;
 
 		for (i = 0 ; i < raid_disks ; i++) {
-			if ((lseek64(source[i], offsets[i]+start, 0) < 0) ||
+			if ((lseek(source[i], offsets[i]+start, 0) < 0) ||
 			    (read(source[i], stripes[i], chunk_size) !=
 			     chunk_size)) {
 				free(q);
--- a/raid6check.c
+++ b/raid6check.c
@@ -22,6 +22,9 @@
  *    Based on "restripe.c" from "mdadm" codebase
  */
 
+/* Enable largefile support */
+#define _FILE_OFFSET_BITS 64
+
 #include "mdadm.h"
 #include <stdint.h>
 #include <signal.h>
@@ -279,9 +282,9 @@ int manual_repair(int chunk_size, int sy
 	}
 
 	int write_res1, write_res2;
-	off64_t seek_res;
+	off_t seek_res;
 
-	seek_res = lseek64(source[fd1],
+	seek_res = lseek(source[fd1],
 			   offsets[fd1] + start * chunk_size, SEEK_SET);
 	if (seek_res < 0) {
 		fprintf(stderr, "lseek failed for failed_disk1\n");
@@ -289,7 +292,7 @@ int manual_repair(int chunk_size, int sy
 	}
 	write_res1 = write(source[fd1], blocks[failed_slot1], chunk_size);
 
-	seek_res = lseek64(source[fd2],
+	seek_res = lseek(source[fd2],
 			   offsets[fd2] + start * chunk_size, SEEK_SET);
 	if (seek_res < 0) {
 		fprintf(stderr, "lseek failed for failed_disk2\n");
@@ -374,7 +377,7 @@ int check_stripes(struct mdinfo *info, i
 			goto exitCheck;
 		}
 		for (i = 0 ; i < raid_disks ; i++) {
-			off64_t seek_res = lseek64(source[i], offsets[i] + start * chunk_size,
+			off_t seek_res = lseek(source[i], offsets[i] + start * chunk_size,
 						   SEEK_SET);
 			if (seek_res < 0) {
 				fprintf(stderr, "lseek to source %d failed\n", i);
--- a/swap_super.c
+++ b/swap_super.c
@@ -1,3 +1,6 @@
+/* Enable largefile support */
+#define _FILE_OFFSET_BITS 64
+
 #include <unistd.h>
 #include <stdlib.h>
 #include <fcntl.h>
@@ -16,8 +19,6 @@
 
 #define MD_NEW_SIZE_SECTORS(x)		((x & ~(MD_RESERVED_SECTORS - 1)) - MD_RESERVED_SECTORS)
 
-extern long long lseek64(int, long long, int);
-
 int main(int argc, char *argv[])
 {
 	int fd, i;
@@ -38,8 +39,8 @@ int main(int argc, char *argv[])
 		exit(1);
 	}
 	offset = MD_NEW_SIZE_SECTORS(size) * 512LL;
-	if (lseek64(fd, offset, 0) < 0LL) {
-		perror("lseek64");
+	if (lseek(fd, offset, 0) < 0LL) {
+		perror("lseek");
 		exit(1);
 	}
 	if (read(fd, super, 4096) != 4096) {
@@ -68,8 +69,8 @@ int main(int argc, char *argv[])
 		super[32*4+10*4 +i] = t;
 	}
 
-	if (lseek64(fd, offset, 0) < 0LL) {
-		perror("lseek64");
+	if (lseek(fd, offset, 0) < 0LL) {
+		perror("lseek");
 		exit(1);
 	}
 	if (write(fd, super, 4096) != 4096) {

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

* Re: [PATCH] restripe.c: Use _FILE_OFFSET_BITS to enable largefile support
  2023-08-23 12:52 ` Mariusz Tkaczyk
@ 2024-02-20 13:02   ` Mariusz Tkaczyk
  0 siblings, 0 replies; 6+ messages in thread
From: Mariusz Tkaczyk @ 2024-02-20 13:02 UTC (permalink / raw)
  To: Khem Raj; +Cc: linux-raid

On Wed, 23 Aug 2023 14:52:56 +0200
Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> wrote:

> On Thu, 10 Nov 2022 14:55:46 -0800
> Khem Raj <raj.khem@gmail.com> wrote:
> 
> > Instead of using the lseek64 and friends, its better to enable it via
> > the feature macro _FILE_OFFSET_BITS = 64 and let the C library deal with
> > the width of types
> > 
> 
> LGTM. There are several style issues but you are not an author of them so I
> see this as good to go.
> 
> Sorry, for long response time, I totally lost this one.
> 
> Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
> 

Hello Khem,
I found this on patchwork, it has been omitted. The patch format is broken, it
cannot be applied. Could you please resend it?

Thanks,
Mariusz

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

* Re: [PATCH] restripe.c: Use _FILE_OFFSET_BITS to enable largefile support
  2022-11-10 22:55 Khem Raj
@ 2023-08-23 12:52 ` Mariusz Tkaczyk
  2024-02-20 13:02   ` Mariusz Tkaczyk
  0 siblings, 1 reply; 6+ messages in thread
From: Mariusz Tkaczyk @ 2023-08-23 12:52 UTC (permalink / raw)
  To: Khem Raj; +Cc: linux-raid

On Thu, 10 Nov 2022 14:55:46 -0800
Khem Raj <raj.khem@gmail.com> wrote:

> Instead of using the lseek64 and friends, its better to enable it via
> the feature macro _FILE_OFFSET_BITS = 64 and let the C library deal with
> the width of types
> 

LGTM. There are several style issues but you are not an author of them so I see
this as good to go.

Sorry, for long response time, I totally lost this one.

Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>


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

* [PATCH] restripe.c: Use _FILE_OFFSET_BITS to enable largefile support
@ 2022-11-10 22:55 Khem Raj
  2023-08-23 12:52 ` Mariusz Tkaczyk
  0 siblings, 1 reply; 6+ messages in thread
From: Khem Raj @ 2022-11-10 22:55 UTC (permalink / raw)
  To: linux-raid; +Cc: Khem Raj

Instead of using the lseek64 and friends, its better to enable it via
the feature macro _FILE_OFFSET_BITS = 64 and let the C library deal with
the width of types

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 restripe.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

--- a/restripe.c
+++ b/restripe.c
@@ -22,6 +22,9 @@
  *    Email: <neilb@suse.de>
  */
 
+/* Enable largefile support */
+#define _FILE_OFFSET_BITS 64
+
 #include "mdadm.h"
 #include <stdint.h>
 
@@ -581,7 +584,7 @@ int save_stripes(int *source, unsigned l
 				       raid_disks, level, layout);
 			if (dnum < 0) abort();
 			if (source[dnum] < 0 ||
-			    lseek64(source[dnum],
+			    lseek(source[dnum],
 				    offsets[dnum] + offset, 0) < 0 ||
 			    read(source[dnum], buf+disk * chunk_size,
 				 chunk_size) != chunk_size) {
@@ -754,8 +757,8 @@ int restore_stripes(int *dest, unsigned
 					   raid_disks, level, layout);
 			if (src_buf == NULL) {
 				/* read from file */
-				if (lseek64(source, read_offset, 0) !=
-					 (off64_t)read_offset) {
+				if (lseek(source, read_offset, 0) !=
+					 (off_t)read_offset) {
 					rv = -1;
 					goto abort;
 				}
@@ -816,7 +819,7 @@ int restore_stripes(int *dest, unsigned
 		}
 		for (i=0; i < raid_disks ; i++)
 			if (dest[i] >= 0) {
-				if (lseek64(dest[i],
+				if (lseek(dest[i],
 					 offsets[i]+offset, 0) < 0) {
 					rv = -1;
 					goto abort;
@@ -866,7 +869,7 @@ int test_stripes(int *source, unsigned l
 		int disk;
 
 		for (i = 0 ; i < raid_disks ; i++) {
-			if ((lseek64(source[i], offsets[i]+start, 0) < 0) ||
+			if ((lseek(source[i], offsets[i]+start, 0) < 0) ||
 			    (read(source[i], stripes[i], chunk_size) !=
 			     chunk_size)) {
 				free(q);
--- a/raid6check.c
+++ b/raid6check.c
@@ -22,6 +22,9 @@
  *    Based on "restripe.c" from "mdadm" codebase
  */
 
+/* Enable largefile support */
+#define _FILE_OFFSET_BITS 64
+
 #include "mdadm.h"
 #include <stdint.h>
 #include <signal.h>
@@ -279,9 +282,9 @@ int manual_repair(int chunk_size, int sy
 	}
 
 	int write_res1, write_res2;
-	off64_t seek_res;
+	off_t seek_res;
 
-	seek_res = lseek64(source[fd1],
+	seek_res = lseek(source[fd1],
 			   offsets[fd1] + start * chunk_size, SEEK_SET);
 	if (seek_res < 0) {
 		fprintf(stderr, "lseek failed for failed_disk1\n");
@@ -289,7 +292,7 @@ int manual_repair(int chunk_size, int sy
 	}
 	write_res1 = write(source[fd1], blocks[failed_slot1], chunk_size);
 
-	seek_res = lseek64(source[fd2],
+	seek_res = lseek(source[fd2],
 			   offsets[fd2] + start * chunk_size, SEEK_SET);
 	if (seek_res < 0) {
 		fprintf(stderr, "lseek failed for failed_disk2\n");
@@ -374,7 +377,7 @@ int check_stripes(struct mdinfo *info, i
 			goto exitCheck;
 		}
 		for (i = 0 ; i < raid_disks ; i++) {
-			off64_t seek_res = lseek64(source[i], offsets[i] + start * chunk_size,
+			off_t seek_res = lseek(source[i], offsets[i] + start * chunk_size,
 						   SEEK_SET);
 			if (seek_res < 0) {
 				fprintf(stderr, "lseek to source %d failed\n", i);
--- a/swap_super.c
+++ b/swap_super.c
@@ -1,3 +1,6 @@
+/* Enable largefile support */
+#define _FILE_OFFSET_BITS 64
+
 #include <unistd.h>
 #include <stdlib.h>
 #include <fcntl.h>
@@ -16,8 +19,6 @@
 
 #define MD_NEW_SIZE_SECTORS(x)		((x & ~(MD_RESERVED_SECTORS - 1)) - MD_RESERVED_SECTORS)
 
-extern long long lseek64(int, long long, int);
-
 int main(int argc, char *argv[])
 {
 	int fd, i;
@@ -38,8 +39,8 @@ int main(int argc, char *argv[])
 		exit(1);
 	}
 	offset = MD_NEW_SIZE_SECTORS(size) * 512LL;
-	if (lseek64(fd, offset, 0) < 0LL) {
-		perror("lseek64");
+	if (lseek(fd, offset, 0) < 0LL) {
+		perror("lseek");
 		exit(1);
 	}
 	if (read(fd, super, 4096) != 4096) {
@@ -68,8 +69,8 @@ int main(int argc, char *argv[])
 		super[32*4+10*4 +i] = t;
 	}
 
-	if (lseek64(fd, offset, 0) < 0LL) {
-		perror("lseek64");
+	if (lseek(fd, offset, 0) < 0LL) {
+		perror("lseek");
 		exit(1);
 	}
 	if (write(fd, super, 4096) != 4096) {

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

end of thread, other threads:[~2024-02-23  8:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-10 20:45 [PATCH] restripe.c: Use _FILE_OFFSET_BITS to enable largefile support Khem Raj
2022-11-10 22:55 Khem Raj
2023-08-23 12:52 ` Mariusz Tkaczyk
2024-02-20 13:02   ` Mariusz Tkaczyk
2024-02-20 16:51 Khem Raj
2024-02-23  8:06 ` Mariusz Tkaczyk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.