diff --git a/lustre/include/linux/obd.h b/lustre/include/linux/obd.h
index 4cf2769d058e219af269c06f225cbb8d4e1f5b10..c9cc688796730ccdc55f53b3309e5aa5a013eda6 100644
--- a/lustre/include/linux/obd.h
+++ b/lustre/include/linux/obd.h
@@ -680,7 +680,7 @@ struct obd_ops {
         int (*o_del_conn)(struct obd_import *imp, struct obd_uuid *uuid);
         int (*o_connect)(struct lustre_handle *conn, struct obd_device *src,
                          struct obd_uuid *cluuid, unsigned long connect_flags);
-        int (*o_connect_post)(struct obd_export *exp);
+        int (*o_connect_post)(struct obd_export *exp, unsigned long connect_flags);
         int (*o_disconnect)(struct obd_export *exp, int flags);
 
         int (*o_statfs)(struct obd_device *obd, struct obd_statfs *osfs,
diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h
index dd05896adfeefc12845b74828d2d2182f01ad5c1..6a2a682275f63ea2bcb7c8a590ac8ef2fbddaa0f 100644
--- a/lustre/include/linux/obd_class.h
+++ b/lustre/include/linux/obd_class.h
@@ -673,7 +673,7 @@ static inline int obd_connect(struct lustre_handle *conn,
         RETURN(rc);
 }
 
-static inline int obd_connect_post(struct obd_export *exp)
+static inline int obd_connect_post(struct obd_export *exp, unsigned long flags)
 {
         int rc;
         ENTRY;
@@ -682,7 +682,7 @@ static inline int obd_connect_post(struct obd_export *exp)
         if (!OBT(exp->exp_obd) || !OBP((exp->exp_obd), connect_post))
                 RETURN(0);
         OBD_COUNTER_INCREMENT(exp->exp_obd, connect_post);
-        rc = OBP(exp->exp_obd, connect_post)(exp);
+        rc = OBP(exp->exp_obd, connect_post)(exp, flags);
         RETURN(rc);
 }
 
diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c
index d0e24663f1d2343ee7a4092358a25627378cf644..f384e96c70d9c117b8d1ce5ee1f98e8d455a4bae 100644
--- a/lustre/ldlm/ldlm_lib.c
+++ b/lustre/ldlm/ldlm_lib.c
@@ -727,7 +727,7 @@ int target_handle_connect(struct ptlrpc_request *req)
         revimp->imp_state = LUSTRE_IMP_FULL;
         class_import_put(revimp);
 
-        rc = obd_connect_post(export);
+        rc = obd_connect_post(export, connect_flags);
 out:
         if (rc)
                 req->rq_status = rc;
diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c
index d827236e8d932a69ac20ce884fe8c67f87537c40..6b72a3110882d50dd1ed73641e4af1f5c358d07f 100644
--- a/lustre/mds/handler.c
+++ b/lustre/mds/handler.c
@@ -396,8 +396,25 @@ static int mds_connect(struct lustre_handle *conn, struct obd_device *obd,
         if (rc)
                 GOTO(out, rc);
        
+        EXIT;
+out:
+        if (rc) {
+                OBD_FREE(mcd, sizeof(*mcd));
+                class_disconnect(exp, 0);
+        }
+        class_export_put(exp);
+
+        return rc;
+}
+
+static int mds_connect_post(struct obd_export *exp, unsigned long connect_flags)
+{
+        struct obd_device *obd = exp->exp_obd;
+        struct mds_obd *mds = &obd->u.mds;
+        int rc = 0;
+        ENTRY;
+
         if (!(connect_flags & OBD_OPT_MDS_CONNECTION)) {
-                struct mds_obd *mds = &obd->u.mds;
                 if (!(exp->exp_flags & OBD_OPT_REAL_CLIENT)) {
                         atomic_inc(&mds->mds_real_clients);
                         CDEBUG(D_OTHER,"%s: peer from %s is real client (%d)\n",
@@ -408,17 +425,8 @@ static int mds_connect(struct lustre_handle *conn, struct obd_device *obd,
                 if (mds->mds_lmv_name)
                         rc = mds_lmv_connect(obd, mds->mds_lmv_name);
         }
-        EXIT;
-out:
-        if (rc) {
-                OBD_FREE(mcd, sizeof(*mcd));
-                class_disconnect(exp, 0);
-        }
-        class_export_put(exp);
-
-        return rc;
+        RETURN(rc);
 }
-
 static int mds_init_export(struct obd_export *exp)
 {
         struct mds_export_data *med = &exp->exp_mds_data;
@@ -2976,6 +2984,7 @@ static struct obd_ops mds_obd_ops = {
         .o_attach          = mds_attach,
         .o_detach          = mds_detach,
         .o_connect         = mds_connect,
+        .o_connect_post    = mds_connect_post,
         .o_init_export     = mds_init_export,
         .o_destroy_export  = mds_destroy_export,
         .o_disconnect      = mds_disconnect,
diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c
index 3e5d9f6a2bef25093da5d3db5046dba582cdb675..04b941ec84e9d919561566d7e94da1409edf9634 100644
--- a/lustre/obdfilter/filter.c
+++ b/lustre/obdfilter/filter.c
@@ -1629,7 +1629,7 @@ static int filter_cleanup(struct obd_device *obd, int flags)
         RETURN(0);
 }
 
-static int filter_connect_post(struct obd_export *exp)
+static int filter_connect_post(struct obd_export *exp, unsigned long connect_flags)
 {
         struct obd_device *obd = exp->exp_obd;
         struct filter_export_data *fed;