diff options
| author | Shreyas Siravara <sshreyas@fb.com> | 2016-11-02 14:32:32 -0700 |
|---|---|---|
| committer | Shreyas Siravara <sshreyas@fb.com> | 2016-12-08 09:40:01 -0800 |
| commit | 9ca52cbf3ff540a3be6f7b5345e4af0f528c9c52 (patch) | |
| tree | f8af3125c76cd0ca4f4fabc1e36f70043b2e683f /xlators | |
| parent | 1508cde8e6022ae40a63cfaf94a7ee387e188dcf (diff) | |
performance/md-cache: Fix caching for root inode
Summary:
- `is_mdc_key_satisfied()` is returning 0 when it has not checked any of the keys
- This causes the cache'd value for the root inode to always be invalid (`mdc_xattr_satisfied()` returns 0, which causes us to jump to `uncached').
- In this diff we add a new option called "strict-xattrs", when enabled winds getxattr calls for those keys not present in our cache.
- This allows "special" getxattr commands (quota cli commands for example) to work when md-cache is enabled.
- This is a port of D4135452
Test Plan:
- Test on devserver and see latency improvements for root inode.
- Prove tests
Signed-off-by: Shreyas Siravara <sshreyas@fb.com>
Change-Id: I8ff75595e821d7a714224b3b3dded23f0a93560a
Reviewed-on: http://review.gluster.org/16060
Smoke: Gluster Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Kevin Vigor <kvigor@fb.com>
Tested-by: Shreyas Siravara <sshreyas@fb.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Diffstat (limited to 'xlators')
| -rw-r--r-- | xlators/performance/md-cache/src/md-cache.c | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/xlators/performance/md-cache/src/md-cache.c b/xlators/performance/md-cache/src/md-cache.c index 30443761c56..c6c4cd1220d 100644 --- a/xlators/performance/md-cache/src/md-cache.c +++ b/xlators/performance/md-cache/src/md-cache.c @@ -33,6 +33,7 @@ struct mdc_conf { gf_boolean_t cache_selinux; gf_boolean_t force_readdirp; gf_boolean_t cache_swift_metadata; + gf_boolean_t strict_xattrs; }; @@ -792,6 +793,7 @@ struct checkpair { static int is_mdc_key_satisfied (const char *key) { + unsigned int checked_keys = 0; const char *mdc_key = NULL; int i = 0; @@ -801,11 +803,13 @@ is_mdc_key_satisfied (const char *key) for (mdc_key = mdc_keys[i].name; (mdc_key = mdc_keys[i].name); i++) { if (!mdc_keys[i].load) continue; + + checked_keys++; if (strcmp (mdc_key, key) == 0) return 1; } - return 0; + return checked_keys > 0 ? 0 : 1; } @@ -1882,6 +1886,7 @@ mdc_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, const char *key, int op_errno = ENODATA; mdc_local_t *local = NULL; dict_t *xattr = NULL; + struct mdc_conf *conf = this->private; local = mdc_local_get (frame); if (!local) @@ -1897,7 +1902,19 @@ mdc_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, const char *key, goto uncached; if (!xattr || !dict_get (xattr, (char *)key)) { - ret = -1; + /* If we can't find the extended attribute, & strict-xattrs + * is enabled, we should wind and try to find them. + * + * NOTE: Quota & AFR queries through the mount + * (i.e, "special" Gluster xattrs) + * won't work unless strict-xattrs is enabled when + * md-cache is on. + */ + if (conf->strict_xattrs) { + goto uncached; + } + + ret = -1; op_errno = ENODATA; } @@ -2363,7 +2380,8 @@ reconfigure (xlator_t *this, dict_t *options) GF_OPTION_RECONF("force-readdirp", conf->force_readdirp, options, bool, out); - + GF_OPTION_RECONF("strict-xattrs", conf->strict_xattrs, options, + bool, out); out: return 0; } @@ -2404,6 +2422,7 @@ init (xlator_t *this) conf->cache_swift_metadata); GF_OPTION_INIT("force-readdirp", conf->force_readdirp, bool, out); + GF_OPTION_INIT ("strict-xattrs", conf->strict_xattrs, bool, out); out: this->private = conf; @@ -2474,7 +2493,7 @@ struct volume_options options[] = { { .key = {"md-cache-timeout"}, .type = GF_OPTION_TYPE_INT, .min = 0, - .max = 60, + .max = 300, .default_value = "1", .description = "Time period after which cache has to be refreshed", }, @@ -2484,5 +2503,14 @@ struct volume_options options[] = { .description = "Convert all readdir requests to readdirplus to " "collect stat info on each entry.", }, + { .key = {"strict-xattrs"}, + .type = GF_OPTION_TYPE_BOOL, + .default_value = "true", + .description = "When reading extended attributes from the cache, " + "if an xattr is not found, attempt to find it by winding " + "instead of returning ENODATA. This is necessary to query " + "the special extended attributes (trusted.glusterfs.quota.size) " + "through a FUSE mount with md-cache enabled." + }, { .key = {NULL} }, }; |
