From c048df835e94a8707254d32db93c42f43f31abda Mon Sep 17 00:00:00 2001 From: Barak Sason Rofman Date: Wed, 18 Dec 2019 19:18:40 +0200 Subject: dht - Reducing methods scope 1. Reduced methods scope in the following: inode read&write, layout, linkfile, shard 2. Removed dead code @ dht-linkkile.c:174-228 & dht-shard.c:44 Change-Id: I2d08a10c7b074fccdb0c020845cad60c6ea32db5 updates: bz#1193929 Signed-off-by: Barak Sason Rofman --- xlators/cluster/dht/src/dht-common.h | 25 +++++----------- xlators/cluster/dht/src/dht-inode-read.c | 50 +++++++++++++++---------------- xlators/cluster/dht/src/dht-inode-write.c | 24 +++++++-------- xlators/cluster/dht/src/dht-layout.c | 11 +++---- xlators/cluster/dht/src/dht-linkfile.c | 7 ++--- xlators/cluster/dht/src/dht-shared.c | 47 +++++------------------------ 6 files changed, 60 insertions(+), 104 deletions(-) (limited to 'xlators/cluster/dht/src') diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index d82087c0448..871b7aed9b3 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -883,7 +883,6 @@ dht_layout_anomalies(xlator_t *this, loc_t *loc, dht_layout_t *layout, int dht_layout_dir_mismatch(xlator_t *this, dht_layout_t *layout, xlator_t *subvol, loc_t *loc, dict_t *xattr); - xlator_t * dht_linkfile_subvol(xlator_t *this, inode_t *inode, struct iatt *buf, dict_t *xattr); @@ -901,9 +900,6 @@ int dht_disk_layout_extract(xlator_t *this, dht_layout_t *layout, int pos, int32_t **disk_layout_p); int -dht_disk_layout_merge(xlator_t *this, dht_layout_t *layout, int pos, - void *disk_layout_raw, int disk_layout_len); -int dht_disk_layout_extract_for_subvol(xlator_t *this, dht_layout_t *layout, xlator_t *subvol, int32_t **disk_layout_p); @@ -949,7 +945,7 @@ dht_selfheal_new_directory(call_frame_t *frame, dht_selfheal_dir_cbk_t cbk, int dht_selfheal_restore(call_frame_t *frame, dht_selfheal_dir_cbk_t cbk, loc_t *loc, dht_layout_t *layout); -int +void dht_layout_sort_volname(dht_layout_t *layout); int @@ -966,14 +962,14 @@ dht_get_du_info_for_subvol(xlator_t *this, int subvol_idx); int dht_layout_preset(xlator_t *this, xlator_t *subvol, inode_t *inode); int -dht_layout_index_for_subvol(dht_layout_t *layout, xlator_t *subvol); -int dht_layout_set(xlator_t *this, inode_t *inode, dht_layout_t *layout); ; void dht_layout_unref(xlator_t *this, dht_layout_t *layout); dht_layout_t * dht_layout_ref(xlator_t *this, dht_layout_t *layout); +int +dht_layout_index_for_subvol(dht_layout_t *layout, xlator_t *subvol); xlator_t * dht_first_up_subvol(xlator_t *this); xlator_t * @@ -1240,10 +1236,6 @@ dht_common_xattrop_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata); int -dht_fxattrop_cbk(call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata); - -int gf_defrag_status_get(dht_conf_t *conf, dict_t *dict); void @@ -1295,10 +1287,6 @@ int dht_dir_attr_heal(void *data); int dht_dir_attr_heal_done(int ret, call_frame_t *sync_frame, void *data); -int -dht_dir_has_layout(dict_t *xattr, char *name); -gf_boolean_t -dht_is_subvol_in_layout(dht_layout_t *layout, xlator_t *xlator); xlator_t * dht_subvol_with_free_space_inodes(xlator_t *this, xlator_t *subvol, xlator_t *ignore, dht_layout_t *layout, @@ -1307,15 +1295,18 @@ xlator_t * dht_subvol_maxspace_nonzeroinode(xlator_t *this, xlator_t *subvol, dht_layout_t *layout); int +dht_dir_has_layout(dict_t *xattr, char *name); +int dht_linkfile_attr_heal(call_frame_t *frame, xlator_t *this); -void -dht_layout_dump(dht_layout_t *layout, const char *prefix); int32_t dht_priv_dump(xlator_t *this); int32_t dht_inodectx_dump(xlator_t *this, inode_t *inode); +gf_boolean_t +dht_is_subvol_in_layout(dht_layout_t *layout, xlator_t *xlator); + int dht_inode_ctx_get_mig_info(xlator_t *this, inode_t *inode, xlator_t **src_subvol, xlator_t **dst_subvol); diff --git a/xlators/cluster/dht/src/dht-inode-read.c b/xlators/cluster/dht/src/dht-inode-read.c index 8007fc70693..dbb8070b0da 100644 --- a/xlators/cluster/dht/src/dht-inode-read.c +++ b/xlators/cluster/dht/src/dht-inode-read.c @@ -10,25 +10,25 @@ #include "dht-common.h" -int +static int dht_access2(xlator_t *this, xlator_t *dst_node, call_frame_t *frame, int ret); -int +static int dht_readv2(xlator_t *this, xlator_t *dst_node, call_frame_t *frame, int ret); -int +static int dht_attr2(xlator_t *this, xlator_t *dst_node, call_frame_t *frame, int ret); -int +static int dht_open2(xlator_t *this, xlator_t *dst_node, call_frame_t *frame, int ret); -int +static int dht_flush2(xlator_t *this, xlator_t *dst_node, call_frame_t *frame, int ret); -int +static int dht_lk2(xlator_t *this, xlator_t *dst_node, call_frame_t *frame, int ret); -int +static int dht_fsync2(xlator_t *this, xlator_t *dst_node, call_frame_t *frame, int ret); -int +static int dht_common_xattrop2(xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret); -int +static int dht_open_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno, fd_t *fd, dict_t *xdata) { @@ -67,7 +67,7 @@ out: return 0; } -int +static int dht_open2(xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret) { dht_local_t *local = NULL; @@ -216,7 +216,7 @@ err: return 0; } -int +static int dht_attr2(xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret) { dht_local_t *local = NULL; @@ -258,7 +258,7 @@ out: return 0; } -int +static int dht_attr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno, struct iatt *stbuf, dict_t *xdata) { @@ -473,7 +473,7 @@ out: return 0; } -int +static int dht_readv2(xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret) { dht_local_t *local = NULL; @@ -558,7 +558,7 @@ err: return 0; } -int +static int dht_access_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno, dict_t *xdata) { @@ -606,7 +606,7 @@ out: return 0; } -int +static int dht_access2(xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret) { dht_local_t *local = NULL; @@ -735,7 +735,7 @@ out: return 0; } -int +static int dht_flush2(xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret) { dht_local_t *local = NULL; @@ -881,7 +881,7 @@ out: return 0; } -int +static int dht_fsync2(xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret) { dht_local_t *local = NULL; @@ -959,7 +959,7 @@ err: /* TODO: for 'lk()' call, we need some other special error, may be ESTALE to indicate that lock migration happened on the fd, so we can consider it as phase 2 of migration */ -int +static int dht_lk_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno, struct gf_flock *flock, dict_t *xdata) { @@ -1006,7 +1006,7 @@ out: return 0; } -int +static int dht_lk2(xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret) { dht_local_t *local = NULL; @@ -1087,7 +1087,7 @@ err: return 0; } -int +static int dht_lease_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno, struct gf_lease *lease, dict_t *xdata) { @@ -1129,7 +1129,7 @@ err: } /* Symlinks are currently not migrated, so no need for any check here */ -int +static int dht_readlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno, const char *path, struct iatt *stbuf, dict_t *xdata) @@ -1305,7 +1305,7 @@ out: return 0; } -int +static int dht_common_xattrop2(xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret) { @@ -1364,7 +1364,7 @@ out: return 0; } -int +static int dht_xattrop_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata) { @@ -1452,7 +1452,7 @@ err: return 0; } -int +static int dht_fxattrop_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata) { @@ -1525,7 +1525,7 @@ err: * below fops, hence not implementing 'migration' related checks */ -int +static int dht_inodelk_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *xdata) diff --git a/xlators/cluster/dht/src/dht-inode-write.c b/xlators/cluster/dht/src/dht-inode-write.c index b6b349d64ed..eda2491e0ff 100644 --- a/xlators/cluster/dht/src/dht-inode-write.c +++ b/xlators/cluster/dht/src/dht-inode-write.c @@ -10,17 +10,17 @@ #include "dht-common.h" -int +static int dht_writev2(xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret); -int +static int dht_truncate2(xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret); -int +static int dht_setattr2(xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret); -int +static int dht_fallocate2(xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret); -int +static int dht_discard2(xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret); -int +static int dht_zerofill2(xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret); int @@ -142,7 +142,7 @@ out: return 0; } -int +static int dht_writev2(xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret) { dht_local_t *local = NULL; @@ -336,7 +336,7 @@ err: return 0; } -int +static int dht_truncate2(xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret) { dht_local_t *local = NULL; @@ -555,7 +555,7 @@ err: return 0; } -int +static int dht_fallocate2(xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret) { dht_local_t *local = NULL; @@ -731,7 +731,7 @@ err: return 0; } -int +static int dht_discard2(xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret) { dht_local_t *local = NULL; @@ -902,7 +902,7 @@ err: return 0; } -int +static int dht_zerofill2(xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret) { dht_local_t *local = NULL; @@ -1049,7 +1049,7 @@ out: return 0; } -int +static int dht_setattr2(xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret) { dht_local_t *local = NULL; diff --git a/xlators/cluster/dht/src/dht-layout.c b/xlators/cluster/dht/src/dht-layout.c index f2bc63d494c..fda904c92c9 100644 --- a/xlators/cluster/dht/src/dht-layout.c +++ b/xlators/cluster/dht/src/dht-layout.c @@ -254,7 +254,7 @@ dht_disk_layout_extract_for_subvol(xlator_t *this, dht_layout_t *layout, return dht_disk_layout_extract(this, layout, i, disk_layout_p); } -int +static int dht_disk_layout_merge(xlator_t *this, dht_layout_t *layout, int pos, void *disk_layout_raw, int disk_layout_len) { @@ -412,8 +412,7 @@ dht_layout_range_swap(dht_layout_t *layout, int i, int j) layout->list[j].start = start_swap; layout->list[j].stop = stop_swap; } - -int64_t +static int64_t dht_layout_entry_cmp_volname(dht_layout_t *layout, int i, int j) { return (strcmp(layout->list[i].xlator->name, layout->list[j].xlator->name)); @@ -436,7 +435,7 @@ dht_is_subvol_in_layout(dht_layout_t *layout, xlator_t *xlator) return _gf_false; } -int64_t +static int64_t dht_layout_entry_cmp(dht_layout_t *layout, int i, int j) { int64_t diff = 0; @@ -472,7 +471,7 @@ dht_layout_sort(dht_layout_t *layout) return 0; } -int +void dht_layout_sort_volname(dht_layout_t *layout) { int i = 0; @@ -488,8 +487,6 @@ dht_layout_sort_volname(dht_layout_t *layout) dht_layout_entry_swap(layout, i, j); } } - - return 0; } void diff --git a/xlators/cluster/dht/src/dht-linkfile.c b/xlators/cluster/dht/src/dht-linkfile.c index 67f2c5ed490..89ec6cca56e 100644 --- a/xlators/cluster/dht/src/dht-linkfile.c +++ b/xlators/cluster/dht/src/dht-linkfile.c @@ -11,7 +11,7 @@ #include #include "dht-common.h" -int +static int dht_linkfile_lookup_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno, inode_t *inode, struct iatt *stbuf, dict_t *xattr, @@ -43,8 +43,7 @@ out: return 0; } -#define is_equal(a, b) ((a) == (b)) -int +static int dht_linkfile_create_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno, inode_t *inode, struct iatt *stbuf, struct iatt *preparent, @@ -251,7 +250,7 @@ out: return subvol; } -int +static int dht_linkfile_setattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno, struct iatt *statpre, struct iatt *statpost, dict_t *xdata) diff --git a/xlators/cluster/dht/src/dht-shared.c b/xlators/cluster/dht/src/dht-shared.c index 0b73121b15a..d85b4d1ce13 100644 --- a/xlators/cluster/dht/src/dht-shared.c +++ b/xlators/cluster/dht/src/dht-shared.c @@ -17,23 +17,6 @@ #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #endif -#define GF_DECIDE_DEFRAG_THROTTLE_COUNT(throttle_count, conf) \ - { \ - throttle_count = MAX((sysconf(_SC_NPROCESSORS_ONLN) - 4), 4); \ - pthread_mutex_lock(&conf->defrag->dfq_mutex); \ - \ - if (!strcasecmp(conf->dthrottle, "lazy")) \ - conf->defrag->recon_thread_count = 1; \ - \ - else if (!strcasecmp(conf->dthrottle, "normal")) \ - conf->defrag->recon_thread_count = (throttle_count / 2); \ - \ - else if (!strcasecmp(conf->dthrottle, "aggressive")) \ - conf->defrag->recon_thread_count = throttle_count; \ - \ - pthread_mutex_unlock(&conf->defrag->dfq_mutex); \ - } - /* TODO: - use volumename in xattr instead of "dht" - use NS locks @@ -41,9 +24,7 @@ - complete linkfile selfheal */ -extern dht_methods_t dht_methods; - -void +static void dht_layout_dump(dht_layout_t *layout, const char *prefix) { char key[GF_DUMP_MAX_BUF_LEN]; @@ -51,8 +32,6 @@ dht_layout_dump(dht_layout_t *layout, const char *prefix) if (!layout) goto out; - if (!prefix) - goto out; gf_proc_dump_build_key(key, prefix, "cnt"); gf_proc_dump_write(key, "%d", layout->cnt); @@ -263,7 +242,7 @@ out: return ret; } -int +static int dht_parse_decommissioned_bricks(xlator_t *this, dht_conf_t *conf, const char *bricks) { @@ -309,14 +288,10 @@ out: return ret; } -int +static void dht_decommissioned_remove(xlator_t *this, dht_conf_t *conf) { int i = 0; - int ret = -1; - - if (!conf) - goto out; for (i = 0; i < conf->subvolume_cnt; i++) { if (conf->decommissioned_bricks[i]) { @@ -324,13 +299,9 @@ dht_decommissioned_remove(xlator_t *this, dht_conf_t *conf) conf->decommission_subvols_cnt--; } } - - ret = 0; -out: - - return ret; } -void + +static void dht_init_regex(xlator_t *this, dict_t *odict, char *name, regex_t *re, gf_boolean_t *re_valid, dht_conf_t *conf) { @@ -387,7 +358,7 @@ out: return ret; } -int +static int dht_configure_throttle(xlator_t *this, dht_conf_t *conf, char *temp_str) { int rebal_thread_count = 0; @@ -526,9 +497,7 @@ dht_reconfigure(xlator_t *this, dict_t *options) if (ret == -1) goto out; } else { - ret = dht_decommissioned_remove(this, conf); - if (ret == -1) - goto out; + dht_decommissioned_remove(this, conf); } dht_init_regex(this, options, "rsync-hash-regex", &conf->rsync_regex, @@ -614,7 +583,7 @@ out: return ret; } -int +static int dht_init_methods(xlator_t *this) { int ret = -1; -- cgit