12a457
From e291f14a85473c1a2b9b9f83eb562bda9afe9659 Mon Sep 17 00:00:00 2001
12a457
From: Prashanth Pai <ppai@redhat.com>
12a457
Date: Tue, 15 Mar 2016 14:21:18 +0530
12a457
Subject: [PATCH 59/80] md-cache: Cache gluster-swift metadata
12a457
12a457
Upstream reference:
12a457
>BUG: 1317788
12a457
>Change-Id: I86efca6a829cdda70ec7ed7fe0a16b73c25888c3
12a457
>Signed-off-by: Prashanth Pai <ppai@redhat.com>
12a457
>Reviewed-on: http://review.gluster.org/13753
12a457
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
12a457
>CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
12a457
>Reviewed-by: Niels de Vos <ndevos@redhat.com>
12a457
>Smoke: Gluster Build System <jenkins@build.gluster.com>
12a457
>Signed-off-by: Prashanth Pai <ppai@redhat.com>
12a457
12a457
BUG: 1317790
12a457
Change-Id: I013e8c0e3960c1cb6a747adae932907fe1051650
12a457
Signed-off-by: Prashanth Pai <ppai@redhat.com>
12a457
Reviewed-on: https://code.engineering.redhat.com/gerrit/71234
12a457
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
12a457
Reviewed-by: Niels de Vos <ndevos@redhat.com>
12a457
Tested-by: Niels de Vos <ndevos@redhat.com>
12a457
---
12a457
 tests/bugs/fuse/bug-1317785.t                   |   22 ++++++++++++++++++++++
12a457
 xlators/mgmt/glusterd/src/glusterd-volume-set.c |    8 ++++++++
12a457
 xlators/performance/md-cache/src/md-cache.c     |   22 ++++++++++++++++++++++
12a457
 3 files changed, 52 insertions(+), 0 deletions(-)
12a457
 create mode 100644 tests/bugs/fuse/bug-1317785.t
12a457
12a457
diff --git a/tests/bugs/fuse/bug-1317785.t b/tests/bugs/fuse/bug-1317785.t
12a457
new file mode 100644
12a457
index 0000000..87c6540
12a457
--- /dev/null
12a457
+++ b/tests/bugs/fuse/bug-1317785.t
12a457
@@ -0,0 +1,22 @@
12a457
+#!/bin/bash
12a457
+
12a457
+. $(dirname $0)/../../include.rc
12a457
+. $(dirname $0)/../../volume.rc
12a457
+
12a457
+cleanup;
12a457
+
12a457
+TEST glusterd
12a457
+
12a457
+TEST $CLI volume create $V0 $H0:$B0/$V0
12a457
+TEST $CLI volume start $V0
12a457
+
12a457
+TEST $CLI volume set $V0 cache-swift-metadata on
12a457
+EXPECT 'on' volinfo_field $V0 'performance.cache-swift-metadata'
12a457
+
12a457
+TEST $CLI volume set $V0 cache-swift-metadata off
12a457
+EXPECT 'off' volinfo_field $V0 'performance.cache-swift-metadata'
12a457
+
12a457
+TEST $CLI volume stop $V0
12a457
+TEST $CLI volume delete $V0
12a457
+
12a457
+cleanup;
12a457
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
12a457
index 1b68c1b..7bb8f91 100644
12a457
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
12a457
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
12a457
@@ -1393,6 +1393,14 @@ struct volopt_map_entry glusterd_volopt_map[] = {
12a457
           .op_version = 2,
12a457
           .flags      = OPT_FLAG_CLIENT_OPT
12a457
         },
12a457
+        { .key        = "performance.cache-swift-metadata",
12a457
+          .voltype    = "performance/md-cache",
12a457
+          .option     = "cache-swift-metadata",
12a457
+          .op_version = GD_OP_VERSION_3_7_10,
12a457
+          .description = "Cache swift metadata (user.swift.metadata xattr)",
12a457
+          .flags      = OPT_FLAG_CLIENT_OPT
12a457
+        },
12a457
+
12a457
 
12a457
  	/* Crypt xlator options */
12a457
 
12a457
diff --git a/xlators/performance/md-cache/src/md-cache.c b/xlators/performance/md-cache/src/md-cache.c
12a457
index d07e768..b94dade 100644
12a457
--- a/xlators/performance/md-cache/src/md-cache.c
12a457
+++ b/xlators/performance/md-cache/src/md-cache.c
12a457
@@ -36,6 +36,7 @@ struct mdc_conf {
12a457
 	gf_boolean_t cache_posix_acl;
12a457
 	gf_boolean_t cache_selinux;
12a457
 	gf_boolean_t force_readdirp;
12a457
+        gf_boolean_t cache_swift_metadata;
12a457
 };
12a457
 
12a457
 
12a457
@@ -69,6 +70,11 @@ static struct mdc_key {
12a457
 		.load = 0,
12a457
 		.check = 1,
12a457
 	},
12a457
+        {
12a457
+                .name = "user.swift.metadata",
12a457
+                .load = 0,
12a457
+                .check = 1,
12a457
+        },
12a457
 	{
12a457
 		.name = "security.capability",
12a457
 		.load = 0,
12a457
@@ -2229,6 +2235,12 @@ reconfigure (xlator_t *this, dict_t *options)
12a457
 	mdc_key_load_set (mdc_keys, "system.posix_acl_", conf->cache_posix_acl);
12a457
 	mdc_key_load_set (mdc_keys, "glusterfs.posix_acl.", conf->cache_posix_acl);
12a457
 
12a457
+        GF_OPTION_RECONF ("cache-swift-metadata", conf->cache_swift_metadata,
12a457
+                          options, bool, out);
12a457
+        mdc_key_load_set (mdc_keys, "user.swift.metadata",
12a457
+                          conf->cache_swift_metadata);
12a457
+
12a457
+
12a457
 	GF_OPTION_RECONF("force-readdirp", conf->force_readdirp, options, bool, out);
12a457
 
12a457
 out:
12a457
@@ -2265,6 +2277,11 @@ init (xlator_t *this)
12a457
 	mdc_key_load_set (mdc_keys, "system.posix_acl_", conf->cache_posix_acl);
12a457
 	mdc_key_load_set (mdc_keys, "glusterfs.posix_acl.", conf->cache_posix_acl);
12a457
 
12a457
+        GF_OPTION_INIT ("cache-swift-metadata",
12a457
+                        conf->cache_swift_metadata, bool, out);
12a457
+        mdc_key_load_set (mdc_keys, "user.swift.metadata",
12a457
+                          conf->cache_swift_metadata);
12a457
+
12a457
 	GF_OPTION_INIT("force-readdirp", conf->force_readdirp, bool, out);
12a457
 out:
12a457
 	this->private = conf;
12a457
@@ -2322,6 +2339,11 @@ struct volume_options options[] = {
12a457
 	  .type = GF_OPTION_TYPE_BOOL,
12a457
 	  .default_value = "false",
12a457
 	},
12a457
+        { .key = {"cache-swift-metadata"},
12a457
+          .type = GF_OPTION_TYPE_BOOL,
12a457
+          .default_value = "true",
12a457
+          .description = "Cache swift metadata (user.swift.metadata xattr)",
12a457
+        },
12a457
 	{ .key = {"cache-posix-acl"},
12a457
 	  .type = GF_OPTION_TYPE_BOOL,
12a457
 	  .default_value = "false",
12a457
-- 
12a457
1.7.1
12a457