don't use O_DIRECT in xfsdump for RT files
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)
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
@@ -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
@@ -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
@@ -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
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_DIRECTfor 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.
Signed-off-by Christoph Hellwig <[email protected]>
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@@ -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 necessarydump/content.c +0
-3@@ -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@@ -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