diff options
author | Pranith Kumar K <pkarampu@redhat.com> | 2015-03-24 12:09:52 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-04-06 22:35:07 -0700 |
commit | 6e7d9a4e77a764e86bcde4e704ec05a3c84f9c11 (patch) | |
tree | 1107ff62bac604d5b05df73281a00e6d1a22cb9a /xlators/cluster/ec/src/ec-combine.c | |
parent | 0e23ce3fbcf1f138105476cf3b86342268e259d9 (diff) |
cluster/ec: Refactor inode-writev
All _cbk() functions in inode-write.c do same things, i.e. store
op_ret/op_errno, stat structures if they are available and combine them. Moved
this common operation into one function ec_inode_write_cbk() and made all the
other _cbk() functions to use this instead.
Change-Id: I2387b9f2d9598ced6299a26ea1900e9deb9fadc4
BUG: 1199767
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/9981
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Dan Lambright <dlambrig@redhat.com>
Diffstat (limited to 'xlators/cluster/ec/src/ec-combine.c')
-rw-r--r-- | xlators/cluster/ec/src/ec-combine.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/xlators/cluster/ec/src/ec-combine.c b/xlators/cluster/ec/src/ec-combine.c index 709da555627..de9a9951179 100644 --- a/xlators/cluster/ec/src/ec-combine.c +++ b/xlators/cluster/ec/src/ec-combine.c @@ -38,6 +38,60 @@ struct _ec_dict_combine int32_t which; }; +int32_t +ec_combine_write (ec_fop_data_t *fop, ec_cbk_data_t *dst, + ec_cbk_data_t *src) +{ + int valid = 0; + + if (!fop || !dst || !src) + return 0; + + switch (fop->id) { + case GF_FOP_REMOVEXATTR: + case GF_FOP_FREMOVEXATTR: + case GF_FOP_SETXATTR: + case GF_FOP_FSETXATTR: + return 1; + + case GF_FOP_SYMLINK: + case GF_FOP_LINK: + case GF_FOP_CREATE: + case GF_FOP_MKNOD: + case GF_FOP_MKDIR: + valid = 3; + break; + case GF_FOP_UNLINK: + case GF_FOP_RMDIR: + case GF_FOP_SETATTR: + case GF_FOP_FSETATTR: + case GF_FOP_TRUNCATE: + case GF_FOP_FTRUNCATE: + case GF_FOP_WRITE: + case GF_FOP_FALLOCATE: + case GF_FOP_DISCARD: + case GF_FOP_ZEROFILL: + valid = 2; + break; + case GF_FOP_RENAME: + valid = 5; + break; + default: + gf_log_callingfn (fop->xl->name, GF_LOG_WARNING, "Invalid fop " + "%d", fop->id); + return 0; + break; + } + + if (!ec_iatt_combine(dst->iatt, src->iatt, valid)) { + gf_log(fop->xl->name, GF_LOG_NOTICE, "Mismatching iatt in " + "answers of '%s'", gf_fop_list[fop->id]); + + return 0; + } + return 1; +} + void ec_iatt_time_merge(uint32_t * dst_sec, uint32_t * dst_nsec, uint32_t src_sec, uint32_t src_nsec) { |