From: Khem Raj <raj.khem@gmail.com>
To: linux-raid@vger.kernel.org
Cc: Khem Raj <raj.khem@gmail.com>
Subject: [PATCH] restripe.c: Use _FILE_OFFSET_BITS to enable largefile support
Date: Thu, 10 Nov 2022 12:45:33 -0800 [thread overview]
Message-ID: <20221110204533.3834872-1-raj.khem@gmail.com> (raw)
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
next reply other threads:[~2022-11-10 20:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-10 20:45 Khem Raj [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-11-10 22:55 [PATCH] restripe.c: Use _FILE_OFFSET_BITS to enable largefile support 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
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=20221110204533.3834872-1-raj.khem@gmail.com \
--to=raj.khem@gmail.com \
--cc=linux-raid@vger.kernel.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 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).