Hi
I finally managed to get the trusted.glusterfs.location work with 2.0.6. I
needed to make some minor modifications to the patch bfb7af7aa316ba, which
adds support for trusted.glusterfs.location, to make it work with the
latest release.
For some reason, getfattr always returned a zero-length value although it
recognized the key. I tracked down this problem to dict_set_static_ptr in
posix.c. Changing this to dict_set_str seemed to fix the problem, combined
with a small change in fuse-bridge.c to drop the zero byte in the end of
the value.
A trickier issue is that the trusted.* namespace is only accessible with
the CAP_SYS_ADMIN capability in linux. This means that ordinary users
can't resolve locations of files as before. Also, we're using OpenVZ
containers for virtualization and apparently not even root has the
CAP_SYS_ADMIN capability in a virtual machine, so
trusted.glusterfs.location can't be accessed in a container at all.
Is there some particular reason why you couldn't expose the attribute in
the user.* namespace? I patched our gluster to use
user.glusterfs.location, which solves both the issue with ordinary users
and makes the attribute available to openvz containers.
Find below a patch against 2.0.6 that fixes the aforementioned issues. I'd
appreciate if you could consider using the user.* namespace in 2.0.7.
Also, as I mentioned in an earlier email, it'd be useful to know all
locations of the file when cluster/replicate is in use, to let Disco and
others utilize replicas in case that the primary copy fails.
Ville
diff --git a/xlators/mount/fuse/src/fuse-bridge.c
b/xlators/mount/fuse/src/fuse-bridge.c
index 61fd257..011b280 100644
--- a/xlators/mount/fuse/src/fuse-bridge.c
+++ b/xlators/mount/fuse/src/fuse-bridge.c
@@ -2000,7 +2000,7 @@ fuse_xattr_cbk (call_frame_t *frame, void *cookie,
xlator_t *this,
/* if callback for getxattr */
value_data = dict_get (dict, state->name);
if (value_data) {
- ret = value_data->len; /* Don't return
the value for '\0' */
+ ret = value_data->len - 1; /* Don't
return the value for '\0' */
value = value_data->data;
fuse_reply_xattr_buf (state, req, value,
ret);
diff --git a/xlators/storage/posix/src/posix.c
b/xlators/storage/posix/src/posix.c
index c88e964..7a04cf9 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -2241,10 +2241,10 @@ posix_getxattr (call_frame_t *frame, xlator_t
*this,
}
if (loc->inode && S_ISREG (loc->inode->st_mode) && name &&
- (strcmp (name, "trusted.glusterfs.location") == 0)) {
- ret = dict_set_static_ptr (dict,
- "trusted.glusterfs.location",
- priv->hostname);
+ (strcmp (name, "user.glusterfs.location") == 0)) {
+ ret = dict_set_str (dict,
+ "user.glusterfs.location",
+ priv->hostname);
if (ret < 0) {
gf_log (this->name, GF_LOG_WARNING,
"could not set hostname (%s) in
dictionary",