diff options
author | Kotresh HR <khiremat@redhat.com> | 2017-07-16 15:16:56 -0400 |
---|---|---|
committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2017-07-31 15:45:02 +0000 |
commit | 32e366bad947926343fdb389f054ca3051e44774 (patch) | |
tree | 4e9da129dc25bcd826e1d4f9041343c338691fee /xlators/storage/posix/src/posix.c | |
parent | 61ea2a44b509cebc566fc18b2c356d88a3f1fdc8 (diff) |
storage/posix: Add virtual xattr to fetch path from gfid
The gfid2path infra stores the "pargfid/bname" as on xattr
value for each non directory entry. Hardlinks would have a
separate xattr. This xattr key is internal and is not
exposed to applications. A virtual xattr is exposed for
the applications to fetch the path from gfid.
Internal xattr:
trusted.gfid2path.<xxhash>
Virtual xattr:
glusterfs.gfidtopath
getfattr -h -n glusterfs.gfidtopath /<aux-mnt>/.gfid/<gfid>
If there are hardlinks, it returns all the paths separated
by ':'.
A volume set option is introduced to change the delimiter
to required string of max length 7.
gluster vol set gfid2path-separator ":::"
> Updates: #139
> Change-Id: Ie3b0c3fd8bd5333c4a27410011e608333918c02a
> Signed-off-by: Kotresh HR <khiremat@redhat.com>
> Reviewed-on: https://review.gluster.org/17785
> Smoke: Gluster Build System <jenkins@build.gluster.org>
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
> Reviewed-by: Krutika Dhananjay <kdhananj@redhat.com>
Updates: #139
Change-Id: Ie3b0c3fd8bd5333c4a27410011e608333918c02a
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Reviewed-on: https://review.gluster.org/17921
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Smoke: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix.c')
-rw-r--r-- | xlators/storage/posix/src/posix.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 92a2f3772cb..6d7fc24b2da 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -4698,6 +4698,23 @@ posix_getxattr (call_frame_t *frame, xlator_t *this, goto done; } + if (loc->inode && name && + (strcmp (name, GFID2PATH_VIRT_XATTR_KEY) == 0)) { + if (!priv->gfid2path) { + op_errno = ENOATTR; + op_ret = -1; + goto out; + } + ret = posix_get_gfid2path (this, loc->inode, real_path, + &op_errno, dict); + if (ret < 0) { + op_ret = -1; + goto out; + } + size = ret; + goto done; + } + if (loc->inode && name && (strcmp (name, GET_ANCESTRY_PATH_KEY) == 0)) { int type = POSIX_ANCESTRY_PATH; @@ -6939,7 +6956,19 @@ posix_set_owner (xlator_t *this, uid_t uid, gid_t gid) return ret; } +static int +set_gfid2path_separator (struct posix_private *priv, const char *str) +{ + int str_len = 0; + str_len = strlen(str); + if (str_len > 0 && str_len < 8) { + strcpy (priv->gfid2path_sep, str); + return 0; + } + + return -1; +} static int set_batch_fsync_mode (struct posix_private *priv, const char *str) @@ -6986,6 +7015,7 @@ reconfigure (xlator_t *this, dict_t *options) int32_t uid = -1; int32_t gid = -1; char *batch_fsync_mode_str = NULL; + char *gfid2path_sep = NULL; priv = this->private; @@ -7006,6 +7036,14 @@ reconfigure (xlator_t *this, dict_t *options) goto out; } + GF_OPTION_RECONF ("gfid2path-separator", gfid2path_sep, options, + str, out); + if (set_gfid2path_separator (priv, gfid2path_sep) != 0) { + gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_ARGUMENT, + "Length of separator exceeds 7: %s", gfid2path_sep); + goto out; + } + #ifdef GF_DARWIN_HOST_OS char *xattr_user_namespace_mode_str = NULL; @@ -7194,6 +7232,7 @@ init (xlator_t *this) int32_t uid = -1; int32_t gid = -1; char *batch_fsync_mode_str; + char *gfid2path_sep = NULL; dir_data = dict_get (this->options, "directory"); @@ -7688,6 +7727,13 @@ init (xlator_t *this) goto out; } + GF_OPTION_INIT ("gfid2path-separator", gfid2path_sep, str, out); + if (set_gfid2path_separator (_private, gfid2path_sep) != 0) { + gf_msg (this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_ARGUMENT, + "Length of separator exceeds 7: %s", gfid2path_sep); + goto out; + } + #ifdef GF_DARWIN_HOST_OS char *xattr_user_namespace_mode_str = NULL; @@ -7878,6 +7924,11 @@ struct volume_options options[] = { .default_value = "off", .description = "Enable logging metadata for gfid to path conversion" }, + { .key = {"gfid2path-separator"}, + .type = GF_OPTION_TYPE_STR, + .default_value = ":", + .description = "Path separator for glusterfs.gfidtopath virt xattr" + }, #if GF_DARWIN_HOST_OS { .key = {"xattr-user-namespace-mode"}, .type = GF_OPTION_TYPE_STR, |