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

Exporting extents / file location on block device #774

Open
thememika opened this issue Nov 2, 2024 · 4 comments
Open

Exporting extents / file location on block device #774

thememika opened this issue Nov 2, 2024 · 4 comments

Comments

@thememika
Copy link

thememika commented Nov 2, 2024

Hello.
Assuming I create a file with the nocow attribute and fully pre-allocate all of needed space (by writing zeroes to the file), and assuming that I have no reflink and no snapshots enabled, is there a way to export the block-layer location of the file from bcachefs, and to safely write there on block level? The original problem is that I created a filesystem that is too big, but shrinking is not supported. Thanks. Loop device on bcachefs is too slow, and causes deadlock if used as Swap, because access through bcachefs is RAM hungry...

@thememika
Copy link
Author

The old good interface used by filefrag utility reports more than 23 thousands of extents for my file. It's just not possible to set up such a table in DeviceMapper, for example. Anyways I'm not sure if it's safe to write to them. i.e. if they can suddenly be relocated and that place can become reused for something else -then it's def not safe.

@thememika
Copy link
Author

thememika commented Nov 2, 2024

DeviceMapper (linear) didn't mind that the table was so huge. I have parsed the filefrag output, and successfully created the mapping to my block device.
I just still really want to know from someone knowledgeable in bcachefs, if this is a safe thing to do.

@thememika
Copy link
Author

For now works ok. I'll post here if something bad happens.

@g2p
Copy link
Contributor

g2p commented Nov 9, 2024

Putting your swap there seems crazy risky, because bcachefs could move the extents at any point (think rebalance, compaction), and you'll be scribbling over data that backs your mounted filesystem. You would have to tackle #368 to do this safely. The way btrfs does it with swap_activate/swap_deactivate could be a good template.

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

No branches or pull requests

2 participants