diff options
author | Anuradha Talur <atalur@commvault.com> | 2018-11-20 13:15:26 -0800 |
---|---|---|
committer | Susant Palai <spalai@redhat.com> | 2019-04-10 09:11:15 +0000 |
commit | dc06e4c408187afcc58ebd72386490ad1e58de03 (patch) | |
tree | 44cb31381fa1197cea914cdbc4d5575ec01ec45d /xlators/storage/posix/src/posix-helpers.c | |
parent | d837b4518c3148752b2eb4d55d22f22c57aa96c2 (diff) |
storage/posix: changes with respect to cloudsync
Main changes include logic to update iatt buf
with file size from extended attributes in posix
rather than having this logic in cloudsync xlator.
Change-Id: I44f5f8df7a01e496372557fe2f4eff368dbdaa33
fixes: bz#1642168
Signed-off-by: Anuradha Talur <atalur@commvault.com>
Diffstat (limited to 'xlators/storage/posix/src/posix-helpers.c')
-rw-r--r-- | xlators/storage/posix/src/posix-helpers.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c index 193afc5f3fa..c7ab13d1163 100644 --- a/xlators/storage/posix/src/posix-helpers.c +++ b/xlators/storage/posix/src/posix-helpers.c @@ -3444,3 +3444,53 @@ posix_check_dev_file(xlator_t *this, inode_t *inode, char *fop, int *op_errno) out: return ret; } + +void +posix_update_iatt_buf(struct iatt *buf, int fd, char *loc, dict_t *xattr_req) +{ + int ret = 0; + char val[4096] = { + 0, + }; + + if (!xattr_req) + return; + + if (!(dict_getn(xattr_req, GF_CS_OBJECT_STATUS, + strlen(GF_CS_OBJECT_STATUS)))) + return; + + if (fd != -1) { + ret = sys_fgetxattr(fd, GF_CS_OBJECT_SIZE, &val, sizeof(val)); + if (ret > 0) { + buf->ia_size = atoll(val); + } else { + /* Safe to assume that the other 2 xattrs are also not set*/ + return; + } + ret = sys_fgetxattr(fd, GF_CS_BLOCK_SIZE, &val, sizeof(val)); + if (ret > 0) { + buf->ia_blksize = atoll(val); + } + ret = sys_fgetxattr(fd, GF_CS_NUM_BLOCKS, &val, sizeof(val)); + if (ret > 0) { + buf->ia_blocks = atoll(val); + } + } else { + ret = sys_lgetxattr(loc, GF_CS_OBJECT_SIZE, &val, sizeof(val)); + if (ret > 0) { + buf->ia_size = atoll(val); + } else { + /* Safe to assume that the other 2 xattrs are also not set*/ + return; + } + ret = sys_lgetxattr(loc, GF_CS_BLOCK_SIZE, &val, sizeof(val)); + if (ret > 0) { + buf->ia_blksize = atoll(val); + } + ret = sys_lgetxattr(loc, GF_CS_NUM_BLOCKS, &val, sizeof(val)); + if (ret > 0) { + buf->ia_blocks = atoll(val); + } + } +} |