Whamcloud - gitweb
Branch: b_new_cmd
authorwangdi <wangdi>
Wed, 20 Sep 2006 16:13:43 +0000 (16:13 +0000)
committerwangdi <wangdi>
Wed, 20 Sep 2006 16:13:43 +0000 (16:13 +0000)
when ost recovery, we may only init llogs for group. not llogs for obd

lustre/include/lustre_log.h
lustre/obdclass/llog_obd.c
lustre/obdfilter/filter.c
lustre/obdfilter/filter_internal.h
lustre/obdfilter/filter_log.c

index 72c3287..1f60ff4 100644 (file)
@@ -127,8 +127,8 @@ int llog_add(struct llog_ctxt *ctxt, struct llog_rec_hdr *rec,
 int llog_cancel(struct llog_ctxt *, struct lov_stripe_md *lsm,
                 int count, struct llog_cookie *cookies, int flags);
 
-int llog_obd_origin_setup(struct obd_device *obd, int index,
-                          struct obd_device *disk_obd, int count,
+int llog_obd_origin_setup(struct obd_device *obd, struct obd_llogs *llogs, 
+                          int index, struct obd_device *disk_obd, int count,
                           struct llog_logid *logid);
 int llog_obd_origin_cleanup(struct llog_ctxt *ctxt);
 int llog_obd_origin_add(struct llog_ctxt *ctxt,
@@ -180,8 +180,8 @@ struct llog_operations {
         int (*lop_close)(struct llog_handle *handle);
         int (*lop_read_header)(struct llog_handle *handle);
 
-        int (*lop_setup)(struct obd_device *obd, int ctxt_idx,
-                         struct obd_device *disk_obd, int count,
+        int (*lop_setup)(struct obd_device *obd, struct obd_llogs *llogs, 
+                         int ctxt_idx, struct obd_device *disk_obd, int count,
                          struct llog_logid *logid);
         int (*lop_sync)(struct llog_ctxt *ctxt, struct obd_export *exp);
         int (*lop_cleanup)(struct llog_ctxt *ctxt);
@@ -276,6 +276,14 @@ static inline struct llog_ctxt *llog_get_context(struct obd_device *obd,
         return obd->obd_llog_ctxt[index];
 }
 
+static inline struct llog_ctxt *
+llog_get_context_from_llogs(struct obd_llogs *llogs, int index)
+{                
+        if (index < 0 || index >= LLOG_MAX_CTXTS)
+                return NULL;
+        return llogs->llog_ctxt[index];
+}
+
 static inline int llog_write_rec(struct llog_handle *handle,
                                  struct llog_rec_hdr *rec,
                                  struct llog_cookie *logcookies,
index 381b8b4..c1a94d7 100644 (file)
@@ -72,7 +72,11 @@ int llog_setup(struct obd_device *obd,  struct obd_llogs *llogs, int index,
         if (index < 0 || index >= LLOG_MAX_CTXTS)
                 RETURN(-EFAULT);
 
-        if (obd->obd_llog_ctxt[index]) {
+        /* in some recovery cases, obd_llog_ctxt might already be set, 
+         * but llogs might still be zero, for example in obd_filter recovery,
+         * Currenn  */
+        if (obd->obd_llog_ctxt[index] &&
+            (!llogs || (llogs && llogs->llog_ctxt[index]))) {
                 /* mds_lov_update_mds might call here multiple times. So if the
                    llog is already set up then don't to do it again. */
                 CDEBUG(D_CONFIG, "obd %s ctxt %d already set up\n", 
@@ -91,7 +95,9 @@ int llog_setup(struct obd_device *obd,  struct obd_llogs *llogs, int index,
         if (llogs)
                 llogs->llog_ctxt[index] = ctxt;
 
-        obd->obd_llog_ctxt[index] = ctxt;
+        if (!obd->obd_llog_ctxt[index])
+                obd->obd_llog_ctxt[index] = ctxt;
+
         ctxt->loc_obd = obd;
         ctxt->loc_exp = class_export_get(disk_obd->obd_self_export);
         ctxt->loc_idx = index;
@@ -99,7 +105,7 @@ int llog_setup(struct obd_device *obd,  struct obd_llogs *llogs, int index,
         sema_init(&ctxt->loc_sem, 1);
 
         if (op->lop_setup)
-                rc = op->lop_setup(obd, index, disk_obd, count, logid);
+                rc = op->lop_setup(obd, llogs, index, disk_obd, count, logid);
 
         if (rc) {
                 obd->obd_llog_ctxt[index] = NULL;
@@ -213,8 +219,8 @@ static int cat_cancel_cb(struct llog_handle *cathandle,
 
 /* lop_setup method for filter/osc */
 // XXX how to set exports
-int llog_obd_origin_setup(struct obd_device *obd, int index,
-                          struct obd_device *disk_obd, int count,
+int llog_obd_origin_setup(struct obd_device *obd, struct obd_llogs *llogs,
+                          int index, struct obd_device *disk_obd, int count,
                           struct llog_logid *logid)
 {
         struct llog_ctxt *ctxt;
@@ -228,7 +234,11 @@ int llog_obd_origin_setup(struct obd_device *obd, int index,
 
         LASSERT(count == 1);
 
-        ctxt = llog_get_context(obd, index);
+        if (!llogs)
+                ctxt = llog_get_context(obd, index);
+        else
+                ctxt = llog_get_context_from_llogs(llogs, index);
+        
         LASSERT(ctxt);
         llog_gen_init(ctxt);
 
index a9402c7..eb83a24 100644 (file)
@@ -2103,7 +2103,9 @@ static int filter_llog_init(struct obd_device *obd, struct obd_llogs *llogs,
         if (!llogs)
                 ctxt = llog_get_context(obd, LLOG_MDS_OST_REPL_CTXT);
         else
-                ctxt = filter_llog_get_context(llogs, LLOG_MDS_OST_REPL_CTXT);
+                ctxt = llog_get_context_from_llogs(llogs, LLOG_MDS_OST_REPL_CTXT);
+        
+        LASSERT(ctxt != NULL);
         ctxt->llog_proc_cb = filter_recov_log_mds_ost_cb;
 
         rc = llog_setup(obd, llogs, LLOG_SIZE_ORIG_CTXT, tgt, 0, NULL,
@@ -2118,11 +2120,11 @@ static int filter_group_llog_finish(struct obd_llogs *llogs)
         int rc = 0, rc2 = 0;
         ENTRY;
        
-        ctxt = filter_llog_get_context(llogs, LLOG_MDS_OST_REPL_CTXT);
+        ctxt = llog_get_context_from_llogs(llogs, LLOG_MDS_OST_REPL_CTXT);
         if (ctxt)
                 rc = llog_cleanup(ctxt);
 
-        ctxt = filter_llog_get_context(llogs, LLOG_SIZE_ORIG_CTXT);
+        ctxt = llog_get_context_from_llogs(llogs, LLOG_SIZE_ORIG_CTXT);
         if (ctxt)
                 rc2 = llog_cleanup(ctxt);
         if (!rc)
@@ -2206,7 +2208,7 @@ struct obd_llogs *filter_grab_llog_for_group(struct obd_device *obd, int group,
 init:
         if (export) {
                 fglog->exp = export;
-                ctxt = filter_llog_get_context(fglog->llogs, 
+                ctxt = llog_get_context_from_llogs(fglog->llogs, 
                                                LLOG_MDS_OST_REPL_CTXT);
                 LASSERT(ctxt != NULL);
 
@@ -2234,7 +2236,7 @@ static int filter_llog_connect(struct obd_export *exp,
 
         llog = filter_grab_llog_for_group(obd, body->lgdc_logid.lgl_ogr, exp);
         LASSERT(llog != NULL);
-        ctxt = filter_llog_get_context(llog, body->lgdc_ctxt_idx);
+        ctxt = llog_get_context_from_llogs(llog, body->lgdc_ctxt_idx);
         rc = llog_connect(ctxt, 1, &body->lgdc_logid,
                           &body->lgdc_gen, NULL);
         if (rc != 0)
@@ -2707,7 +2709,7 @@ static void filter_sync_llogs(struct obd_device *obd, struct obd_export *dexp)
 
                 worked = fglog->group;
                 if (fglog->exp && (dexp == fglog->exp || dexp == NULL)) {
-                        ctxt = filter_llog_get_context(fglog->llogs,
+                        ctxt = llog_get_context_from_llogs(fglog->llogs,
                                                 LLOG_MDS_OST_REPL_CTXT);
                         LASSERT(ctxt != NULL);
                         llog_sync(ctxt, fglog->exp);
index 5f7f04d..9933a1b 100644 (file)
@@ -118,14 +118,6 @@ struct dentry *filter_create_object(struct obd_device *obd, struct obdo *oa);
 struct obd_llogs *filter_grab_llog_for_group(struct obd_device *obd, int group,
                                              struct obd_export *export);
 
-static inline struct llog_ctxt *filter_llog_get_context(struct obd_llogs *llogs,
-                                                        int index)
-{                
-        if (index < 0 || index >= LLOG_MAX_CTXTS)
-                return NULL;
-        return llogs->llog_ctxt[index];
-}
-
 /* filter_lvb.c */
 extern struct ldlm_valblock_ops filter_lvbo;
 
index fc0dc92..d737983 100644 (file)
@@ -112,7 +112,7 @@ void filter_cancel_cookies_cb(struct obd_device *obd, __u64 transno,
         llogs = filter_grab_llog_for_group(obd, cookie->lgc_lgl.lgl_ogr, NULL);
 
         if (llogs) {
-                ctxt = filter_llog_get_context(llogs, cookie->lgc_subsys + 1);
+                ctxt = llog_get_context_from_llogs(llogs, cookie->lgc_subsys + 1);
                 if (ctxt) {
                         llog_cancel(ctxt, NULL, 1, cookie, 0);
                 } else