diff options
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.c | 39 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-store.h | 1 | ||||
| -rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 24 | 
3 files changed, 39 insertions, 25 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 7560cacc031..e1089be9b30 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -383,6 +383,11 @@ glusterd_store_brickinfo_write (int fd, glusterd_brickinfo_t *brickinfo)          if (ret)                  goto out; +        ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_BRICK_REAL_PATH, +                                   brickinfo->path); +        if (ret) +                goto out; +          snprintf (value, sizeof(value), "%d", brickinfo->port);          ret = gf_store_save_value (fd, GLUSTERD_STORE_KEY_BRICK_PORT, value); @@ -2310,6 +2315,10 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo)                                      strlen (GLUSTERD_STORE_KEY_BRICK_PATH))) {                                  strncpy (brickinfo->path, value,                                           sizeof (brickinfo->path)); +                        } else if (!strncmp (key, GLUSTERD_STORE_KEY_BRICK_REAL_PATH, +                                    strlen (GLUSTERD_STORE_KEY_BRICK_REAL_PATH))) { +                                strncpy (brickinfo->real_path, value, +                                         sizeof (brickinfo->real_path));                          } else if (!strncmp (key, GLUSTERD_STORE_KEY_BRICK_PORT,                                      strlen (GLUSTERD_STORE_KEY_BRICK_PORT))) {                                  gf_string2int (value, &brickinfo->port); @@ -2410,8 +2419,8 @@ glusterd_store_retrieve_bricks (glusterd_volinfo_t *volinfo)                   * snapshot or snapshot restored volume this would be done post                   * creating the brick mounts                   */ -                if (!volinfo->is_snap_volume && -                    gf_uuid_is_null (volinfo->restored_from_snap)) { +                if (brickinfo->real_path[0] == '\0' && !volinfo->is_snap_volume +                    && gf_uuid_is_null (volinfo->restored_from_snap)) {                          /* By now if the brick is a local brick then it will be                           * able to resolve which is the only thing we want now                           * for checking  whether the brickinfo->uuid matches @@ -3305,19 +3314,21 @@ glusterd_recreate_vol_brick_mounts (xlator_t  *this,                                  "Failed to mount brick_mount_path");                  }                  if (!gf_uuid_compare(brickinfo->uuid, MY_UUID)) { -                        if (!realpath (brickinfo->path, abspath)) { -                                gf_msg (this->name, GF_LOG_CRITICAL, -                                        errno, -                                        GD_MSG_BRICKINFO_CREATE_FAIL, -                                        "realpath() failed for brick %s" -                                        ". The underlying file system " -                                        "may be in bad state", -                                        brickinfo->path); -                                ret = -1; -                                goto out; +                        if (brickinfo->real_path[0] == '\0') { +                                if (!realpath (brickinfo->path, abspath)) { +                                        gf_msg (this->name, GF_LOG_CRITICAL, +                                                errno, +                                                GD_MSG_BRICKINFO_CREATE_FAIL, +                                                "realpath() failed for brick %s" +                                                ". The underlying file system " +                                                "may be in bad state", +                                                brickinfo->path); +                                        ret = -1; +                                        goto out; +                                } +                                strncpy (brickinfo->real_path, abspath, +                                         strlen(abspath));                          } -                        strncpy (brickinfo->real_path, abspath, -                                 strlen(abspath));                  }                  if (brick_mount_path) { diff --git a/xlators/mgmt/glusterd/src/glusterd-store.h b/xlators/mgmt/glusterd/src/glusterd-store.h index 683edaef058..93096d9972f 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.h +++ b/xlators/mgmt/glusterd/src/glusterd-store.h @@ -90,6 +90,7 @@ typedef enum glusterd_store_ver_ac_{  #define GLUSTERD_STORE_KEY_BRICK_HOSTNAME       "hostname"  #define GLUSTERD_STORE_KEY_BRICK_PATH           "path" +#define GLUSTERD_STORE_KEY_BRICK_REAL_PATH      "real_path"  #define GLUSTERD_STORE_KEY_BRICK_PORT           "listen-port"  #define GLUSTERD_STORE_KEY_BRICK_RDMA_PORT      "rdma.listen-port"  #define GLUSTERD_STORE_KEY_BRICK_DECOMMISSIONED "decommissioned" diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index aebfb2c70c7..baa4e3dab3a 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -1113,7 +1113,7 @@ glusterd_brickinfo_new_from_brick (char *brick,          strncpy (new_brickinfo->hostname, hostname, 1024);          strncpy (new_brickinfo->path, path, 1024); -        if (construct_real_path) { +        if (construct_real_path && new_brickinfo->real_path[0] == '\0') {                  if (!realpath (new_brickinfo->path, abspath)) {                          /* ENOENT indicates that brick path has not been created                           * which is a valid scenario */ @@ -3106,17 +3106,19 @@ glusterd_import_new_brick (dict_t *peer_data, int32_t vol_count,          gf_uuid_parse (brick_uuid_str, new_brickinfo->uuid);          if (!gf_uuid_compare(new_brickinfo->uuid, MY_UUID)) { -                if (!realpath (new_brickinfo->path, abspath)) { -                        gf_msg (this->name, GF_LOG_CRITICAL, errno, -                                GD_MSG_BRICKINFO_CREATE_FAIL, "realpath() " -                                "failed for brick %s. The underlying file " -                                "system may be in bad state", -                                new_brickinfo->path); -                        ret = -1; -                        goto out; +                if (new_brickinfo->real_path[0] == '\0') { +                        if (!realpath (new_brickinfo->path, abspath)) { +                                gf_msg (this->name, GF_LOG_CRITICAL, errno, +                                        GD_MSG_BRICKINFO_CREATE_FAIL, +                                        "realpath() failed for brick %s. The " +                                        "underlying file system may be in bad " +                                        "state", new_brickinfo->path); +                                ret = -1; +                                goto out; +                        } +                        strncpy (new_brickinfo->real_path, abspath, +                                 strlen(abspath));                  } -                strncpy (new_brickinfo->real_path, abspath, -                         strlen(abspath));          }          *brickinfo = new_brickinfo;  | 
