summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnand Avati <avati@gluster.com>2010-09-03 14:00:51 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-09-04 01:45:33 -0700
commit71c66d9c9a36a28107cfc202aa38f51b3dde8731 (patch)
tree7f13b241b621790c3ceff674fcadcf3cb59b97d9
parent8a5e677bbd8bdec555e6699ec5b8b1a66fe8096d (diff)
gfid: handling of gfids in storage/posix
Signed-off-by: Anand V. Avati <avati@amp.gluster.com> Signed-off-by: Anand V. Avati <avati@blackhole.gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 971 (dynamic volume management) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=971
-rw-r--r--xlators/storage/posix/src/posix.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 0730dc2cd..aad52096b 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -252,6 +252,34 @@ out:
int
+posix_fill_gfid_path (xlator_t *this, const char *path, struct iatt *iatt)
+{
+ int ret = 0;
+
+ if (!iatt)
+ return 0;
+
+ ret = sys_lgetxattr (path, "trusted.gfid", iatt->ia_gfid, 16);
+
+ return ret;
+}
+
+
+int
+posix_fill_gfid_fd (xlator_t *this, int fd, struct iatt *iatt)
+{
+ int ret = 0;
+
+ if (!iatt)
+ return 0;
+
+ ret = sys_fgetxattr (fd, "trusted.gfid", iatt->ia_gfid, 16);
+
+ return ret;
+}
+
+
+int
posix_lstat_with_gen (xlator_t *this, const char *path, struct iatt *stbuf_p)
{
struct posix_private *priv = NULL;
@@ -292,6 +320,8 @@ posix_lstat_with_gen (xlator_t *this, const char *path, struct iatt *stbuf_p)
}
#endif /* !GF_LINUX_HOST_OS */
+ ret = posix_fill_gfid_path (this, path, &stbuf);
+
ret = snprintf (gen_key, 1024, "trusted.%s.gen", this->name);
if (ret == 1024)
@@ -361,6 +391,8 @@ posix_fstat_with_gen (xlator_t *this, int fd, struct iatt *stbuf_p)
}
#endif /* !GF_LINUX_HOST_OS */
+ ret = posix_fill_gfid_fd (this, fd, &stbuf);
+
ret = snprintf (gen_key, 1024, "trusted.%s.gen", this->name);
if (ret == 1024)
@@ -472,6 +504,36 @@ out:
}
+int
+posix_gfid_set (xlator_t *this, const char *path, dict_t *xattr_req)
+{
+ void *uuid_req = NULL;
+ uuid_t uuid_curr;
+ int ret = 0;
+ struct stat stat = {0, };
+
+ if (!xattr_req)
+ return 0;
+
+ if (sys_lstat (path, &stat) != 0)
+ return 0;
+
+ ret = sys_lgetxattr (path, "trusted.gfid", uuid_curr, 16);
+
+ if (ret == 16)
+ return 0;
+
+ ret = dict_get_ptr (xattr_req, "gfid-req", &uuid_req);
+ if (ret)
+ goto out;
+
+ ret = sys_lsetxattr (path, "trusted.gfid", uuid_req, 16, XATTR_CREATE);
+
+out:
+ return ret;
+}
+
+
int32_t
posix_lookup (call_frame_t *frame, xlator_t *this,
loc_t *loc, dict_t *xattr_req)
@@ -493,6 +555,8 @@ posix_lookup (call_frame_t *frame, xlator_t *this,
MAKE_REAL_PATH (real_path, this, loc->path);
+ posix_gfid_set (this, real_path, xattr_req);
+
op_ret = posix_lstat_with_gen (this, real_path, &buf);
op_errno = errno;
@@ -1134,6 +1198,8 @@ posix_mknod (call_frame_t *frame, xlator_t *this,
}
}
+ op_ret = posix_gfid_set (this, real_path, params);
+
#ifndef HAVE_SET_FSID
op_ret = lchown (real_path, frame->root->uid, gid);
if (op_ret == -1) {
@@ -1389,6 +1455,8 @@ posix_mkdir (call_frame_t *frame, xlator_t *this,
goto out;
}
+ op_ret = posix_gfid_set (this, real_path, params);
+
#ifndef HAVE_SET_FSID
op_ret = chown (real_path, frame->root->uid, gid);
if (op_ret == -1) {
@@ -1663,6 +1731,8 @@ posix_symlink (call_frame_t *frame, xlator_t *this,
goto out;
}
+ op_ret = posix_gfid_set (this, real_path, params);
+
#ifndef HAVE_SET_FSID
op_ret = lchown (real_path, frame->root->uid, gid);
if (op_ret == -1) {
@@ -2080,6 +2150,8 @@ posix_create (call_frame_t *frame, xlator_t *this,
goto out;
}
+ op_ret = posix_gfid_set (this, real_path, params);
+
#ifndef HAVE_SET_FSID
op_ret = chown (real_path, frame->root->uid, gid);
if (op_ret == -1) {