diff options
author | Barak Sason Rofman <bsasonro@redhat.com> | 2019-11-26 12:36:16 +0200 |
---|---|---|
committer | Amar Tumballi <amarts@gmail.com> | 2019-12-17 09:07:38 +0000 |
commit | ff7865be148d5f4f22861fe93710c0b97d24f81f (patch) | |
tree | cbfe81a11f3623f5a1d8db1c1c9fb779fd50d760 /xlators/cluster/dht/src/dht-inode-read.c | |
parent | 49f524def676e62e0f0cfb8a674bc28923c28f13 (diff) |
DHT - Reduce methods scope (dht-common.c)
Methods that should have been static were defined as global, and the
other way around.
This patch fixes the issue in order to enforce encapsulation.
updates: bz#1776757
Change-Id: I3eb5781849c5e597c1dd347e03f356c00db62a39
Signed-off-by: Barak Sason Rofman <bsasonro@redhat.com>
Diffstat (limited to 'xlators/cluster/dht/src/dht-inode-read.c')
-rw-r--r-- | xlators/cluster/dht/src/dht-inode-read.c | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/xlators/cluster/dht/src/dht-inode-read.c b/xlators/cluster/dht/src/dht-inode-read.c index 0c209a52312..8007fc70693 100644 --- a/xlators/cluster/dht/src/dht-inode-read.c +++ b/xlators/cluster/dht/src/dht-inode-read.c @@ -1192,6 +1192,29 @@ err: return 0; } +/* Get both DHT_IATT_IN_XDATA_KEY and DHT_MODE_IN_XDATA_KEY + * Use DHT_MODE_IN_XDATA_KEY if available, else fall back to + * DHT_IATT_IN_XDATA_KEY + * This will return a dummy iatt with only the mode and type set + */ +static int +dht_read_iatt_from_xdata(dict_t *xdata, struct iatt *stbuf) +{ + int ret = -1; + int32_t mode = 0; + + ret = dict_get_int32(xdata, DHT_MODE_IN_XDATA_KEY, &mode); + + if (ret) { + ret = dict_get_bin(xdata, DHT_IATT_IN_XDATA_KEY, (void **)&stbuf); + } else { + stbuf->ia_prot = ia_prot_from_st_mode(mode); + stbuf->ia_type = ia_type_from_st_mode(mode); + } + + return ret; +} + int dht_common_xattrop_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *dict, @@ -1230,7 +1253,7 @@ dht_common_xattrop_cbk(call_frame_t *frame, void *cookie, xlator_t *this, return 0; } - ret = dht_read_iatt_from_xdata(this, xdata, &stbuf); + ret = dht_read_iatt_from_xdata(xdata, &stbuf); if ((!op_ret) && (ret)) { /* This is a potential problem and can cause corruption @@ -1349,6 +1372,22 @@ dht_xattrop_cbk(call_frame_t *frame, void *cookie, xlator_t *this, return 0; } +/* Set both DHT_IATT_IN_XDATA_KEY and DHT_MODE_IN_XDATA_KEY + * Use DHT_MODE_IN_XDATA_KEY if available. Else fall back to + * DHT_IATT_IN_XDATA_KEY + */ +static int +dht_request_iatt_in_xdata(dict_t *xattr_req) +{ + int ret = -1; + + ret = dict_set_int8(xattr_req, DHT_MODE_IN_XDATA_KEY, 1); + ret = dict_set_int8(xattr_req, DHT_IATT_IN_XDATA_KEY, 1); + + /* At least one call succeeded */ + return ret; +} + int dht_xattrop(call_frame_t *frame, xlator_t *this, loc_t *loc, gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata) @@ -1391,7 +1430,7 @@ dht_xattrop(call_frame_t *frame, xlator_t *this, loc_t *loc, local->rebalance.xattr = dict_ref(dict); local->rebalance.flags = flags; - ret = dht_request_iatt_in_xdata(this, local->xattr_req); + ret = dht_request_iatt_in_xdata(local->xattr_req); if (ret) { gf_msg_debug(this->name, 0, @@ -1461,7 +1500,7 @@ dht_fxattrop(call_frame_t *frame, xlator_t *this, fd_t *fd, local->rebalance.xattr = dict_ref(dict); local->rebalance.flags = flags; - ret = dht_request_iatt_in_xdata(this, local->xattr_req); + ret = dht_request_iatt_in_xdata(local->xattr_req); if (ret) { gf_msg_debug(this->name, 0, "Failed to set dictionary key %s fd=%p", |