Conversation
|
@mlawren Thanks for the suggestion. Wanna test or review this? |
On bcachefs, subvolumes share the same st_dev (unlike btrfs), so rmw correctly matched the waste folder by device number but rename() still returned EXDEV when moving across subvolumes. Add a fallback to safe_mv_via_exec() when rename() fails with EXDEV on a same-device move. Also switch from BTRFS_IOC_CLONE (linux/btrfs.h) to the generic FICLONE ioctl (linux/fs.h), which is supported by any reflink-capable filesystem (btrfs, bcachefs, xfs, etc.), and update the meson header check accordingly. Add test/test_bcachefs.sh which creates an 8M bcachefs image on-the-fly, exercises cross-subvolume file and directory moves, and cleans up after itself. Skips gracefully when bcachefs kernel support is unavailable. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Fixes #526
- test/COMMON: add SKIP=77 for Meson skip exit code - test/test_bcachefs.sh: use pre-existing image from test dir instead of creating one; skip if kernel bcachefs support or image is absent; guard against stale mounts/loop devices and leftover files from previous runs - .github/workflows/c-cpp.yml: add bcachefs image cache/download step - test/rmw-bcachefs-test.img.sha256sum: add checksum file for CI caching - man/rmw.1: add BTRFS AND BCACHEFS subsection under NOTES - Rename want_btrfs_clone option to want_ficlone - Rename HAVE_LINUX_BTRFS macro to HAVE_FICLONE - Rename has_btrfs_header variable to has_linux_fs_header - Rename src/btrfs.c and src/btrfs.h to src/ficlone.c and src/ficlone.h - Rename is_btrfs() to is_ficlone_fs() and do_btrfs_clone() to do_ficlone() - Rename is_btrfs struct field in st_waste to is_ficlone_fs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
mlawren
left a comment
There was a problem hiding this comment.
This is a little hard to review for two reasons:
- I'm not at all familiar with the codebase (but that is changing :-)
- The breakdown of changes and commits is not great. Code changes and build-system changs and CI changes and renames are not cleanly separated.
Since Claude is doing the work, perhaps it could be instructed to redo the steps.
But more strategically, I don't like (as an interested user / random internet commenter :-) the focus on a single bugfix for the single file case I presented. These commits do appear to enable a reflink copy for a single file. However if the target is a directory then the whole thing gets mved, which copies all the files in the tree. That is the extra work (and disk space) that a reflink is supposed to avoid.
So to my mind, the code needs to be architected a little differently, to almost re-implement mv internally by copying the directory tree and FICLONEing each file within. But perhaps that should be a patch against mv...
So, one probably should raise an issue against
The above is specific to a |
|
Finally, just another (somewhat unrelated) comment on code structure. The |
Originally the code was more btrfs-specific. So it makes sense to change some of the variables, the functions, and what I had in the build system. And I needed to rename btrfs.c for the purpose of this PR. Unfortunately it does make the PR more convoluted, but the code is cleaner in the long-run.
GNU coreutils mv has clone support, so even though 'mv' is getting called in some cases, It's not actually "copying" all the files, but cloning them (#497). Unfortunately that's not very robust because last time I checked, busybox mv doesn't support cloning. So... this all depends on what's built into mv on the user's target system. The reason I decided to use mv like that was to avoid re-inventing the wheel by adding recursive copy/clone/delete or whatever, but I think I'll do that soon, a separate patch.
Agreed ;) |
I'll have a look. |
|
On bcachefs, subvolumes share the same st_dev (unlike btrfs), so rmw correctly matched the waste folder by device number but rename() still returned EXDEV when moving across subvolumes. Add a fallback to safe_mv_via_exec() when rename() fails with EXDEV on a same-device move.
Also switch from BTRFS_IOC_CLONE (linux/btrfs.h) to the generic FICLONE ioctl (linux/fs.h), which is supported by any reflink-capable filesystem (btrfs, bcachefs, xfs, etc.), and update the meson header check accordingly.
Add test/test_bcachefs.sh which creates an 8M bcachefs image on-the-fly, exercises cross-subvolume file and directory moves, and cleans up after itself. Skips gracefully when bcachefs kernel support is unavailable.
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com
Fixes #526