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,
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, \
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, \
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), \
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, \
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), \
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], \
int ngroups;
struct lvfs_callback_ops cb_ops;
#ifdef OBD_CTXT_DEBUG
+ int pid;
__u32 magic;
#endif
};
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;
int bufsize;
int refcount;
int lo_catalog_loaded:1;
+ unsigned long lov_connect_flags;
struct lov_tgt_desc *tgts;
};
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);
/*
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);
}
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,
{
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;
}
{
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))
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
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) {
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__
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;
}
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);
}
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;
}
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);
struct ll_sb_info *sbi = ll_s2sbi(sb);
ENTRY;
+ CWARN("Starting a LOV/OST update !\n");
RETURN(ll_process_config_update(sbi, 0));
}
}
static int lmv_notify(struct obd_device *obd, struct obd_device *watched,
- int active)
+ int active, void *data)
{
int rc;
struct obd_uuid *uuid;
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);
}
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;
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);
}
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)
{
.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,
#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;
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;
}
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",
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);
}
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);
{
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);
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",
/* 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;
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)
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;
* 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);
}
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);
}
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))
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) {
.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,
{
//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,
{
//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");
}
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: {
}
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:
}
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;
/* 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);
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);
{
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,
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);
}
}
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)
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);
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",
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;
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)
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;
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;
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 ? */
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);
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);
}
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: {
}
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:
}
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;
}
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);
struct llog_create_locks *lcl;
int nlocks;
int been_handled;
- char str[PTL_NALFMT_SIZE];
ENTRY;
spin_lock_irqsave (&svc->srv_lock, flags);
/* 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",
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:
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 */
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))) /
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));
*ost_count = desc.ld_tgt_count;
out:
free(buf);
- free(obdgens);
return 0;
}
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);
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;
}
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");
}
--delete ost
--node node_name
--ost ost_name
+ --migrate
--deactivate ost
--node node_name
--ost ost_name
('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),
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:
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)
(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." %
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):
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")
# 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):