* [PATCH v3 1/4] Remove use of LFS64 interfaces
@ 2023-12-15 1:36 Sam James
2023-12-15 1:36 ` [PATCH v3 2/4] io: Assert we have a sensible off_t Sam James
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: Sam James @ 2023-12-15 1:36 UTC (permalink / raw)
To: linux-xfs; +Cc: Violet Purcell, Felix Janda, Sam James
From: Violet Purcell <vimproved@inventati.org>
LFS64 interfaces are non-standard and are being removed in the upcoming musl
1.2.5. Setting _FILE_OFFSET_BITS=64 (which is currently being done) makes all
interfaces on glibc 64-bit by default, so using the LFS64 interfaces is
redundant. This commit replaces all occurences of off64_t with off_t,
stat64 with stat, and fstat64 with fstat.
Link: https://bugs.gentoo.org/907039
Cc: Felix Janda <felix.janda@posteo.de>
Signed-off-by: Violet Purcell <vimproved@inventati.org>
Signed-off-by: Sam James <sam@gentoo.org>
---
copy/xfs_copy.c | 2 +-
fsr/xfs_fsr.c | 2 +-
io/bmap.c | 6 +++---
io/copy_file_range.c | 4 ++--
io/cowextsize.c | 6 +++---
io/fadvise.c | 2 +-
io/fiemap.c | 6 +++---
io/fsmap.c | 6 +++---
io/io.h | 10 +++++-----
io/madvise.c | 2 +-
io/mincore.c | 2 +-
io/mmap.c | 13 +++++++------
io/pread.c | 22 +++++++++++-----------
io/pwrite.c | 20 ++++++++++----------
io/reflink.c | 4 ++--
io/seek.c | 6 +++---
io/sendfile.c | 6 +++---
io/stat.c | 2 +-
io/sync_file_range.c | 2 +-
io/truncate.c | 2 +-
libxfs/rdwr.c | 8 ++++----
mdrestore/xfs_mdrestore.c | 2 +-
repair/prefetch.c | 2 +-
scrub/spacemap.c | 6 +++---
spaceman/freesp.c | 4 ++--
spaceman/trim.c | 2 +-
26 files changed, 75 insertions(+), 74 deletions(-)
diff --git a/copy/xfs_copy.c b/copy/xfs_copy.c
index 79f65946..854fd7f4 100644
--- a/copy/xfs_copy.c
+++ b/copy/xfs_copy.c
@@ -888,7 +888,7 @@ main(int argc, char **argv)
}
} else {
char *lb[XFS_MAX_SECTORSIZE] = { NULL };
- off64_t off;
+ off_t off;
/* ensure device files are sufficiently large */
diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
index ba02506d..12fffbd8 100644
--- a/fsr/xfs_fsr.c
+++ b/fsr/xfs_fsr.c
@@ -1148,7 +1148,7 @@ packfile(char *fname, char *tname, int fd,
struct dioattr dio;
static xfs_swapext_t sx;
struct xfs_flock64 space;
- off64_t cnt, pos;
+ off_t cnt, pos;
void *fbuf = NULL;
int ct, wc, wc_b4;
char ffname[SMBUFSZ];
diff --git a/io/bmap.c b/io/bmap.c
index 722a389b..6182e1c5 100644
--- a/io/bmap.c
+++ b/io/bmap.c
@@ -257,7 +257,7 @@ bmap_f(
#define FLG_BSW 0000010 /* Not on begin of stripe width */
#define FLG_ESW 0000001 /* Not on end of stripe width */
int agno;
- off64_t agoff, bbperag;
+ off_t agoff, bbperag;
int foff_w, boff_w, aoff_w, tot_w, agno_w;
char rbuf[32], bbuf[32], abuf[32];
int sunit, swidth;
@@ -267,8 +267,8 @@ bmap_f(
if (is_rt)
sunit = swidth = bbperag = 0;
else {
- bbperag = (off64_t)fsgeo.agblocks *
- (off64_t)fsgeo.blocksize / BBSIZE;
+ bbperag = (off_t)fsgeo.agblocks *
+ (off_t)fsgeo.blocksize / BBSIZE;
sunit = (fsgeo.sunit * fsgeo.blocksize) / BBSIZE;
swidth = (fsgeo.swidth * fsgeo.blocksize) / BBSIZE;
}
diff --git a/io/copy_file_range.c b/io/copy_file_range.c
index d154fa76..422e691a 100644
--- a/io/copy_file_range.c
+++ b/io/copy_file_range.c
@@ -54,7 +54,7 @@ copy_file_range_cmd(int fd, long long *src_off, long long *dst_off, size_t len)
return 0;
}
-static off64_t
+static off_t
copy_src_filesize(int fd)
{
struct stat st;
@@ -154,7 +154,7 @@ copy_range_f(int argc, char **argv)
}
if (!len_specified) {
- off64_t sz;
+ off_t sz;
sz = copy_src_filesize(fd);
if (sz < 0 || (unsigned long long)sz > SIZE_MAX) {
diff --git a/io/cowextsize.c b/io/cowextsize.c
index f6b134df..00e40c6f 100644
--- a/io/cowextsize.c
+++ b/io/cowextsize.c
@@ -50,10 +50,10 @@ static int
set_cowextsize(const char *path, int fd, long extsz)
{
struct fsxattr fsx;
- struct stat64 stat;
+ struct stat stat;
- if (fstat64(fd, &stat) < 0) {
- perror("fstat64");
+ if (fstat(fd, &stat) < 0) {
+ perror("fstat");
exitcode = 1;
return 0;
}
diff --git a/io/fadvise.c b/io/fadvise.c
index 60cc0f08..0966c41b 100644
--- a/io/fadvise.c
+++ b/io/fadvise.c
@@ -39,7 +39,7 @@ fadvise_f(
int argc,
char **argv)
{
- off64_t offset = 0, length = 0;
+ off_t offset = 0, length = 0;
int c, range = 0, advise = POSIX_FADV_NORMAL;
while ((c = getopt(argc, argv, "dnrsw")) != EOF) {
diff --git a/io/fiemap.c b/io/fiemap.c
index f0c74dfe..b41f71bf 100644
--- a/io/fiemap.c
+++ b/io/fiemap.c
@@ -234,9 +234,9 @@ fiemap_f(
int tot_w = 5; /* 5 since its just one number */
int flg_w = 5;
__u64 last_logical = 0; /* last extent offset handled */
- off64_t start_offset = 0; /* mapping start */
- off64_t length = -1LL; /* mapping length */
- off64_t range_end = -1LL; /* mapping end*/
+ off_t start_offset = 0; /* mapping start */
+ off_t length = -1LL; /* mapping length */
+ off_t range_end = -1LL; /* mapping end*/
size_t fsblocksize, fssectsize;
struct stat st;
diff --git a/io/fsmap.c b/io/fsmap.c
index 7db51847..bf119639 100644
--- a/io/fsmap.c
+++ b/io/fsmap.c
@@ -170,7 +170,7 @@ dump_map_verbose(
unsigned long long i;
struct fsmap *p;
int agno;
- off64_t agoff, bperag;
+ off_t agoff, bperag;
int foff_w, boff_w, aoff_w, tot_w, agno_w, own_w;
int nr_w, dev_w;
char rbuf[40], bbuf[40], abuf[40], obuf[40];
@@ -183,8 +183,8 @@ dump_map_verbose(
dev_w = 3;
nr_w = 4;
tot_w = MINTOT_WIDTH;
- bperag = (off64_t)fsgeo->agblocks *
- (off64_t)fsgeo->blocksize;
+ bperag = (off_t)fsgeo->agblocks *
+ (off_t)fsgeo->blocksize;
sunit = (fsgeo->sunit * fsgeo->blocksize);
swidth = (fsgeo->swidth * fsgeo->blocksize);
diff --git a/io/io.h b/io/io.h
index fe474faf..68e5e487 100644
--- a/io/io.h
+++ b/io/io.h
@@ -53,7 +53,7 @@ extern int stat_f(int argc, char **argv);
typedef struct mmap_region {
void *addr; /* address of start of mapping */
size_t length; /* length of mapping */
- off64_t offset; /* start offset into backing file */
+ off_t offset; /* start offset into backing file */
int prot; /* protection mode of the mapping */
int flags; /* MAP_* flags passed to mmap() */
char *name; /* name of backing file */
@@ -63,13 +63,13 @@ extern mmap_region_t *maptable; /* mmap'd region array */
extern int mapcount; /* #entries in the mapping table */
extern mmap_region_t *mapping; /* active mapping table entry */
extern int maplist_f(void);
-extern void *check_mapping_range(mmap_region_t *, off64_t, size_t, int);
+extern void *check_mapping_range(mmap_region_t *, off_t, size_t, int);
/*
* Various xfs_io helper routines/globals
*/
-extern off64_t filesize(void);
+extern off_t filesize(void);
extern int openfile(char *, struct xfs_fsop_geom *, int, mode_t,
struct fs_path *);
extern int addfile(char *, int , struct xfs_fsop_geom *, int,
@@ -84,9 +84,9 @@ extern size_t io_buffersize;
extern int vectors;
extern struct iovec *iov;
extern int alloc_buffer(size_t, int, unsigned int);
-extern int read_buffer(int, off64_t, long long, long long *,
+extern int read_buffer(int, off_t, long long, long long *,
int, int);
-extern void dump_buffer(off64_t, ssize_t);
+extern void dump_buffer(off_t, ssize_t);
extern void attr_init(void);
extern void bmap_init(void);
diff --git a/io/madvise.c b/io/madvise.c
index bde31539..6e9c5b12 100644
--- a/io/madvise.c
+++ b/io/madvise.c
@@ -39,7 +39,7 @@ madvise_f(
int argc,
char **argv)
{
- off64_t offset, llength;
+ off_t offset, llength;
size_t length;
void *start;
int advise = MADV_NORMAL, c;
diff --git a/io/mincore.c b/io/mincore.c
index 67f1d6c4..24147ac2 100644
--- a/io/mincore.c
+++ b/io/mincore.c
@@ -17,7 +17,7 @@ mincore_f(
int argc,
char **argv)
{
- off64_t offset, llength;
+ off_t offset, llength;
size_t length;
size_t blocksize, sectsize;
void *start;
diff --git a/io/mmap.c b/io/mmap.c
index 425957d4..7161ae8e 100644
--- a/io/mmap.c
+++ b/io/mmap.c
@@ -63,11 +63,11 @@ print_mapping(
void *
check_mapping_range(
mmap_region_t *map,
- off64_t offset,
+ off_t offset,
size_t length,
int pagealign)
{
- off64_t relative;
+ off_t relative;
if (offset < mapping->offset) {
printf(_("offset (%lld) is before start of mapping (%lld)\n"),
@@ -155,7 +155,8 @@ mmap_f(
int argc,
char **argv)
{
- off64_t offset;
+ off_t offset;
+
ssize_t length = 0, length2 = 0;
void *address = NULL;
char *filename;
@@ -308,7 +309,7 @@ msync_f(
int argc,
char **argv)
{
- off64_t offset;
+ off_t offset;
ssize_t length;
void *start;
int c, flags = 0;
@@ -401,7 +402,7 @@ mread_f(
int argc,
char **argv)
{
- off64_t offset, tmp, dumpoffset, printoffset;
+ off_t offset, tmp, dumpoffset, printoffset;
ssize_t length;
size_t dumplen, cnt = 0;
char *bp;
@@ -566,7 +567,7 @@ mwrite_f(
int argc,
char **argv)
{
- off64_t offset, tmp;
+ off_t offset, tmp;
ssize_t length;
void *start;
char *sp;
diff --git a/io/pread.c b/io/pread.c
index 0f1d8b97..79990c6a 100644
--- a/io/pread.c
+++ b/io/pread.c
@@ -116,7 +116,7 @@ alloc_buffer(
static void
__dump_buffer(
void *buf,
- off64_t offset,
+ off_t offset,
ssize_t len)
{
int i, j;
@@ -141,7 +141,7 @@ __dump_buffer(
void
dump_buffer(
- off64_t offset,
+ off_t offset,
ssize_t len)
{
int i, l;
@@ -164,7 +164,7 @@ dump_buffer(
static ssize_t
do_preadv(
int fd,
- off64_t offset,
+ off_t offset,
long long count)
{
int vecs = 0;
@@ -199,7 +199,7 @@ do_preadv(
static ssize_t
do_pread(
int fd,
- off64_t offset,
+ off_t offset,
long long count,
size_t buffer_size)
{
@@ -212,13 +212,13 @@ do_pread(
static int
read_random(
int fd,
- off64_t offset,
+ off_t offset,
long long count,
long long *total,
unsigned int seed,
int eof)
{
- off64_t end, off, range;
+ off_t end, off, range;
ssize_t bytes;
int ops = 0;
@@ -259,12 +259,12 @@ read_random(
static int
read_backward(
int fd,
- off64_t *offset,
+ off_t *offset,
long long *count,
long long *total,
int eof)
{
- off64_t end, off = *offset;
+ off_t end, off = *offset;
ssize_t bytes = 0, bytes_requested;
long long cnt = *count;
int ops = 0;
@@ -319,7 +319,7 @@ read_backward(
static int
read_forward(
int fd,
- off64_t offset,
+ off_t offset,
long long count,
long long *total,
int verbose,
@@ -353,7 +353,7 @@ read_forward(
int
read_buffer(
int fd,
- off64_t offset,
+ off_t offset,
long long count,
long long *total,
int verbose,
@@ -368,7 +368,7 @@ pread_f(
char **argv)
{
size_t bsize;
- off64_t offset;
+ off_t offset;
unsigned int zeed = 0;
long long count, total, tmp;
size_t fsblocksize, fssectsize;
diff --git a/io/pwrite.c b/io/pwrite.c
index 467bfa9f..8d134c56 100644
--- a/io/pwrite.c
+++ b/io/pwrite.c
@@ -54,7 +54,7 @@ pwrite_help(void)
static ssize_t
do_pwritev(
int fd,
- off64_t offset,
+ off_t offset,
long long count,
int pwritev2_flags)
{
@@ -97,7 +97,7 @@ do_pwritev(
static ssize_t
do_pwrite(
int fd,
- off64_t offset,
+ off_t offset,
long long count,
size_t buffer_size,
int pwritev2_flags)
@@ -110,13 +110,13 @@ do_pwrite(
static int
write_random(
- off64_t offset,
+ off_t offset,
long long count,
unsigned int seed,
long long *total,
int pwritev2_flags)
{
- off64_t off, range;
+ off_t off, range;
ssize_t bytes;
int ops = 0;
@@ -155,12 +155,12 @@ write_random(
static int
write_backward(
- off64_t offset,
+ off_t offset,
long long *count,
long long *total,
int pwritev2_flags)
{
- off64_t end, off = offset;
+ off_t end, off = offset;
ssize_t bytes = 0, bytes_requested;
long long cnt = *count;
int ops = 0;
@@ -214,11 +214,11 @@ write_backward(
static int
write_buffer(
- off64_t offset,
+ off_t offset,
long long count,
size_t bs,
int fd,
- off64_t skip,
+ off_t skip,
long long *total,
int pwritev2_flags)
{
@@ -253,7 +253,7 @@ write_buffer(
static int
write_once(
- off64_t offset,
+ off_t offset,
long long count,
long long *total,
int pwritev2_flags)
@@ -275,7 +275,7 @@ pwrite_f(
char **argv)
{
size_t bsize;
- off64_t offset, skip = 0;
+ off_t offset, skip = 0;
long long count, total, tmp;
unsigned int zeed = 0, seed = 0xcdcdcdcd;
size_t fsblocksize, fssectsize;
diff --git a/io/reflink.c b/io/reflink.c
index 8e4f3899..b6a3c05a 100644
--- a/io/reflink.c
+++ b/io/reflink.c
@@ -98,7 +98,7 @@ dedupe_f(
int argc,
char **argv)
{
- off64_t soffset, doffset;
+ off_t soffset, doffset;
long long count, total;
char *infile;
int condensed, quiet_flag;
@@ -226,7 +226,7 @@ reflink_f(
int argc,
char **argv)
{
- off64_t soffset, doffset;
+ off_t soffset, doffset;
long long count = 0, total;
char *infile = NULL;
int condensed, quiet_flag;
diff --git a/io/seek.c b/io/seek.c
index 6734ecb5..ffe7439c 100644
--- a/io/seek.c
+++ b/io/seek.c
@@ -63,8 +63,8 @@ static void
seek_output(
int startflag,
char *type,
- off64_t start,
- off64_t offset)
+ off_t start,
+ off_t offset)
{
if (offset == -1) {
if (errno == ENXIO) {
@@ -92,7 +92,7 @@ seek_f(
int argc,
char **argv)
{
- off64_t offset, start;
+ off_t offset, start;
size_t fsblocksize, fssectsize;
int c;
int current; /* specify data or hole */
diff --git a/io/sendfile.c b/io/sendfile.c
index a003bb55..2ce569c2 100644
--- a/io/sendfile.c
+++ b/io/sendfile.c
@@ -34,12 +34,12 @@ sendfile_help(void)
static int
send_buffer(
- off64_t offset,
+ off_t offset,
size_t count,
int fd,
long long *total)
{
- off64_t off = offset;
+ off_t off = offset;
ssize_t bytes, bytes_remaining = count;
int ops = 0;
@@ -66,7 +66,7 @@ sendfile_f(
int argc,
char **argv)
{
- off64_t offset = 0;
+ off_t offset = 0;
long long count, total;
size_t blocksize, sectsize;
struct timeval t1, t2;
diff --git a/io/stat.c b/io/stat.c
index b57f9eef..e8f68dc3 100644
--- a/io/stat.c
+++ b/io/stat.c
@@ -21,7 +21,7 @@ static cmdinfo_t stat_cmd;
static cmdinfo_t statfs_cmd;
static cmdinfo_t statx_cmd;
-off64_t
+off_t
filesize(void)
{
struct stat st;
diff --git a/io/sync_file_range.c b/io/sync_file_range.c
index 94285c22..2375a060 100644
--- a/io/sync_file_range.c
+++ b/io/sync_file_range.c
@@ -30,7 +30,7 @@ sync_range_f(
int argc,
char **argv)
{
- off64_t offset = 0, length = 0;
+ off_t offset = 0, length = 0;
int c, sync_mode = 0;
size_t blocksize, sectsize;
diff --git a/io/truncate.c b/io/truncate.c
index 1d049194..a74b6131 100644
--- a/io/truncate.c
+++ b/io/truncate.c
@@ -16,7 +16,7 @@ truncate_f(
int argc,
char **argv)
{
- off64_t offset;
+ off_t offset;
size_t blocksize, sectsize;
init_cvtnum(&blocksize, §size);
diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
index ccd1501a..4eba0094 100644
--- a/libxfs/rdwr.c
+++ b/libxfs/rdwr.c
@@ -576,7 +576,7 @@ libxfs_balloc(
static int
-__read_buf(int fd, void *buf, int len, off64_t offset, int flags)
+__read_buf(int fd, void *buf, int len, off_t offset, int flags)
{
int sts;
@@ -639,7 +639,7 @@ libxfs_readbufr_map(struct xfs_buftarg *btp, struct xfs_buf *bp, int flags)
fd = libxfs_device_to_fd(btp->bt_bdev);
buf = bp->b_addr;
for (i = 0; i < bp->b_nmaps; i++) {
- off64_t offset = LIBXFS_BBTOOFF64(bp->b_maps[i].bm_bn);
+ off_t offset = LIBXFS_BBTOOFF64(bp->b_maps[i].bm_bn);
int len = BBTOB(bp->b_maps[i].bm_len);
error = __read_buf(fd, buf, len, offset, flags);
@@ -798,7 +798,7 @@ err:
}
static int
-__write_buf(int fd, void *buf, int len, off64_t offset, int flags)
+__write_buf(int fd, void *buf, int len, off_t offset, int flags)
{
int sts;
@@ -864,7 +864,7 @@ libxfs_bwrite(
void *buf = bp->b_addr;
for (i = 0; i < bp->b_nmaps; i++) {
- off64_t offset = LIBXFS_BBTOOFF64(bp->b_maps[i].bm_bn);
+ off_t offset = LIBXFS_BBTOOFF64(bp->b_maps[i].bm_bn);
int len = BBTOB(bp->b_maps[i].bm_len);
bp->b_error = __write_buf(fd, buf, len, offset,
diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c
index 7c1a66c4..bb54e382 100644
--- a/mdrestore/xfs_mdrestore.c
+++ b/mdrestore/xfs_mdrestore.c
@@ -116,7 +116,7 @@ perform_restore(
/* ensure device is sufficiently large enough */
char *lb[XFS_MAX_SECTORSIZE] = { NULL };
- off64_t off;
+ off_t off;
off = sb.sb_dblocks * sb.sb_blocksize - sizeof(lb);
if (pwrite(dst_fd, lb, sizeof(lb), off) < 0)
diff --git a/repair/prefetch.c b/repair/prefetch.c
index 017750e9..35b50134 100644
--- a/repair/prefetch.c
+++ b/repair/prefetch.c
@@ -475,7 +475,7 @@ pf_batch_read(
{
struct xfs_buf *bplist[MAX_BUFS];
unsigned int num;
- off64_t first_off, last_off, next_off;
+ off_t first_off, last_off, next_off;
int len, size;
int i;
int inode_bufs;
diff --git a/scrub/spacemap.c b/scrub/spacemap.c
index 03440d3a..00bee179 100644
--- a/scrub/spacemap.c
+++ b/scrub/spacemap.c
@@ -97,11 +97,11 @@ scan_ag_rmaps(
struct scrub_ctx *ctx = (struct scrub_ctx *)wq->wq_ctx;
struct scan_blocks *sbx = arg;
struct fsmap keys[2];
- off64_t bperag;
+ off_t bperag;
int ret;
- bperag = (off64_t)ctx->mnt.fsgeom.agblocks *
- (off64_t)ctx->mnt.fsgeom.blocksize;
+ bperag = (off_t)ctx->mnt.fsgeom.agblocks *
+ (off_t)ctx->mnt.fsgeom.blocksize;
memset(keys, 0, sizeof(struct fsmap) * 2);
keys->fmr_device = ctx->fsinfo.fs_datadev;
diff --git a/spaceman/freesp.c b/spaceman/freesp.c
index 70dcdb5c..f5177cb4 100644
--- a/spaceman/freesp.c
+++ b/spaceman/freesp.c
@@ -62,7 +62,7 @@ static void
addtohist(
xfs_agnumber_t agno,
xfs_agblock_t agbno,
- off64_t len)
+ off_t len)
{
long i;
@@ -152,7 +152,7 @@ scan_ag(
struct fsmap *l, *h;
struct fsmap *p;
struct xfs_fd *xfd = &file->xfd;
- off64_t aglen;
+ off_t aglen;
xfs_agblock_t agbno;
unsigned long long freeblks = 0;
unsigned long long freeexts = 0;
diff --git a/spaceman/trim.c b/spaceman/trim.c
index e9ed47e4..727dd818 100644
--- a/spaceman/trim.c
+++ b/spaceman/trim.c
@@ -26,7 +26,7 @@ trim_f(
struct xfs_fd *xfd = &file->xfd;
struct xfs_fsop_geom *fsgeom = &xfd->fsgeom;
xfs_agnumber_t agno = 0;
- off64_t offset = 0;
+ off_t offset = 0;
ssize_t length = 0;
ssize_t minlen = 0;
int aflag = 0;
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH v3 2/4] io: Assert we have a sensible off_t
2023-12-15 1:36 [PATCH v3 1/4] Remove use of LFS64 interfaces Sam James
@ 2023-12-15 1:36 ` Sam James
2023-12-19 5:19 ` Darrick J. Wong
2023-12-19 5:54 ` Christoph Hellwig
2023-12-15 1:36 ` [PATCH v3 3/4] build: Request 64-bit time_t where possible Sam James
` (2 subsequent siblings)
3 siblings, 2 replies; 13+ messages in thread
From: Sam James @ 2023-12-15 1:36 UTC (permalink / raw)
To: linux-xfs; +Cc: Sam James, Felix Janda
Suggested by Darrick during review of the first LFSization patch. Assert
we have an off_t capable of handling >=4GiB as a failsafe against the macros
not doing the right thing.
This is not the first time we've been on this adventure in XFS:
* 5c0599b721d1d232d2e400f357abdf2736f24a97 ('Fix building xfsprogs on 32-bit platforms')
* 65b4f302b7a1ddc14684ffbf8690227a67362586 ('platform: remove use of off64_t')
* 7fda99a0c2970f7da2661118b438e64dec1751b4 ('xfs.h: require transparent LFS for all users')
* ebe750ed747cbc59a5675193cdcbc3459ebda107 ('configure: error out when LFS does not work')
* 69268aaec5fb39ad71674336c0f6f75ca9f57999 ('configure: use AC_SYS_LARGEFILE')
Cc: Felix Janda <felix.janda@posteo.de>
Signed-off-by: Sam James <sam@gentoo.org>
---
io/init.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/io/init.c b/io/init.c
index 104cd2c1..2fb598ac 100644
--- a/io/init.c
+++ b/io/init.c
@@ -44,6 +44,9 @@ init_cvtnum(
static void
init_commands(void)
{
+ /* We're only interested in supporting an off_t which can handle >=4GiB. */
+ BUILD_BUG_ON(sizeof(off_t) < 8);
+
attr_init();
bmap_init();
bulkstat_init();
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH v3 2/4] io: Assert we have a sensible off_t
2023-12-15 1:36 ` [PATCH v3 2/4] io: Assert we have a sensible off_t Sam James
@ 2023-12-19 5:19 ` Darrick J. Wong
2023-12-19 5:54 ` Christoph Hellwig
1 sibling, 0 replies; 13+ messages in thread
From: Darrick J. Wong @ 2023-12-19 5:19 UTC (permalink / raw)
To: Sam James; +Cc: linux-xfs, Felix Janda
On Fri, Dec 15, 2023 at 01:36:41AM +0000, Sam James wrote:
> Suggested by Darrick during review of the first LFSization patch. Assert
> we have an off_t capable of handling >=4GiB as a failsafe against the macros
> not doing the right thing.
>
> This is not the first time we've been on this adventure in XFS:
> * 5c0599b721d1d232d2e400f357abdf2736f24a97 ('Fix building xfsprogs on 32-bit platforms')
> * 65b4f302b7a1ddc14684ffbf8690227a67362586 ('platform: remove use of off64_t')
> * 7fda99a0c2970f7da2661118b438e64dec1751b4 ('xfs.h: require transparent LFS for all users')
> * ebe750ed747cbc59a5675193cdcbc3459ebda107 ('configure: error out when LFS does not work')
> * 69268aaec5fb39ad71674336c0f6f75ca9f57999 ('configure: use AC_SYS_LARGEFILE')
>
> Cc: Felix Janda <felix.janda@posteo.de>
> Signed-off-by: Sam James <sam@gentoo.org>
Looks ok,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--D
> ---
> io/init.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/io/init.c b/io/init.c
> index 104cd2c1..2fb598ac 100644
> --- a/io/init.c
> +++ b/io/init.c
> @@ -44,6 +44,9 @@ init_cvtnum(
> static void
> init_commands(void)
> {
> + /* We're only interested in supporting an off_t which can handle >=4GiB. */
> + BUILD_BUG_ON(sizeof(off_t) < 8);
> +
> attr_init();
> bmap_init();
> bulkstat_init();
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH v3 2/4] io: Assert we have a sensible off_t
2023-12-15 1:36 ` [PATCH v3 2/4] io: Assert we have a sensible off_t Sam James
2023-12-19 5:19 ` Darrick J. Wong
@ 2023-12-19 5:54 ` Christoph Hellwig
2023-12-26 20:49 ` Sam James
1 sibling, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2023-12-19 5:54 UTC (permalink / raw)
To: Sam James; +Cc: linux-xfs, Felix Janda
On Fri, Dec 15, 2023 at 01:36:41AM +0000, Sam James wrote:
> + /* We're only interested in supporting an off_t which can handle >=4GiB. */
This adds a < 80 character line. Also I find the wording a bit odd, the
point is that xfsprogs relies on (it or rather will with your entire
series), so maybe:
/*
* xfsprogs relies on the LFS interfaces with a 64-bit off_t to
* actually support sensible file systems sizes.
*/
And while I'm nitpicking, maybe a better place would be to move this to
libxfs as that's where we really care. If you use the C99 static_assert
instead of the kernel BUILD_BUG_ON this can even move outside a function
and just into a header somewhere, say include/xfs,h. Which actually
happens to have this assert in an awkware open coded way already:
/*
* make sure that any user of the xfs headers has a 64bit off_t type
*/
extern int xfs_assert_largefile[sizeof(off_t)-8];
Enough of my stream of consciousness, sorry. To summarize the findings:
- we don't really need this patch all
- but cleaning up xfs_assert_largefile to just use static_assert would
probably be nice to have anyway
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 2/4] io: Assert we have a sensible off_t
2023-12-19 5:54 ` Christoph Hellwig
@ 2023-12-26 20:49 ` Sam James
2024-01-22 4:58 ` Sam James
0 siblings, 1 reply; 13+ messages in thread
From: Sam James @ 2023-12-26 20:49 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Sam James, linux-xfs, Felix Janda
Christoph Hellwig <hch@infradead.org> writes:
> On Fri, Dec 15, 2023 at 01:36:41AM +0000, Sam James wrote:
>> + /* We're only interested in supporting an off_t which can handle >=4GiB. */
>
> This adds a < 80 character line. Also I find the wording a bit odd, the
> point is that xfsprogs relies on (it or rather will with your entire
> series), so maybe:
>
> /*
> * xfsprogs relies on the LFS interfaces with a 64-bit off_t to
> * actually support sensible file systems sizes.
> */
>
> And while I'm nitpicking, maybe a better place would be to move this to
> libxfs as that's where we really care. If you use the C99 static_assert
> instead of the kernel BUILD_BUG_ON this can even move outside a function
> and just into a header somewhere, say include/xfs,h. Which actually
> happens to have this assert in an awkware open coded way already:
>
> /*
> * make sure that any user of the xfs headers has a 64bit off_t type
> */
> extern int xfs_assert_largefile[sizeof(off_t)-8];
>
> Enough of my stream of consciousness, sorry. To summarize the findings:
>
> - we don't really need this patch all
> - but cleaning up xfs_assert_largefile to just use static_assert would
> probably be nice to have anyway
Thanks, I agree, but I think static_assert is C11 (and then it gets a
nicer name in C23). If it's still fine for us, I can then use it.
Does it change your thinking at all or should I send a v4 with it
included?
Thanks,
sam
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 2/4] io: Assert we have a sensible off_t
2023-12-26 20:49 ` Sam James
@ 2024-01-22 4:58 ` Sam James
2024-01-22 6:33 ` Christoph Hellwig
0 siblings, 1 reply; 13+ messages in thread
From: Sam James @ 2024-01-22 4:58 UTC (permalink / raw)
To: Sam James; +Cc: Christoph Hellwig, linux-xfs, Felix Janda
Sam James <sam@gentoo.org> writes:
> Christoph Hellwig <hch@infradead.org> writes:
>
>> On Fri, Dec 15, 2023 at 01:36:41AM +0000, Sam James wrote:
>>> + /* We're only interested in supporting an off_t which can handle >=4GiB. */
>>
>> This adds a < 80 character line. Also I find the wording a bit odd, the
>> point is that xfsprogs relies on (it or rather will with your entire
>> series), so maybe:
>>
>> /*
>> * xfsprogs relies on the LFS interfaces with a 64-bit off_t to
>> * actually support sensible file systems sizes.
>> */
>>
>> And while I'm nitpicking, maybe a better place would be to move this to
>> libxfs as that's where we really care. If you use the C99 static_assert
>> instead of the kernel BUILD_BUG_ON this can even move outside a function
>> and just into a header somewhere, say include/xfs,h. Which actually
>> happens to have this assert in an awkware open coded way already:
>>
>> /*
>> * make sure that any user of the xfs headers has a 64bit off_t type
>> */
>> extern int xfs_assert_largefile[sizeof(off_t)-8];
>>
>> Enough of my stream of consciousness, sorry. To summarize the findings:
>>
>> - we don't really need this patch all
>> - but cleaning up xfs_assert_largefile to just use static_assert would
>> probably be nice to have anyway
>
> Thanks, I agree, but I think static_assert is C11 (and then it gets a
> nicer name in C23). If it's still fine for us, I can then use it.
>
> Does it change your thinking at all or should I send a v4 with it
> included?
ping. I don't mind doing a followup, but I'd love to get this in given
there's a bunch of other projects still to handle with this sort of
problem.
>
> Thanks,
> sam
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 2/4] io: Assert we have a sensible off_t
2024-01-22 4:58 ` Sam James
@ 2024-01-22 6:33 ` Christoph Hellwig
2024-01-22 7:22 ` Sam James
0 siblings, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2024-01-22 6:33 UTC (permalink / raw)
To: Sam James; +Cc: Christoph Hellwig, linux-xfs, Felix Janda
On Mon, Jan 22, 2024 at 04:58:07AM +0000, Sam James wrote:
> >> - we don't really need this patch all
> >> - but cleaning up xfs_assert_largefile to just use static_assert would
> >> probably be nice to have anyway
> >
> > Thanks, I agree, but I think static_assert is C11 (and then it gets a
> > nicer name in C23). If it's still fine for us, I can then use it.
> >
> > Does it change your thinking at all or should I send a v4 with it
> > included?
>
> ping. I don't mind doing a followup, but I'd love to get this in given
> there's a bunch of other projects still to handle with this sort of
> problem.
Well, we certainly should drop this patch from the series. Adding
a cleanup to switch the existing odd way of asserting the size to
static_assert would be nice, but I don't think is required.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 2/4] io: Assert we have a sensible off_t
2024-01-22 6:33 ` Christoph Hellwig
@ 2024-01-22 7:22 ` Sam James
0 siblings, 0 replies; 13+ messages in thread
From: Sam James @ 2024-01-22 7:22 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Sam James, linux-xfs, Felix Janda
Christoph Hellwig <hch@infradead.org> writes:
> On Mon, Jan 22, 2024 at 04:58:07AM +0000, Sam James wrote:
>> >> - we don't really need this patch all
>> >> - but cleaning up xfs_assert_largefile to just use static_assert would
>> >> probably be nice to have anyway
>> >
>> > Thanks, I agree, but I think static_assert is C11 (and then it gets a
>> > nicer name in C23). If it's still fine for us, I can then use it.
>> >
>> > Does it change your thinking at all or should I send a v4 with it
>> > included?
>>
>> ping. I don't mind doing a followup, but I'd love to get this in given
>> there's a bunch of other projects still to handle with this sort of
>> problem.
>
> Well, we certainly should drop this patch from the series. Adding
> a cleanup to switch the existing odd way of asserting the size to
> static_assert would be nice, but I don't think is required.
OK, sure. Thanks!
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3 3/4] build: Request 64-bit time_t where possible
2023-12-15 1:36 [PATCH v3 1/4] Remove use of LFS64 interfaces Sam James
2023-12-15 1:36 ` [PATCH v3 2/4] io: Assert we have a sensible off_t Sam James
@ 2023-12-15 1:36 ` Sam James
2023-12-19 5:27 ` Darrick J. Wong
2023-12-15 1:36 ` [PATCH v3 4/4] io: Adapt to >= 64-bit time_t Sam James
2023-12-19 5:55 ` [PATCH v3 1/4] Remove use of LFS64 interfaces Christoph Hellwig
3 siblings, 1 reply; 13+ messages in thread
From: Sam James @ 2023-12-15 1:36 UTC (permalink / raw)
To: linux-xfs; +Cc: Sam James
Suggested by Darrick during LFS review. We take the same approach as in
5c0599b721d1d232d2e400f357abdf2736f24a97 ('Fix building xfsprogs on 32-bit platforms')
to avoid autoconf hell - just take the tried & tested approach which is working
fine for us with LFS already.
Signed-off-by: Sam James <sam@gentoo.org>
---
include/builddefs.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/builddefs.in b/include/builddefs.in
index 147c9b98..969254f3 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -13,8 +13,8 @@ OPTIMIZER = @opt_build@
MALLOCLIB = @malloc_lib@
LOADERFLAGS = @LDFLAGS@
LTLDFLAGS = @LDFLAGS@
-CFLAGS = @CFLAGS@ -D_FILE_OFFSET_BITS=64 -Wno-address-of-packed-member
-BUILD_CFLAGS = @BUILD_CFLAGS@ -D_FILE_OFFSET_BITS=64
+CFLAGS = @CFLAGS@ -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 -Wno-address-of-packed-member
+BUILD_CFLAGS = @BUILD_CFLAGS@ -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
# make sure we don't pick up whacky LDFLAGS from the make environment and
# only use what we calculate from the configured options above.
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH v3 3/4] build: Request 64-bit time_t where possible
2023-12-15 1:36 ` [PATCH v3 3/4] build: Request 64-bit time_t where possible Sam James
@ 2023-12-19 5:27 ` Darrick J. Wong
0 siblings, 0 replies; 13+ messages in thread
From: Darrick J. Wong @ 2023-12-19 5:27 UTC (permalink / raw)
To: Sam James; +Cc: linux-xfs
On Fri, Dec 15, 2023 at 01:36:42AM +0000, Sam James wrote:
> Suggested by Darrick during LFS review. We take the same approach as in
> 5c0599b721d1d232d2e400f357abdf2736f24a97 ('Fix building xfsprogs on 32-bit platforms')
> to avoid autoconf hell - just take the tried & tested approach which is working
> fine for us with LFS already.
>
> Signed-off-by: Sam James <sam@gentoo.org>
Looks good to me,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--D
> ---
> include/builddefs.in | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/builddefs.in b/include/builddefs.in
> index 147c9b98..969254f3 100644
> --- a/include/builddefs.in
> +++ b/include/builddefs.in
> @@ -13,8 +13,8 @@ OPTIMIZER = @opt_build@
> MALLOCLIB = @malloc_lib@
> LOADERFLAGS = @LDFLAGS@
> LTLDFLAGS = @LDFLAGS@
> -CFLAGS = @CFLAGS@ -D_FILE_OFFSET_BITS=64 -Wno-address-of-packed-member
> -BUILD_CFLAGS = @BUILD_CFLAGS@ -D_FILE_OFFSET_BITS=64
> +CFLAGS = @CFLAGS@ -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64 -Wno-address-of-packed-member
> +BUILD_CFLAGS = @BUILD_CFLAGS@ -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
>
> # make sure we don't pick up whacky LDFLAGS from the make environment and
> # only use what we calculate from the configured options above.
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v3 4/4] io: Adapt to >= 64-bit time_t
2023-12-15 1:36 [PATCH v3 1/4] Remove use of LFS64 interfaces Sam James
2023-12-15 1:36 ` [PATCH v3 2/4] io: Assert we have a sensible off_t Sam James
2023-12-15 1:36 ` [PATCH v3 3/4] build: Request 64-bit time_t where possible Sam James
@ 2023-12-15 1:36 ` Sam James
2023-12-19 5:27 ` Darrick J. Wong
2023-12-19 5:55 ` [PATCH v3 1/4] Remove use of LFS64 interfaces Christoph Hellwig
3 siblings, 1 reply; 13+ messages in thread
From: Sam James @ 2023-12-15 1:36 UTC (permalink / raw)
To: linux-xfs; +Cc: Sam James
We now require (at least) 64-bit time_t, so we need to adjust some printf
specifiers accordingly.
Unfortunately, we've stumbled upon a ridiculous C mmoment whereby there's
no neat format specifier (not even one of the inttypes ones) for time_t, so
we cast to intmax_t and use %jd.
Signed-off-by: Sam James <sam@gentoo.org>
---
v3: uintmax_t -> intmax_t as time_t is signed
io/stat.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/io/stat.c b/io/stat.c
index e8f68dc3..743a7586 100644
--- a/io/stat.c
+++ b/io/stat.c
@@ -66,11 +66,11 @@ dump_raw_stat(struct stat *st)
printf("stat.ino = %llu\n", (unsigned long long)st->st_ino);
printf("stat.size = %lld\n", (long long)st->st_size);
printf("stat.blocks = %lld\n", (long long)st->st_blocks);
- printf("stat.atime.tv_sec = %ld\n", st->st_atim.tv_sec);
+ printf("stat.atime.tv_sec = %jd\n", (intmax_t)st->st_atim.tv_sec);
printf("stat.atime.tv_nsec = %ld\n", st->st_atim.tv_nsec);
- printf("stat.ctime.tv_sec = %ld\n", st->st_ctim.tv_sec);
+ printf("stat.ctime.tv_sec = %jd\n", (intmax_t)st->st_ctim.tv_sec);
printf("stat.ctime.tv_nsec = %ld\n", st->st_ctim.tv_nsec);
- printf("stat.mtime.tv_sec = %ld\n", st->st_mtim.tv_sec);
+ printf("stat.mtime.tv_sec = %jd\n", (intmax_t)st->st_mtim.tv_sec);
printf("stat.mtime.tv_nsec = %ld\n", st->st_mtim.tv_nsec);
printf("stat.rdev_major = %u\n", major(st->st_rdev));
printf("stat.rdev_minor = %u\n", minor(st->st_rdev));
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH v3 4/4] io: Adapt to >= 64-bit time_t
2023-12-15 1:36 ` [PATCH v3 4/4] io: Adapt to >= 64-bit time_t Sam James
@ 2023-12-19 5:27 ` Darrick J. Wong
0 siblings, 0 replies; 13+ messages in thread
From: Darrick J. Wong @ 2023-12-19 5:27 UTC (permalink / raw)
To: Sam James; +Cc: linux-xfs
On Fri, Dec 15, 2023 at 01:36:43AM +0000, Sam James wrote:
> We now require (at least) 64-bit time_t, so we need to adjust some printf
> specifiers accordingly.
>
> Unfortunately, we've stumbled upon a ridiculous C mmoment whereby there's
Plenty of those to go around...
> no neat format specifier (not even one of the inttypes ones) for time_t, so
> we cast to intmax_t and use %jd.
>
> Signed-off-by: Sam James <sam@gentoo.org>
> ---
> v3: uintmax_t -> intmax_t as time_t is signed
>
> io/stat.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/io/stat.c b/io/stat.c
> index e8f68dc3..743a7586 100644
> --- a/io/stat.c
> +++ b/io/stat.c
> @@ -66,11 +66,11 @@ dump_raw_stat(struct stat *st)
> printf("stat.ino = %llu\n", (unsigned long long)st->st_ino);
> printf("stat.size = %lld\n", (long long)st->st_size);
> printf("stat.blocks = %lld\n", (long long)st->st_blocks);
> - printf("stat.atime.tv_sec = %ld\n", st->st_atim.tv_sec);
> + printf("stat.atime.tv_sec = %jd\n", (intmax_t)st->st_atim.tv_sec);
I almost wonder if we want a similar
BUILD_BUG_ON(sizeof(time_t) < 8);
here or something?
Also I totally didn't realize that "intmax_t" is actually s64 on x86_64.
I saw "int" and assumed "still 32-bit".
But, I guess C99 says "...capable of representing any value of any basic
signed integer type supported by the implementation."
So it apparently works even for 32-bit compilers, at least according to
godbolt.org...
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--D
> printf("stat.atime.tv_nsec = %ld\n", st->st_atim.tv_nsec);
> - printf("stat.ctime.tv_sec = %ld\n", st->st_ctim.tv_sec);
> + printf("stat.ctime.tv_sec = %jd\n", (intmax_t)st->st_ctim.tv_sec);
> printf("stat.ctime.tv_nsec = %ld\n", st->st_ctim.tv_nsec);
> - printf("stat.mtime.tv_sec = %ld\n", st->st_mtim.tv_sec);
> + printf("stat.mtime.tv_sec = %jd\n", (intmax_t)st->st_mtim.tv_sec);
> printf("stat.mtime.tv_nsec = %ld\n", st->st_mtim.tv_nsec);
> printf("stat.rdev_major = %u\n", major(st->st_rdev));
> printf("stat.rdev_minor = %u\n", minor(st->st_rdev));
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 1/4] Remove use of LFS64 interfaces
2023-12-15 1:36 [PATCH v3 1/4] Remove use of LFS64 interfaces Sam James
` (2 preceding siblings ...)
2023-12-15 1:36 ` [PATCH v3 4/4] io: Adapt to >= 64-bit time_t Sam James
@ 2023-12-19 5:55 ` Christoph Hellwig
3 siblings, 0 replies; 13+ messages in thread
From: Christoph Hellwig @ 2023-12-19 5:55 UTC (permalink / raw)
To: Sam James; +Cc: linux-xfs, Violet Purcell, Felix Janda
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2024-01-22 7:22 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-15 1:36 [PATCH v3 1/4] Remove use of LFS64 interfaces Sam James
2023-12-15 1:36 ` [PATCH v3 2/4] io: Assert we have a sensible off_t Sam James
2023-12-19 5:19 ` Darrick J. Wong
2023-12-19 5:54 ` Christoph Hellwig
2023-12-26 20:49 ` Sam James
2024-01-22 4:58 ` Sam James
2024-01-22 6:33 ` Christoph Hellwig
2024-01-22 7:22 ` Sam James
2023-12-15 1:36 ` [PATCH v3 3/4] build: Request 64-bit time_t where possible Sam James
2023-12-19 5:27 ` Darrick J. Wong
2023-12-15 1:36 ` [PATCH v3 4/4] io: Adapt to >= 64-bit time_t Sam James
2023-12-19 5:27 ` Darrick J. Wong
2023-12-19 5:55 ` [PATCH v3 1/4] Remove use of LFS64 interfaces Christoph Hellwig
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.