All of lore.kernel.org
 help / color / mirror / Atom feed
From: Khem Raj <raj.khem@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: Khem Raj <raj.khem@gmail.com>
Subject: [PATCH 10/11] mdadm: Use _FILE_OFFSET_BITS to use largefile support
Date: Thu, 15 Dec 2022 00:45:45 -0800	[thread overview]
Message-ID: <20221215084546.125368-10-raj.khem@gmail.com> (raw)
In-Reply-To: <20221215084546.125368-1-raj.khem@gmail.com>

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 ...FILE_OFFSET_BITS-to-enable-largefile.patch | 147 ++++++++++++++++++
 meta/recipes-extended/mdadm/mdadm_4.2.bb      |   1 +
 2 files changed, 148 insertions(+)
 create mode 100644 meta/recipes-extended/mdadm/files/0001-restripe.c-Use-_FILE_OFFSET_BITS-to-enable-largefile.patch

diff --git a/meta/recipes-extended/mdadm/files/0001-restripe.c-Use-_FILE_OFFSET_BITS-to-enable-largefile.patch b/meta/recipes-extended/mdadm/files/0001-restripe.c-Use-_FILE_OFFSET_BITS-to-enable-largefile.patch
new file mode 100644
index 0000000000..142ed355ef
--- /dev/null
+++ b/meta/recipes-extended/mdadm/files/0001-restripe.c-Use-_FILE_OFFSET_BITS-to-enable-largefile.patch
@@ -0,0 +1,147 @@
+From 6b861a267a6ef6f60f6cc21e4c8e6d7cdd2451dc Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Thu, 10 Nov 2022 12:31:22 -0800
+Subject: [PATCH] restripe.c: Use _FILE_OFFSET_BITS to enable largefile support
+
+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: Submitted [https://lore.kernel.org/linux-raid/20221110225546.337164-1-raj.khem@gmail.com/]
+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) {
diff --git a/meta/recipes-extended/mdadm/mdadm_4.2.bb b/meta/recipes-extended/mdadm/mdadm_4.2.bb
index 19035caaec..7298860241 100644
--- a/meta/recipes-extended/mdadm/mdadm_4.2.bb
+++ b/meta/recipes-extended/mdadm/mdadm_4.2.bb
@@ -24,6 +24,7 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/raid/mdadm/${BPN}-${PV}.tar.xz \
            file://0001-mdadm-skip-test-11spare-migration.patch \
            file://0001-Fix-parsing-of-r-in-monitor-manager-mode.patch \
            file://0001-Makefile-install-mdcheck.patch \
+           file://0001-restripe.c-Use-_FILE_OFFSET_BITS-to-enable-largefile.patch \
            "
 
 SRC_URI[sha256sum] = "461c215670864bb74a4d1a3620684aa2b2f8296dffa06743f26dda5557acf01d"
-- 
2.39.0



  parent reply	other threads:[~2022-12-15  8:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-15  8:45 [PATCH 01/11] erofs-utils: Convert from off64_t to off_t Khem Raj
2022-12-15  8:45 ` [PATCH 02/11] pseudo: Remove 64bit time_t flags Khem Raj
2022-12-15  8:45 ` [PATCH 03/11] unfs3: Define off64_t in terms of off_t on musl Khem Raj
2022-12-15  8:45 ` [PATCH 04/11] acpid: Fix largefile enabled build Khem Raj
2022-12-15  8:45 ` [PATCH 05/11] efivar: Replace off64_t with off_t Khem Raj
2022-12-15  8:45 ` [PATCH 06/11] ltp: Fix largefile support Khem Raj
2022-12-15  8:45 ` [PATCH 07/11] acl: Enable largefile support by default Khem Raj
2022-12-15  8:45 ` [PATCH 08/11] e2fsprogs: Do not use 64bit functions for largefile support Khem Raj
2022-12-15  9:14   ` [OE-core] " Alexander Kanavin
2022-12-15  8:45 ` [PATCH 09/11] libpciaccess: " Khem Raj
2022-12-15  8:45 ` Khem Raj [this message]
2022-12-15  8:45 ` [PATCH 11/11] btrfs-tools: " Khem Raj

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221215084546.125368-10-raj.khem@gmail.com \
    --to=raj.khem@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.