Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

virtio/fs: Munge device number into inode number #204

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

asahilina
Copy link
Contributor

virtio-fs can expose multiple host mounts as a single mount. This means that all st_dev numbers from the host get collapsed into a single st_dev, breaking st_ino/st_dev comparisons for file identity.

Short of replicating the mount hierarchy with separate virtio-fs mounts, there's no good way to fix this in all cases. So, do a best-effort hack by XORing st_dev into the top bits of st_ino. This can still have collisions, but it's a lot better than ignoring st_dev entirely (which is very likely to have collisions with multiple mounted filesystems).

Fixes Wine in krun on Fedora systems with separate btrfs subvolumes for / and /home (which causes Wine to think / and /home are the same path, breaking DOS device selection).

virtio-fs can expose multiple host mounts as a single mount. This means
that all st_dev numbers from the host get collapsed into a single
st_dev, breaking st_ino/st_dev comparisons for file identity.

Short of replicating the mount hierarchy with separate virtio-fs mounts,
there's no good way to fix this in all cases. So, do a best-effort hack
by XORing st_dev into the top bits of st_ino. This can still have
collisions, but it's a lot better than ignoring st_dev entirely (which
is very likely to have collisions with multiple mounted filesystems).

Fixes Wine in krun on Fedora systems with separate btrfs subvolumes for
/ and /home (which causes Wine to think / and /home are the same path,
breaking DOS device selection).

Signed-off-by: Asahi Lina <[email protected]>
@asahilina
Copy link
Contributor Author

If this sounds a bit dangerous, one possible improvement here would be to XOR in the st_dev of the root of the virtio-fs mount. That way, inode numbers from the same root mount would be unchanged, and only inodes from other filesystems mounted further down the hierarchy would be mangled.

(On Fedora Asahi that still affects all of /home of course, so it doesn't make much difference since workloads are more likely to be in /home than not...)

@slp
Copy link
Contributor

slp commented Jul 19, 2024

We should probably add support for FUSE's ATTR_SUBMOUNT to announce submounts when parent.st_dev != inode.st_dev. Do you want to give it a try in the PR or should I try to come with another one myself?

virtiofsd already does this, so we can use its implementation as reference.

@slp
Copy link
Contributor

slp commented Jul 19, 2024

#209 can be used as a basis for implementing in on Linux, possibly using mnt_id there in addition to st_dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants