From 273e40aa6a61423ddf9c9cea4c1b9d092f0d3116 Mon Sep 17 00:00:00 2001 From: Mikhail Pershin Date: Mon, 27 Jun 2011 21:02:14 +0400 Subject: [PATCH] LU-462 Don't alloc/free client data for self export Self export doesn't need client data and ldlm initialization. Change-Id: I31307d2212e3d11c79f1ab215edbb840c3cfb8c6 Signed-off-by: Mikhail Pershin Reviewed-on: http://review.whamcloud.com/1023 Tested-by: Hudson Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/mdt/mdt_handler.c | 21 ++++++++++++--------- lustre/mgs/mgs_handler.c | 7 +++++++ lustre/obdfilter/filter.c | 21 ++++++++++++++++----- lustre/ptlrpc/target.c | 4 ++++ 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 8143935..e1cdd5c 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -5186,7 +5186,7 @@ static int mdt_obd_disconnect(struct obd_export *exp) static int mdt_init_export(struct obd_export *exp) { struct mdt_export_data *med = &exp->exp_mdt_data; - int rc; + int rc = 0; ENTRY; CFS_INIT_LIST_HEAD(&med->med_open_head); @@ -5196,35 +5196,38 @@ 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); + + /* self-export doesn't need client data and ldlm initialization */ + if (unlikely(exp == exp->exp_obd->obd_self_export)) + RETURN(0); + rc = lut_client_alloc(exp); if (rc == 0) rc = ldlm_init_export(exp); - 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) { - struct mdt_export_data *med; - int rc = 0; ENTRY; - med = &exp->exp_mdt_data; if (exp_connect_rmtclient(exp)) mdt_cleanup_idmap(&exp->exp_mdt_data); target_destroy_export(exp); + if (unlikely(exp == exp->exp_obd->obd_self_export)) + 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)); - 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) diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index 45c74b29..5719b5d 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -859,6 +859,9 @@ static inline int mgs_init_export(struct obd_export *exp) exp->exp_connecting = 1; cfs_spin_unlock(&exp->exp_lock); + /* self-export doesn't need client data and ldlm initialization */ + if (unlikely(exp == exp->exp_obd->obd_self_export)) + return 0; return ldlm_init_export(exp); } @@ -868,6 +871,10 @@ static inline int mgs_destroy_export(struct obd_export *exp) target_destroy_export(exp); mgs_client_free(exp); + + if (unlikely(exp == exp->exp_obd->obd_self_export)) + RETURN(0); + ldlm_destroy_export(exp); RETURN(0); diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index aa8a8f6..e740d16 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -647,18 +647,28 @@ static void filter_fmd_cleanup(struct obd_export *exp) static int filter_init_export(struct obd_export *exp) { - int rc; + int rc = 0; + 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); + + /* self-export doesn't need client data and ldlm initialization */ + if (unlikely(exp == exp->exp_obd->obd_self_export)) + RETURN(0); + 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) @@ -2984,12 +2994,13 @@ static int filter_destroy_export(struct obd_export *exp) lquota_clearinfo(filter_quota_interface_ref, exp, exp->exp_obd); target_destroy_export(exp); - ldlm_destroy_export(exp); - lut_client_free(exp); - if (obd_uuid_equals(&exp->exp_client_uuid, &exp->exp_obd->obd_uuid)) + if (unlikely(exp == exp->exp_obd->obd_self_export)) RETURN(0); + ldlm_destroy_export(exp); + lut_client_free(exp); + if (!exp->exp_obd->obd_replayable) fsfilt_sync(exp->exp_obd, exp->exp_obd->u.obt.obt_sb); diff --git a/lustre/ptlrpc/target.c b/lustre/ptlrpc/target.c index e7ea1f5..df732ad 100644 --- a/lustre/ptlrpc/target.c +++ b/lustre/ptlrpc/target.c @@ -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) { + 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); @@ -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); + LASSERT(exp != exp->exp_obd->obd_self_export); + OBD_FREE_PTR(ted->ted_lcd); ted->ted_lcd = NULL; -- 1.8.3.1