diff options
author | Anand Avati <avati@redhat.com> | 2012-06-07 23:23:55 -0700 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2012-07-04 01:15:42 -0700 |
commit | e6e0e5bede9315db377afdec9c7bd92cfaa9c4bb (patch) | |
tree | 5bc732639c575e2e7c71173df6540bb5d6605671 /xlators/performance | |
parent | 96e24e01fa01144e784597c9dc3648c78da78a61 (diff) |
md-cache: cache SELinux and Posix ACL xattrs only if enabled
Fetch and cache SELinux and Posix ACL extended attributes only if
they are enabled in the command line respectively. Fetching the
extra extended attributes is pointless and negatively impacts
performance
Change-Id: I1bd1dbb1abb4a6929fad5f78bbfeaab8542ab4e2
BUG: 765785
Signed-off-by: Anand Avati <avati@redhat.com>
Reviewed-on: http://review.gluster.com/3538
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
Diffstat (limited to 'xlators/performance')
-rw-r--r-- | xlators/performance/md-cache/src/md-cache.c | 61 |
1 files changed, 56 insertions, 5 deletions
diff --git a/xlators/performance/md-cache/src/md-cache.c b/xlators/performance/md-cache/src/md-cache.c index b3179b5ed..9acffba2a 100644 --- a/xlators/performance/md-cache/src/md-cache.c +++ b/xlators/performance/md-cache/src/md-cache.c @@ -30,32 +30,34 @@ struct mdc_conf { int timeout; + gf_boolean_t cache_posix_acl; + gf_boolean_t cache_selinux; }; -struct mdc_key { +static struct mdc_key { const char *name; int load; int check; } mdc_keys[] = { { .name = "system.posix_acl_access", - .load = 1, + .load = 0, .check = 1, }, { .name = "system.posix_acl_default", - .load = 1, + .load = 0, .check = 1, }, { .name = "security.selinux", - .load = 1, + .load = 0, .check = 1, }, { .name = "security.capability", - .load = 1, + .load = 0, .check = 1, }, { @@ -1798,6 +1800,35 @@ mdc_forget (xlator_t *this, inode_t *inode) int +is_strpfx (const char *str1, const char *str2) +{ + /* is one of the string a prefix of the other? */ + int i; + + for (i = 0; str1[i] == str2[i]; i++) { + if (!str1[i] || !str2[i]) + break; + } + + return !(str1[i] && str2[i]); +} + + +int +mdc_key_load_set (struct mdc_key *keys, char *pattern, gf_boolean_t val) +{ + struct mdc_key *key = NULL; + + for (key = keys; key->name; key++) { + if (is_strpfx (key->name, pattern)) + key->load = val; + } + + return 0; +} + + +int reconfigure (xlator_t *this, dict_t *options) { struct mdc_conf *conf = NULL; @@ -1805,6 +1836,13 @@ reconfigure (xlator_t *this, dict_t *options) conf = this->private; GF_OPTION_RECONF ("md-cache-timeout", conf->timeout, options, int32, out); + + GF_OPTION_RECONF ("cache-selinux", conf->cache_selinux, options, bool, out); + mdc_key_load_set (mdc_keys, "security.", conf->cache_selinux); + + GF_OPTION_RECONF ("cache-posix-acl", conf->cache_posix_acl, options, bool, out); + mdc_key_load_set (mdc_keys, "system.posix_acl_", conf->cache_posix_acl); + out: return 0; } @@ -1832,6 +1870,11 @@ init (xlator_t *this) GF_OPTION_INIT ("md-cache-timeout", conf->timeout, int32, out); + GF_OPTION_INIT ("cache-selinux", conf->cache_selinux, bool, out); + mdc_key_load_set (mdc_keys, "security.", conf->cache_selinux); + + GF_OPTION_INIT ("cache-posix-acl", conf->cache_posix_acl, bool, out); + mdc_key_load_set (mdc_keys, "system.posix_acl_", conf->cache_posix_acl); out: this->private = conf; @@ -1879,6 +1922,14 @@ struct xlator_cbks cbks = { }; struct volume_options options[] = { + { .key = {"cache-selinux"}, + .type = GF_OPTION_TYPE_BOOL, + .default_value = "false", + }, + { .key = {"cache-posix-acl"}, + .type = GF_OPTION_TYPE_BOOL, + .default_value = "false", + }, { .key = {"md-cache-timeout"}, .type = GF_OPTION_TYPE_INT, .min = 0, |