From: Bobi Jam Date: Mon, 31 Jan 2011 13:33:49 +0000 (+0800) Subject: b=23499 ASSERTION(atomic_read(&client_stat->nid_exp_ref_count) == 0) X-Git-Tag: 1.8.5.54~8 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=ccfe355f01ba05729f4b8072413e4fd5607e0b9b;p=fs%2Flustre-release.git b=23499 ASSERTION(atomic_read(&client_stat->nid_exp_ref_count) == 0) i=johann i=liang In lprocfs_exp_setup(), we need release old stats in all cases. --- diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index ed58e7a..f60764c 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -397,7 +397,7 @@ struct obd_export; extern int lprocfs_add_clear_entry(struct obd_device * obd, cfs_proc_dir_entry_t *entry); extern int lprocfs_exp_setup(struct obd_export *exp, - lnet_nid_t *peer_nid, int reconnect, int *newnid); + lnet_nid_t *peer_nid, int *newnid); extern int lprocfs_exp_cleanup(struct obd_export *exp); extern cfs_proc_dir_entry_t *lprocfs_add_simple(struct proc_dir_entry *root, char *name, @@ -769,7 +769,7 @@ struct obd_export; static inline int lprocfs_add_clear_entry(struct obd_export *exp) { return 0; } static inline int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *peer_nid, - int reconnect, int *newnid) + int *newnid) { return 0; } static inline int lprocfs_exp_cleanup(struct obd_export *exp) { return 0; } diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index afde40e..6225881 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -323,7 +323,7 @@ static int mds_reconnect(struct obd_export *exp, struct obd_device *obd, rc = mds_connect_internal(exp, data); if (rc == 0) - mds_export_stats_init(obd, exp, 1, localdata); + mds_export_stats_init(obd, exp, localdata); RETURN(rc); } diff --git a/lustre/mds/mds_fs.c b/lustre/mds/mds_fs.c index 13d565b..99fe802 100644 --- a/lustre/mds/mds_fs.c +++ b/lustre/mds/mds_fs.c @@ -62,15 +62,13 @@ #include "mds_internal.h" -int mds_export_stats_init(struct obd_device *obd, - struct obd_export *exp, - int reconnect, - void *localdata) +int mds_export_stats_init(struct obd_device *obd, struct obd_export *exp, + void *localdata) { lnet_nid_t *client_nid = localdata; int rc, num_stats, newnid = 0; - rc = lprocfs_exp_setup(exp, client_nid, reconnect, &newnid); + rc = lprocfs_exp_setup(exp, client_nid, &newnid); if (rc) { /* Mask error for already created * /proc entries */ @@ -214,7 +212,7 @@ int mds_client_add(struct obd_device *obd, struct obd_export *exp, med->med_lr_off = le32_to_cpu(mds->mds_server_data->lsd_client_start) + (cl_idx * le16_to_cpu(mds->mds_server_data->lsd_client_size)); LASSERTF(med->med_lr_off > 0, "med_lr_off = %llu\n", med->med_lr_off); - mds_export_stats_init(obd, exp, 0, localdata); + mds_export_stats_init(obd, exp, localdata); if (new_client) { struct lvfs_run_ctxt *saved = NULL; @@ -269,7 +267,7 @@ int mds_client_add(struct obd_device *obd, struct obd_export *exp, } struct lsd_client_data zero_lcd; /* globals are implicitly zeroed */ - + int mds_client_free(struct obd_export *exp) { struct mds_export_data *med = &exp->exp_mds_data; diff --git a/lustre/mds/mds_internal.h b/lustre/mds/mds_internal.h index d0d4bb0..7c8979b 100644 --- a/lustre/mds/mds_internal.h +++ b/lustre/mds/mds_internal.h @@ -266,7 +266,6 @@ int mds_update_client_epoch(struct obd_export *exp); void mds_update_last_epoch(struct obd_device *obd); int mds_export_stats_init(struct obd_device *obd, struct obd_export *exp, - int reconnect, void *client_nid); int mds_client_add(struct obd_device *obd, struct obd_export *exp, int cl_off, void *localdata); diff --git a/lustre/mgs/mgs_fs.c b/lustre/mgs/mgs_fs.c index e6e733f..41aca79 100644 --- a/lustre/mgs/mgs_fs.c +++ b/lustre/mgs/mgs_fs.c @@ -61,13 +61,12 @@ int mgs_export_stats_init(struct obd_device *obd, struct obd_export *exp, - int reconnect, void *localdata) { lnet_nid_t *client_nid = localdata; int rc, num_stats, newnid = 0; - rc = lprocfs_exp_setup(exp, client_nid, reconnect, &newnid); + rc = lprocfs_exp_setup(exp, client_nid, &newnid); if (rc) { /* Mask error for already created * /proc entries */ @@ -111,7 +110,7 @@ int mgs_client_add(struct obd_device *obd, /* Remove client export data from the MGS */ int mgs_client_free(struct obd_export *exp) { - return 0; + return 0; } /* Same as mds_fid2dentry */ diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index 6ce1c6c..d9a9a3a 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -87,7 +87,7 @@ static int mgs_connect(struct lustre_handle *conn, struct obd_device *obd, data->ocd_version = LUSTRE_VERSION_CODE; } - rc = mgs_export_stats_init(obd, exp, 0, localdata); + rc = mgs_export_stats_init(obd, exp, localdata); if (rc) { class_disconnect(exp); } else { @@ -114,7 +114,7 @@ static int mgs_reconnect(struct obd_export *exp, struct obd_device *obd, data->ocd_version = LUSTRE_VERSION_CODE; } - RETURN(mgs_export_stats_init(obd, exp, 1, localdata)); + RETURN(mgs_export_stats_init(obd, exp, localdata)); } static int mgs_disconnect(struct obd_export *exp) diff --git a/lustre/mgs/mgs_internal.h b/lustre/mgs/mgs_internal.h index 2bb77fd..ddc19ed 100644 --- a/lustre/mgs/mgs_internal.h +++ b/lustre/mgs/mgs_internal.h @@ -87,7 +87,7 @@ int mgs_pool_cmd(struct obd_device *obd, enum lcfg_command_type cmd, /* mgs_fs.c */ int mgs_export_stats_init(struct obd_device *obd, struct obd_export *exp, - int reconnect, void *localdata); + void *localdata); int mgs_client_free(struct obd_export *exp); int mgs_fs_setup(struct obd_device *obd, struct vfsmount *mnt); int mgs_fs_cleanup(struct obd_device *obddev); diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 6b7158e..40410c0 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -1077,7 +1077,8 @@ static void lprocfs_free_client_stats(struct nid_stat *client_stat) client_stat->nid_brw_stats); LASSERTF(atomic_read(&client_stat->nid_exp_ref_count) == 0, - "count %d\n", atomic_read(&client_stat->nid_exp_ref_count)); + "nid %s:count %d\n", libcfs_nid2str(client_stat->nid), + atomic_read(&client_stat->nid_exp_ref_count)); hlist_del_init(&client_stat->nid_hash); @@ -1665,8 +1666,7 @@ int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer, } EXPORT_SYMBOL(lprocfs_nid_stats_clear_write); -int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int reconnect, - int *newnid) +int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) { int rc = 0; struct nid_stat *new_stat, *old_stat; @@ -1706,15 +1706,16 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int reconnect, old_stat, libcfs_nid2str(*nid), atomic_read(&new_stat->nid_exp_ref_count)); + /* we need to release old stats because lprocfs_exp_cleanup() hasn't + * been and will never be called. */ + if (exp->exp_nid_stats != NULL) { + nidstat_putref(exp->exp_nid_stats); + exp->exp_nid_stats = NULL; + } + /* Return -EALREADY here so that we know that the /proc * entry already has been created */ if (old_stat != new_stat) { - /* if this reconnect to live export from diffrent nid, we need - * to release old stats because disconnect will be never called. - * */ - if (reconnect && exp->exp_nid_stats) - nidstat_putref(exp->exp_nid_stats); - exp->exp_nid_stats = old_stat; GOTO(destroy_new, rc = -EALREADY); } diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index f5679b5..290e4b7 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -235,7 +235,6 @@ static int lprocfs_init_rw_stats(struct obd_device *obd, plus the procfs overhead :( */ static int filter_export_stats_init(struct obd_device *obd, struct obd_export *exp, - int reconnect, void *client_nid) { struct proc_dir_entry *brw_entry; @@ -245,8 +244,7 @@ static int filter_export_stats_init(struct obd_device *obd, if (obd_uuid_equals(&exp->exp_client_uuid, &obd->obd_uuid)) /* Self-export gets no proc entry */ RETURN(0); - rc = lprocfs_exp_setup(exp, (lnet_nid_t *)client_nid, - reconnect, &newnid); + rc = lprocfs_exp_setup(exp, (lnet_nid_t *)client_nid, &newnid); if (rc) { /* Mask error for already created * /proc entries */ @@ -945,7 +943,7 @@ static int filter_init_server_data(struct obd_device *obd, struct file * filp) } else { fed = &exp->exp_filter_data; fed->fed_lcd = lcd; - filter_export_stats_init(obd, exp, 0, NULL); + filter_export_stats_init(obd, exp, NULL); rc = filter_client_add(obd, exp, cl_idx); /* can't fail for existing client */ LASSERTF(rc == 0, "rc = %d\n", rc); @@ -2349,7 +2347,7 @@ static int filter_connect_internal(struct obd_export *exp, LPU64" left: "LPU64"\n", exp->exp_obd->obd_name, exp->exp_client_uuid.uuid, exp, data->ocd_grant, want, left); - + filter->fo_tot_granted_clients ++; } @@ -2440,7 +2438,7 @@ static int filter_reconnect(struct obd_export *exp, struct obd_device *obd, rc = filter_connect_internal(exp, data, 1); if (rc == 0) - filter_export_stats_init(obd, exp, 1, localdata); + filter_export_stats_init(obd, exp, localdata); RETURN(rc); } @@ -2475,7 +2473,7 @@ static int filter_connect(struct lustre_handle *conn, struct obd_device *obd, if (rc) GOTO(cleanup, rc); - filter_export_stats_init(obd, exp, 0, localdata); + filter_export_stats_init(obd, exp, localdata); if (!obd->obd_replayable) GOTO(cleanup, rc = 0); @@ -2981,7 +2979,7 @@ int filter_setattr(struct obd_export *exp, struct obd_info *oinfo, filter = &exp->exp_obd->u.filter; push_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, NULL); - /* + /* * We need to be atomic against a concurrent write * (which takes the semaphore for reading). fmd_mactime_xid * checks will have no effect if a write request with lower @@ -3797,7 +3795,7 @@ static int filter_truncate(struct obd_export *exp, struct obd_info *oinfo, oinfo->oi_policy.l_extent.end); RETURN(-EFAULT); } - + CDEBUG(D_INODE, "calling truncate for object "LPU64", valid = "LPX64 ", o_size = "LPD64"\n", oinfo->oi_oa->o_id, oinfo->oi_oa->o_valid, oinfo->oi_policy.l_extent.start);