diff options
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/cluster/dht/src/dht-common.c | 43 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-common.h | 11 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-helper.c | 13 |
3 files changed, 62 insertions, 5 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 0234bbbd409..29a63437f7b 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -3035,7 +3035,6 @@ err: return 0; } - int dht_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno, gf_dirent_t *orig_entries, dict_t *xdata) @@ -3051,7 +3050,9 @@ dht_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, dht_layout_t *layout = 0; dht_conf_t *conf = NULL; xlator_t *subvol = 0; + xlator_t *hashed_subvol = 0; int ret = 0; + int readdir_optimize = 0; INIT_LIST_HEAD (&entries.list); prev = cookie; @@ -3066,15 +3067,47 @@ dht_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, layout = local->layout; + if (conf->readdir_optimize == _gf_true) + readdir_optimize = 1; + list_for_each_entry (orig_entry, (&orig_entries->list), list) { next_offset = orig_entry->d_off; - if ((check_is_dir (NULL, (&orig_entry->d_stat), NULL) && - (prev->this != local->first_up_subvol)) || - check_is_linkfile (NULL, (&orig_entry->d_stat), + if (check_is_dir (NULL, (&orig_entry->d_stat), NULL)) { + + /*Directory entries filtering : + * a) If rebalance is running, pick from first_up_subvol + * b) (rebalance not running)hashed subvolume is NULL or + * down then filter in first_up_subvolume. Other wise the + * corresponding hashed subvolume will take care of the + * directory entry. + */ + + if (readdir_optimize) { + if (prev->this == local->first_up_subvol) + goto list; + else + continue; + + } + + hashed_subvol = dht_layout_search (this, layout, \ + orig_entry->d_name); + + if (prev->this == hashed_subvol) + goto list; + if ((hashed_subvol + && dht_subvol_status (conf, hashed_subvol)) + ||(prev->this != local->first_up_subvol)) + continue; + + goto list; + } + + if (check_is_linkfile (NULL, (&orig_entry->d_stat), orig_entry->dict)) { continue; } - +list: entry = gf_dirent_for_name (orig_entry->d_name); if (!entry) { diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index 3e9fabdbd9b..49fbd3878a0 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -740,4 +740,15 @@ dht_subvol_maxspace_nonzeroinode (xlator_t *this, xlator_t *subvol, dht_layout_t *layout); 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); + +int +dht_subvol_status (dht_conf_t *conf, xlator_t *subvol); + #endif/* _DHT_H */ diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c index dd8dc495d02..5a9047836cc 100644 --- a/xlators/cluster/dht/src/dht-helper.c +++ b/xlators/cluster/dht/src/dht-helper.c @@ -1073,3 +1073,16 @@ int dht_inode_ctx_set (inode_t *inode, xlator_t *this, dht_inode_ctx_t *ctx) out: return ret; } + +int +dht_subvol_status (dht_conf_t *conf, xlator_t *subvol) +{ + int i; + + for (i=0 ; i < conf->subvolume_cnt; i++) { + if (conf->subvolumes[i] == subvol) { + return conf->subvolume_status[i]; + } + } + return 0; +} |