gluster / glusterfs

Gluster Filesystem : Build your distributed storage in minutes
https://www.gluster.org
GNU General Public License v2.0
4.54k stars 1.07k forks source link

snapshots: plugin architecture #2834

Closed aravindavk closed 2 years ago

aravindavk commented 2 years ago

A few plugin APIs are based on below repo. New plugin methods are added that were not present in the initial code, also some of the methods like getting device, missed_snaps are removed.

https://github.com/major0/glusterfs/commits/glusterfs-snapshots

Retained the original authors. This PR contains only the code changes that are required to make the current glusterd code pluggable.

ZFS and Btrfs plugins from the above glusterfs fork are not included in this PR. Those will be sent as separate PRs with tests.

Every plugin should implement the following Struct

struct glusterd_snap_ops {
    /* Name of the Plugin */
    const char *name;

    /* To check if a plugin is supported or not */
    gf_boolean_t (*const probe)(
        char *brick_path
    );

    /* To get usage details */
    int (*const details)(
        dict_t *rsp_dict,
        glusterd_brickinfo_t *snap_brickinfo,
        char *key_prefix
    );

    /* Create the Snapshot */
    int32_t (*const create)(
        glusterd_brickinfo_t *snap_brickinfo,
        char *snapname,
        char *snap_volume_id,
        int32_t brick_num
    );

    /* Create a Clone */
    int32_t (*const clone)(
        glusterd_brickinfo_t *snap_brickinfo,
        char *snapname,
        char *snap_volume_id,
        char *clonename,
        char *clone_volume_id,
        int32_t brick_num
    );

    /* Remove a Snapshot */
    int32_t (*const remove)(
        glusterd_brickinfo_t *snap_brickinfo,
        char *snapname,
        char *snap_volume_id,
        int32_t brick_num
    );

    /* Activate and Mount a Snapshot */
    int32_t (*const activate)(
        glusterd_brickinfo_t *snap_brickinfo,
        char *snapname,
        char *snap_volume_id,
        int32_t brick_num
    );

    /* Unmount and Deactivate a Snapshot */
    int32_t (*const deactivate)(
        glusterd_brickinfo_t *snap_brickinfo,
        char *snapname,
        char *snap_volume_id,
        int32_t brick_num
    );

    /* Restore a Snapshot */
    int32_t (*const restore)(
        glusterd_brickinfo_t *snap_brickinfo,
        char *snapname,
        char *snap_volume_id,
        int32_t brick_num,
        gf_boolean_t *retain_origin_path
    );

    /* Brick Path of a Snapshot/Clone */
    int32_t (*const brick_path)(
        char *snap_mount_dir,
        int clone,
        char *snap_clone_name,
        char *snap_clone_volume_id,
        char *snap_brick_dir,
        int brick_num,
        char **snap_brick_path
    );
};

Change-Id: I3c8b8b0801d8b6f03362494e2ccf672e569071db Updates: #145 Signed-off-by: Sriram Raghunathan sriram@marirs.net.in Signed-off-by: Mark Ferrell major@homeonderanged.org Signed-off-by: Aravinda Vishwanathapura aravinda@kadalu.io

amarts commented 2 years ago

/run regression