diff options
| -rw-r--r-- | tests/bugs/snapshot/bug-1227646.t | 32 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-snapshot.c | 1 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 22 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.h | 4 | 
4 files changed, 44 insertions, 15 deletions
diff --git a/tests/bugs/snapshot/bug-1227646.t b/tests/bugs/snapshot/bug-1227646.t new file mode 100644 index 00000000000..643d814e2ee --- /dev/null +++ b/tests/bugs/snapshot/bug-1227646.t @@ -0,0 +1,32 @@ +#!/bin/bash + +. $(dirname $0)/../../volume.rc +. $(dirname $0)/../../snapshot.rc +. $(dirname $0)/../../include.rc + +cleanup; + +TEST init_n_bricks 3; +TEST setup_lvm 3; + +TEST glusterd; +TEST pidof glusterd; + +#TEST $CLI volume create $V0 $H0:$L1 $H0:$L2 $H0:$L3; +TEST $CLI volume create $V0 $H0:$L2 $H0:$L3; +TEST $CLI volume start $V0; + +TEST $CLI snapshot create snap1 $V0 no-timestamp; +TEST $CLI volume stop $V0 +TEST $CLI snapshot restore snap1; +TEST $CLI volume start $V0 +TEST $CLI volume attach-tier $V0 $H0:$L1 $H0:$L2 + +TEST pkill gluster +TEST glusterd +EXPECT_WITHIN $PROCESS_UP_TIMEOUT 'Started' volinfo_field $V0 'Status' + +TEST $CLI volume stop $V0 + +cleanup  ; + diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index 668c26e3ff5..0ea39358404 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -2721,7 +2721,6 @@ glusterd_lvm_snapshot_remove (dict_t *rsp_dict, glusterd_volinfo_t *snap_vol)                  /* Fetch the brick mount path from the brickinfo->path */                  ret = glusterd_find_brick_mount_path (brickinfo->path, -                                                      brick_count + 1,                                                        &brick_mount_path);                  if (ret) {                          gf_msg (this->name, GF_LOG_ERROR, 0, diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index cb312ae9a63..ee279d30d17 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -2972,11 +2972,10 @@ out:  /* Figure out the brick mount path, from the brick path */  int32_t -glusterd_find_brick_mount_path (char *brick_path, int32_t brick_count, -                                char **brick_mount_path) +glusterd_find_brick_mount_path (char *brick_path, char **brick_mount_path)  { -        char                     brick_num[PATH_MAX] = "";          char                    *ptr                 = NULL; +        char                    *save_ptr            = NULL;          int32_t                  ret                 = -1;          xlator_t                *this                = NULL; @@ -2991,12 +2990,10 @@ glusterd_find_brick_mount_path (char *brick_path, int32_t brick_count,                  goto out;          } -        snprintf (brick_num, sizeof(brick_num), "brick%d", brick_count); -          /* Finding the pointer to the end of           * /var/run/gluster/snaps/<snap-uuid>           */ -        ptr = strstr (*brick_mount_path, brick_num); +        ptr = strstr (*brick_mount_path, "brick");          if (!ptr) {                  /* Snapshot bricks must have brick num as part                   * of the brickpath @@ -3011,8 +3008,13 @@ glusterd_find_brick_mount_path (char *brick_path, int32_t brick_count,           * /var/run/gluster/snaps/<snap-uuid>/<brick_num>           * and assigning '\0' to it.           */ -        ptr += strlen(brick_num); -        *ptr = '\0'; +        while ((*ptr != '\0') && (*ptr != '/')) +                ptr++; + +        if (*ptr == '/') { +                ptr++; +                *ptr = '\0'; +        }          ret = 0;  out: @@ -3096,15 +3098,12 @@ glusterd_recreate_vol_brick_mounts (xlator_t  *this,          char                    *brick_mount_path    = NULL;          glusterd_brickinfo_t    *brickinfo           = NULL;          int32_t                  ret                 = -1; -        int32_t                  brick_count         = -1;          struct stat              st_buf              = {0, };          GF_ASSERT (this);          GF_ASSERT (volinfo); -        brick_count = 0;          cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { -                brick_count++;                  /* If the brick is not of this node, or its                   * snapshot is pending, or the brick is not                   * a snapshotted brick, we continue @@ -3116,7 +3115,6 @@ glusterd_recreate_vol_brick_mounts (xlator_t  *this,                  /* Fetch the brick mount path from the brickinfo->path */                  ret = glusterd_find_brick_mount_path (brickinfo->path, -                                                      brick_count,                                                        &brick_mount_path);                  if (ret) {                          gf_log (this->name, GF_LOG_ERROR, diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h index d617f6005c5..27c51fa90b7 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.h +++ b/xlators/mgmt/glusterd/src/glusterd-utils.h @@ -582,8 +582,8 @@ int  glusterd_unlink_file (char *sock_file_path);  int32_t -glusterd_find_brick_mount_path (char *brick_path, int32_t brick_count, -                                char **brick_mount_path); +glusterd_find_brick_mount_path (char *brick_path, char **brick_mount_path); +  /*   * Function to retrieve list of snap volnames and their uuids   */  | 
