Page MenuHomeFreeBSD

hyperv/vss: implement the VSS (Volume Shadow Copy Service)
ClosedPublic

Authored by honzhan_microsoft.com on Oct 12 2016, 2:39 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Mar 10, 6:54 PM
Unknown Object (File)
Sun, Mar 10, 6:54 PM
Unknown Object (File)
Thu, Mar 7, 9:34 PM
Unknown Object (File)
Thu, Mar 7, 9:34 PM
Unknown Object (File)
Thu, Mar 7, 9:34 PM
Unknown Object (File)
Thu, Mar 7, 9:34 PM
Unknown Object (File)
Thu, Mar 7, 9:34 PM
Unknown Object (File)
Thu, Mar 7, 9:08 PM
Subscribers
None

Details

Summary

This feature is to support VSS (Volume Shadow Copy Service) on Hyper-V.

VSS is a service on Hyper-V. Any VM wants to support this feature should implement such service on VM side.
When Hyper-V host wants to do a snapshot for a given FreeBSD VM, it sends request of freezing file system to VM. VM freezes its file system, and responses to Hyper-V. Then Hyper-V starts to take snapshot. After that, Hyper-V will inform VM to thaw the file system.

On FreeBSD side, the VSS driver implements the protocol to communicate with Hyper-V host and a user space daemon (hv_vss_daemon). The daemon hv_vss_daemon conducts the real UFS freeze/thaw.

Submitted by: Hongjiang Zhang <honzhan microsoft com>

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

honzhan_microsoft.com retitled this revision from to hyperv/vss: implement the VSS (Volume Shadow Copy Service).

Did we consider the generic apporach to implement suspend inside vfs and VM?

contrib/hyperv/tools/hv_kvp_daemon.c
835 ↗(On Diff #21288)

Suggest to create a separate patch for this renaming.

contrib/hyperv/tools/hv_vss_daemon.c
23

how about zfs? or other filesystem doesn't support suspend?

contrib/hyperv/tools/hv_kvp_daemon.c
835 ↗(On Diff #21288)

hv_kvp_daemon and hv_vss_daemon has something common to share. Error code is one of them. Another is negotiation with host. That is why this patch impacts kvp daemon. Of course, I can separate them to another patch.

contrib/hyperv/tools/hv_vss_daemon.c
23

As I know, ZFS does not support it. I need to double check it. If we want to extend this driver to support the other filesystem, what we need to modify is the daemon. So, the effort is not big.

Do you have specific questions to me, e.g. about the interfaces used ? I definitely would not read the hv daemon code, but sure can answer questions about the supposed use of the FreeBSD interfaces to VFS/VM.

In D8224#170848, @kib wrote:

Do you have specific questions to me, e.g. about the interfaces used ? I definitely would not read the hv daemon code, but sure can answer questions about the supposed use of the FreeBSD interfaces to VFS/VM.

Yeah, that's why I propose him to add you :). Mainly for the UFS freeze syscall.

In D8224#170848, @kib wrote:

Do you have specific questions to me, e.g. about the interfaces used ? I definitely would not read the hv daemon code, but sure can answer questions about the supposed use of the FreeBSD interfaces to VFS/VM.

I'm not sure about the usage of API for freeze/thaw is correct or not. Could you please help me review the file of contrib/hyperv/tools/hv_vss_daemon.c?

As I was told once the file handle for "/dev/ufssuspend" was closed, the freezed file system will be thawed. So, here I implement thaw functionality by close the file handle. Is it correct?

contrib/hyperv/tools/hv_vss_daemon.c
23

This path is already defiined in paths.h.

27

Why do you need additional define for 'unopened handle' ? Common unix practice is to mark closed file descriptor with the -1 value, which is very convenient since error return from open(2) is also -1. Below you test for -1 and UNOPENED_HANDLE, which would remove several lines of code if testing only for -1.

50

Use ANSI C definitions (freeze(void)).

73

space between for and '('.

85

This is excessive. The suspend ioctl does race-free sync when needed (after the writes are blocked), and only for the suspended volume.

96

This is rather useless label. Why not write return (1); instead of all error = 1; goto handle_error; places ?

104

Use ANSI C.

125
static void
usage(const char *cmd)
{

   fprintf();
149

You silently ignore invalid options or stray arguments there.

172

Excessive ().

198

Do not do that. errno values and exit(3) codes are different value spaces. Please see sysexits(3) for common exit(3) codes.

251

This return is not needed, and it is in fact strange to see use of exit() and return mixed in the main() function.

contrib/hyperv/tools/hv_vss_daemon.c
27

Yeah, I'll remove UNOPEND_HANDLE.

73

Yeah.

85

Thanks. That is what I want to confirm.

104

Sure.

125

Thanks for your example.

149

Oh, I need to print usage information for wrong options.

172

Ok.

198

Thanks for pointing this preferable exit.

251

Yes.

contrib/hyperv/tools/hv_vss_daemon.8
79

It was whacked.

include/Makefile
50

Add this after dev/hwpmc. This list is sorted in alphabetic order.

158

Probably after evdev, not acpica. ditto

174

After evdev.

264

After evdev.

sys/dev/hyperv/utilities/hv_snapshot.c
95

Use __packed.

764–765

callout_reset(..., hz * sec, );

sys/dev/hyperv/utilities/hv_snapshot.h
52

Better comment it as: reserved 0.

I have nothing to add beyond the comments made by kib.

This revision was automatically updated to reflect the committed changes.