mirror of
https://github.com/Zygo/bees.git
synced 2025-05-17 21:35:45 +02:00
roots: move flags check after file identity checks and make error message style consistent
If we lose a race and open the wrong file, we will not retry with the next path if the file we opened had incompatible flags. We need to keep trying paths until we open the correct file or run out of paths. Fix by moving the inode flag check after the checks for file identity. Output attributes in hex to be consistent with other attribute error messages. There is no need to report root and file paths separately in the error message for incompatible flags because we have confirmed the identity of the file before the incompatible flag error is detected. Other messages in this loop still output root path and file_path separately because the identity of 'rv' is unknown at the time these messages are emitted. Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
parent
702a8eec8c
commit
339579096f
@ -576,14 +576,6 @@ BeesRoots::open_root_ino_nocache(uint64_t root, uint64_t ino)
|
||||
break;
|
||||
}
|
||||
|
||||
int attr = ioctl_iflags_get(rv);
|
||||
if (attr & FS_NOCOW_FL) {
|
||||
BEESLOG("Opening " << name_fd(root_fd) << "/" << file_path << " found incompatible flags " << attr << " (FS_NOCOW_FL)");
|
||||
rv = Fd();
|
||||
BEESCOUNT(open_wrong_flags);
|
||||
break;
|
||||
}
|
||||
|
||||
// Correct root?
|
||||
auto file_root = btrfs_get_root_id(rv);
|
||||
if (file_root != root) {
|
||||
@ -602,6 +594,27 @@ BeesRoots::open_root_ino_nocache(uint64_t root, uint64_t ino)
|
||||
break;
|
||||
}
|
||||
|
||||
// As of 4.12 the kernel rejects dedup requests with
|
||||
// src and dst that have different datasum flags.
|
||||
//
|
||||
// We can't detect those from userspace reliably, but
|
||||
// we can detect the common case where one file is
|
||||
// marked with the nodatasum (which implies nodatacow)
|
||||
// on a filesystem that is mounted with datacow.
|
||||
// These are arguably out of scope for dedup.
|
||||
//
|
||||
// To fix this properly, we have to keep track of which
|
||||
// pairs of inodes failed to dedup, guess that the reason
|
||||
// for failure was a mismatch of datasum flags, and
|
||||
// create temporary files with the right flags somehow.
|
||||
int attr = ioctl_iflags_get(rv);
|
||||
if (attr & FS_NOCOW_FL) {
|
||||
BEESLOG("Opening " << name_fd(rv) << " found FS_NOCOW_FL flag in " << to_hex(attr));
|
||||
rv = Fd();
|
||||
BEESCOUNT(open_wrong_flags);
|
||||
break;
|
||||
}
|
||||
|
||||
BEESTRACE("mapped " << BeesFileId(root, ino));
|
||||
BEESTRACE("\tto " << name_fd(rv));
|
||||
BEESCOUNT(open_hit);
|
||||
|
Loading…
x
Reference in New Issue
Block a user