--- xlators/cluster/afr/src/afr.h-3.2.6	2012-04-03 18:18:57.738893869 +1000
+++ xlators/cluster/afr/src/afr.h	2012-04-03 18:20:40.631877186 +1000
@@ -74,6 +74,7 @@
 
         unsigned int background_self_heal_count;
         unsigned int background_self_heals_started;
+        gf_boolean_t background_self_heal_only;   /* on/off */
         gf_boolean_t metadata_self_heal;   /* on/off */
         gf_boolean_t entry_self_heal;      /* on/off */
 
--- xlators/cluster/afr/src/afr.c-3.2.6	2012-04-03 18:17:51.133895275 +1000
+++ xlators/cluster/afr/src/afr.c	2012-04-03 18:56:57.748850077 +1000
@@ -103,6 +103,7 @@
         gf_boolean_t metadata_change_log;   /* on/off */
         gf_boolean_t entry_change_log;      /* on/off */
         gf_boolean_t strict_readdir;
+        gf_boolean_t background_self_heal_only; /* on/off */
 
         afr_private_t * priv        = NULL;
         xlator_list_t * trav        = NULL;
@@ -112,6 +113,7 @@
         char * change_log      = NULL;
         char * str_readdir     = NULL;
         char * self_heal_algo  = NULL;
+        char * background_only = NULL;
 
         int32_t background_count  = 0;
         int32_t window_size       = 0;
@@ -134,6 +136,26 @@
                 priv->background_self_heal_count = background_count;
         }
 
+        dict_ret = dict_get_str (options, "background-self-heal-only",
+                                 &background_only);
+        if (dict_ret == 0) {
+                temp_ret = gf_string2boolean (background_only,
+				&background_self_heal_only);
+                if (temp_ret < 0) {
+                        gf_log (this->name, GF_LOG_WARNING,
+                                "Reconfiguration Invalid 'option background"
+                                "-self-heal-only %s'. Defaulting to off.",
+                                background_only);
+                        ret = -1;
+                        goto out;
+                }
+
+                priv->background_self_heal_only = background_self_heal_only;
+                gf_log (this->name, GF_LOG_DEBUG,
+                        "Reconfiguring 'option background"
+                        "-self-heal-only %s'.", background_only);
+        }
+
         dict_ret = dict_get_str (options, "metadata-self-heal",
                                  &self_heal);
         if (dict_ret == 0) {
@@ -380,6 +402,7 @@
         char * inodelk_trace   = NULL;
         char * entrylk_trace   = NULL;
         char * def_val         = NULL;
+        char * background_only = NULL;
         int32_t background_count  = 0;
         int32_t lock_server_count = 1;
         int32_t window_size       = 0;
@@ -422,6 +445,23 @@
                 priv->background_self_heal_count = background_count;
         }
 
+        priv->background_self_heal_only = 0;
+
+        dict_ret = dict_get_str (this->options, "background-self-heal-only",
+                                 &background_only);
+        if (dict_ret == 0) {
+                ret = gf_string2boolean (background_only,
+                        &priv->background_self_heal_only);
+                if (ret < 0) {
+                        gf_log (this->name, GF_LOG_WARNING,
+                                "Invalid 'option background-self-heal-only %s'"
+                                ". Defaulting to background-self-heal-only as"
+                                " 'off'.",
+                                background_only);
+                        priv->background_self_heal_only = 0;
+                }
+        }
+
         /* Default values */
 
         priv->data_self_heal     = 1;
@@ -828,6 +868,16 @@
           .type = GF_OPTION_TYPE_INT,
           .min  = 0
         },
+        { .key  = {"background-self-heal-only"},
+          .type = GF_OPTION_TYPE_BOOL,
+          .default_value = "0",
+          .description = "Action to take once background-self-heal-count has "
+                         "been reached. The default is \"off\" which blocks "
+                         "subsequent requests, by self healing in the "
+                         "foreground. Setting this to \"on\" ensures that "
+                         "subsequent requests are passed through without "
+                         "triggering the self heal process."
+        },
         { .key  = {"data-self-heal"},
           .type = GF_OPTION_TYPE_BOOL
         },
--- xlators/cluster/afr/src/afr-common.c-3.2.6	2012-04-03 20:32:59.863736798 +1000
+++ xlators/cluster/afr/src/afr-common.c	2012-04-03 20:30:37.197729183 +1000
@@ -1283,6 +1283,7 @@
                                         gf_boolean_t *sh_launched)
 {
         size_t              up_count = 0;
+	int                 bg_maxed = 0;
         afr_private_t       *priv    = NULL;
         afr_local_t         *local   = NULL;
 
@@ -1298,6 +1299,23 @@
                 goto out;
         }
 
+	if(priv->background_self_heal_only) {
+		LOCK (&priv->lock);
+		{
+			bg_maxed = 0;
+			if (priv->background_self_heals_started
+			    >= priv->background_self_heal_count) {
+				bg_maxed = 1;
+			}
+		}
+		UNLOCK (&priv->lock);
+		if(bg_maxed) {
+			gf_log (this->name, GF_LOG_DEBUG,
+			    "Max background self heals reached - do not attempt to detect self heal");
+	                goto out;
+		}
+	}
+
         afr_lookup_set_self_heal_data (local, this);
         if (afr_can_self_heal_proceed (&local->self_heal, priv)) {
                 if  (afr_is_self_heal_running (local))
--- xlators/cluster/afr/src/pump.c-3.2.6	2012-04-03 18:44:14.933864242 +1000
+++ xlators/cluster/afr/src/pump.c	2012-04-03 18:44:38.479865804 +1000
@@ -2311,6 +2311,7 @@
         priv->read_child = source_child;
         priv->favorite_child = source_child;
         priv->background_self_heal_count = 0;
+        priv->background_self_heal_only = 0;
 
 	priv->data_self_heal     = 1;
 	priv->metadata_self_heal = 1;
