Whamcloud - gitweb
LU-462 Don't alloc/free client data for self export
authorMikhail Pershin <tappro@whamcloud.com>
Fri, 21 Oct 2011 12:38:29 +0000 (16:38 +0400)
committerOleg Drokin <green@whamcloud.com>
Thu, 3 Nov 2011 04:11:15 +0000 (00:11 -0400)
Self export doesn't need client data and ldlm initialization.
Patch uses uuid comparision to determine self_export.

Change-Id: Id26ef90e9857e4c1d3a0e7a3756eaf67607890d6
Signed-off-by: Mikhail Pershin <tappro@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/1574
Tested-by: Hudson
Reviewed-by: Jinshan Xiong <jay@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdt/mdt_handler.c
lustre/mgs/mgs_handler.c
lustre/obdfilter/filter.c
lustre/ptlrpc/target.c

index e94ade4..d4de547 100644 (file)
@@ -5196,35 +5196,42 @@ static int mdt_init_export(struct obd_export *exp)
         cfs_spin_lock(&exp->exp_lock);
         exp->exp_connecting = 1;
         cfs_spin_unlock(&exp->exp_lock);
         cfs_spin_lock(&exp->exp_lock);
         exp->exp_connecting = 1;
         cfs_spin_unlock(&exp->exp_lock);
+
+        /* self-export doesn't need client data and ldlm initialization */
+        if (unlikely(obd_uuid_equals(&exp->exp_obd->obd_uuid,
+                                     &exp->exp_client_uuid)))
+                RETURN(0);
+
         rc = lut_client_alloc(exp);
         if (rc == 0)
                 rc = ldlm_init_export(exp);
         rc = lut_client_alloc(exp);
         if (rc == 0)
                 rc = ldlm_init_export(exp);
-
         if (rc)
         if (rc)
-                CERROR("Error %d while initializing export\n", rc);
+                CERROR("%s: Error %d while initializing export\n",
+                       exp->exp_obd->obd_name, rc);
         RETURN(rc);
 }
 
 static int mdt_destroy_export(struct obd_export *exp)
 {
         RETURN(rc);
 }
 
 static int mdt_destroy_export(struct obd_export *exp)
 {
-        struct mdt_export_data *med;
-        int rc = 0;
         ENTRY;
 
         ENTRY;
 
-        med = &exp->exp_mdt_data;
         if (exp_connect_rmtclient(exp))
                 mdt_cleanup_idmap(&exp->exp_mdt_data);
 
         target_destroy_export(exp);
         if (exp_connect_rmtclient(exp))
                 mdt_cleanup_idmap(&exp->exp_mdt_data);
 
         target_destroy_export(exp);
+        /* destroy can be called from failed obd_setup, so
+         * checking uuid is safer than obd_self_export */
+        if (unlikely(obd_uuid_equals(&exp->exp_obd->obd_uuid,
+                                     &exp->exp_client_uuid)))
+                RETURN(0);
+
         ldlm_destroy_export(exp);
         lut_client_free(exp);
 
         LASSERT(cfs_list_empty(&exp->exp_outstanding_replies));
         LASSERT(cfs_list_empty(&exp->exp_mdt_data.med_open_head));
         ldlm_destroy_export(exp);
         lut_client_free(exp);
 
         LASSERT(cfs_list_empty(&exp->exp_outstanding_replies));
         LASSERT(cfs_list_empty(&exp->exp_mdt_data.med_open_head));
-        if (obd_uuid_equals(&exp->exp_client_uuid, &exp->exp_obd->obd_uuid))
-                RETURN(0);
 
 
-        RETURN(rc);
+        RETURN(0);
 }
 
 static void mdt_allow_cli(struct mdt_device *m, unsigned int flag)
 }
 
 static void mdt_allow_cli(struct mdt_device *m, unsigned int flag)
index cf3a0ba..ff572f8 100644 (file)
@@ -931,6 +931,10 @@ static inline int mgs_init_export(struct obd_export *exp)
         exp->exp_connecting = 1;
         cfs_spin_unlock(&exp->exp_lock);
 
         exp->exp_connecting = 1;
         cfs_spin_unlock(&exp->exp_lock);
 
+        /* self-export doesn't need client data and ldlm initialization */
+        if (unlikely(obd_uuid_equals(&exp->exp_obd->obd_uuid,
+                                     &exp->exp_client_uuid)))
+                return 0;
         return ldlm_init_export(exp);
 }
 
         return ldlm_init_export(exp);
 }
 
@@ -940,6 +944,11 @@ static inline int mgs_destroy_export(struct obd_export *exp)
 
         target_destroy_export(exp);
         mgs_client_free(exp);
 
         target_destroy_export(exp);
         mgs_client_free(exp);
+
+        if (unlikely(obd_uuid_equals(&exp->exp_obd->obd_uuid,
+                                     &exp->exp_client_uuid)))
+                RETURN(0);
+
         ldlm_destroy_export(exp);
 
         RETURN(0);
         ldlm_destroy_export(exp);
 
         RETURN(0);
index d1804ab..276ecc5 100644 (file)
@@ -648,17 +648,28 @@ static void filter_fmd_cleanup(struct obd_export *exp)
 static int filter_init_export(struct obd_export *exp)
 {
         int rc;
 static int filter_init_export(struct obd_export *exp)
 {
         int rc;
+        ENTRY;
+
         cfs_spin_lock_init(&exp->exp_filter_data.fed_lock);
         CFS_INIT_LIST_HEAD(&exp->exp_filter_data.fed_mod_list);
 
         cfs_spin_lock(&exp->exp_lock);
         exp->exp_connecting = 1;
         cfs_spin_unlock(&exp->exp_lock);
         cfs_spin_lock_init(&exp->exp_filter_data.fed_lock);
         CFS_INIT_LIST_HEAD(&exp->exp_filter_data.fed_mod_list);
 
         cfs_spin_lock(&exp->exp_lock);
         exp->exp_connecting = 1;
         cfs_spin_unlock(&exp->exp_lock);
+
+        /* self-export doesn't need client data and ldlm initialization */
+        if (unlikely(obd_uuid_equals(&exp->exp_obd->obd_uuid,
+                                     &exp->exp_client_uuid)))
+                RETURN(0);
+
         rc = lut_client_alloc(exp);
         if (rc == 0)
                 rc = ldlm_init_export(exp);
         rc = lut_client_alloc(exp);
         if (rc == 0)
                 rc = ldlm_init_export(exp);
+        if (rc)
+                CERROR("%s: Can't initialize export: rc %d\n",
+                       exp->exp_obd->obd_name, rc);
 
 
-        return rc;
+        RETURN(rc);
 }
 
 static int filter_free_server_data(struct obd_device_target *obt)
 }
 
 static int filter_free_server_data(struct obd_device_target *obt)
@@ -2976,12 +2987,14 @@ static int filter_destroy_export(struct obd_export *exp)
         lquota_clearinfo(filter_quota_interface_ref, exp, exp->exp_obd);
 
         target_destroy_export(exp);
         lquota_clearinfo(filter_quota_interface_ref, exp, exp->exp_obd);
 
         target_destroy_export(exp);
+
+        if (unlikely(obd_uuid_equals(&exp->exp_obd->obd_uuid,
+                                     &exp->exp_client_uuid)))
+               RETURN(0);
+
         ldlm_destroy_export(exp);
         lut_client_free(exp);
 
         ldlm_destroy_export(exp);
         lut_client_free(exp);
 
-        if (obd_uuid_equals(&exp->exp_client_uuid, &exp->exp_obd->obd_uuid))
-                RETURN(0);
-
         if (!exp->exp_obd->obd_replayable)
                 fsfilt_sync(exp->exp_obd, exp->exp_obd->u.obt.obt_sb);
 
         if (!exp->exp_obd->obd_replayable)
                 fsfilt_sync(exp->exp_obd, exp->exp_obd->u.obt.obt_sb);
 
index e7ea1f5..df732ad 100644 (file)
@@ -175,6 +175,8 @@ static int lut_last_rcvd_write(const struct lu_env *env, struct lu_target *lut,
  */
 int lut_client_alloc(struct obd_export *exp)
 {
  */
 int lut_client_alloc(struct obd_export *exp)
 {
+        LASSERT(exp != exp->exp_obd->obd_self_export);
+
         OBD_ALLOC_PTR(exp->exp_target_data.ted_lcd);
         if (exp->exp_target_data.ted_lcd == NULL)
                 RETURN(-ENOMEM);
         OBD_ALLOC_PTR(exp->exp_target_data.ted_lcd);
         if (exp->exp_target_data.ted_lcd == NULL)
                 RETURN(-ENOMEM);
@@ -192,6 +194,8 @@ void lut_client_free(struct obd_export *exp)
         struct tg_export_data *ted = &exp->exp_target_data;
         struct lu_target *lut = class_exp2tgt(exp);
 
         struct tg_export_data *ted = &exp->exp_target_data;
         struct lu_target *lut = class_exp2tgt(exp);
 
+        LASSERT(exp != exp->exp_obd->obd_self_export);
+
         OBD_FREE_PTR(ted->ted_lcd);
         ted->ted_lcd = NULL;
 
         OBD_FREE_PTR(ted->ted_lcd);
         ted->ted_lcd = NULL;