From 0c37752eec0b93d423260d00901816904057daae Mon Sep 17 00:00:00 2001 From: shadow <shadow> Date: Mon, 29 Sep 2008 06:37:54 +0000 Subject: [PATCH] fix more llog locking problems. Branch b1_6 b=17157 i=johann i=wangdi --- lustre/include/lustre_log.h | 3 +++ lustre/include/obd.h | 1 + lustre/mds/handler.c | 15 +++++++++++---- lustre/mds/mds_lov.c | 4 ++-- lustre/obdclass/llog_cat.c | 24 +++++++++++++++--------- lustre/obdclass/llog_ioctl.c | 13 ++++++++----- lustre/obdclass/llog_lvfs.c | 9 +++++++-- lustre/obdclass/llog_obd.c | 7 +++++++ lustre/obdclass/obd_config.c | 1 + lustre/ptlrpc/llog_server.c | 4 ++++ 10 files changed, 59 insertions(+), 22 deletions(-) diff --git a/lustre/include/lustre_log.h b/lustre/include/lustre_log.h index 90e40ccb50..15bb9c6d75 100644 --- a/lustre/include/lustre_log.h +++ b/lustre/include/lustre_log.h @@ -248,6 +248,9 @@ int llog_get_cat_list(struct obd_device *obd, struct obd_device *disk_obd, char *name, int idx, int count, struct llog_catid *idarray); +int llog_put_cat_list(struct obd_device *obd, struct obd_device *disk_obd, + char *name, int idx, int count, struct llog_catid *idarray); + struct llog_ctxt { int loc_idx; /* my index the obd array of ctxt's */ struct llog_gen loc_gen; diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 7db51c5ac7..314e695944 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -844,6 +844,7 @@ struct obd_device { struct llog_ctxt *obd_llog_ctxt[LLOG_MAX_CTXTS]; struct semaphore obd_llog_alloc; + struct semaphore obd_llog_cat_process; cfs_waitq_t obd_llog_waitq; struct obd_device *obd_observer; diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index bf31f947b4..8451ba0292 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -2815,12 +2815,19 @@ static int mds_health_check(struct obd_device *obd) static int mds_process_config(struct obd_device *obd, obd_count len, void *buf) { struct lustre_cfg *lcfg = buf; - struct lprocfs_static_vars lvars; - int rc; + int rc = 0; - lprocfs_mds_init_vars(&lvars); + switch(lcfg->lcfg_command) { + case LCFG_PARAM: { + struct lprocfs_static_vars lvars; + lprocfs_mds_init_vars(&lvars); - rc = class_process_proc_param(PARAM_MDT, lvars.obd_vars, lcfg, obd); + rc = class_process_proc_param(PARAM_MDT, lvars.obd_vars, lcfg, obd); + break; + } + default: + break; + } return(rc); } diff --git a/lustre/mds/mds_lov.c b/lustre/mds/mds_lov.c index 7f47814ed3..8d68775549 100644 --- a/lustre/mds/mds_lov.c +++ b/lustre/mds/mds_lov.c @@ -491,8 +491,8 @@ static int mds_lov_update_desc(struct obd_device *obd, __u32 index, /* Don't change the mds_lov_desc until the objids size matches the count (paranoia) */ mds->mds_lov_desc = *ld; - CDEBUG(D_CONFIG, "updated lov_desc, tgt_count: %d\n", - mds->mds_lov_desc.ld_tgt_count); + CDEBUG(D_CONFIG, "updated lov_desc, tgt_count: %d - idx %d / uuid %s\n", + mds->mds_lov_desc.ld_tgt_count, index, uuid->uuid); mutex_down(&obd->obd_dev_sem); rc = mds_lov_update_max_ost(mds, index); diff --git a/lustre/obdclass/llog_cat.c b/lustre/obdclass/llog_cat.c index 3470611d78..b440994e0a 100644 --- a/lustre/obdclass/llog_cat.c +++ b/lustre/obdclass/llog_cat.c @@ -63,7 +63,8 @@ * * Assumes caller has already pushed us into the kernel context and is locking. */ -static struct llog_handle *llog_cat_new_log(struct llog_handle *cathandle) +static struct llog_handle *llog_cat_new_log(struct llog_handle *cathandle, + struct llog_logid *lid) { struct llog_handle *loghandle; struct llog_log_hdr *llh; @@ -84,11 +85,14 @@ static struct llog_handle *llog_cat_new_log(struct llog_handle *cathandle) if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_MDS_LLOG_CREATE_FAILED)) RETURN(ERR_PTR(-ENOSPC)); - - rc = llog_create(cathandle->lgh_ctxt, &loghandle, NULL, NULL); + + if (lid != NULL && lid->lgl_oid == 0) + lid = NULL; + + rc = llog_create(cathandle->lgh_ctxt, &loghandle, lid, NULL); if (rc) RETURN(ERR_PTR(rc)); - + rc = llog_init_handle(loghandle, LLOG_F_IS_PLAIN | LLOG_F_ZAP_WHEN_EMPTY, &cathandle->lgh_hdr->llh_tgtuuid); @@ -128,13 +132,12 @@ static struct llog_handle *llog_cat_new_log(struct llog_handle *cathandle) LASSERT(list_empty(&loghandle->u.phd.phd_entry)); list_add_tail(&loghandle->u.phd.phd_entry, &cathandle->u.chd.chd_head); - out_destroy: +out_destroy: if (rc < 0) llog_destroy(loghandle); RETURN(loghandle); } -EXPORT_SYMBOL(llog_cat_new_log); /* Open an existent log handle and add it to the open list. * This log handle will be closed when all of the records in it are removed. @@ -218,6 +221,7 @@ EXPORT_SYMBOL(llog_cat_put); * NOTE: loghandle is write-locked upon successful return */ static struct llog_handle *llog_cat_current_log(struct llog_handle *cathandle, + struct llog_logid *lid, int create) { struct llog_handle *loghandle = NULL; @@ -232,6 +236,7 @@ static struct llog_handle *llog_cat_current_log(struct llog_handle *cathandle, up_read(&cathandle->lgh_lock); RETURN(loghandle); } else { + lid = NULL; up_write(&loghandle->lgh_lock); } } @@ -255,12 +260,13 @@ static struct llog_handle *llog_cat_current_log(struct llog_handle *cathandle, up_write(&cathandle->lgh_lock); RETURN(loghandle); } else { + lid = NULL; up_write(&loghandle->lgh_lock); } } CDEBUG(D_INODE, "creating new log\n"); - loghandle = llog_cat_new_log(cathandle); + loghandle = llog_cat_new_log(cathandle, lid); if (!IS_ERR(loghandle)) down_write(&loghandle->lgh_lock); up_write(&cathandle->lgh_lock); @@ -280,7 +286,7 @@ int llog_cat_add_rec(struct llog_handle *cathandle, struct llog_rec_hdr *rec, ENTRY; LASSERT(rec->lrh_len <= LLOG_CHUNK_SIZE); - loghandle = llog_cat_current_log(cathandle, 1); + loghandle = llog_cat_current_log(cathandle, &reccookie->lgc_lgl, 1); if (IS_ERR(loghandle)) RETURN(PTR_ERR(loghandle)); /* loghandle is already locked by llog_cat_current_log() for us */ @@ -288,7 +294,7 @@ int llog_cat_add_rec(struct llog_handle *cathandle, struct llog_rec_hdr *rec, up_write(&loghandle->lgh_lock); if (rc == -ENOSPC) { /* to create a new plain log */ - loghandle = llog_cat_current_log(cathandle, 1); + loghandle = llog_cat_current_log(cathandle, &reccookie->lgc_lgl, 1); if (IS_ERR(loghandle)) RETURN(PTR_ERR(loghandle)); rc = llog_write_rec(loghandle, rec, reccookie, 1, buf, -1); diff --git a/lustre/obdclass/llog_ioctl.c b/lustre/obdclass/llog_ioctl.c index 48b9cc1ec0..261c031b64 100644 --- a/lustre/obdclass/llog_ioctl.c +++ b/lustre/obdclass/llog_ioctl.c @@ -436,11 +436,10 @@ int llog_catalog_list(struct obd_device *obd, int count, if (!idarray) RETURN(-ENOMEM); + mutex_down(&obd->obd_llog_cat_process); rc = llog_get_cat_list(obd, obd, name, 0, count, idarray); - if (rc) { - OBD_FREE(idarray, size); - RETURN(rc); - } + if (rc) + GOTO(out, rc); out = data->ioc_bulk; remains = data->ioc_inllen1; @@ -456,8 +455,12 @@ int llog_catalog_list(struct obd_device *obd, int count, break; } } +out: + /* release semaphore */ + mutex_up(&obd->obd_llog_cat_process); + OBD_VFREE(idarray, size); - RETURN(0); + RETURN(rc); } EXPORT_SYMBOL(llog_catalog_list); diff --git a/lustre/obdclass/llog_lvfs.c b/lustre/obdclass/llog_lvfs.c index 4627507da7..05b5066807 100644 --- a/lustre/obdclass/llog_lvfs.c +++ b/lustre/obdclass/llog_lvfs.c @@ -777,6 +777,8 @@ int llog_get_cat_list(struct obd_device *obd, struct obd_device *disk_obd, if (!count) RETURN(0); + LASSERT_SEM_LOCKED(&obd->obd_llog_cat_process); + push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); file = filp_open(name, O_RDWR | O_CREAT | O_LARGEFILE, 0700); if (!file || IS_ERR(file)) { @@ -828,8 +830,9 @@ int llog_put_cat_list(struct obd_device *obd, struct obd_device *disk_obd, loff_t off = idx * sizeof(*idarray); if (!count) - return (0); + GOTO(out1, rc = 0); + LASSERT_SEM_LOCKED(&obd->obd_llog_cat_process); push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); file = filp_open(name, O_RDWR | O_CREAT | O_LARGEFILE, 0700); if (!file || IS_ERR(file)) { @@ -852,15 +855,17 @@ int llog_put_cat_list(struct obd_device *obd, struct obd_device *disk_obd, GOTO(out, rc); } - out: +out: pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); if (file && !IS_ERR(file)) rc1 = filp_close(file, 0); if (rc == 0) rc = rc1; +out1: RETURN(rc); } +EXPORT_SYMBOL(llog_put_cat_list); struct llog_operations llog_lvfs_ops = { lop_write_rec: llog_lvfs_write_rec, diff --git a/lustre/obdclass/llog_obd.c b/lustre/obdclass/llog_obd.c index 77163a8095..cb3fe72ae4 100644 --- a/lustre/obdclass/llog_obd.c +++ b/lustre/obdclass/llog_obd.c @@ -410,12 +410,17 @@ int llog_cat_initialize(struct obd_device *obd, int idx, int rc; ENTRY; + mutex_down(&obd->obd_llog_cat_process); rc = llog_get_cat_list(obd, obd, name, idx, 1, &idarray); if (rc) { CERROR("rc: %d\n", rc); GOTO(out, rc); } + CDEBUG(D_INFO, "init llog for %s/%d - catid "LPX64"/"LPX64"/%x\n", + uuid->uuid, idx, idarray.lci_logid.lgl_oid, + idarray.lci_logid.lgl_ogr, idarray.lci_logid.lgl_ogen); + rc = obd_llog_init(obd, obd, 1, &idarray, uuid); if (rc) { CERROR("rc: %d\n", rc); @@ -429,6 +434,8 @@ int llog_cat_initialize(struct obd_device *obd, int idx, } out: + mutex_up(&obd->obd_llog_cat_process); + RETURN(rc); } EXPORT_SYMBOL(llog_cat_initialize); diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index 754cea4147..ccb7a69c9c 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -225,6 +225,7 @@ int class_attach(struct lustre_cfg *lcfg) cfs_waitq_init(&obd->obd_evict_inprogress_waitq); cfs_waitq_init(&obd->obd_llog_waitq); init_mutex(&obd->obd_llog_alloc); + init_mutex(&obd->obd_llog_cat_process); CFS_INIT_LIST_HEAD(&obd->obd_recovery_queue); CFS_INIT_LIST_HEAD(&obd->obd_delayed_reply_queue); diff --git a/lustre/ptlrpc/llog_server.c b/lustre/ptlrpc/llog_server.c index f5ee909bfe..bc436524c5 100644 --- a/lustre/ptlrpc/llog_server.c +++ b/lustre/ptlrpc/llog_server.c @@ -597,6 +597,7 @@ static int llog_catinfo_deletions(struct obd_device *obd, char *buf, if (!idarray) GOTO(release_ctxt, rc = -ENOMEM); + mutex_down(&obd->obd_llog_cat_process); rc = llog_get_cat_list(obd, obd, name, 0, count, idarray); if (rc) GOTO(out_free, rc); @@ -641,6 +642,9 @@ static int llog_catinfo_deletions(struct obd_device *obd, char *buf, out_pop: pop_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL); out_free: + /* release semphore */ + mutex_up(&obd->obd_llog_cat_process); + OBD_VFREE(idarray, size); release_ctxt: llog_ctxt_put(ctxt); -- GitLab