diff options
author | Venky Shankar <vshankar@redhat.com> | 2015-02-09 18:28:21 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-03-24 06:37:19 -0700 |
commit | a20101e2e4d5f5595655544cfc798eb1d445638c (patch) | |
tree | 0c3ceb7ba0ba3bba7e41663d728fb2f60208e5a8 /xlators/storage/posix/src/posix-helpers.c | |
parent | 3c474a042aed68659fe0cfdf32e01285bde9f689 (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/posix/src/posix-helpers.c')
-rw-r--r-- | xlators/storage/posix/src/posix-helpers.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c index edbf0241f26..4a062970f7d 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; + +} |