diff options
| author | Sachin Pandit <spandit@redhat.com> | 2014-10-21 07:57:22 +0530 | 
|---|---|---|
| committer | Raghavendra Bhat <raghavendra@redhat.com> | 2014-12-18 22:53:03 -0800 | 
| commit | 859cdebc2d2b425fd76f46d598ad59933396b279 (patch) | |
| tree | 2ee57f4dca095cd15b59b2eec281627ae468d8ca | |
| parent | df0ff94a64bd597e61f26a2a56297de7abf80a0f (diff) | |
USS : Display only the activated snapshots.
Instead of displaying all the snapshots in the uss world,
it is better if we display only the activated snapshots.
Change-Id: I70d3ec212b62ec15956ae3e826bc4201d8dedd17
BUG: 1170548
Signed-off-by: Sachin Pandit <spandit@redhat.com>
Reviewed-on: http://review.gluster.org/8958
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Avra Sengupta <asengupt@redhat.com>
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
Signed-off-by: Sachin Pandit <spandit@redhat.com>
Reviewed-on: http://review.gluster.org/9242
Reviewed-by: Vijaikumar Mallikarjuna <vmallika@redhat.com>
Reviewed-by: Raghavendra Bhat <raghavendra@redhat.com>
| -rwxr-xr-x | tests/bugs/bug-1045333.t | 1 | ||||
| -rw-r--r-- | tests/bugs/bug-1170548-dont-display-deactivated-snapshots.t | 36 | ||||
| -rwxr-xr-x | tests/snapshot.rc | 16 | ||||
| -rw-r--r-- | xlators/features/snapview-server/src/snapview-server-helpers.c | 98 | ||||
| -rw-r--r-- | xlators/features/snapview-server/src/snapview-server.h | 5 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-snapshot.c | 6 | 
6 files changed, 120 insertions, 42 deletions
diff --git a/tests/bugs/bug-1045333.t b/tests/bugs/bug-1045333.t index d877d14c204..cfba8429642 100755 --- a/tests/bugs/bug-1045333.t +++ b/tests/bugs/bug-1045333.t @@ -13,7 +13,6 @@ TEST setup_lvm 1  TEST $CLI volume create $V0 $H0:$L1  TEST $CLI volume start $V0 -  S1="${V0}-snap1"    #Create snapshot with name contains hyphen(-)  S2="-${V0}-snap2"   #Create snapshot with name starts with hyphen(-)  #Create snapshot with a long name diff --git a/tests/bugs/bug-1170548-dont-display-deactivated-snapshots.t b/tests/bugs/bug-1170548-dont-display-deactivated-snapshots.t new file mode 100644 index 00000000000..4c2e568ae4d --- /dev/null +++ b/tests/bugs/bug-1170548-dont-display-deactivated-snapshots.t @@ -0,0 +1,36 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc +. $(dirname $0)/../snapshot.rc + +cleanup; + +TEST init_n_bricks 2 +TEST setup_lvm 2 +TEST glusterd; + +TEST $CLI volume create $V0 $H0:$L1 $H0:$L2 +TEST $CLI volume start $V0 + +# enable uss and mount the volume +TEST $CLI volume set $V0 features.uss enable +TEST glusterfs --volfile-server=$H0 --volfile-id=$V0 $M0 + +# create 10 snapshots and check if all are being reflected +# in the USS world +TEST gluster snapshot config activate-on-create enable +for i in {1..10}; do $CLI snapshot create snap$i $V0; done +EXPECT 10 uss_count_snap_displayed $M0 + +# snapshots should not be displayed after deactivation +for i in {1..10}; do $CLI snapshot deactivate snap$i --mode=script; done +EXPECT 0 uss_count_snap_displayed $M0 + +# activate all the snapshots and check if all the activated snapshots +# are displayed again +for i in {1..10}; do $CLI snapshot activate snap$i --mode=script; done +EXPECT 10 uss_count_snap_displayed $M0 + +cleanup; + diff --git a/tests/snapshot.rc b/tests/snapshot.rc index 16549ec249f..175344ef5f7 100755 --- a/tests/snapshot.rc +++ b/tests/snapshot.rc @@ -394,3 +394,19 @@ function check_if_snapd_exist() {          pid=$(ps aux | grep "snapd" | grep -v grep | awk '{print $2}')          if [ -n "$pid" ]; then echo "Y"; else echo "N"; fi  } + +# returns number of snapshot being displayed in ".snaps" directory +function uss_count_snap_displayed() { +        local path=$1 +        ls $path/.snaps | wc -l +} + +case $OSTYPE in +NetBSD) +        echo "Skip test on LVM which is not available on NetBSD" >&2 +        SKIP_TESTS +        exit 0 +        ;; +*) +        ;; +esac diff --git a/xlators/features/snapview-server/src/snapview-server-helpers.c b/xlators/features/snapview-server/src/snapview-server-helpers.c index 0817e145e26..46e7d49a036 100644 --- a/xlators/features/snapview-server/src/snapview-server-helpers.c +++ b/xlators/features/snapview-server/src/snapview-server-helpers.c @@ -395,8 +395,9 @@ out:          return;  } +/* priv->snaplist_lock should be held before calling this function */  snap_dirent_t * -svs_get_snap_dirent (xlator_t *this, const char *name) +__svs_get_snap_dirent (xlator_t *this, const char *name)  {          svs_private_t      *private     = NULL;          int                 i           = 0; @@ -404,45 +405,36 @@ svs_get_snap_dirent (xlator_t *this, const char *name)          snap_dirent_t      *tmp_dirent  = NULL;          snap_dirent_t      *dirent      = NULL; -        GF_VALIDATE_OR_GOTO ("snapview-server", this, out); -        GF_VALIDATE_OR_GOTO (this->name, this->private, out); -        GF_VALIDATE_OR_GOTO (this->name, name, out); -          private = this->private; -        LOCK (&private->snaplist_lock); -        { -                dirents = private->dirents; -                if (!dirents) { -                        goto unlock; -                } +        dirents = private->dirents; +        if (!dirents) { +                goto out; +        } -                tmp_dirent = dirents; -                for (i = 0; i < private->num_snaps; i++) { -                        if (!strcmp (tmp_dirent->name, name)) { -                                dirent = tmp_dirent; -                                break; -                        } -                        tmp_dirent++; +        tmp_dirent = dirents; +        for (i = 0; i < private->num_snaps; i++) { +                if (!strcmp (tmp_dirent->name, name)) { +                        dirent = tmp_dirent; +                        break;                  } +                tmp_dirent++;          } -unlock: -        UNLOCK (&private->snaplist_lock); -out: + out:          return dirent;  }  glfs_t * -svs_initialise_snapshot_volume (xlator_t *this, const char *name) +__svs_initialise_snapshot_volume (xlator_t *this, const char *name)  { -        svs_private_t      *priv              = NULL; -        int32_t             ret               = -1; -        snap_dirent_t      *dirent            = NULL; -        char                volname[PATH_MAX] = {0, }; -        glfs_t             *fs                = NULL; -        int                 loglevel          = GF_LOG_INFO; -        char                logfile[PATH_MAX] = {0, }; +        svs_private_t      *priv                = NULL; +        int32_t             ret                 = -1; +        snap_dirent_t      *dirent              = NULL; +        char                volname[PATH_MAX]   = {0, }; +        glfs_t             *fs                  = NULL; +        int                 loglevel            = GF_LOG_INFO; +        char                logfile[PATH_MAX]   = {0, };          GF_VALIDATE_OR_GOTO ("snapview-server", this, out);          GF_VALIDATE_OR_GOTO (this->name, this->private, out); @@ -450,10 +442,10 @@ svs_initialise_snapshot_volume (xlator_t *this, const char *name)          priv = this->private; -        dirent = svs_get_snap_dirent (this, name); +        dirent = __svs_get_snap_dirent (this, name);          if (!dirent) { -                gf_log (this->name, GF_LOG_ERROR, "snap entry for name %s " -                        "not found", name); +                gf_log (this->name, GF_LOG_ERROR, "snap entry for " +                        "name %s not found", name);                  goto out;          } @@ -466,6 +458,7 @@ svs_initialise_snapshot_volume (xlator_t *this, const char *name)          snprintf (volname, sizeof (volname), "/snaps/%s/%s",                    dirent->name, dirent->snap_volname); +          fs = glfs_new (volname);          if (!fs) {                  gf_log (this->name, GF_LOG_ERROR, @@ -483,13 +476,6 @@ svs_initialise_snapshot_volume (xlator_t *this, const char *name)                  goto out;          } -        ret = glfs_init (fs); -        if (ret) { -                gf_log (this->name, GF_LOG_ERROR, "initing the " -                        "fs for %s failed", dirent->name); -                goto out; -        } -          snprintf (logfile, sizeof (logfile),                    DEFAULT_SVD_LOG_FILE_DIRECTORY "/%s-%s.log",                    name, dirent->uuid); @@ -501,6 +487,13 @@ svs_initialise_snapshot_volume (xlator_t *this, const char *name)                  goto out;          } +        ret = glfs_init (fs); +        if (ret) { +                gf_log (this->name, GF_LOG_ERROR, "initing the " +                        "fs for %s failed", dirent->name); +                goto out; +        } +          ret = 0;  out: @@ -509,8 +502,33 @@ out:                  fs = NULL;          } -        if (fs) +        if (fs) {                  dirent->fs = fs; +        } + +        return fs; +} + +glfs_t * +svs_initialise_snapshot_volume (xlator_t *this, const char *name) +{ +        glfs_t             *fs   = NULL; +        svs_private_t      *priv = NULL; + +        GF_VALIDATE_OR_GOTO ("snapview-server", this, out); +        GF_VALIDATE_OR_GOTO (this->name, this->private, out); +        GF_VALIDATE_OR_GOTO (this->name, name, out); + +        priv = this->private; + +        LOCK (&priv->snaplist_lock); +        { +                fs = __svs_initialise_snapshot_volume (this, name); +        } +        UNLOCK (&priv->snaplist_lock); + + +out:          return fs;  } diff --git a/xlators/features/snapview-server/src/snapview-server.h b/xlators/features/snapview-server/src/snapview-server.h index 47effb19758..6033c0e250f 100644 --- a/xlators/features/snapview-server/src/snapview-server.h +++ b/xlators/features/snapview-server/src/snapview-server.h @@ -214,8 +214,11 @@ svs_get_latest_snapshot (xlator_t *this);  glfs_t *  svs_initialise_snapshot_volume (xlator_t *this, const char *name); +glfs_t * +__svs_initialise_snapshot_volume (xlator_t *this, const char *name); +  snap_dirent_t * -svs_get_snap_dirent (xlator_t *this, const char *name); +__svs_get_snap_dirent (xlator_t *this, const char *name);  int  svs_mgmt_init (xlator_t *this); diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index a36e4043d32..66935154608 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -7511,6 +7511,8 @@ glusterd_snapshot_postvalidate (dict_t *dict, int32_t op_ret, char **op_errstr,                  break;          case GF_SNAP_OPTION_TYPE_ACTIVATE:          case GF_SNAP_OPTION_TYPE_DEACTIVATE: +                glusterd_fetchsnap_notify (this); +                break;          case GF_SNAP_OPTION_TYPE_STATUS:          case GF_SNAP_OPTION_TYPE_CONFIG:          case GF_SNAP_OPTION_TYPE_INFO: @@ -8280,6 +8282,10 @@ glusterd_snapshot_get_volnames_uuids (dict_t *dict,          list_for_each_entry_safe (snap_vol, tmp_vol, &volinfo->snap_volumes,                                    snapvol_list) { + +                if (GLUSTERD_STATUS_STARTED != snap_vol->status) +                        continue; +                  snapcount++;                  /* Set Snap Name */  | 
