diff options
| author | Raghavendra Manjunath <raghavendr@redhat.com> | 2018-08-23 22:24:25 -0400 | 
|---|---|---|
| committer | mohammed rafi kc <rkavunga@redhat.com> | 2018-09-05 13:13:21 +0000 | 
| commit | 3ee5f7ee34e1768a0b15c6acc54481c2372f9c92 (patch) | |
| tree | 1273b317add4bd9fc72be47bede05245078b3514 /xlators/features | |
| parent | 9716ce88b3a1faf135a6badc02d94249898059dd (diff) | |
features/uss: Use xxh64 to generate gfid instead of md5sum
* This is to ensure FIPS support
* Also changed the signature of svs_uuid_generate to
  get xlator argument
* Added xxh64 wrapper functions in common-utils to
  generate gfid using xxh64
  - Those wrapper functions can be used by other xlators
    as well to generate gfids using xxh64. But as of now
    snapview-server is going to be the only consumer.
Change-Id: Ide66573125dd74122430cccc4c4dc2a376d642a2
Updates: #230
Signed-off-by: Raghavendra Manjunath <raghavendra@redhat.com>
Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com>
Diffstat (limited to 'xlators/features')
3 files changed, 44 insertions, 13 deletions
diff --git a/xlators/features/snapview-server/src/snapview-server-helpers.c b/xlators/features/snapview-server/src/snapview-server-helpers.c index 091feb59180..9e12501807b 100644 --- a/xlators/features/snapview-server/src/snapview-server-helpers.c +++ b/xlators/features/snapview-server/src/snapview-server-helpers.c @@ -16,7 +16,6 @@  #include "protocol-common.h"  #include <pthread.h> -  int  __svs_inode_ctx_set (xlator_t *this, inode_t *inode, svs_inode_t *svs_inode)  { @@ -329,18 +328,37 @@ out:          return svs_fd;  } -void -svs_uuid_generate (uuid_t gfid, char *snapname, uuid_t origin_gfid) +int +svs_uuid_generate (xlator_t *this, uuid_t gfid, char *snapname, +                   uuid_t origin_gfid)  { -        unsigned char md5_sum[MD5_DIGEST_LENGTH] = {0}; -        char          ino_string[NAME_MAX + 32]  = ""; +        char ino_string[NAME_MAX + 32]  = ""; +        uuid_t tmp = {0, }; +        int    ret = -1; -        GF_ASSERT (snapname); +        GF_VALIDATE_OR_GOTO ("snapview-server", this, out); +        GF_VALIDATE_OR_GOTO (this->name, snapname, out);          (void) snprintf (ino_string, sizeof (ino_string), "%s%s",                           snapname, uuid_utoa(origin_gfid)); -        MD5((unsigned char *)ino_string, strlen(ino_string), md5_sum); -        gf_uuid_copy (gfid, md5_sum); + +        if (gf_gfid_generate_from_xxh64 (tmp, ino_string)) { +                gf_log (this->name, GF_LOG_WARNING, "failed to generate " +                        "gfid for object with actual gfid of %s " +                        "(snapname: %s, key: %s)", uuid_utoa (origin_gfid), +                        snapname, ino_string); +                goto out; +        } + +        gf_uuid_copy (gfid, tmp); + +        ret = 0; + +        gf_log (this->name, GF_LOG_DEBUG, "gfid generated is %s ", +                uuid_utoa (gfid)); + +out: +        return ret;  }  void diff --git a/xlators/features/snapview-server/src/snapview-server.c b/xlators/features/snapview-server/src/snapview-server.c index ed56937aa7c..664889b4a16 100644 --- a/xlators/features/snapview-server/src/snapview-server.c +++ b/xlators/features/snapview-server/src/snapview-server.c @@ -323,6 +323,8 @@ svs_lookup_entry (xlator_t *this, loc_t *loc, struct iatt *buf,          svs_inode_t    *inode_ctx                       = NULL;          glfs_object_t  *parent_object                   = NULL;          uuid_t          gfid                            = {0, }; +        int             ret                             = -1; +          GF_VALIDATE_OR_GOTO ("snapview-server", this, out);          GF_VALIDATE_OR_GOTO (this->name, loc, out); @@ -364,9 +366,19 @@ svs_lookup_entry (xlator_t *this, loc_t *loc, struct iatt *buf,          }          if (gf_uuid_is_null (loc->gfid) && -            gf_uuid_is_null (loc->inode->gfid)) -                svs_uuid_generate (gfid, parent_ctx->snapname, object->gfid); -        else { +            gf_uuid_is_null (loc->inode->gfid)) { +                ret = svs_uuid_generate (this, gfid, parent_ctx->snapname, +                                         object->gfid); +                /* +                 * should op_errno be something else such as +                 * EINVAL or ESTALE? +                 */ +                if (ret) { +                        op_ret = -1; +                        *op_errno = EIO; +                        goto out; +                } +        } else {                  if (!gf_uuid_is_null (loc->inode->gfid))                          gf_uuid_copy (gfid, loc->inode->gfid);                  else diff --git a/xlators/features/snapview-server/src/snapview-server.h b/xlators/features/snapview-server/src/snapview-server.h index a805c7435bd..d024a77011b 100644 --- a/xlators/features/snapview-server/src/snapview-server.h +++ b/xlators/features/snapview-server/src/snapview-server.h @@ -209,8 +209,9 @@ __svs_fd_ctx_get_or_new (xlator_t *this, fd_t *fd);  svs_fd_t *  svs_fd_ctx_get_or_new (xlator_t *this, fd_t *fd); -void -svs_uuid_generate (uuid_t gfid, char *snapname, uuid_t origin_gfid); +int +svs_uuid_generate (xlator_t *this, uuid_t gfid, char *snapname, +                   uuid_t origin_gfid);  void  svs_fill_ino_from_gfid (struct iatt *buf);  | 
