int (*lop_next_block)(struct llog_handle *h, int *curr_idx,
int next_idx, __u64 *offset, void *buf, int len);
int (*lop_create)(struct llog_ctxt *ctxt, struct llog_handle **,
- struct llog_logid *logid, char* fsname, char *name);
+ struct llog_logid *logid, char *name);
int (*lop_close)(struct llog_handle *handle);
int (*lop_read_header)(struct llog_handle *handle);
}
static inline int llog_create(struct llog_ctxt *ctxt, struct llog_handle **res,
- struct llog_logid *logid, char*fsname, char *name)
+// struct llog_logid *logid, char*fsname, char *name)
+ struct llog_logid *logid, char *name)
{
struct llog_operations *lop;
int rc;
if (lop->lop_create == NULL)
RETURN(-EOPNOTSUPP);
- rc = lop->lop_create(ctxt, res, logid, fsname, name);
+ // rc = lop->lop_create(ctxt, res, logid, fsname, name);
+ rc = lop->lop_create(ctxt, res, logid, name);
RETURN(rc);
}
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
rc = llog_create(llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT),
- &mds->mds_cfg_llh, NULL, NULL, name);
+ &mds->mds_cfg_llh, NULL, name);
if (rc == 0)
llog_init_handle(mds->mds_cfg_llh, LLOG_F_IS_PLAIN,
&cfg_uuid);
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
rc = llog_create(llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT),
- &mds->mds_cfg_llh, NULL, NULL, name);
+ &mds->mds_cfg_llh, NULL, name);
if (rc == 0) {
llog_init_handle(mds->mds_cfg_llh, LLOG_F_IS_PLAIN,
NULL);
memcpy(mcd->mcd_uuid, cluuid, sizeof(mcd->mcd_uuid));
med->med_mcd = mcd;
-
+#if 0
+ /* FIXME: recovery of connection*/
+ rc = mgs_client_add(obd, &obd->u.mgs, med, -1);
+ GOTO(out, rc);
+#endif
out:
if (rc) {
if (mcd) {
/* Disconnect early so that clients can't keep using export */
rc = class_disconnect(exp);
+ ldlm_cancel_locks_for_export(exp);
/* complete all outstanding replies */
spin_lock_irqsave(&exp->exp_lock, irqflags);
CDEBUG(D_SUPER, "%s: mnt = %p\n", lustre_cfg_string(lcfg, 1), mnt);
+ /*namespace for mgs llog */
+ sprintf(ns_name, "mgs-%s", obd->obd_uuid.uuid);
+ obd->obd_namespace = ldlm_namespace_new(ns_name, LDLM_NAMESPACE_SERVER);
+ if (obd->obd_namespace == NULL) {
+ mgs_cleanup(obd);
+ GOTO(err_put, rc = -ENOMEM);
+ }
+
LASSERT(!lvfs_check_rdonly(lvfs_sbdev(mnt->mnt_sb)));
rc = mgs_fs_setup(obd, mnt);
if (rc) {
CERROR("%s: MGS filesystem method init failed: rc = %d\n",
obd->obd_name, rc);
- GOTO(err_put, rc);
+ GOTO(err_ns, rc);
}
INIT_LIST_HEAD(&mgs->mgs_open_llogs);
rc = llog_start_commit_thread();
if (rc < 0)
GOTO(err_fs, rc);
-#if 0
- //FIXME: no LDLM support for llog now
- ptlrpc_init_client(LDLM_CB_REQUEST_PORTAL, LDLM_CB_REPLY_PORTAL,
- "mgs_ldlm_client", &obd->obd_ldlm_client);
-#endif
- obd->obd_replayable = 1;
rc = mgs_postsetup(obd);
if (rc)
lustre_cfg_string(lcfg, 1),
obd->obd_replayable ? "enabled" : "disabled");
}
-//FIXME: no ldlm support now
+
ldlm_timeout = 6;
ping_evictor_start();
err_fs:
/* No extra cleanup needed for llog_init_commit_thread() */
mgs_fs_cleanup(obd);
+err_ns:
+ ldlm_namespace_free(obd->obd_namespace, 0);
+ obd->obd_namespace = NULL;
err_put:
unlock_kernel();
mntput(mgs->mgs_vfsmnt);
mntput(mgs->mgs_vfsmnt);
mgs->mgs_sb = NULL;
+ ldlm_namespace_free(obd->obd_namespace, obd->obd_force);
+
spin_lock_bh(&obd->obd_processing_task_lock);
if (obd->obd_recovering) {
target_cancel_recovery_timer(obd);
fsfilt_put_ops(obd->obd_fsops);
- LCONSOLE_INFO("MDT %s has stopped.\n", obd->obd_name);
+ LCONSOLE_INFO("MGT %s has stopped.\n", obd->obd_name);
RETURN(0);
}
-/* Look up an entry by inode number. */
-/* this function ONLY returns valid dget'd dentries with an initialized inode
- or errors */
-struct dentry *mgs_fid2dentry(struct mgs_obd *mgs, struct ll_fid *fid,
- struct vfsmount **mnt)
-{
- unsigned long ino = fid->id;
- __u32 generation = fid->generation;
- struct mgs_open_llog *mollog, *n;
- struct list_head *llog_list = &mgs->mgs_open_llogs;
- struct inode *inode;
- struct dentry *result = NULL;
-
- if (ino == 0)
- RETURN(ERR_PTR(-ESTALE));
-
-
- CDEBUG(D_DENTRY, "--> mgs_fid2dentry: ino/gen %lu/%u, sb %p\n",
- ino, generation, mgs->mgs_sb);
-
- list_for_each_entry_safe(mollog, n, llog_list, mol_list) {
- if (mollog->mol_id == ino) {
- result = mollog->mol_dentry;
- dget(result);
- }
- }
-
- if (!result)
- RETURN(NULL);
-
- inode = result->d_inode;
- if (!inode)
- RETURN(ERR_PTR(-ENOENT));
-
- if (generation && inode->i_generation != generation) {
- /* we didn't find the right inode.. */
- CERROR("bad inode %lu, link: %lu ct: %d or generation %u/%u\n",
- inode->i_ino, (unsigned long)inode->i_nlink,
- atomic_read(&inode->i_count), inode->i_generation,
- generation);
- dput(result);
- RETURN(ERR_PTR(-ENOENT));
- }
-
- if (mnt) {
- *mnt = mgs->mgs_vfsmnt;
- mntget(*mnt);
- }
-
- RETURN(result);
-}
-
-static struct dentry *mgs_lvfs_fid2dentry(__u64 id, __u32 gen, __u64 gr,
- void *data)
-{
- struct obd_device *obd = data;
- struct ll_fid fid;
- fid.id = id;
- fid.generation = gen;
- return mgs_fid2dentry(&obd->u.mgs, &fid, NULL);
-}
-
-static int mgs_open_llog(__u64 id, void *data, void *handle)
-{
- struct obd_device *obd = data;
- struct mgs_update_llh *mul = handle;
- struct llog_handle *lgh = &mul->mul_lgh;
- struct dentry *dentry = lgh->lgh_file->f_dentry;
- __u64 id = dentry->d_inode->i_ino;
- struct mgs_obd *mgs = &obd->u.mgs;
- struct mgs_open_llog *mollog, *n;
- struct list_head *llog_list = &mgs->mgs_open_llogs;
-
- list_for_each_entry_safe(mollog, n, llog_list, mol_list) {
- if (mollog->mol_id == id) {
- spin_lock(&mollog->mol_lock);
- mollog->mol_ref++;
- spin_unlock(&mollog->mol_lock);
- dget(dentry);
- return 0;
- }
- }
-
- /* add a new open llog to mgs_open_llogs */
- OBD_ALLOC(mollog, sizeof(*mollog));
- if (!mollog) {
- CERROR("No memory for mollog.\n");
- return -ENOMEM;
- }
- mollog->mol_id = id;
- mollog->mol_dentry = dentry;
- mollog->mol_update = 0;
- mollog->mol_ref = 1;
- spin_lock_init(&mollog->mol_lock);
-
- spin_lock(&mgs->mgs_llogs_lock);
- list_add(&mollog->mol_list, &mgs->mgs_open_llogs);
- spin_unlock(&mgs->mgs_llogs_lock);
-
- lgh->
- return 0;
-}
-
int mgs_handle(struct ptlrpc_request *req)
{
int fail = OBD_FAIL_MGS_ALL_REPLY_NET;
req->rq_status = rc; /* superfluous? */
break;
+ case LDLM_ENQUEUE:
+ DEBUG_REQ(D_INODE, req, "enqueue");
+ OBD_FAIL_RETURN(OBD_FAIL_LDLM_ENQUEUE, 0);
+ rc = ldlm_handle_enqueue(req, ldlm_server_completion_ast,
+ ldlm_server_blocking_ast, NULL);
+ fail = OBD_FAIL_LDLM_REPLY;
+ break;
+ case LDLM_BL_CALLBACK:
+ case LDLM_CP_CALLBACK:
+ DEBUG_REQ(D_INODE, req, "callback");
+ CERROR("callbacks should not happen on MDS\n");
+ LBUG();
+ OBD_FAIL_RETURN(OBD_FAIL_LDLM_BL_CALLBACK, 0);
+ break;
+
case OBD_PING:
DEBUG_REQ(D_INODE, req, "ping");
rc = target_handle_ping(req);
llh->llh_tail.lrt_index = index;
}
- rc = llog_create(cathandle->lgh_ctxt, &loghandle, NULL, NULL, NULL);
+ rc = llog_create(cathandle->lgh_ctxt, &loghandle, NULL, NULL);
if (rc)
RETURN(ERR_PTR(rc));
}
}
- rc = llog_create(cathandle->lgh_ctxt, &loghandle, logid, NULL, NULL);
+ rc = llog_create(cathandle->lgh_ctxt, &loghandle, logid, NULL);
if (rc) {
CERROR("error opening log id "LPX64":%x: rc %d\n",
logid->lgl_oid, logid->lgl_ogen, rc);
err = str2logid(&logid, data->ioc_inlbuf1, data->ioc_inllen1);
if (err)
GOTO(out, err);
- err = llog_create(ctxt, &handle, &logid, NULL, NULL);
+ err = llog_create(ctxt, &handle, &logid, NULL);
if (err)
GOTO(out, err);
} else if (*data->ioc_inlbuf1 == '$') {
char *name = data->ioc_inlbuf1 + 1;
- err = llog_create(ctxt, &handle, NULL, NULL, name);
+ err = llog_create(ctxt, &handle, NULL, name);
if (err)
GOTO(out, err);
} else {
llog_gen_init(ctxt);
if (logid->lgl_oid)
- rc = llog_create(ctxt, &handle, logid, NULL, NULL);
+ rc = llog_create(ctxt, &handle, logid, NULL);
else {
- rc = llog_create(ctxt, &handle, NULL, NULL, NULL);
+ rc = llog_create(ctxt, &handle, NULL, NULL);
if (!rc)
*logid = handle->lgh_id;
}
CWARN("1a: create a log with name: %s\n", name);
LASSERT(ctxt);
- rc = llog_create(ctxt, &llh, NULL, NULL, name);
+ rc = llog_create(ctxt, &llh, NULL, name);
if (rc) {
CERROR("1a: llog_create with name %s failed: %d\n", name, rc);
RETURN(rc);
ENTRY;
CWARN("2a: re-open a log with name: %s\n", name);
- rc = llog_create(ctxt, llh, NULL, NULL, name);
+ rc = llog_create(ctxt, llh, NULL, name);
if (rc) {
CERROR("2a: re-open log with name %s failed: %d\n", name, rc);
RETURN(rc);
RETURN(rc);
CWARN("2b: create a log without specified NAME & LOGID\n");
- rc = llog_create(ctxt, &loghandle, NULL, NULL, NULL);
+ rc = llog_create(ctxt, &loghandle, NULL, NULL);
if (rc) {
CERROR("2b: create log failed\n");
RETURN(rc);
llog_close(loghandle);
CWARN("2b: re-open the log by LOGID\n");
- rc = llog_create(ctxt, &loghandle, &logid, NULL, NULL);
+ rc = llog_create(ctxt, &loghandle, &logid, NULL);
if (rc) {
CERROR("2b: re-open log by LOGID failed\n");
RETURN(rc);
sprintf(name, "%x", llog_test_rand+1);
CWARN("4a: create a catalog log with name: %s\n", name);
- rc = llog_create(ctxt, &cath, NULL, NULL, name);
+ rc = llog_create(ctxt, &cath, NULL, name);
if (rc) {
CERROR("1a: llog_create with name %s failed: %d\n", name, rc);
GOTO(out, rc);
lmr.lmr_hdr.lrh_type = 0xf00f00;
CWARN("5a: re-open catalog by id\n");
- rc = llog_create(ctxt, &llh, &cat_logid, NULL, NULL);
+ rc = llog_create(ctxt, &llh, &cat_logid, NULL);
if (rc) {
CERROR("5a: llog_create with logid failed: %d\n", rc);
GOTO(out, rc);
exp = class_conn2export(&exph);
nctxt = llog_get_context(mdc_obd, LLOG_CONFIG_REPL_CTXT);
- rc = llog_create(nctxt, &llh, NULL, NULL, name);
+ rc = llog_create(nctxt, &llh, NULL, name);
if (rc) {
CERROR("6: llog_create failed %d\n", rc);
RETURN(rc);
CWARN("7: create a log with name: %s\n", name);
LASSERT(ctxt);
- rc = llog_create(ctxt, &llh, NULL, NULL, name);
+ rc = llog_create(ctxt, &llh, NULL, name);
if (rc) {
CERROR("7: llog_create with name %s failed: %d\n", name, rc);
RETURN(rc);