Whamcloud - gitweb
fix llog_create to old pattern
authorlincent <lincent>
Sun, 9 Oct 2005 09:40:05 +0000 (09:40 +0000)
committerlincent <lincent>
Sun, 9 Oct 2005 09:40:05 +0000 (09:40 +0000)
lustre/include/linux/lustre_log.h
lustre/mds/mds_lov.c
lustre/mgs/mgs_handler.c
lustre/obdclass/llog_cat.c
lustre/obdclass/llog_ioctl.c
lustre/obdclass/llog_obd.c
lustre/obdclass/llog_test.c

index 215e6a0..108e656 100644 (file)
@@ -164,7 +164,7 @@ struct llog_operations {
         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);
 
@@ -364,7 +364,8 @@ static inline int llog_next_block(struct llog_handle *loghandle, int *cur_idx,
 }
 
 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;
@@ -376,7 +377,8 @@ static inline int llog_create(struct llog_ctxt *ctxt, struct llog_handle **res,
         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);
 }
 
index 9649dfa..4680639 100644 (file)
@@ -265,7 +265,7 @@ int mds_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 
                 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);
@@ -295,7 +295,7 @@ int mds_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 
                 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);
index 9d864ab..8b1d4e4 100644 (file)
@@ -88,7 +88,11 @@ static int mgs_connect(struct lustre_handle *conn, struct obd_device *obd,
 
         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) {
@@ -123,6 +127,7 @@ static int mgs_disconnect(struct obd_export *exp)
 
         /* 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);
@@ -190,13 +195,21 @@ static int mgs_setup(struct obd_device *obd, obd_count len, void *buf)
 
         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);
@@ -205,12 +218,6 @@ static int mgs_setup(struct obd_device *obd, obd_count len, void *buf)
         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)
@@ -240,7 +247,7 @@ static int mgs_setup(struct obd_device *obd, obd_count len, void *buf)
                               lustre_cfg_string(lcfg, 1),
                               obd->obd_replayable ? "enabled" : "disabled");
         }
-//FIXME: no ldlm support now
+
         ldlm_timeout = 6;
         ping_evictor_start();
 
@@ -249,6 +256,9 @@ static int mgs_setup(struct obd_device *obd, obd_count len, void *buf)
 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);
@@ -312,6 +322,8 @@ static int mgs_cleanup(struct obd_device *obd)
         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);
@@ -326,114 +338,11 @@ static int mgs_cleanup(struct obd_device *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;
@@ -504,6 +413,21 @@ int mgs_handle(struct ptlrpc_request *req)
                 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);
index b975f14..fd2c198 100644 (file)
@@ -80,7 +80,7 @@ static struct llog_handle *llog_cat_new_log(struct llog_handle *cathandle)
                 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));
 
@@ -152,7 +152,7 @@ int llog_cat_id2handle(struct llog_handle *cathandle, struct llog_handle **res,
                 }
         }
 
-        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);
index 7e37945..ce3f0a1 100644 (file)
@@ -270,12 +270,12 @@ int llog_ioctl(struct llog_ctxt *ctxt, int cmd, struct obd_ioctl_data *data)
                 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 {
index c98ae41..11e41dd 100644 (file)
@@ -210,9 +210,9 @@ int llog_obd_origin_setup(struct obd_device *obd, int index,
         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;
         }
index b66d5a3..7a2f82b 100644 (file)
@@ -92,7 +92,7 @@ static int llog_test_1(struct obd_device *obd, char *name)
         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);
@@ -124,7 +124,7 @@ static int llog_test_2(struct obd_device *obd, char *name,
         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);
@@ -135,7 +135,7 @@ static int llog_test_2(struct obd_device *obd, char *name,
                 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);
@@ -145,7 +145,7 @@ static int llog_test_2(struct obd_device *obd, char *name,
         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);
@@ -245,7 +245,7 @@ static int llog_test_4(struct obd_device *obd)
 
         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);
@@ -382,7 +382,7 @@ static int llog_test_5(struct obd_device *obd)
         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);
@@ -463,7 +463,7 @@ static int llog_test_6(struct obd_device *obd, char *name)
         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);
@@ -503,7 +503,7 @@ static int llog_test_7(struct obd_device *obd)
         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);