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

Feature request: moving datasets #13393

Open
clarfonthey opened this issue Apr 30, 2022 · 12 comments
Open

Feature request: moving datasets #13393

clarfonthey opened this issue Apr 30, 2022 · 12 comments
Labels
Type: Feature Feature request or new feature

Comments

@clarfonthey
Copy link

clarfonthey commented Apr 30, 2022

Describe the feature would like to see added to OpenZFS

I would like to see the ability to live move datasets. In other words zfs rename should be able to work for mounted datasets, and zfs set mountpoint=... should be able perform some kind of mount --move operation.

Presumably, this would work recursively, transferring snapshots and child datasets.

How will this feature improve OpenZFS?

It would be extremely desirable to be able to rename or move datasets that are currently in use, for example, moving /var/log from one physical drive to another. Since it's difficult to configure an existing system to unmount these filesystems without booting into another system (it can be done, since it's done at shutdown, but it's a huge pain), letting the user simply move these datasets over would be incredibly useful. Obviously, this substantially increases the complexity of the implementation, but it could be very useful for administering systems.

Additional context

For cross-pool moves:

  1. Set a quota on the old dataset to ensure that it cannot become larger than the space of the target dataset (e.g. moving from a large volume to a smaller one). This could potentially be configurable, with the quota being the size of the data plus some "wiggle room" for extra writes.
  2. Pause all dataset-related operations on the source dataset.
  3. Create the new dataset with the same options as the old one, also with an inability to perform dataset-related operations. Make sure the dataset is unmounted and reserved with an adequate amount of space.
  4. Start copying over data from the old dataset to the new dataset.
  5. During this process, writes to the dataset are still allowed, but they may need to be throttled to ensure that the copying of old data outpaces the writing of new data.
  6. Once the datasets are synced, pause all I/O operations on the old dataset.
  7. If the dataset is mounted, modify all open files to point to the new dataset.
  8. Unmount the old dataset and put the new dataset in its place.
  9. Unpause I/O.
  10. Destroy the old dataset.

For same-pool moves, probably several of the above steps are redundant, but I'm not 100% sure how many of them are.

I think I've seen discussions of this before, but did a quick search and saw no open features here on it. Apologies if there is some existing discussion somewhere else that I didn't find.

@clarfonthey clarfonthey added the Type: Feature Feature request or new feature label Apr 30, 2022
@nabijaczleweli
Copy link
Contributor

How's this different from zfs rename (or, for the simpler case, zfs set mountpoint=)?

@rincebrain
Copy link
Contributor

rincebrain commented Apr 30, 2022

Or mount --move.

I suspect the functionality desired here could be implemented with purely userland work, since it seems like they'd like a readonly version at the old mountpoint and a readwrite at the new, and since we allowed multiple mounting of a dataset, we could probably do it...

Well, most of it. I don't know that there's anything short of horrific reaching around in the kernel that's going to let you go tell old FDs that their paths changed unless something like mount --move does that for you already.

@clarfonthey
Copy link
Author

So, when I created this, I for some reason had no idea that zfs rename existed. I guess that I had been relying on knowledge since before it did, and then just for some reason never found out when it was implemented.

At some point I'll reword the OP to make this issue specifically about moving online datasets, rather than offline ones, since that's the thing that doesn't exist right now.

I was under the impression that something along these lines existed in some other filesystem, but I could have been mistaken. I guess that everything right now is flexible in terms of the actual data moving on disk (for example, via replication or devices being added/removed from a pool) but not the data moving between physical mounts. I'm not actually sure how file handlers are done in ZFS on Linux, and whether they're forced to be linked to the specific dataset or can actually be moved within a zpool. Because most of my use cases are things like moving pool/log to pool/data/log, etc., with the dataset being mounted at /var/log.

@rincebrain
Copy link
Contributor

rincebrain commented May 3, 2022 via email

@clarfonthey
Copy link
Author

Yeah, I must have just been compounding misunderstandings when I didn't know that zfs rename existed, or that it allowed changing the nesting of datasets.

Anyway, updated the original description to reference zfs rename and mount --move, so that hopefully it's a bit clearer what's being requested.

@GregorKopka
Copy link
Contributor

I would be happy if zfs rename would not remount a filesystem in case the effective mountpoint does not change.

@ghost
Copy link

ghost commented Feb 11, 2023

Is zfs rename -u what you're looking for? I suppose you might want it automatically...

@GregorKopka
Copy link
Contributor

GregorKopka commented Feb 12, 2023

Is zfs rename -u what you're looking for? I suppose you might want it automatically...

Apart from having missed that this option exists by now (thanks for the info):
Yes.

An operation (or a part of it) that is an effective NOP should IMHO not have side effects.

@clarfonthey
Copy link
Author

Oh huh, glad to know that zfs rename -u exists now.

This is a bit of an awkward side effect though, since can't ZFS perform some kind of mount --move operation when setting mountpoint normally? It would be nice to combine this effect in the command somehow, although I'm not sure if that just transparently unmounts and remounts instead.

@rincebrain
Copy link
Contributor

It unmounts/remounts, AFAIK.

@clarfonthey
Copy link
Author

I don't have the time to look into this right now, but if that's the case it may make more sense to close this issue and open an issue specifically on using mount --move instead of unmounting & remounting volumes when changing mount points. If someone else wants to open an issue elaborating on that, feel free, otherwise I'll do it when I get around to it.

@rincebrain
Copy link
Contributor

Seems reasonable to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature Feature request or new feature
Projects
None yet
Development

No branches or pull requests

4 participants