Whamcloud - gitweb
land lustre part of b_hd_sec on HEAD.
[fs/lustre-release.git] / lustre / obdfilter / filter_log.c
index 686fd30..9d7afe9 100644 (file)
@@ -30,7 +30,7 @@
 #include <linux/module.h>
 #include <linux/version.h>
 
-#include <portals/list.h>
+#include <libcfs/list.h>
 #include <linux/obd_class.h>
 #include <linux/lustre_fsfilt.h>
 #include <linux/lustre_commit_confd.h>
 #include "filter_internal.h"
 
 int filter_log_sz_change(struct llog_handle *cathandle, 
-                         struct ll_fid *mds_fid,
-                         __u32 io_epoch,
+                         struct lustre_id *id, __u32 io_epoch,
                          struct llog_cookie *logcookie, 
                          struct inode *inode)
 {
         struct llog_size_change_rec *lsc;
-        int rc;
+#ifdef IFILTERDATA_ACTUALLY_USED
         struct ost_filterdata *ofd;
+#endif
+        int rc;
         ENTRY;
 
         down(&inode->i_sem);
+#ifdef IFILTERDATA_ACTUALLY_USED
         ofd = inode->i_filterdata;
         
         if (ofd && ofd->ofd_epoch >= io_epoch) {
@@ -69,6 +71,7 @@ int filter_log_sz_change(struct llog_handle *cathandle,
                 inode->i_filterdata = ofd;
                 ofd->ofd_epoch = io_epoch;
         }
+#endif
         /* the decision to write a record is now made, unlock */
         up(&inode->i_sem);
 
@@ -77,10 +80,11 @@ int filter_log_sz_change(struct llog_handle *cathandle,
                 RETURN(-ENOMEM);
         lsc->lsc_hdr.lrh_len = lsc->lsc_tail.lrt_len = sizeof(*lsc);
         lsc->lsc_hdr.lrh_type =  OST_SZ_REC;
-        lsc->lsc_fid = *mds_fid;
+        lsc->lsc_id = *id;
         lsc->lsc_io_epoch = io_epoch;
 
-        rc = llog_cat_add_rec(cathandle, &lsc->lsc_hdr, logcookie, NULL);
+        rc = llog_cat_add_rec(cathandle, &lsc->lsc_hdr, logcookie,
+                              NULL, NULL, NULL);
         OBD_FREE(lsc, sizeof(*lsc));
 
         if (rc > 0) {
@@ -88,18 +92,36 @@ int filter_log_sz_change(struct llog_handle *cathandle,
                 rc = 0;
         }
 
-        out:
+#ifdef IFILTERDATA_ACTUALLY_USED
+out:
+#endif
         RETURN(rc);
 }
+struct obd_llogs * filter_grab_llog_for_group(struct obd_device *,
+                                              int, struct obd_export *);
 
 /* When this (destroy) operation is committed, return the cancel cookie */
 void filter_cancel_cookies_cb(struct obd_device *obd, __u64 transno,
-                                     void *cb_data, int error)
+                              void *cb_data, int error)
 {
         struct llog_cookie *cookie = cb_data;
-        llog_cancel(llog_get_context(obd, cookie->lgc_subsys + 1),
-                             NULL, 1, cookie, 0);
-                             //NULL, 1, cookie, OBD_LLOG_FL_SENDNOW);
+        struct obd_llogs *llogs = NULL;
+        struct llog_ctxt *ctxt;
+
+        /* we have to find context for right group */
+        llogs = filter_grab_llog_for_group(obd, cookie->lgc_lgl.lgl_ogr, NULL);
+
+        if (llogs) {
+                ctxt = llog_get_context(llogs, cookie->lgc_subsys + 1);
+                if (ctxt) {
+                        llog_cancel(ctxt, 1, cookie, 0, NULL);
+                } else
+                        CERROR("no valid context for group "LPU64"\n",
+                               cookie->lgc_lgl.lgl_ogr);
+        } else {
+                CDEBUG(D_HA, "unknown group "LPU64"!\n", cookie->lgc_lgl.lgl_ogr);
+        }
+
         OBD_FREE(cb_data, sizeof(struct llog_cookie));
 }
 
@@ -119,7 +141,7 @@ int filter_recov_log_unlink_cb(struct llog_handle *llh,
         obd_id oid;
         int rc = 0;
         ENTRY;
-                                                                                                                             
+    
         if (!(le32_to_cpu(llh->lgh_hdr->llh_flags) & LLOG_F_IS_PLAIN)) {
                 CERROR("log is not plain\n");
                 RETURN(-EINVAL);
@@ -141,7 +163,7 @@ int filter_recov_log_unlink_cb(struct llog_handle *llh,
                 else
                         rc = LLOG_PROC_BREAK;
                 CWARN("fetch generation log, send cookie\n");
-                llog_cancel(ctxt, NULL, 1, &cookie, 0);
+                llog_cancel(ctxt, 1, &cookie, 0, NULL);
                 RETURN(rc);
         }
 
@@ -152,19 +174,20 @@ int filter_recov_log_unlink_cb(struct llog_handle *llh,
         oa->o_valid |= OBD_MD_FLCOOKIE;
         oa->o_id = lur->lur_oid;
         oa->o_gr = lur->lur_ogen;
+        oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
         memcpy(obdo_logcookie(oa), &cookie, sizeof(cookie));
         oid = oa->o_id;
 
         rc = obd_destroy(exp, oa, NULL, NULL);
         obdo_free(oa);
         if (rc == -ENOENT) {
-                CWARN("object already removed, send cookie\n");
-                llog_cancel(ctxt, NULL, 1, &cookie, 0);
+                CDEBUG(D_HA, "object already removed, send cookie\n");
+                llog_cancel(ctxt, 1, &cookie, 0, NULL);
                 RETURN(0);
         }
 
         if (rc == 0)
-                CWARN("object: "LPU64" in record is destroyed\n", oid);
+                CDEBUG(D_HA, "object: "LPU64" in record is destroyed\n", oid);
 
         RETURN(rc);
 }