glusterfs icon indicating copy to clipboard operation
glusterfs copied to clipboard

Snapshot: improvements

Open amarts opened this issue 9 years ago • 30 comments

I currently have 2 branches related to snapshots on GlusterFS.

https://github.com/major0/glusterfs/tree/lvm-snapshot-cleanup Based code from Sriram that I found on GitHub, though I removed the ZFS code from Sriram's patches and created this LVM-only branch. Subsequent changes to this branch where done i response to changes necessary to implement support for btrfs snapshots (and cleanup a memory leak in the missed-snapshot code)...

https://github.com/major0/glusterfs/tree/btrfs-snapshots This code is branched from my lvm-snapshot-cleanup branch and is directly dependant on the changes contained there-in.

Both of these branches are currently in-flux, and I have been performing regular rebasing against the GlusterFS master branch.

Btrfs snapshots currently work and have been tested on Ubuntu 16.04, though the process for configuring btrfs for gluster snapshots has not yet been documented.

Required interfaces to support hard-coded snapshot support can be found: https://github.com/major0/glusterfs/blob/lvm-snapshot-cleanup/xlators/mgmt/glusterd/src/snapshot/glusterd-lvm-snapshot.h

It should be relatively straight-forward to package up these interfaces into a structure of function pointers and allow glusterd to itterate the array firing off the glusterd_is__brick() function at the path to figure out which subsystem to use.

@major0

amarts avatar Mar 24 '17 12:03 amarts

Went through the total PR (ie, git diff origin/master), changes look fine. Even though I recommend getting these as 2 separate patches in gerrit.

  1. LVM snapshot cleanup branch merged into one,
  2. All changes from btrfs snapshot branch to get in there.

@samikshan @atinmu would like you to have a look on GlusterD changes. If everything is OK, we should be taking these in.

amarts avatar Mar 28 '17 07:03 amarts

@amarts Ack. Any specific timeline are we looking at?

atinmu avatar Mar 28 '17 07:03 atinmu

@atinmu As for the feature alone, i guess targetting 4.0 is good. But helps us to have it before 3.11 cut-off date, so in case there is a huge demand to backport, we can consider it.

@rajeshjoseph @avra any thoughts? I don't have Sriram's github id to add here.

amarts avatar Mar 28 '17 08:03 amarts

2 separate patches would be good. I am going through the changes. Will provide the feedback.

On Tue, Mar 28, 2017 at 3:36 AM, Amar Tumballi [email protected] wrote:

Went through the total PR (ie, git diff origin/master), changes look fine. Even though I recommend getting these as 2 separate patches in gerrit.

  1. LVM snapshot cleanup branch merged into one,
  2. All changes from btrfs snapshot branch to get in there.

@samikshan https://github.com/samikshan @atinmu https://github.com/atinmu would like you to have a look on GlusterD changes. If everything is OK, we should be taking these in.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gluster/glusterfs/issues/145#issuecomment-289688403, or mute the thread https://github.com/notifications/unsubscribe-auth/AAmAbEEbsXcdj3nMH7p89fbf7yDtoF2oks5rqLiWgaJpZM4MoNiB .

raghavendrabhat avatar Mar 28 '17 13:03 raghavendrabhat

The LVM branch has a memory-leak bug-fix for the upstream code that can be split from the LVM patch as a possible consideration for an earlier release: https://github.com/major0/glusterfs/commit/4ba82ca7614b85745205913abfadb2de78054fd3

Further more, in the btrfs branch is a proposed change to the mount-point detection code that should be file system agnostic while allowing btrfs subvols to be used for bricks. https://github.com/major0/glusterfs/commit/8ffc22cb762299cf9b07d4385e607ffb0fa67718

I believe Sriram's GitHub ID is @sriramster (See: https://github.com/sriramster/glusterfs)

major0 avatar Mar 28 '17 16:03 major0

@major0 Sorry for the delayed response. Was going through both your branches, from the initial discussion's we'd planned to move the snapshot implementation something like this: $ROOT/xlators/mgmt/glusterd/plugins/snapshot/src/

I see from your branch, the code being moved into xlators/mgmt/glusterd/src/snapshot.

Was this change intentional?

sriramster avatar Mar 29 '17 06:03 sriramster

@raghavendrabhat thanks for looking into these. Once @sriramster also looks into @major0's changes, we can finalize on this.

amarts avatar Mar 29 '17 08:03 amarts

Moving the code elsewhere is easily done, but was outside of my primary goal of simply figuring which interfaces were needed. I am also not certain what sort of plug-in support was being targeted/proposed. dlopen() of plug-in modules vs simple shared objects vs just segregating the code. Even now all I really know is that there are interfaces being proposed that have a lot of overlap with working code.

My first-pass focus was to untangle the LVM code from the rest of glusterd such that I could figure out how much of the code was in-fact LVM specific vs simply named using LVM naming. To that end I chose simple code-segregation as that allowed me to focus my primary efforts on code clean-up/clarity (and mucking with automake and source code directory structure was IMHO a distraction).

My second-pass focus was to attempt to implement BTRFS & ZFS snapshots as a method or proving/testing my LVM modifications (as well as challenge my assumptions about the code base and the direction I was going). The work in implementing BTRFS support resulted in extra modifications being made to the LVM code to make some things more generic. Generally I feel the BTRFS case is the more difficult case, and I had hoped that by focusing on supporting it that the final snapshot API would be generic enough to support everything else fairly easily.

To that end, my branches reflect my efforts up to this point.

I still have a number of things I am working on in the BTRFS side before I can spin up ZFS code, but I have not had much time this week to get them ironed out.

  1. The BTRFS code doesn't support returning size information about snapshots (requires enabling quotas on the btrfs file system).
  2. I need to figure out how to sanely implement configuration keys for specifying things such as btrfs-snapshot-subvol-prefix instead of hard-coding @.
  3. Documentation.
  4. Automated testing.

I also suspect that the LVM, ZFS, and BTRFS snapshots can be more easily implemented moving to library interfaces instead of the runner() API, but I feel that is an issue for later.

major0 avatar Mar 29 '17 15:03 major0

@major0 Ok. @amarts If the case mentioned by Mark goes, then these patches cannot be directly merged into master. Since it'd add a overhead of moving the code back again to the structure mentioned by Rajesh.

My work, was based on moving the patches to a directory outside that of glusterd. May be we might have to rework these patches to fit into the structure. Or if you guys have suggestions lets discuss. Thanks.

sriramster avatar Mar 29 '17 16:03 sriramster

Well, nothing in the patches (outside of changes to the Makefile.am) is directly tied to the current directory structure. If the goal is to move them to outside the directory that can be done, but how they are used by glusterd becomes a substantial question (and design decision) IMHO.

  1. Some sort of shared/static library that glusterd links to.
  2. Dynamic interface which can be loaded by glusterd as necessary (dlopen())
  3. Individual scripts/binaries which glusterd can call out to via the runner() API?

Moving the sources outside of glusterd would, I assume, imply they are no longer going to be compiled into glusterd and is a much larger (and complicated) issue than the work I have done.

major0 avatar Mar 29 '17 19:03 major0

Can we do it as a 2 step development?

  1. Patches as is: Helps to validate, test and fix the overall snapshot code for btrfs / lvm snapshot, and also a quick edits to support ZFS if required.: Timeframe - 3.11/3.12 (Anytime before July to merge the code)?

  2. Moving the whole snapshot management as a separate tool which we can dlopen() etc etc: Look at the integration with glusterd2. Timeframe: 4.0 (Anytime before october 15th, 2017).

@sriramster @raghavendrabhat @rajeshjoseph @major0 ??

amarts avatar Mar 31 '17 07:03 amarts

IMHO, it would be great keep making smaller progress than a big giant step/leap. But its the call of people involved in this effort to see which will be easier to support, better to solve the problems, and finally a cleaner software solution. (in my experience, keeping the above order for development always helps).

amarts avatar Mar 31 '17 07:03 amarts

@major0 I'd pushed in the work based on creating a library shared one, which @rajeshjoseph (Rajesh Joseph)'d proposed initally in the design for creating a plugin architecture. And on compile time, we'd the choice of choosing the binary (LVM/ZFS/any_other).

https://docs.google.com/document/d/1dHij_oy8V8CF2I7WfdYqKXFTGw0SKGzGlngDBpSwSGc/edit

The document captures all the discussion and work we'd done for the same. There would'nt be too much of an overhead if we move the code out of glusterd except for the code isolation (i.e the plugin would be unaware of glusterd implementations) which is what is needed for any future seamless integration of any new tool.

Let me know your thoughts.

@amarts Agreed, we'd plans to do the same push code in smaller chunks. First task was to move LVM specific code out of glusterd/ and move it into plugins.

sriramster avatar Apr 02 '17 06:04 sriramster

@sriramster At this point I am not certain what the definition of a plugin is in this conversation. The term seems to be used to reference moving code into something maybe called libglusterd-snapshots.so which will contain LVM, ZFS, and BTRFS interfaces, and using a separate Makefile.am to build/install them and then link glusted against it (we need to be able to compile all backend snapshot types into this .so at the same time since OS vendors do not know what sort of file systems their users will be using). Is this correct? If this is the case then I am fairly confused as to what the gain is outside of code separation. I can easily perform the git move command to do this .. but .. why?

I am not entirely certain how this document was drawn up (https://docs.google.com/document/d/1dHij_oy8V8CF2I7WfdYqKXFTGw0SKGzGlngDBpSwSGc), but I have doubts as to the ability for these interfaces to be implemented within the current glusterd code base .. in part because many of these interfaces require we rewrite glusterd to stop using generic interfaces that don't need special snapshot knowledge (E.g. snapshot_restore(), snapshot_mount()). Further more, there is an implication that the snapshot interface is going to replicate data already stored and tracked by glusterd (brickinfo->fstype).

If we delete snapshot_mount() and snapshot_restore() from the proposed API (the glusterd versions are generic and do not need to know anything about the backend snapshot types), and we replace snapshot_status() w/ snapshot_details(), AND we use the glusterd_is_(lvm|btrfs|zfs)_brick() functions for probing the bricks for snapshot types .. then the proposed plugin API looks the same as the API I am using with the exception of not being contained to a structure of function pointers. Adding this structure is pretty cut and dry, I am just not certain where to place it (brickinfo->snapshot maybe?). If someone has a good suggestion I can implement the details in less time then it took to write this post.

Unfortunately. the assumption of snap_device in the glusterd code (and the proposed API) is something a problem for btrfs support, since snapshots in btr do not operate against /dev/ and as such there is no way for a seamless integration of btrfs with the current proposal. Even my current code pulls something of a hack to make btrfs work (via the snapshot_device() function .. which LVM support needs but the proposed API lacks), and fixing this universally will require a good deal of overhaul in glusterd and the snapshot code. For now I was content to hack around the assumption and use it as a learning experience for future interfaces.

major0 avatar Apr 02 '17 08:04 major0

I have been reading and re-reading the document (https://docs.google.com/document/d/1dHij_oy8V8CF2I7WfdYqKXFTGw0SKGzGlngDBpSwSGc) with the proposed architecture and have a few issues/questions I would like clarified:

  1. The document does not outline the ultimate goal of the model. It frequently refers to a "plugin model" but proceeds to describe an API with no reference to what sort of method will be used to load/unload the API. On the 3rd page of the document, under the definition of plugins the document basically describes linking the plugins as a static or shared library .. this seems to confirm that the document is attempting to use the term plugin to as a redefinition of API and has little to do with actually defining a pluggable interface in the traditional sense of being able to run-time load/unload interfaces. So is the document describing a plugin interface, or an API? If it is a plugin interface, what is the method which will be used for plugging/unplugging the interface?
  2. The document claims that each snapshot plugin should be named after the file-system the snapshot interface supports and gives xfs as an example. This is misleading in that XFS does not support snapshots, but rather thin-provisioned LVM is handling the snapshots, as such the fs-type has little, if anything, to do with the availability of the plugin to be useful. The only file-systems that natively support snapshots are btrfs (gluster snapshots currently work) and zfs (code should be done shortly). It seems the document has ignored the possibility of performing lvm+ext2/3/4 and the like. What will be the naming convention of lvm+xfs vs lvm+ext2/3/4, is there a reason to even make a distinction considering the interface code in question is LVM specific and not FS specific.
  3. Document lists the following interfaces: snapshot_(create|delete|restore|status|mount), as well as referencing "Externalize", "Internalize", "Fetch_backend_info". Of these interfaces, there is no explanation as to the purpose of "Externalize", "Internalize" and "Fetch_backend_info" and no hint as to why they are even included in the document... what are these for? Of the snapshot_*() interfaces, 2 require a rewrite of huge swaths of the glusterd code such that it no longer utilizes generic storage-agnostic restore and mount interfaces (currently glusterd assumes that given a source_path and mount_options it can mount any file-system .. an assumption which is generally valid). Migrating that code into the snapshot back-end seems to be begging to create copy/paste code (since everything only needs the src-path and the mount options).
  4. The specified snapshot_status() is undocumented, but I assume it is an a request to rename the existing glusterd_get_brick_lvm_details() interface .. if not then what is the purpose of the status() interface?
  5. Document describes adding fstype to the brickinfo_t structure, which seems sort of odd considering brickinfo->fstype is already valid (and heavily used within glusterd).
  6. There is a reference to a backend-specific structure. I assume this is effectively referring to the ever common struct->priv, but gives no example as to what sort of data would make use of this interface .. or why it was believed to be necessary (premature optimization?).

Generally I feel the document is not really describing a plug-in interface so much as it is describing a proposed API. Some of these proposals are fairly drastic, and there is no explanation given as to why such drastic changes are necessary (E.g. snapshot_mount()).

In so much as future direction, I personally feel the right approach generally follows:

  1. Re-factor the LVM portion of the code such that true LVM specific interfaces are self-contained to their own file and make it easier to add new interfaces. (done)
  2. Add a new interface to "test" the current restructure and continue re-factoring such that both the old and new systems use the same interfaces. (btrfs done)
  3. Outline possible changes to the code-base that can be made to reduce the number of interfaces that are necessary. E.g. can an interface be made more generic. (in-progress)
  4. Add more interfaces. (in-progress)

Whether or not the final code lives in src/foo vs src/bar has little to no effect on the functionality of the code. If anything, debating the directory the final code lives in at such an early stage of development is, IMHO, embracing "premature optimization".

major0 avatar Apr 11 '17 03:04 major0

As a point of interest I have captured the output from my btrfs-snapshot tests using Vagrant. The log includes mkfs.btrfs, creation and status of the testvol, testsnap, and testclone: https://gist.github.com/major0/246f1eafc42ceb075e1bb3043d26ad29

major0 avatar Apr 12 '17 19:04 major0

I think the proposal can be vastly simplified by maintaining an array of structures with function pointers to appropriate snapshot operations. We could have separate self-contained files for each backend that is supported. brickinfo->fstype or a switch could be used to determine the appropriate set of handlers to be invoked for performing snapshot operations. Thoughts?

vbellur avatar Apr 13 '17 01:04 vbellur

@vbellur generally I agree, though I do not know that it will simplify things that much. The current code changes already keep each snapshot back-end handler in separate files. E.g. glusterd-btrfs-snapshot.c, glusterd-lvm-snapshot.c, glusterd-zfs-snapshot.c, and the interfaces are already fairly minimal.

Still, as suggested, I have made the changes to support a structure of function pointers per back-end and added an array of back-ends. This was relatively straight forward as it was mostly just a matter of replacing the if/else back-end checks with if (glusterd_snapshot_probe(path, brickinfo)) and adding the structures of function pointers to each of the backends. The rest of the code has generally remained untouched.

LVM changes: https://github.com/major0/glusterfs/tree/lvm-snapshot-cleanup BTRFS support (includes LVM changes repo): https://github.com/major0/glusterfs/tree/btrfs-snapshots

Basic create/snap/clone test results w/ btrfs:https://gist.github.com/major0/246f1eafc42ceb075e1bb3043d26ad29

If there are further clean-ups/changes/suggestions please let me know. Until then I am going to see about finishing up the ZFS back-end.

major0 avatar Apr 13 '17 21:04 major0

ZFS Snapshots are working.

  • LVM Changes: https://github.com/major0/glusterfs/tree/lvm-snapshot-cleanup
  • BTRFS Changes: https://github.com/major0/glusterfs/tree/btrfs-snapshots
  • ZFS Changes: https://github.com/major0/glusterfs/tree/zfs-snapshots
  • All changes merged into one repo: https://github.com/major0/glusterfs/tree/glusterfs-snapshots

The log of the basic create/snap/clone tests w/ zfs: https://gist.github.com/major0/48caeae9896ac5682f42b756cdc9530a

At this time I am working on fixing up glusterd_mount_brick_paths() such that all supported snap-types are properly mounted after a reboot.

major0 avatar Apr 14 '17 21:04 major0

Hi Mark,

Thanks for the changes. I will review them.

Regards, Raghavendra

On Fri, Apr 14, 2017 at 5:29 PM, Mark Ferrell [email protected] wrote:

ZFS Snapshots are working.

  • LVM Changes: https://github.com/major0/glusterfs/tree/lvm-snapshot- cleanup
  • BTRFS Changes: https://github.com/major0/ glusterfs/tree/btrfs-snapshots
  • ZFS Changes: https://github.com/major0/glusterfs/tree/zfs-snapshots
  • All changes merged into one repo: https://github.com/major0/ glusterfs/tree/glusterfs-snapshots https://github.com/major0/glusterfs/tree/glusterfs-snapshots

The log of the basic create/snap/clone tests w/ zfs: https://gist.github.com/major0/48caeae9896ac5682f42b756cdc9530a

At this time I am working on fixing up glusterd_mount_brick_paths() such that all supported snap-types are properly mounted after a reboot.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/gluster/glusterfs/issues/145#issuecomment-294240350, or mute the thread https://github.com/notifications/unsubscribe-auth/AAmAbC9dQbs6eHq-YZvL7gQdEutqltWrks5rv-UggaJpZM4MoNiB .

raghavendrabhat avatar Apr 17 '17 14:04 raghavendrabhat