summaryrefslogtreecommitdiffstats
path: root/xlators/storage
diff options
context:
space:
mode:
authorVenky Shankar <vshankar@redhat.com>2015-02-09 18:28:21 +0530
committerVijay Bellur <vbellur@redhat.com>2015-03-24 06:37:19 -0700
commita20101e2e4d5f5595655544cfc798eb1d445638c (patch)
tree0c3ceb7ba0ba3bba7e41663d728fb2f60208e5a8 /xlators/storage
parent3c474a042aed68659fe0cfdf32e01285bde9f689 (diff)
Bitrot Stub
Bitrot stub implements object versioning required for identifying signature freshness. More details about versioning is explained as a part of the "bitrot feature documentation" patch. Change-Id: I2ad70d9eb109ba4a12148ab8d81336afda529ad9 BUG: 1170075 Signed-off-by: Venky Shankar <vshankar@redhat.com> Reviewed-on: http://review.gluster.org/9709 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/storage')
-rw-r--r--xlators/storage/posix/src/posix-helpers.c70
-rw-r--r--xlators/storage/posix/src/posix.c23
-rw-r--r--xlators/storage/posix/src/posix.h3
3 files changed, 96 insertions, 0 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index edbf024..4a06297 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -1855,3 +1855,73 @@ posix_fsyncer (void *d)
}
}
}
+
+/**
+ * fetch on-disk ongoing version and object signature extended
+ * attribute.
+ */
+int32_t
+posix_get_objectsignature (char *real_path, dict_t *xattr)
+{
+ int32_t op_ret = 0;
+ char *memptr = NULL;
+ ssize_t xattrsize = 0;
+ ssize_t allocsize = 0;
+
+ op_ret = -EINVAL;
+ xattrsize = sys_lgetxattr (real_path,
+ BITROT_CURRENT_VERSION_KEY, NULL, 0);
+ if (xattrsize == -1)
+ goto error_return;
+ allocsize += xattrsize;
+
+ xattrsize = sys_lgetxattr (real_path,
+ BITROT_SIGNING_VERSION_KEY, NULL, 0);
+ if (xattrsize == -1)
+ goto error_return;
+ allocsize += xattrsize;
+
+ op_ret = -ENOMEM;
+ /* bulk alloc */
+ memptr = GF_CALLOC (allocsize + 2, sizeof (char), gf_posix_mt_char);
+ if (!memptr)
+ goto error_return;
+
+ op_ret = sys_lgetxattr (real_path, BITROT_CURRENT_VERSION_KEY,
+ memptr, allocsize - xattrsize);
+ if (op_ret == -1) {
+ op_ret = -errno;
+ goto dealloc_mem;
+ }
+
+ xattrsize = op_ret; /* save for correct _in_ memory pointing */
+
+ op_ret = sys_lgetxattr (real_path, BITROT_SIGNING_VERSION_KEY,
+ (memptr + op_ret + 1), allocsize - op_ret);
+ if (op_ret == -1) {
+ op_ret = -errno;
+ goto dealloc_mem;
+ }
+
+ /* this is a dynamic set */
+ op_ret = dict_set_dynptr (xattr, BITROT_CURRENT_VERSION_KEY,
+ memptr, allocsize);
+ if (op_ret < 0)
+ goto dealloc_mem;
+
+ /* rest all should be static */
+ op_ret = dict_set_static_ptr (xattr, BITROT_SIGNING_VERSION_KEY,
+ memptr + xattrsize + 1);
+ if (op_ret < 0)
+ goto delkey;
+
+ return allocsize;
+
+ delkey:
+ dict_del (xattr, BITROT_CURRENT_VERSION_KEY);
+ dealloc_mem:
+ GF_FREE (memptr);
+ error_return:
+ return op_ret;
+
+}
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 8001f23..ae08adc 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -3882,6 +3882,18 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
goto done;
}
+ if (loc->inode && name
+ && (strncmp (name, GLUSTERFS_GET_OBJECT_SIGNATURE,
+ strlen (GLUSTERFS_GET_OBJECT_SIGNATURE)) == 0)) {
+ op_ret = posix_get_objectsignature (real_path, dict);
+ if (op_ret < 0) {
+ op_errno = -op_ret;
+ op_ret = -1;
+ }
+
+ goto done;
+ }
+
if (name) {
strcpy (keybuffer, name);
char *key = keybuffer;
@@ -4316,6 +4328,17 @@ posix_fsetxattr (call_frame_t *frame, xlator_t *this,
op_ret = -1;
}
+ if (!ret && xdata && dict_get (xdata, GLUSTERFS_DURABLE_OP)) {
+ op_ret = fsync (_fd);
+ if (op_ret < 0) {
+ op_ret = -1;
+ op_errno = errno;
+ gf_log (this->name, GF_LOG_WARNING,
+ "could not satisfy durability request: "
+ "reason (%s)", strerror (errno));
+ }
+ }
+
out:
SET_TO_OLD_FS_ID ();
diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h
index bdb56b1..452248d 100644
--- a/xlators/storage/posix/src/posix.h
+++ b/xlators/storage/posix/src/posix.h
@@ -242,4 +242,7 @@ posix_pacl_set (const char *path, const char *key, const char *acl_s);
int
posix_pacl_get (const char *path, const char *key, char **acl_s);
+int32_t
+posix_get_objectsignature (char *, dict_t *);
+
#endif /* _POSIX_H */