Whamcloud - gitweb
land b_llog on b_devel:
authorphil <phil>
Tue, 9 Sep 2003 04:49:16 +0000 (04:49 +0000)
committerphil <phil>
Tue, 9 Sep 2003 04:49:16 +0000 (04:49 +0000)
reorganization and API update of the logging infrastructure. minimal
changes to the other code.

lnet/utils/debug.c
lustre/mds/mds_internal.h
lustre/obdfilter/filter_internal.h
lustre/obdfilter/filter_io.c
lustre/obdfilter/filter_log.c
lustre/portals/utils/debug.c

index 5921259..c2308bd 100644 (file)
@@ -532,7 +532,9 @@ int jt_dbg_modules(int argc, char **argv)
         } *mp, mod_paths[] = {
                 {"portals", "lustre/portals/libcfs"},
                 {"ksocknal", "lustre/portals/knals/socknal"},
+                {"lvfs", "lustre/lvfs"},
                 {"obdclass", "lustre/obdclass"},
+                {"llog_test", "lustre/obdclass"},
                 {"ptlrpc", "lustre/ptlrpc"},
                 {"obdext2", "lustre/obdext2"},
                 {"ost", "lustre/ost"},
@@ -545,8 +547,9 @@ int jt_dbg_modules(int argc, char **argv)
                 {"obdfilter", "lustre/obdfilter"},
                 {"extN", "lustre/extN"},
                 {"lov", "lustre/lov"},
-                {"fsfilt_ext3", "lustre/obdclass"},
-                {"fsfilt_extN", "lustre/obdclass"},
+                {"fsfilt_ext3", "lustre/lvfs"},
+                {"fsfilt_extN", "lustre/lvfs"},
+                {"fsfilt_reiserfs", "lustre/lvfs"},
                 {"mds_ext2", "lustre/mds"},
                 {"mds_ext3", "lustre/mds"},
                 {"mds_extN", "lustre/mds"},
index 3950b05..cc4ab10 100644 (file)
@@ -32,8 +32,7 @@ int mds_update_unpack(struct ptlrpc_request *, int offset,
 
 /* mds/mds_lov.c */
 int mds_lov_connect(struct obd_device *obd);
-int mds_get_lovtgts(struct mds_obd *mds, int tgt_count,
-                    struct obd_uuid *uuidarray);
+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_growth(struct mds_obd *mds, int count);
@@ -57,6 +56,7 @@ int mds_object_create(struct obd_export *exp, struct obdo *oa,
                       struct lov_stripe_md **ea, struct obd_trans_info *oti);
 
 /* mds/handler.c */
+extern struct lvfs_callback_ops mds_lvfs_ops;
 extern int mds_iocontrol(unsigned int cmd, struct obd_export *exp,
                          int len, void *karg, void *uarg);
 
index df2fd65..81f2c66 100644 (file)
@@ -127,14 +127,12 @@ int filter_commitrw_write(struct obd_export *exp, int objcount,
                           struct obd_trans_info *oti);
 
 /* filter_log.c */
-int filter_log_cancel(struct obd_export *, struct lov_stripe_md *,
-                      int num_cookies, struct llog_cookie *, int flags);
 int filter_log_op_create(struct llog_handle *cathandle, struct ll_fid *mds_fid,
                          obd_id oid, obd_count ogen, struct llog_cookie *);
 int filter_log_op_orphan(struct llog_handle *cathandle, obd_id oid,
                          obd_count ogen, struct llog_cookie *);
 struct llog_handle *filter_get_catalog(struct obd_device *);
-void filter_put_catalog(struct llog_handle *cathandle);
+
 
 /* filter_san.c */
 int filter_san_setup(struct obd_device *obd, obd_count len, void *buf);
index 4240800..a8d77c5 100644 (file)
@@ -126,7 +126,7 @@ static int filter_preprw_read(int cmd, struct obd_export *exp, struct obdo *oa,
 
         memset(res, 0, niocount * sizeof(*res));
 
-        push_ctxt(&saved, &exp->exp_obd->u.filter.fo_ctxt, NULL);
+        push_ctxt(&saved, &exp->exp_obd->obd_ctxt, NULL);
         for (i = 0, o = obj; i < objcount; i++, o++) {
                 LASSERT(o->ioo_bufcnt);
 
@@ -228,7 +228,7 @@ static int filter_preprw_read(int cmd, struct obd_export *exp, struct obdo *oa,
                         CERROR("NULL dentry in cleanup -- tell CFS\n");
         case 0:
                 OBD_FREE(fso, objcount * sizeof(*fso));
-                pop_ctxt(&saved, &exp->exp_obd->u.filter.fo_ctxt, NULL);
+                pop_ctxt(&saved, &exp->exp_obd->obd_ctxt, NULL);
         }
         return rc;
 }
@@ -276,7 +276,7 @@ static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa,
 
         memset(res, 0, niocount * sizeof(*res));
 
-        push_ctxt(&saved, &exp->exp_obd->u.filter.fo_ctxt, NULL);
+        push_ctxt(&saved, &exp->exp_obd->obd_ctxt, NULL);
         dentry = filter_fid2dentry(exp->exp_obd, NULL, 0, obj->ioo_id);
         if (IS_ERR(dentry))
                 GOTO(cleanup, rc = PTR_ERR(dentry));
@@ -328,7 +328,7 @@ static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa,
                             tot_bytes);
         EXIT;
 cleanup:
-        pop_ctxt(&saved, &exp->exp_obd->u.filter.fo_ctxt, NULL);
+        pop_ctxt(&saved, &exp->exp_obd->obd_ctxt, NULL);
         return rc;
 }
 
index d63847c..de21a1f 100644 (file)
 
 #include "filter_internal.h"
 
-static struct llog_handle *filter_log_create(struct obd_device *obd);
-
-/* This is a callback from the llog_* functions.
- * Assumes caller has already pushed us into the kernel context. */
-static int filter_log_close(struct llog_handle *cathandle,
-                            struct llog_handle *loghandle)
-{
-        struct llog_object_hdr *llh = loghandle->lgh_hdr;
-        struct file *file = loghandle->lgh_file;
-        struct dentry *dparent = NULL, *dchild = NULL;
-        struct lustre_handle parent_lockh;
-        struct llog_logid *lgl = &loghandle->lgh_cookie.lgc_lgl;
-        int rc;
-        ENTRY;
-
-        /* If we are going to delete this log, grab a ref before we close
-         * it so we don't have to immediately do another lookup. */
-        if (llh->llh_hdr.lth_type != LLOG_CATALOG_MAGIC && llh->llh_count == 0){
-                CDEBUG(D_INODE, "deleting log file "LPX64":%x\n",
-                       lgl->lgl_oid, lgl->lgl_ogen);
-                dparent = filter_parent_lock(loghandle->lgh_obd, 1,
-                                             lgl->lgl_oid,LCK_PW,&parent_lockh);
-                if (IS_ERR(dparent)) {
-                        rc = PTR_ERR(dparent);
-                        CERROR("error locking parent, orphan log %*s: rc %d\n",
-                               file->f_dentry->d_name.len,
-                               file->f_dentry->d_name.name, rc);
-                        RETURN(rc);
-                } else {
-                        dchild = dget(file->f_dentry);
-                        llog_delete_log(cathandle, loghandle);
-                }
-        } else {
-                CDEBUG(D_INODE, "closing log file "LPX64":%x\n",
-                       lgl->lgl_oid, lgl->lgl_ogen);
-        }
-
-        rc = filp_close(file, 0);
-
-        llog_free_handle(loghandle); /* also removes loghandle from list */
-
-        if (dchild != NULL) {
-                int err = vfs_unlink(dparent->d_inode, dchild);
-                if (err) {
-                        CERROR("error unlinking empty log %*s: rc %d\n",
-                               dchild->d_name.len, dchild->d_name.name, err);
-                        if (!rc)
-                                rc = err;
-                }
-                f_dput(dchild);
-                ldlm_lock_decref(&parent_lockh, LCK_PW);
-        }
-        RETURN(rc);
-}
-
-/* This is a callback from the llog_* functions.
- * Assumes caller has already pushed us into the kernel context. */
-static struct llog_handle *filter_log_open(struct obd_device *obd,
-                                           struct llog_cookie *logcookie)
-{
-        struct llog_logid *lgl = &logcookie->lgc_lgl;
-        struct llog_handle *loghandle;
-        struct dentry *dchild;
-        int rc;
-        ENTRY;
-
-        loghandle = llog_alloc_handle();
-        if (!loghandle)
-                RETURN(ERR_PTR(-ENOMEM));
-
-        dchild = filter_fid2dentry(obd, NULL, 1, lgl->lgl_oid);
-        if (IS_ERR(dchild))
-                GOTO(out_handle, rc = PTR_ERR(dchild));
-
-        if (dchild->d_inode == NULL) {
-                CERROR("logcookie references non-existent object %*s\n",
-                       dchild->d_name.len, dchild->d_name.name);
-                GOTO(out_dentry, rc = -ENOENT);
-        }
-
-        if (dchild->d_inode->i_generation != lgl->lgl_ogen) {
-                CERROR("logcookie for %*s had different generation %x != %x\n",
-                       dchild->d_name.len, dchild->d_name.name,
-                       dchild->d_inode->i_generation, lgl->lgl_ogen);
-                GOTO(out_dentry, rc = -ESTALE);
-        }
-
-        /* dentry_open does a dput(dchild) and mntput(mnt) on error */
-        mntget(obd->u.filter.fo_vfsmnt);
-        loghandle->lgh_file = dentry_open(dchild, obd->u.filter.fo_vfsmnt,
-                                          O_RDWR);
-        if (IS_ERR(loghandle->lgh_file)) {
-                rc = PTR_ERR(loghandle->lgh_file);
-                CERROR("error opening logfile %*s: rc %d\n",
-                       dchild->d_name.len, dchild->d_name.name, rc);
-                GOTO(out_dentry, rc);
-        }
-        memcpy(&loghandle->lgh_cookie, logcookie, sizeof(*logcookie));
-        loghandle->lgh_log_create = filter_log_create;
-        loghandle->lgh_log_open = filter_log_open;
-        loghandle->lgh_log_close = filter_log_close;
-        loghandle->lgh_obd = obd;
-        RETURN(loghandle);
-
-out_dentry:
-        f_dput(dchild);
-out_handle:
-        llog_free_handle(loghandle);
-        RETURN(ERR_PTR(rc));
-}
-
-/* This is a callback from the llog_* functions.
- * Assumes caller has already pushed us into the kernel context. */
-static struct llog_handle *filter_log_create(struct obd_device *obd)
-{
-        struct filter_obd *filter = &obd->u.filter;
-        struct lustre_handle parent_lockh;
-        struct dentry *dparent, *dchild;
-        struct llog_handle *loghandle;
-        struct file *file;
-        struct obdo obdo;
-        int err, rc;
-        obd_id id;
-        ENTRY;
-
-        loghandle = llog_alloc_handle();
-        if (!loghandle)
-                RETURN(ERR_PTR(-ENOMEM));
-
-        memset(&obdo, 0, sizeof(obdo));
-        obdo.o_valid = OBD_MD_FLGROUP;
-        obdo.o_gr = 1; /* FIXME: object groups */
- retry:
-        id = filter_next_id(filter, &obdo);
-
-        dparent = filter_parent_lock(obd, obdo.o_gr, id, LCK_PW, &parent_lockh);
-        if (IS_ERR(dparent))
-                GOTO(out_ctxt, rc = PTR_ERR(dparent));
-
-        dchild = filter_fid2dentry(obd, dparent, obdo.o_gr, id);
-        if (IS_ERR(dchild))
-                GOTO(out_lock, rc = PTR_ERR(dchild));
-
-        if (dchild->d_inode != NULL) {
-                /* This would only happen if lastobjid was bad on disk */
-                CERROR("Serious error: objid %*s already exists; is this "
-                       "filesystem corrupt?  I will try to work around it.\n",
-                       dchild->d_name.len, dchild->d_name.name);
-                f_dput(dchild);
-                ldlm_lock_decref(&parent_lockh, LCK_PW);
-                goto retry;
-        }
-
-        rc = ll_vfs_create(dparent->d_inode, dchild, S_IFREG, NULL);
-        if (rc) {
-                CERROR("log create failed rc = %d\n", rc);
-                GOTO(out_child, rc);
-        }
-
-        rc = filter_update_last_objid(obd, obdo.o_gr, 0);
-        if (rc) {
-                CERROR("can't write lastobjid but log created: rc %d\n",rc);
-                GOTO(out_destroy, rc);
-        }
-
-        /* dentry_open does a dput(dchild) and mntput(mnt) on error */
-        mntget(filter->fo_vfsmnt);
-        file = dentry_open(dchild, filter->fo_vfsmnt, O_RDWR | O_LARGEFILE);
-        if (IS_ERR(file)) {
-                rc = PTR_ERR(file);
-                CERROR("error opening log file "LPX64": rc %d\n", id, rc);
-                GOTO(out_destroy, rc);
-        }
-        ldlm_lock_decref(&parent_lockh, LCK_PW);
-
-        loghandle->lgh_file = file;
-        loghandle->lgh_cookie.lgc_lgl.lgl_oid = id;
-        loghandle->lgh_cookie.lgc_lgl.lgl_ogen = dchild->d_inode->i_generation;
-        loghandle->lgh_log_create = filter_log_create;
-        loghandle->lgh_log_open = filter_log_open;
-        loghandle->lgh_log_close = filter_log_close;
-        loghandle->lgh_obd = obd;
-
-        RETURN(loghandle);
-
-out_destroy:
-        err = vfs_unlink(dparent->d_inode, dchild);
-        if (err)
-                CERROR("error unlinking %*s on error: rc %d\n",
-                       dchild->d_name.len, dchild->d_name.name, err);
-out_child:
-        f_dput(dchild);
-out_lock:
-        ldlm_lock_decref(&parent_lockh, LCK_PW);
-out_ctxt:
-        llog_free_handle(loghandle);
-        RETURN(ERR_PTR(rc));
-}
-
 /* This is called from filter_setup() and should be single threaded */
 struct llog_handle *filter_get_catalog(struct obd_device *obd)
 {
@@ -243,20 +44,18 @@ struct llog_handle *filter_get_catalog(struct obd_device *obd)
         struct filter_server_data *fsd = filter->fo_fsd;
         struct obd_run_ctxt saved;
         struct llog_handle *cathandle = NULL;
+        struct llog_logid logid;
         int rc;
         ENTRY;
 
-        push_ctxt(&saved, &filter->fo_ctxt, NULL);
+        push_ctxt(&saved, &obd->obd_ctxt, NULL);
         if (fsd->fsd_catalog_oid) {
-                struct llog_cookie catcookie;
-
-                catcookie.lgc_lgl.lgl_oid = le64_to_cpu(fsd->fsd_catalog_oid);
-                catcookie.lgc_lgl.lgl_ogen = le32_to_cpu(fsd->fsd_catalog_ogen);
-                cathandle = filter_log_open(obd, &catcookie);
-                if (IS_ERR(cathandle)) {
+                logid.lgl_oid = le64_to_cpu(fsd->fsd_catalog_oid);
+                logid.lgl_ogen = le32_to_cpu(fsd->fsd_catalog_ogen);
+                rc = llog_create(obd, &cathandle, &logid, NULL);
+                if (rc) {
                         CERROR("error opening catalog "LPX64":%x: rc %d\n",
-                               catcookie.lgc_lgl.lgl_oid,
-                               catcookie.lgc_lgl.lgl_ogen,
+                               logid.lgl_oid, logid.lgl_ogen,
                                (int)PTR_ERR(cathandle));
                         fsd->fsd_catalog_oid = 0;
                         fsd->fsd_catalog_ogen = 0;
@@ -264,17 +63,15 @@ struct llog_handle *filter_get_catalog(struct obd_device *obd)
         }
 
         if (!fsd->fsd_catalog_oid) {
-                struct llog_logid *lgl;
-
-                cathandle = filter_log_create(obd);
-                if (IS_ERR(cathandle)) {
-                        CERROR("error creating new catalog: rc %d\n",
-                               (int)PTR_ERR(cathandle));
+                rc = llog_create(obd, &cathandle, NULL, NULL);
+                if (rc) {
+                        CERROR("error creating new catalog: rc %d\n", rc);
+                        cathandle = ERR_PTR(rc);
                         GOTO(out, cathandle);
                 }
-                lgl = &cathandle->lgh_cookie.lgc_lgl;
-                fsd->fsd_catalog_oid = cpu_to_le64(lgl->lgl_oid);
-                fsd->fsd_catalog_ogen = cpu_to_le32(lgl->lgl_ogen);
+                logid = cathandle->lgh_id;
+                fsd->fsd_catalog_oid = cpu_to_le64(logid.lgl_oid);
+                fsd->fsd_catalog_ogen = cpu_to_le32(logid.lgl_ogen);
                 rc = filter_update_server_data(obd, filter->fo_rcvd_filp,fsd,0);
                 if (rc) {
                         CERROR("error writing new catalog to disk: rc %d\n",rc);
@@ -282,52 +79,19 @@ struct llog_handle *filter_get_catalog(struct obd_device *obd)
                 }
         }
 
-        rc = llog_init_catalog(cathandle, &obd->u.filter.fo_mdc_uuid);
+        rc = llog_init_handle(cathandle, LLOG_F_IS_CAT, &obd->u.filter.fo_mdc_uuid);
         if (rc)
                 GOTO(out_handle, rc);
 out:
-        pop_ctxt(&saved, &filter->fo_ctxt, NULL);
+        pop_ctxt(&saved, &obd->obd_ctxt, NULL);
         RETURN(cathandle);
 
 out_handle:
-        filter_log_close(cathandle, cathandle);
+        llog_close(cathandle);
         cathandle = ERR_PTR(rc);
         goto out;
 }
 
-void filter_put_catalog(struct llog_handle *cathandle)
-{
-        struct llog_handle *loghandle, *n;
-        int rc;
-        ENTRY;
-
-        list_for_each_entry_safe(loghandle, n, &cathandle->lgh_list, lgh_list)
-                filter_log_close(cathandle, loghandle);
-
-        rc = filp_close(cathandle->lgh_file, 0);
-        if (rc)
-                CERROR("error closing catalog: rc %d\n", rc);
-
-        llog_free_handle(cathandle);
-        EXIT;
-}
-
-int filter_log_cancel(struct obd_export *exp, struct lov_stripe_md *lsm,
-                      int num_cookies, struct llog_cookie *logcookies,
-                      int flags)
-{
-        struct obd_device *obd = exp->exp_obd;
-        struct obd_run_ctxt saved;
-        int rc;
-        ENTRY;
-
-        push_ctxt(&saved, &obd->u.filter.fo_ctxt, NULL);
-        rc = llog_cancel_records(obd->u.filter.fo_catalog, num_cookies,
-                                 logcookies);
-        pop_ctxt(&saved, &obd->u.filter.fo_ctxt, NULL);
-
-        RETURN(rc);
-}
 
 int filter_log_op_create(struct llog_handle *cathandle, struct ll_fid *mds_fid,
                          obd_id oid, obd_count ogen,
@@ -340,15 +104,15 @@ int filter_log_op_create(struct llog_handle *cathandle, struct ll_fid *mds_fid,
         OBD_ALLOC(lcr, sizeof(*lcr));
         if (lcr == NULL)
                 RETURN(-ENOMEM);
-        lcr->lcr_hdr.lth_len = lcr->lcr_end_len = sizeof(*lcr);
-        lcr->lcr_hdr.lth_type = OST_CREATE_REC;
+        lcr->lcr_hdr.lrh_len = lcr->lcr_tail.lrt_len = sizeof(*lcr);
+        lcr->lcr_hdr.lrh_type = OST_CREATE_REC;
         lcr->lcr_fid.id = mds_fid->id;
         lcr->lcr_fid.generation = mds_fid->generation;
         lcr->lcr_fid.f_type = mds_fid->f_type;
         lcr->lcr_oid = oid;
         lcr->lcr_ogen = ogen;
 
-        rc = llog_add_record(cathandle, &lcr->lcr_hdr, logcookie);
+        rc = llog_cat_add_rec(cathandle, &lcr->lcr_hdr, logcookie, NULL);
         OBD_FREE(lcr, sizeof(*lcr));
 
         if (rc > 0) {
@@ -368,12 +132,12 @@ int filter_log_op_orphan(struct llog_handle *cathandle, obd_id oid,
         OBD_ALLOC(lor, sizeof(*lor));
         if (lor == NULL)
                 RETURN(-ENOMEM);
-        lor->lor_hdr.lth_len = lor->lor_end_len = sizeof(*lor);
-        lor->lor_hdr.lth_type = OST_ORPHAN_REC;
+        lor->lor_hdr.lrh_len = lor->lor_tail.lrt_len = sizeof(*lor);
+        lor->lor_hdr.lrh_type = OST_ORPHAN_REC;
         lor->lor_oid = oid;
         lor->lor_ogen = ogen;
 
-        rc = llog_add_record(cathandle, &lor->lor_hdr, logcookie);
+        rc = llog_cat_add_rec(cathandle, &lor->lor_hdr, logcookie, NULL);
 
         if (rc > 0) {
                 LASSERT(rc == sizeof(*logcookie));
index 5921259..c2308bd 100644 (file)
@@ -532,7 +532,9 @@ int jt_dbg_modules(int argc, char **argv)
         } *mp, mod_paths[] = {
                 {"portals", "lustre/portals/libcfs"},
                 {"ksocknal", "lustre/portals/knals/socknal"},
+                {"lvfs", "lustre/lvfs"},
                 {"obdclass", "lustre/obdclass"},
+                {"llog_test", "lustre/obdclass"},
                 {"ptlrpc", "lustre/ptlrpc"},
                 {"obdext2", "lustre/obdext2"},
                 {"ost", "lustre/ost"},
@@ -545,8 +547,9 @@ int jt_dbg_modules(int argc, char **argv)
                 {"obdfilter", "lustre/obdfilter"},
                 {"extN", "lustre/extN"},
                 {"lov", "lustre/lov"},
-                {"fsfilt_ext3", "lustre/obdclass"},
-                {"fsfilt_extN", "lustre/obdclass"},
+                {"fsfilt_ext3", "lustre/lvfs"},
+                {"fsfilt_extN", "lustre/lvfs"},
+                {"fsfilt_reiserfs", "lustre/lvfs"},
                 {"mds_ext2", "lustre/mds"},
                 {"mds_ext3", "lustre/mds"},
                 {"mds_extN", "lustre/mds"},