From 9647f2c881f81127c2ac17b25540425e128257a2 Mon Sep 17 00:00:00 2001 From: Ben McClelland Date: Wed, 1 Sep 2021 10:54:40 -0700 Subject: [PATCH] add StageMoveAt for sparse staging --- scoutfs.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/scoutfs.go b/scoutfs.go index e44a4fd..b0337f1 100644 --- a/scoutfs.go +++ b/scoutfs.go @@ -826,3 +826,34 @@ func StageMove(from, to *os.File, offset, version uint64) error { return nil } + +// StageMoveAt will move the extents (based on len) in "from" file handle at +// given offset to the "to" file handle at given offset. +// All offsets must be 4KB aligned boundary. +// All destination offsets must be offline extents. +// EINVAL: from_off, len, or to_off aren't a multiple of 4KB; the source +// and destination files are the same inode; either the source or +// destination is not a regular file; the destination file has +// an existing overlapping extent. +// EOVERFLOW: either from_off + len or to_off + len exceeded 64bits. +// EBADF: from_fd isn't a valid open file descriptor. +// EXDEV: the source and destination files are in different filesystems. +// EISDIR: either the source or destination is a directory. +// ENODATA: either the source or destination file have offline extents. +func StageMoveAt(from, to *os.File, len, fromOffset, toOffset, version uint64) error { + mb := moveBlocks{ + From_fd: uint64(from.Fd()), + From_off: fromOffset, + Len: len, + To_off: toOffset, + Data_version: version, + Flags: MBSTAGEFLG, + } + + _, err := scoutfsctl(to, IOCMOVEBLOCKS, unsafe.Pointer(&mb)) + if err != nil { + return err + } + + return nil +}