Skip to contentSkip to conversation

don't use O_DIRECT in xfsdump for RT files

PATCH In review Christoph Hellwig 2 participants 3 messages Feb 28, 2024

lore
Share & tools
lore
#0 lore raw

Hi all,

for reasons unknown to me xfsdump has been using O_DIRECT for files on the RT subvolume since day 1. But on 4k file system this causes writes to fail due to alignment problem, which shows up in xfstests xfs/060.

This removes the O_DIRET flag and treats RT files like files on the data device and thus fixes the test failure.

(xfs/059 still fails on 4k file system when using rthinherit with what looks file data corruption, I'll look into that next)

#1 lore raw

PATCH 1/1 xfsdump/xfsrestore: don't use O_DIRECT on the RT device

For undocumented reasons xfsdump and xfsrestore use O_DIRECT for RT files. On a rt device with 4k sector size this runs into alignment issues, e.g. xfs/060 fails with this message:

xfsrestore: attempt to write 237568 bytes to dumpdir/large000 at offset 54947844 failed: Invalid argument

Switch to using buffered I/O to match the main device and make these alignment issues go away.

---
 doc/xfsdump.html  | 1 -
 dump/content.c    | 3 ---
 restore/content.c | 3 ---
 3 files changed, 7 deletions(-)
doc/xfsdump.html +0 -1
index efd3890..eec7dac 100644
@@ -884,7 +884,6 @@ Initialize the mmap files of:
                    <ul>
                    <li> S_IFREG -> <b>restore_reg</b> - restore regular file
                       <ul>
-                      <li>if realtime set O_DIRECT
                       <li>truncate file to bs_size
                       <li>set the bs_xflags for extended attributes
                       <li>set DMAPI fields if necessary
dump/content.c +0 -3
index 9117d39..f06dda1 100644
@@ -4325,9 +4325,6 @@ init_extent_group_context(jdm_fshandle_t *fshandlep,
 
 	isrealtime = (bool_t)(statp->bs_xflags & XFS_XFLAG_REALTIME);
 	oflags = O_RDONLY;
-	if (isrealtime) {
-		oflags |= O_DIRECT;
-	}
 	(void)memset((void *)gcp, 0, sizeof(*gcp));
 	gcp->eg_bmap[0].bmv_offset = 0;
 	gcp->eg_bmap[0].bmv_length = -1;
restore/content.c +0 -3
index 488ae20..c80ff34 100644
@@ -7471,9 +7471,6 @@ restore_reg(drive_t *drivep,
 		return BOOL_TRUE;
 
 	oflags = O_CREAT | O_RDWR;
-	if (persp->a.dstdirisxfspr && bstatp->bs_xflags & XFS_XFLAG_REALTIME)
-		oflags |= O_DIRECT;
-
 	*fdp = open(path, oflags, S_IRUSR | S_IWUSR);
 	if (*fdp < 0) {
 		mlog(MLOG_NORMAL | MLOG_WARNING,
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#2 lore raw

Re: [PATCH] xfsdump/xfsrestore: don't use O_DIRECT on the RT device

Quoted 10 lines · Christoph Hellwig

For undocumented reasons xfsdump and xfsrestore use O_DIRECT for RT files. On a rt device with 4k sector size this runs into alignment issues, e.g. xfs/060 fails with this message:

xfsrestore: attempt to write 237568 bytes to dumpdir/large000 at offset 54947844 failed: Invalid argument

Switch to using buffered I/O to match the main device and make these alignment issues go away.

Hah, I have an (never submitted) patch in my xfsdump repo that does exactly this. Now I don't have to find someone to review mine, excellent. :)

--D

Quoted 50 lines
---
 doc/xfsdump.html  | 1 -
 dump/content.c    | 3 ---
 restore/content.c | 3 ---
 3 files changed, 7 deletions(-)
doc/xfsdump.html +0 -1
index efd3890..eec7dac 100644
@@ -884,7 +884,6 @@ Initialize the mmap files of:
                    <ul>
                    <li> S_IFREG -> <b>restore_reg</b> - restore regular file
                       <ul>
-                      <li>if realtime set O_DIRECT
                       <li>truncate file to bs_size
                       <li>set the bs_xflags for extended attributes
                       <li>set DMAPI fields if necessary
dump/content.c +0 -3
index 9117d39..f06dda1 100644
@@ -4325,9 +4325,6 @@ init_extent_group_context(jdm_fshandle_t *fshandlep,
 
 	isrealtime = (bool_t)(statp->bs_xflags & XFS_XFLAG_REALTIME);
 	oflags = O_RDONLY;
-	if (isrealtime) {
-		oflags |= O_DIRECT;
-	}
 	(void)memset((void *)gcp, 0, sizeof(*gcp));
 	gcp->eg_bmap[0].bmv_offset = 0;
 	gcp->eg_bmap[0].bmv_length = -1;
restore/content.c +0 -3
index 488ae20..c80ff34 100644
@@ -7471,9 +7471,6 @@ restore_reg(drive_t *drivep,
 		return BOOL_TRUE;
 
 	oflags = O_CREAT | O_RDWR;
-	if (persp->a.dstdirisxfspr && bstatp->bs_xflags & XFS_XFLAG_REALTIME)
-		oflags |= O_DIRECT;
-
 	*fdp = open(path, oflags, S_IRUSR | S_IWUSR);
 	if (*fdp < 0) {
 		mlog(MLOG_NORMAL | MLOG_WARNING,
Signature · 1 line
2.39.2