From d2fa1e4266926cc5cdf46be8da77227e626119b5 Mon Sep 17 00:00:00 2001 From: adilger Date: Sat, 7 Aug 2004 00:33:37 +0000 Subject: [PATCH] Commit OST AMD support to HEAD so we can being running with a common code base. --- lustre/cobd/cache_obd.c | 7 +- lustre/include/linux/lustre_dlm.h | 17 +++-- lustre/include/linux/lvfs.h | 1 + lustre/include/linux/obd.h | 17 ++++- lustre/include/linux/obd_class.h | 16 ++--- lustre/ldlm/ldlm_lockd.c | 14 ++-- lustre/liblustre/super.c | 7 +- lustre/llite/file.c | 6 +- lustre/llite/llite_lib.c | 15 ++-- lustre/llite/lproc_llite.c | 1 + lustre/lmv/lmv_obd.c | 47 +++++++++++- lustre/lov/lov_internal.h | 2 + lustre/lov/lov_obd.c | 119 ++++++++++++------------------ lustre/lvfs/lvfs_linux.c | 5 ++ lustre/mdc/mdc_request.c | 4 +- lustre/mds/handler.c | 3 +- lustre/mds/mds_internal.h | 5 +- lustre/mds/mds_lov.c | 147 ++++++++++++++++++++++++-------------- lustre/osc/osc_request.c | 4 +- lustre/ptlrpc/service.c | 7 +- lustre/utils/lconf | 2 +- lustre/utils/liblustreapi.c | 38 +++++----- lustre/utils/lmc | 82 ++++++++++++--------- 23 files changed, 325 insertions(+), 241 deletions(-) diff --git a/lustre/cobd/cache_obd.c b/lustre/cobd/cache_obd.c index 72d0ab7..43b29ab 100644 --- a/lustre/cobd/cache_obd.c +++ b/lustre/cobd/cache_obd.c @@ -770,15 +770,14 @@ static int cobd_llog_finish(struct obd_device *obd, struct obd_llogs *llogs, return obd_llog_finish(cobd_obd, &cobd_obd->obd_llogs, count); } -static int cobd_notify(struct obd_device *obd, - struct obd_device *watched, - int active) +static int cobd_notify(struct obd_device *obd, struct obd_device *watched, + int active, void *data) { struct obd_export *cobd_exp; cobd_exp = cobd_get_exp(obd); - return obd_notify(class_exp2obd(cobd_exp), watched, active); + return obd_notify(class_exp2obd(cobd_exp), watched, active, data); } static int cobd_pin(struct obd_export *exp, obd_id ino, __u32 gen, diff --git a/lustre/include/linux/lustre_dlm.h b/lustre/include/linux/lustre_dlm.h index da00920..ef991c2 100644 --- a/lustre/include/linux/lustre_dlm.h +++ b/lustre/include/linux/lustre_dlm.h @@ -324,9 +324,9 @@ do { \ if (lock->l_resource->lr_type == LDLM_EXTENT) { \ CDEBUG(level, "### " format \ " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " \ - "res: "LPU64"/"LPU64" rrc: %d type: %s ["LPU64"->"LPU64\ - "] (req "LPU64"->"LPU64") flags: %x remote: "LPX64 \ - " expref: %d\n" , ## a, \ + "res: "LPU64"/"LPU64"/"LPU64" rrc: %d type: %s ["LPU64 \ + "->"LPU64"] (req "LPU64"->"LPU64") flags: %x remote: " \ + LPX64" expref: %d\n" , ## a, \ lock->l_resource->lr_namespace->ns_name, lock, \ lock->l_handle.h_cookie, atomic_read(&lock->l_refc), \ lock->l_readers, lock->l_writers, \ @@ -334,6 +334,7 @@ do { \ ldlm_lockname[lock->l_req_mode], \ lock->l_resource->lr_name.name[0], \ lock->l_resource->lr_name.name[1], \ + lock->l_resource->lr_name.name[2], \ atomic_read(&lock->l_resource->lr_refcount), \ ldlm_typename[lock->l_resource->lr_type], \ lock->l_policy_data.l_extent.start, \ @@ -347,8 +348,8 @@ do { \ if (lock->l_resource->lr_type == LDLM_FLOCK) { \ CDEBUG(level, "### " format \ " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " \ - "res: "LPU64"/"LPU64" rrc: %d type: %s pid: "LPU64" " \ - "["LPU64"->"LPU64"] flags: %x remote: "LPX64 \ + "res: "LPU64"/"LPU64"/"LPU64" rrc: %d type: %s pid: " \ + LPU64" ["LPU64"->"LPU64"] flags: %x remote: "LPX64 \ " expref: %d\n" , ## a, \ lock->l_resource->lr_namespace->ns_name, lock, \ lock->l_handle.h_cookie, atomic_read(&lock->l_refc), \ @@ -357,6 +358,7 @@ do { \ ldlm_lockname[lock->l_req_mode], \ lock->l_resource->lr_name.name[0], \ lock->l_resource->lr_name.name[1], \ + lock->l_resource->lr_name.name[2], \ atomic_read(&lock->l_resource->lr_refcount), \ ldlm_typename[lock->l_resource->lr_type], \ lock->l_policy_data.l_flock.pid, \ @@ -370,8 +372,8 @@ do { \ if (lock->l_resource->lr_type == LDLM_IBITS) { \ CDEBUG(level, "### " format \ " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " \ - "res: "LPU64"/"LPU64" bits "LPX64" rrc: %d type: %s " \ - "flags: %x remote: "LPX64" expref: %d\n" , ## a, \ + "res: "LPU64"/"LPU64"/"LPU64" bits "LPX64" rrc: %d " \ + "type: %s flags: %x remote: "LPX64" expref: %d\n" , ## a,\ lock->l_resource->lr_namespace->ns_name, \ lock, lock->l_handle.h_cookie, \ atomic_read (&lock->l_refc), \ @@ -380,6 +382,7 @@ do { \ ldlm_lockname[lock->l_req_mode], \ lock->l_resource->lr_name.name[0], \ lock->l_resource->lr_name.name[1], \ + lock->l_resource->lr_name.name[2], \ lock->l_policy_data.l_inodebits.bits, \ atomic_read(&lock->l_resource->lr_refcount), \ ldlm_typename[lock->l_resource->lr_type], \ diff --git a/lustre/include/linux/lvfs.h b/lustre/include/linux/lvfs.h index 4327cf7..1937168 100644 --- a/lustre/include/linux/lvfs.h +++ b/lustre/include/linux/lvfs.h @@ -36,6 +36,7 @@ struct lvfs_run_ctxt { int ngroups; struct lvfs_callback_ops cb_ops; #ifdef OBD_CTXT_DEBUG + int pid; __u32 magic; #endif }; diff --git a/lustre/include/linux/obd.h b/lustre/include/linux/obd.h index 55ad715..e3f37d6 100644 --- a/lustre/include/linux/obd.h +++ b/lustre/include/linux/obd.h @@ -95,6 +95,20 @@ struct lov_stripe_md { struct lov_oinfo lsm_oinfo[0]; }; +static inline void dump_lsm(int level, struct lov_stripe_md *lsm) +{ + int i; + CDEBUG(level, "objid "LPX64"/"LPU64", maxbytes "LPX64", magic 0x%08X, " + "stripe_size %u, stripe_count %u\n", + lsm->lsm_object_id, lsm->lsm_object_gr, lsm->lsm_maxbytes, + lsm->lsm_magic, lsm->lsm_stripe_size, lsm->lsm_stripe_count); + for (i = 0; i < lsm->lsm_stripe_count; i++) + CDEBUG(level, "idx %u ostidx %u/%u object "LPU64"/"LPU64"\n", + i, lsm->lsm_oinfo[i].loi_ost_idx, + lsm->lsm_oinfo[i].loi_ost_gen, + lsm->lsm_oinfo[i].loi_id, lsm->lsm_oinfo[i].loi_gr); +} + struct obd_type { struct list_head typ_chain; struct obd_ops *typ_ops; @@ -427,6 +441,7 @@ struct lov_obd { int bufsize; int refcount; int lo_catalog_loaded:1; + unsigned long lov_connect_flags; struct lov_tgt_desc *tgts; }; @@ -768,7 +783,7 @@ struct obd_ops { enum obd_import_event); int (*o_notify)(struct obd_device *obd, struct obd_device *watched, - int active); + int active, void *data); int (*o_init_ea_size)(struct obd_export *, int, int); /* diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index bb85d8c..60c4745 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -1116,9 +1116,8 @@ static inline int obd_llog_connect(struct obd_export *exp, return OBP(exp->exp_obd, llog_connect)(exp, body); } -static inline int obd_notify(struct obd_device *obd, - struct obd_device *watched, - int active) +static inline int obd_notify(struct obd_device *obd, struct obd_device *watched, + int active, void *data) { if (!obd->obd_set_up) { CERROR("obd %s not set up\n", obd->obd_name); @@ -1131,7 +1130,7 @@ static inline int obd_notify(struct obd_device *obd, } OBD_COUNTER_INCREMENT(obd, notify); - return OBP(obd, notify)(obd, watched, active); + return OBP(obd, notify)(obd, watched, active, data); } static inline int obd_register_observer(struct obd_device *obd, @@ -1464,11 +1463,7 @@ static inline struct obdo *obdo_alloc(void) { struct obdo *oa; - oa = kmem_cache_alloc(obdo_cachep, SLAB_KERNEL); - if (oa == NULL) - LBUG(); - CDEBUG(D_MALLOC, "kmem_cache_alloced oa at %p\n", oa); - memset(oa, 0, sizeof (*oa)); + OBD_SLAB_ALLOC(oa, obdo_cachep, GFP_KERNEL, sizeof(*oa)); return oa; } @@ -1477,8 +1472,7 @@ static inline void obdo_free(struct obdo *oa) { if (!oa) return; - CDEBUG(D_MALLOC, "kmem_cache_freed oa at %p\n", oa); - kmem_cache_free(obdo_cachep, oa); + OBD_SLAB_FREE(oa, obdo_cachep, sizeof(*oa)); } #if !defined(__KERNEL__) || (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index 8bb18d2..b4acd61 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -1092,7 +1092,7 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) static int ldlm_cancel_handler(struct ptlrpc_request *req) { - int rc; + int rc = 0; ENTRY; /* Requests arrive in sender's byte order. The ptlrpc service @@ -1111,7 +1111,8 @@ static int ldlm_cancel_handler(struct ptlrpc_request *req) lustre_swab_ldlm_request); if (dlm_req != NULL) ldlm_lock_dump_handle(D_ERROR, &dlm_req->lock_handle1); - RETURN(-ENOTCONN); + ldlm_callback_reply(req, -ENOTCONN); + RETURN(0); } switch (req->rq_reqmsg->opc) { @@ -1121,16 +1122,13 @@ static int ldlm_cancel_handler(struct ptlrpc_request *req) CDEBUG(D_INODE, "cancel\n"); OBD_FAIL_RETURN(OBD_FAIL_LDLM_CANCEL, 0); rc = ldlm_handle_cancel(req); - if (rc) - break; - RETURN(0); - + break; default: CERROR("invalid opcode %d\n", req->rq_reqmsg->opc); - RETURN(-EINVAL); + ldlm_callback_reply(req, -EINVAL); } - RETURN(0); + RETURN(rc); } #ifdef __KERNEL__ diff --git a/lustre/liblustre/super.c b/lustre/liblustre/super.c index 558885a..0b6c96a 100644 --- a/lustre/liblustre/super.c +++ b/lustre/liblustre/super.c @@ -495,11 +495,12 @@ static int llu_iop_getattr(struct pnode *pno, static int null_if_equal(struct ldlm_lock *lock, void *data) { - if (data == lock->l_ast_data) + if (data == lock->l_ast_data) { lock->l_ast_data = NULL; - if (lock->l_req_mode != lock->l_granted_mode) - return LDLM_ITER_STOP; + if (lock->l_req_mode != lock->l_granted_mode) + LDLM_ERROR(lock,"clearing inode with ungranted lock\n"); + } return LDLM_ITER_CONTINUE; } diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 659db37..edc28c4 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -329,9 +329,11 @@ static int ll_lock_to_stripe_offset(struct inode *inode, struct ldlm_lock *lock) check: if (lsm->lsm_oinfo[stripe].loi_id != lock->l_resource->lr_name.name[0]|| lsm->lsm_oinfo[stripe].loi_gr != lock->l_resource->lr_name.name[2]){ - LDLM_ERROR(lock, "resource doesn't match object "LPU64"/"LPU64, + LDLM_ERROR(lock, "resource doesn't match object "LPU64"/"LPU64 + " inode=%lu/%u (%p)\n", lsm->lsm_oinfo[stripe].loi_id, - lsm->lsm_oinfo[stripe].loi_gr); + lsm->lsm_oinfo[stripe].loi_gr, + inode->i_ino, inode->i_generation, inode); RETURN(-ELDLM_NO_LOCK_DATA); } diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 2cab4c8..906e978 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -840,11 +840,12 @@ struct inode *ll_inode_from_lock(struct ldlm_lock *lock) int null_if_equal(struct ldlm_lock *lock, void *data) { - if (data == lock->l_ast_data) + if (data == lock->l_ast_data) { lock->l_ast_data = NULL; - if (lock->l_req_mode != lock->l_granted_mode) - return LDLM_ITER_STOP; + if (lock->l_req_mode != lock->l_granted_mode) + LDLM_ERROR(lock,"clearing inode with ungranted lock\n"); + } return LDLM_ITER_CONTINUE; } @@ -1151,14 +1152,6 @@ int ll_statfs(struct super_block *sb, struct kstatfs *sfs) return 0; } -void dump_lsm(int level, struct lov_stripe_md *lsm) -{ - CDEBUG(level, "objid "LPX64", maxbytes "LPX64", magic 0x%08X, " - "stripe_size %u, stripe_count %u\n", - lsm->lsm_object_id, lsm->lsm_maxbytes, lsm->lsm_magic, - lsm->lsm_stripe_size, lsm->lsm_stripe_count); -} - void ll_update_inode(struct inode *inode, struct lustre_md *md) { struct ll_inode_info *lli = ll_i2info(inode); diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index ccf05f0..d432d1b0 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -221,6 +221,7 @@ static int ll_wr_config_update(struct file *file, const char *buffer, struct ll_sb_info *sbi = ll_s2sbi(sb); ENTRY; + CWARN("Starting a LOV/OST update !\n"); RETURN(ll_process_config_update(sbi, 0)); } diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 66d9d7f..e99c488 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -110,7 +110,7 @@ static int lmv_set_mdc_active(struct lmv_obd *lmv, struct obd_uuid *uuid, } static int lmv_notify(struct obd_device *obd, struct obd_device *watched, - int active) + int active, void *data) { int rc; struct obd_uuid *uuid; @@ -135,7 +135,7 @@ static int lmv_notify(struct obd_device *obd, struct obd_device *watched, if (obd->obd_observer) /* Pass the notification up the chain. */ - rc = obd_notify(obd->obd_observer, watched, active); + rc = obd_notify(obd->obd_observer, watched, active, data); RETURN(rc); } @@ -436,6 +436,7 @@ static int lmv_setup(struct obd_device *obd, obd_count len, void *buf) struct lmv_desc *desc; struct obd_uuid *uuids; struct lmv_tgt_desc *tgts; + struct obd_device *tgt_obd; struct lustre_cfg *lcfg = buf; struct lmv_obd *lmv = &obd->u.lmv; ENTRY; @@ -489,6 +490,18 @@ static int lmv_setup(struct obd_device *obd, obd_count len, void *buf) OBD_FREE(lmv->tgts, lmv->bufsize); } + tgt_obd = class_find_client_obd(&lmv->tgts->uuid, LUSTRE_MDC_NAME, + &obd->obd_uuid); + if (!tgt_obd) { + CERROR("Target %s not attached\n", lmv->tgts->uuid.uuid); + RETURN(-EINVAL); + } + + rc = obd_llog_init(obd, &obd->obd_llogs, tgt_obd, 0, NULL); + if (rc) { + CERROR("failed to setup llogging subsystems\n"); + } + RETURN(rc); } @@ -1555,6 +1568,34 @@ int lmv_obd_create(struct obd_export *exp, struct obdo *oa, RETURN(rc); } +static int lmv_llog_init(struct obd_device *obd, struct obd_llogs *llogs, + struct obd_device *tgt, int count, + struct llog_catid *logid) +{ + struct llog_ctxt *ctxt; + int rc; + ENTRY; + + rc = obd_llog_setup(obd, llogs, LLOG_CONFIG_REPL_CTXT, tgt, 0, NULL, + &llog_client_ops); + if (rc == 0) { + ctxt = llog_get_context(llogs, LLOG_CONFIG_REPL_CTXT); + ctxt->loc_imp = tgt->u.cli.cl_import; + } + + RETURN(rc); +} + +static int lmv_llog_finish(struct obd_device *obd, + struct obd_llogs *llogs, int count) +{ + int rc; + ENTRY; + + rc = obd_llog_cleanup(llog_get_context(llogs, LLOG_CONFIG_REPL_CTXT)); + RETURN(rc); +} + static int lmv_get_info(struct obd_export *exp, __u32 keylen, void *key, __u32 *vallen, void *val) { @@ -1718,6 +1759,8 @@ struct obd_ops lmv_obd_ops = { .o_connect = lmv_connect, .o_disconnect = lmv_disconnect, .o_statfs = lmv_statfs, + .o_llog_init = lmv_llog_init, + .o_llog_finish = lmv_llog_finish, .o_get_info = lmv_get_info, .o_set_info = lmv_set_info, .o_create = lmv_obd_create, diff --git a/lustre/lov/lov_internal.h b/lustre/lov/lov_internal.h index 5e0d326..4291f39 100644 --- a/lustre/lov/lov_internal.h +++ b/lustre/lov/lov_internal.h @@ -14,6 +14,8 @@ #define LAP_MAGIC 8200 +#define LOV_MAX_TGT_COUNT 1024 + static inline int lov_tgt_changed(struct lov_obd *lov, struct lov_oinfo *loi) { return lov->tgts[loi->loi_ost_idx].ltd_gen != loi->loi_ost_gen; diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index a025ea2..d1a0a8a 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -227,6 +227,8 @@ static int lov_connect(struct lustre_handle *conn, struct obd_device *obd, RETURN(0); } + /* connect_flags is the MDS number, save for use in lov_add_obd */ + lov->lov_connect_flags = connect_flags; for (i = 0, tgt = lov->tgts; i < lov->desc.ld_tgt_count; i++, tgt++) { if (obd_uuid_empty(&tgt->uuid)) continue; @@ -393,10 +395,11 @@ static int lov_set_osc_active(struct lov_obd *lov, struct obd_uuid *uuid, } static int lov_notify(struct obd_device *obd, struct obd_device *watched, - int active) + int active, void *data) { int rc; struct obd_uuid *uuid; + ENTRY; if (strcmp(watched->obd_type->typ_name, LUSTRE_OSC_NAME)) { CERROR("unexpected notification of %s %s!\n", @@ -418,7 +421,7 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched, if (obd->obd_observer) /* Pass the notification up the chain. */ - rc = obd_notify(obd->obd_observer, watched, active); + rc = obd_notify(obd->obd_observer, watched, active, data); RETURN(rc); } @@ -484,20 +487,17 @@ static int lov_setup(struct obd_device *obd, obd_count len, void *buf) RETURN(-EINVAL); } - if (desc->ld_tgt_count) { - lov->bufsize = desc->ld_tgt_count * sizeof(struct lov_tgt_desc); - OBD_ALLOC(lov->tgts, lov->bufsize); - if (lov->tgts == NULL) { - lov->bufsize = 0; - CERROR("couldn't allocate %d bytes for target table.\n", - lov->bufsize); - RETURN(-EINVAL); - } - desc->ld_tgt_count = 0; + lov->bufsize = LOV_MAX_TGT_COUNT * sizeof(struct lov_tgt_desc); + OBD_ALLOC(lov->tgts, lov->bufsize); + if (lov->tgts == NULL) { + lov->bufsize = 0; + CERROR("couldn't allocate %d bytes for target table.\n", + lov->bufsize); + RETURN(-EINVAL); } + desc->ld_tgt_count = 0; desc->ld_active_tgt_count = 0; - CDEBUG(D_CONFIG, "tgts: %p bufsize: 0x%x\n", lov->tgts, lov->bufsize); lov->desc = *desc; spin_lock_init(&lov->lov_lock); sema_init(&lov->lov_llog_sem, 1); @@ -518,18 +518,13 @@ lov_add_obd(struct obd_device *obd, struct obd_uuid *uuidp, int index, int gen) { struct lov_obd *lov = &obd->u.lov; struct lov_tgt_desc *tgt; - struct obd_export *exp_observer; - __u32 bufsize; - __u32 size = 2; - obd_id params[2]; - char name[32] = "CATLIST"; - int rc, old_count; + int rc; ENTRY; CDEBUG(D_CONFIG, "uuid: %s idx: %d gen: %d\n", uuidp->uuid, index, gen); - if (index < 0) { + if ((index < 0) || (index >= LOV_MAX_TGT_COUNT)) { CERROR("request to add OBD %s at invalid index: %d\n", uuidp->uuid, index); RETURN(-EINVAL); @@ -541,27 +536,6 @@ lov_add_obd(struct obd_device *obd, struct obd_uuid *uuidp, int index, int gen) RETURN(-EINVAL); } - bufsize = sizeof(struct lov_tgt_desc) * (index + 1); - if (bufsize > lov->bufsize) { - OBD_ALLOC(tgt, bufsize); - if (tgt == NULL) { - CERROR("couldn't allocate %d bytes for new table.\n", - bufsize); - RETURN(-ENOMEM); - } - - memset(tgt, 0, bufsize); - if (lov->tgts) { - memcpy(tgt, lov->tgts, lov->bufsize); - OBD_FREE(lov->tgts, lov->bufsize); - } - - lov->tgts = tgt; - lov->bufsize = bufsize; - CDEBUG(D_CONFIG, "tgts: %p bufsize: %d\n", - lov->tgts, lov->bufsize); - } - tgt = lov->tgts + index; if (!obd_uuid_empty(&tgt->uuid)) { CERROR("OBD already assigned at LOV target index %d\n", @@ -573,7 +547,6 @@ lov_add_obd(struct obd_device *obd, struct obd_uuid *uuidp, int index, int gen) /* XXX - add a sanity check on the generation number. */ tgt->ltd_gen = gen; - old_count = lov->desc.ld_tgt_count; if (index >= lov->desc.ld_tgt_count) lov->desc.ld_tgt_count = index + 1; @@ -591,29 +564,16 @@ lov_add_obd(struct obd_device *obd, struct obd_uuid *uuidp, int index, int gen) osc_obd->obd_no_recov = 0; } - rc = lov_connect_obd(obd, tgt, 1, 0); - if (rc || !obd->obd_observer) - RETURN(rc); - - /* tell the mds_lov about the new target */ - obd_llog_finish(obd->obd_observer, &obd->obd_observer->obd_llogs, - old_count); - obd_llog_cat_initialize(obd->obd_observer, - &obd->obd_observer->obd_llogs, - lov->desc.ld_tgt_count, name); - - params[0] = index; - rc = obd_get_info(tgt->ltd_exp, strlen("last_id"), "last_id", &size, - ¶ms[1]); + rc = lov_connect_obd(obd, tgt, 1, lov->lov_connect_flags); if (rc) GOTO(out, rc); - exp_observer = obd->obd_observer->obd_self_export; - rc = obd_set_info(exp_observer, strlen("next_id"),"next_id", 2, params); - if (rc) - GOTO(out, rc); + if (obd->obd_observer) { + /* tell the mds_lov about the new target */ + rc = obd_notify(obd->obd_observer, tgt->ltd_exp->exp_obd, 1, + (void *)index); + } - rc = lov_notify(obd, tgt->ltd_exp->exp_obd, 1); GOTO(out, rc); out: if (rc && tgt->ltd_exp != NULL) @@ -1146,7 +1106,7 @@ static int lov_create(struct obd_export *exp, struct obdo *src_oa, static int lov_revalidate_policy(struct lov_obd *lov, struct lov_stripe_md *lsm) { - static int last_idx = 0; + static int next_idx = 0; struct lov_tgt_desc *tgt; int i, count; @@ -1157,13 +1117,19 @@ static int lov_revalidate_policy(struct lov_obd *lov, struct lov_stripe_md *lsm) * ld_tgt_count currently cannot shrink. */ count = lov->desc.ld_tgt_count; - for (i = last_idx, tgt = lov->tgts + i; i < count; i++, tgt++) - if (tgt->active) - RETURN(last_idx = i); + for (i = next_idx, tgt = lov->tgts + i; i < count; i++, tgt++) { + if (tgt->active) { + next_idx = (i + 1) % count; + RETURN(i); + } + } - for (i = 0, tgt = lov->tgts; i < last_idx; i++, tgt++) - if (tgt->active) - RETURN(last_idx = i); + for (i = 0, tgt = lov->tgts; i < next_idx; i++, tgt++) { + if (tgt->active) { + next_idx = (i + 1) % count; + RETURN(i); + } + } RETURN(-EIO); } @@ -2908,17 +2874,17 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, data = (struct obd_ioctl_data *)buf; if (sizeof(*desc) > data->ioc_inllen1) { - OBD_FREE(buf, len); + obd_ioctl_freedata(buf, len); RETURN(-EINVAL); } if (sizeof(uuidp->uuid) * count > data->ioc_inllen2) { - OBD_FREE(buf, len); + obd_ioctl_freedata(buf, len); RETURN(-EINVAL); } if (sizeof(__u32) * count > data->ioc_inllen3) { - OBD_FREE(buf, len); + obd_ioctl_freedata(buf, len); RETURN(-EINVAL); } @@ -3001,6 +2967,7 @@ static int lov_get_info(struct obd_export *exp, __u32 keylen, struct lov_stripe_md *lsm; } *data = key; struct lov_oinfo *loi; + struct ldlm_res_id *res_id = &data->lock->l_resource->lr_name; __u32 *stripe = val; if (*vallen < sizeof(*stripe)) @@ -3017,11 +2984,15 @@ static int lov_get_info(struct obd_export *exp, __u32 keylen, i < data->lsm->lsm_stripe_count; i++, loi++) { if (lov->tgts[loi->loi_ost_idx].ltd_exp == - data->lock->l_conn_export) { + data->lock->l_conn_export && + loi->loi_id == res_id->name[0] && + loi->loi_gr == res_id->name[2]) { *stripe = i; RETURN(0); } } + LDLM_ERROR(data->lock, "lock on inode without such object\n"); + dump_lsm(D_ERROR, data->lsm); RETURN(-ENXIO); } else if (keylen >= strlen("size_to_stripe") && strcmp(key, "size_to_stripe") == 0) { @@ -3296,13 +3267,13 @@ struct obd_ops lov_obd_ops = { .o_detach = lov_detach, .o_setup = lov_setup, .o_cleanup = lov_cleanup, - o_process_config: lov_process_config, + .o_process_config = lov_process_config, .o_connect = lov_connect, .o_disconnect = lov_disconnect, .o_statfs = lov_statfs, .o_packmd = lov_packmd, .o_unpackmd = lov_unpackmd, - o_revalidate_md: lov_revalidate_md, + .o_revalidate_md = lov_revalidate_md, .o_create = lov_create, .o_destroy = lov_destroy, .o_getattr = lov_getattr, diff --git a/lustre/lvfs/lvfs_linux.c b/lustre/lvfs/lvfs_linux.c index 657076c..df8d84c 100644 --- a/lustre/lvfs/lvfs_linux.c +++ b/lustre/lvfs/lvfs_linux.c @@ -79,7 +79,9 @@ void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx, { //ASSERT_NOT_KERNEL_CTXT("already in kernel context!\n"); ASSERT_CTXT_MAGIC(new_ctx->magic); + LASSERT(save->magic != OBD_RUN_CTXT_MAGIC || save->pid != current->pid); OBD_SET_CTXT_MAGIC(save); + save->pid = current->pid; /* CDEBUG(D_INFO, @@ -142,6 +144,9 @@ void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx, { //printk("pc0"); ASSERT_CTXT_MAGIC(saved->magic); + LASSERT(saved->pid == current->pid); + saved->magic = 0; + saved->pid = 0; //printk("pc1"); ASSERT_KERNEL_CTXT("popping non-kernel context!\n"); diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 4e88c5f..55ec795 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -904,7 +904,7 @@ static int mdc_import_event(struct obd_device *obd, struct obd_import *imp, } case IMP_EVENT_INACTIVE: { if (obd->obd_observer) - rc = obd_notify(obd->obd_observer, obd, 0); + rc = obd_notify(obd->obd_observer, obd, 0, 0); break; } case IMP_EVENT_INVALIDATE: { @@ -916,7 +916,7 @@ static int mdc_import_event(struct obd_device *obd, struct obd_import *imp, } case IMP_EVENT_ACTIVE: { if (obd->obd_observer) - rc = obd_notify(obd->obd_observer, obd, 1); + rc = obd_notify(obd->obd_observer, obd, 1, 0); break; } default: diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 38512da..d9353a6 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -2679,8 +2679,7 @@ static int mds_get_info(struct obd_export *exp, __u32 keylen, } mds = &obd->u.mds; - keylen == strlen("mdsize"); - if (keylen && memcmp(key, "mdsize", keylen) == 0) { + if (keylen >= strlen("mdsize") && memcmp(key, "mdsize", keylen) == 0) { __u32 *mdsize = val; *vallen = sizeof(*mdsize); *mdsize = mds->mds_max_mdsize; diff --git a/lustre/mds/mds_internal.h b/lustre/mds/mds_internal.h index f1b1517..f492548 100644 --- a/lustre/mds/mds_internal.h +++ b/lustre/mds/mds_internal.h @@ -77,6 +77,8 @@ int mds_llog_finish(struct obd_device *obd, struct obd_llogs *, int count); /* mds/mds_lov.c */ int mds_lov_connect(struct obd_device *obd, char * lov_name); int mds_lov_disconnect(struct obd_device *obd, int flags); +int mds_lov_set_info(struct obd_export *exp, obd_count keylen, + void *key, obd_count vallen, void *val); int mds_get_lovtgts(struct obd_device *, int tgt_count, struct obd_uuid *); int mds_lov_write_objids(struct obd_device *obd); void mds_lov_update_objids(struct obd_device *obd, obd_id *ids); @@ -84,7 +86,8 @@ int mds_lov_set_growth(struct mds_obd *mds, int count); int mds_lov_set_nextid(struct obd_device *obd); int mds_lov_clearorphans(struct mds_obd *mds, struct obd_uuid *ost_uuid); int mds_post_mds_lovconf(struct obd_device *obd); -int mds_notify(struct obd_device *obd, struct obd_device *watched, int active); +int mds_notify(struct obd_device *obd, struct obd_device *watched, + int active, void *data); int mds_lov_update_config(struct obd_device *obd, int transno); int mds_convert_lov_ea(struct obd_device *obd, struct inode *inode, struct lov_mds_md *lmm, int lmm_size); diff --git a/lustre/mds/mds_lov.c b/lustre/mds/mds_lov.c index 0668691..b61caf0 100644 --- a/lustre/mds/mds_lov.c +++ b/lustre/mds/mds_lov.c @@ -176,6 +176,7 @@ static int mds_lov_update_desc(struct obd_device *obd, struct obd_export *lov) { struct mds_obd *mds = &obd->u.mds; int valsize = sizeof(mds->mds_lov_desc), rc, i; + int old_count = mds->mds_lov_desc.ld_tgt_count; ENTRY; rc = obd_get_info(lov, strlen("lovdesc") + 1, "lovdesc", &valsize, @@ -183,11 +184,32 @@ static int mds_lov_update_desc(struct obd_device *obd, struct obd_export *lov) if (rc) RETURN(rc); + /* The size of the LOV target table may have increased. */ + if (old_count >= mds->mds_lov_desc.ld_tgt_count) { + obd_id *ids; + int size; + + size = mds->mds_lov_desc.ld_tgt_count * sizeof(*ids); + OBD_ALLOC(ids, size); + if (ids == NULL) + RETURN(-ENOMEM); + + memset(ids, 0, size); + + if (mds->mds_lov_objids != NULL) { + int oldsize = old_count * sizeof(*ids); + + memcpy(ids, mds->mds_lov_objids, oldsize); + OBD_FREE(mds->mds_lov_objids, oldsize); + } + mds->mds_lov_objids = ids; + } + i = lov_mds_md_size(mds->mds_lov_desc.ld_tgt_count); if (i > mds->mds_max_mdsize) mds->mds_max_mdsize = i; mds->mds_max_cookiesize = mds->mds_lov_desc.ld_tgt_count * - sizeof(struct llog_cookie); + sizeof(struct llog_cookie); mds->mds_has_lov_desc = 1; RETURN(0); } @@ -524,8 +546,9 @@ int mds_iocontrol(unsigned int cmd, struct obd_export *exp, int len, } struct mds_lov_sync_info { - struct obd_device *mlsi_obd; /* the lov device to sync */ - struct obd_uuid *mlsi_uuid; /* target to sync */ + struct obd_device *mlsi_obd; /* the mds to sync */ + struct obd_device *mlsi_watched; /* new lov target */ + int mlsi_index; /* index into mds_lov_objids */ }; int mds_lov_synchronize(void *data) @@ -533,44 +556,76 @@ int mds_lov_synchronize(void *data) struct mds_lov_sync_info *mlsi = data; struct llog_ctxt *ctxt; struct obd_device *obd; + struct obd_device *watched; + struct mds_obd *mds; struct obd_uuid *uuid; + obd_id vals[2]; unsigned long flags; + __u32 vallen; + __u32 group; + int old_count; + int count; + int index; int rc; - int valsize; - __u32 group; + char name[32] = "CATLIST"; lock_kernel(); + ptlrpc_daemonize(); - snprintf (current->comm, sizeof (current->comm), "%s", "mds_lov_sync"); SIGNAL_MASK_LOCK(current, flags); sigfillset(¤t->blocked); RECALC_SIGPENDING; SIGNAL_MASK_UNLOCK(current, flags); + unlock_kernel(); + obd = mlsi->mlsi_obd; - uuid = mlsi->mlsi_uuid; + watched = mlsi->mlsi_watched; + index = mlsi->mlsi_index; + + LASSERT(obd != NULL); + LASSERT(watched != NULL); OBD_FREE(mlsi, sizeof(*mlsi)); + mds = &obd->u.mds; + uuid = &watched->u.cli.cl_import->imp_target_uuid; - LASSERT(obd != NULL); - LASSERT(uuid != NULL); + group = FILTER_GROUP_FIRST_MDS + mds->mds_num; + rc = obd_set_info(watched->obd_self_export, strlen("mds_conn"), + "mds_conn", sizeof(group), &group); + if (rc) + RETURN(rc); - group = FILTER_GROUP_FIRST_MDS + obd->u.mds.mds_num; - valsize = sizeof(group); - rc = obd_set_info(obd->u.mds.mds_osc_exp, strlen("mds_conn"), - "mds_conn", valsize, &group); - if (rc != 0) { - CERROR("obd_set_info(mds_conn) failed %d\n", rc); + old_count = mds->mds_lov_desc.ld_tgt_count; + + rc = mds_lov_update_desc(obd, mds->mds_osc_exp); + if (rc) RETURN(rc); - } - + + count = mds->mds_lov_desc.ld_tgt_count; + LASSERT(count >= old_count); + + vallen = sizeof(vals[1]); + rc = obd_get_info(watched->obd_self_export, strlen("last_id"), + "last_id", &vallen, &vals[1]); + if (rc) + RETURN(rc); + + vals[0] = index; + rc = mds_lov_set_info(obd->obd_self_export, strlen("next_id"), + "next_id", 2, vals); + if (rc) + RETURN(rc); + + obd_llog_finish(obd, &obd->obd_llogs, old_count); + obd_llog_cat_initialize(obd, &obd->obd_llogs, count, name); + ctxt = llog_get_context(&obd->obd_llogs, LLOG_UNLINK_ORIG_CTXT); LASSERT(ctxt != NULL); - rc = llog_connect(ctxt, obd->u.mds.mds_lov_desc.ld_tgt_count, - NULL, NULL, uuid); + rc = llog_connect(ctxt, count, NULL, NULL, uuid); if (rc != 0) { CERROR("%s: failed at llog_origin_connect: %d\n", obd->obd_name, rc); @@ -579,6 +634,7 @@ int mds_lov_synchronize(void *data) CWARN("MDS %s: %s now active, resetting orphans\n", obd->obd_name, uuid->uuid); + rc = mds_lov_clearorphans(&obd->u.mds, uuid); if (rc != 0) { CERROR("%s: failed at mds_lov_clearorphans: %d\n", @@ -589,7 +645,8 @@ int mds_lov_synchronize(void *data) RETURN(0); } -int mds_lov_start_synchronize(struct obd_device *obd, struct obd_uuid *uuid) +int mds_lov_start_synchronize(struct obd_device *obd, + struct obd_device *watched, void *data) { struct mds_lov_sync_info *mlsi; int rc; @@ -601,7 +658,8 @@ int mds_lov_start_synchronize(struct obd_device *obd, struct obd_uuid *uuid) RETURN(-ENOMEM); mlsi->mlsi_obd = obd; - mlsi->mlsi_uuid = uuid; + mlsi->mlsi_watched = watched; + mlsi->mlsi_index = (int)data; rc = kernel_thread(mds_lov_synchronize, mlsi, CLONE_VM | CLONE_FILES); if (rc < 0) @@ -616,9 +674,9 @@ int mds_lov_start_synchronize(struct obd_device *obd, struct obd_uuid *uuid) RETURN(rc); } -int mds_notify(struct obd_device *obd, struct obd_device *watched, int active) +int mds_notify(struct obd_device *obd, struct obd_device *watched, + int active, void *data) { - struct obd_uuid *uuid; int rc = 0; ENTRY; @@ -631,18 +689,20 @@ int mds_notify(struct obd_device *obd, struct obd_device *watched, int active) RETURN(-EINVAL); } - uuid = &watched->u.cli.cl_import->imp_target_uuid; if (obd->obd_recovering) { + struct obd_uuid *uuid; + uuid = &watched->u.cli.cl_import->imp_target_uuid; + CWARN("MDS %s: in recovery, not resetting orphans on %s\n", obd->obd_name, uuid->uuid); } else { - rc = mds_lov_start_synchronize(obd, uuid); + rc = mds_lov_start_synchronize(obd, watched, data); } RETURN(rc); } -int mds_set_info(struct obd_export *exp, obd_count keylen, - void *key, obd_count vallen, void *val) +int mds_lov_set_info(struct obd_export *exp, obd_count keylen, + void *key, obd_count vallen, void *val) { struct obd_device *obd = class_exp2obd(exp); struct mds_obd *mds = &obd->u.mds; @@ -653,41 +713,19 @@ int mds_set_info(struct obd_export *exp, obd_count keylen, if (KEY_IS("next_id")) { obd_id *id = (obd_id *)val; - int idx, rc; + int idx; /* XXX - this really should be vallen != (2 * sizeof(*id)) * * Just following the precedent set by lov_set_info. */ if (vallen != 2) RETURN(-EINVAL); - if ((idx = *id) != *id) + idx = *id; + if ((idx != *id) || (idx >= mds->mds_lov_desc.ld_tgt_count)) RETURN(-EINVAL); CDEBUG(D_CONFIG, "idx: %d id: %llu\n", idx, *(id + 1)); - /* The size of the LOV target table may have increased. */ - if (idx >= mds->mds_lov_desc.ld_tgt_count) { - obd_id *ids; - int oldsize, size; - - oldsize = mds->mds_lov_desc.ld_tgt_count * sizeof(*ids); - rc = mds_lov_update_desc(obd, mds->mds_osc_exp); - if (rc) - RETURN(rc); - if (idx >= mds->mds_lov_desc.ld_tgt_count) - RETURN(-EINVAL); - size = mds->mds_lov_desc.ld_tgt_count * sizeof(*ids); - OBD_ALLOC(ids, size); - if (ids == NULL) - RETURN(-ENOMEM); - memset(ids, 0, size); - if (mds->mds_lov_objids != NULL) { - memcpy(ids, mds->mds_lov_objids, oldsize); - OBD_FREE(mds->mds_lov_objids, oldsize); - } - mds->mds_lov_objids = ids; - } - mds->mds_lov_objids[idx] = *++id; CDEBUG(D_CONFIG, "objid: %d: %lld\n", idx, *id); /* XXX - should we be writing this out here ? */ @@ -734,7 +772,6 @@ int mds_lov_update_config(struct obd_device *obd, int clean) pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); if (rc == 0) { mds->mds_config_version = version; - rc = mds_lov_update_desc(obd, mds->mds_osc_exp); } CWARN("Finished applying configuration log %s: %d\n", name, rc); @@ -839,9 +876,11 @@ int mds_revalidate_lov_ea(struct obd_device *obd, struct inode *inode, oa->o_generation = inode->i_generation; oa->o_uid = 0; /* must have 0 uid / gid on OST */ oa->o_gid = 0; + oa->o_gr = FILTER_GROUP_FIRST_MDS + mds->mds_num; oa->o_valid = OBD_MD_FLID | OBD_MD_FLGENER | OBD_MD_FLTYPE | - OBD_MD_FLMODE | OBD_MD_FLUID | OBD_MD_FLGID; + OBD_MD_FLMODE | OBD_MD_FLUID | OBD_MD_FLGID | + OBD_MD_FLGROUP; valid = OBD_MD_FLTYPE | OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME; obdo_from_inode(oa, inode, valid); diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index ee27de5..ed75cfd 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -2908,7 +2908,7 @@ static int osc_import_event(struct obd_device *obd, } case IMP_EVENT_INACTIVE: { if (obd->obd_observer) - rc = obd_notify(obd->obd_observer, obd, 0); + rc = obd_notify(obd->obd_observer, obd, 0, 0); break; } case IMP_EVENT_INVALIDATE: { @@ -2929,7 +2929,7 @@ static int osc_import_event(struct obd_device *obd, } case IMP_EVENT_ACTIVE: { if (obd->obd_observer) - rc = obd_notify(obd->obd_observer, obd, 1); + rc = obd_notify(obd->obd_observer, obd, 1, 0); break; } default: diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c index 3cea525..388fd01 100644 --- a/lustre/ptlrpc/service.c +++ b/lustre/ptlrpc/service.c @@ -100,7 +100,7 @@ ptlrpc_alloc_rqbd (struct ptlrpc_srv_ni *srv_ni) } void -ptlrpc_free_rqbd (struct ptlrpc_request_buffer_desc *rqbd) +ptlrpc_free_rqbd(struct ptlrpc_request_buffer_desc *rqbd) { struct ptlrpc_srv_ni *sni = rqbd->rqbd_srv_ni; struct ptlrpc_service *svc = sni->sni_service; @@ -118,8 +118,7 @@ ptlrpc_free_rqbd (struct ptlrpc_request_buffer_desc *rqbd) } void -ptlrpc_save_llog_lock (struct ptlrpc_request *req, - struct llog_create_locks *lcl) +ptlrpc_save_llog_lock(struct ptlrpc_request *req, struct llog_create_locks *lcl) { struct ptlrpc_reply_state *rs = req->rq_reply_state; LASSERT (rs != NULL); @@ -538,7 +537,6 @@ ptlrpc_server_handle_reply (struct ptlrpc_service *svc) struct llog_create_locks *lcl; int nlocks; int been_handled; - char str[PTL_NALFMT_SIZE]; ENTRY; spin_lock_irqsave (&svc->srv_lock, flags); @@ -586,6 +584,7 @@ ptlrpc_server_handle_reply (struct ptlrpc_service *svc) /* If we see this, we should already have seen the warning * in mds_steal_ack_locks() */ #if 0 + char str[PTL_NALFMT_SIZE]; /* CMD may ask to save request with no DLM locks -bzzz */ CWARN("All locks stolen from rs %p x"LPD64".t"LPD64 " o%d NID %s\n", diff --git a/lustre/utils/lconf b/lustre/utils/lconf index 99ffab2..3cb8ba9 100755 --- a/lustre/utils/lconf +++ b/lustre/utils/lconf @@ -3445,7 +3445,7 @@ def main(): lctl.end_record() - process_updates(db, config.record_device, config.record_log) + process_updates(lustreDB, config.record_device, config.record_log) if __name__ == "__main__": try: diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index c522a9f..bb563ca 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -163,6 +163,7 @@ struct find_param { struct lov_user_md *lum; int got_uuids; int obdindex; + __u32 *obdgens; }; /* XXX Max obds per lov currently hardcoded to 1000 in lov/lov_obd.c */ @@ -192,13 +193,13 @@ static void cleanup_find(struct find_param *param) free(param->lum); } -int llapi_lov_get_uuids(int fd, struct obd_uuid *uuidp, int *ost_count) +int llapi_lov_get_uuids(int fd, struct obd_uuid *uuidp, __u32 *obdgens, + int *ost_count) { struct obd_ioctl_data data = { 0, }; struct lov_desc desc = { 0, }; char *buf = NULL; int max_ost_count, rc; - __u32 *obdgens; max_ost_count = (OBD_MAX_IOCTL_BUFFER - size_round(sizeof(data)) - size_round(sizeof(desc))) / @@ -206,12 +207,6 @@ int llapi_lov_get_uuids(int fd, struct obd_uuid *uuidp, int *ost_count) if (max_ost_count > *ost_count) max_ost_count = *ost_count; - obdgens = malloc(size_round(max_ost_count * sizeof(*obdgens))); - if (!obdgens) { - err_msg("no memory for %d generation #'s", max_ost_count); - return(-ENOMEM); - } - data.ioc_inllen1 = sizeof(desc); data.ioc_inlbuf1 = (char *)&desc; data.ioc_inllen2 = size_round(max_ost_count * sizeof(*uuidp)); @@ -243,7 +238,6 @@ int llapi_lov_get_uuids(int fd, struct obd_uuid *uuidp, int *ost_count) *ost_count = desc.ld_tgt_count; out: free(buf); - free(obdgens); return 0; } @@ -251,12 +245,14 @@ out: static int setup_obd_uuids(DIR *dir, char *dname, struct find_param *param) { struct obd_uuid uuids[1024], *uuidp; + __u32 obdgens[1024], *genp; + int obdcount = 1024; int rc, i; param->got_uuids = 1; - rc = llapi_lov_get_uuids(dirfd(dir), uuids, &obdcount); + rc = llapi_lov_get_uuids(dirfd(dir), uuids, obdgens, &obdcount); if (rc != 0) return (param->obduuid ? rc : 0); @@ -276,11 +272,16 @@ static int setup_obd_uuids(DIR *dir, char *dname, struct find_param *param) return EINVAL; } } else if (!param->quiet) { - printf("OBDS:\n"); - for (i = 0, uuidp = uuids; i < obdcount; i++, uuidp++) - printf("%4d: %s\n", i, uuidp->uuid); - } + printf("OBDS:\tobdidx\t\tobdgen\t\t obduuid\n"); + uuidp = uuids; + genp = obdgens; + for (i = 0; i < obdcount; i++, uuidp++, genp++) { + if (obd_uuid_empty(uuidp)) + continue; + printf("\t%6u\t%14u\t\t %s\n", i, *genp, uuidp->uuid); + } + } return 0; } @@ -323,16 +324,17 @@ void lov_dump_user_lmm_v1(struct lov_user_md_v1 *lum, char *dname, char *fname, if (body) { if ((!quiet) && (obdstripe == 1)) - printf("\tobdidx\t\t objid\t\tobjid\t\t group\n"); + printf("\tobdidx\t\t obdgen\t\t objid\t\tobjid\t\t group\n"); for (i = 0; i < lum->lmm_stripe_count; i++) { int idx = lum->lmm_objects[i].l_ost_idx; long long oid = lum->lmm_objects[i].l_object_id; + int gen = lum->lmm_objects[i].l_ost_gen; long long gr = lum->lmm_objects[i].l_object_gr; if ((obdindex == OBD_NOT_FOUND) || (obdindex == idx)) - printf("\t%6u\t%14llu\t%#13llx\t%14llu%s\n", - idx, oid, oid, gr, - obdindex == idx ? " *" : ""); + printf("\t%6u\t%14u\t%14llu\t%#13llx\t%14lld%s\n", + idx, gen, oid, oid, gr, + obdindex == idx ? " *" : ""); } printf("\n"); } diff --git a/lustre/utils/lmc b/lustre/utils/lmc index 849afb49..b60e251 100755 --- a/lustre/utils/lmc +++ b/lustre/utils/lmc @@ -127,6 +127,7 @@ Object creation command summary: --delete ost --node node_name --ost ost_name + --migrate --deactivate ost --node node_name --ost ost_name @@ -232,6 +233,7 @@ lmc_options = [ ('ostuuid', "", PARAM,""), ('nspath', "Local mount point of server namespace.", PARAM,""), ('format', ""), + ('migrate', "used for offline migrate of an ost in conjunctio with add/delete"), # clients: mountpoint and echo ('echo_client', "", PARAM), @@ -702,6 +704,18 @@ def get_net_uuid(lustre, node_name): return getUUID(net[0]) return None +def lov_mod_obd(gen, lustre, lov, tgt, osc_uuid, options): + tgt.setAttribute('uuidref', osc_uuid) + if options.migrate: + gener = int(tgt.getAttribute('generation')) + else: + gener = int(tgt.getAttribute('generation')) + 1 + tgt.setAttribute('generation', str(gener)) + lov_index = int(tgt.getAttribute('index')) + addUpdate(gen, lustre, gen.add(getUUID(lov), osc_uuid, str(lov_index), + str(gener))) + return + def lov_add_obd(gen, lustre, lov, osc_uuid, options): lov_name = getName(lov) if options.index: @@ -712,28 +726,23 @@ def lov_add_obd(gen, lustre, lov, osc_uuid, options): if uuidref != '': raise OptionError("%s --index %d is still in use: %s" % (lov_name, lov_index, uuidref)) - tgt.setAttribute('uuidref', osc_uuid) - gener = int(tgt.getAttribute('generation')) + 1 - tgt.setAttribute('generation', str(gener)) - addUpdate(gen, lustre, gen.add(getUUID(lov), osc_uuid, - str(lov_index), str(gener))) + lov_mod_obd(gen, lustre, lov, tgt, osc_uuid, options) return - gener = 1 - lov.appendChild(gen.lov_tgt(osc_uuid, str(lov_index), '1')) - addUpdate(gen, lustre, gen.add(getUUID(lov), osc_uuid, str(lov_index), - str(gener))) - return - - index = -1 - for tgt in lov.getElementsByTagName('lov_tgt'): - uuidref = tgt.getAttribute('uuidref') - tmp = int(tgt.getAttribute('index')) - if tmp != index + 1: - error('malformed xml: LOV targets are not ordered; found index '+str(tmp)+', expected '+str(index + 1)+'.') - index = tmp - - lov.appendChild(gen.lov_tgt(osc_uuid, str(index + 1), '1')) - addUpdate(gen, lustre, gen.add(getUUID(lov), osc_uuid, str(index + 1), '1')) + else: + lov_index = 0 + for tgt in lustre.getElementsByTagName('lov_tgt'): + uuidref = tgt.getAttribute('uuidref') + tmp = int(tgt.getAttribute('index')) + if tmp != lov_index: + error('malformed xml: LOV targets are not ordered; found index '+str(tmp)+', expected '+str(lov_index)+'.') + uuidref = tgt.getAttribute('uuidref') + if uuidref == '': + lov_mod_obd(gen, lustre, lov, tgt, osc_uuid, options) + return + lov_index = lov_index + 1 + + lov.appendChild(gen.lov_tgt(osc_uuid, str(lov_index), '1')) + addUpdate(gen, lustre, gen.add(getUUID(lov), osc_uuid, str(lov_index), '1')) def lov_del_obd(gen, lustre, lov, osc_uuid, options): lov_name = getName(lov) @@ -748,10 +757,14 @@ def lov_del_obd(gen, lustre, lov, osc_uuid, options): (lov_name, lov_index, osc_uuid, uuidref)) if options.delete: tgt.setAttribute('uuidref', '') - else: - tgt.setAttribute('active', '0') + # bump the generation just in case... - gen = int(tgt.getAttribute('generation')) + 1 + if options.migrate: + gen = int(tgt.getAttribute('generation')) + else: + gen = int(tgt.getAttribute('generation')) + 1 + + tgt.setAttribute('active', '0') tgt.setAttribute('generation', str(gen)) return raise OptionError("%s --index %d not in use by %s." % @@ -768,9 +781,9 @@ def lov_del_obd(gen, lustre, lov, osc_uuid, options): if options.delete: tgt.setAttribute('uuidref', '') - else: - tgt.setAttribute('active', '0') - genera = genera + 1 + if not options.migrate: + genera = genera + 1 + tgt.setAttribute('active', '0') tgt.setAttribute('generation', str(genera)) def lmv_add_obd(gen, lmv, mdc_uuid): @@ -1081,15 +1094,15 @@ def add_ost(gen, lustre, options): ost = gen.ost(ostname, ost_uuid, osd_uuid, options.group) lustre.appendChild(ost) - - if lovname: - lov = findByName(lustre, lovname, "lov") - if not lov: - error('add_ost:', '"'+lovname+'"', "lov element not found.") - lov_add_obd(gen, lustre, lov, ost_uuid, options) else: ost = lookup(lustre, ost_uuid) + if lovname: + lov = findByName(lustre, lovname, "lov") + if not lov: + error('add_ost:', '"'+lovname+'"', "lov element not found.") + lov_add_obd(gen, lustre, lov, ost_uuid, options) + if options.failover: ost.setAttribute('failover', "1") @@ -1132,7 +1145,8 @@ def del_ost(gen, lustre, options): # remove OSD references from all LOVs for n in lustre.getElementsByTagName('lov'): lov_del_obd(gen, lustre, n, ost_uuid, options) - return + if not options.migrate: + return # delete the OSDs for osd in lustre.getElementsByTagName('osd'): if ref_exists(osd, ost_uuid): -- 1.8.3.1