Whamcloud - gitweb
LU-1302 llog: pass lu_env as parametr in llog functions
[fs/lustre-release.git] / lustre / obdfilter / filter_log.c
index bca819c..d997ae8 100644 (file)
@@ -62,29 +62,29 @@ int filter_log_sz_change(struct llog_handle *cathandle,
         struct ost_filterdata *ofd;
         ENTRY;
 
-        LOCK_INODE_MUTEX(inode);
-        ofd = INODE_PRIVATE_DATA(inode);
-
-        if (ofd && ofd->ofd_epoch >= ioepoch) {
-                if (ofd->ofd_epoch > ioepoch)
-                        CERROR("client sent old epoch %d for obj ino %ld\n",
-                               ioepoch, inode->i_ino);
-                UNLOCK_INODE_MUTEX(inode);
-                RETURN(0);
-        }
-
-        if (ofd && ofd->ofd_epoch < ioepoch) {
-                ofd->ofd_epoch = ioepoch;
-        } else if (!ofd) {
-                OBD_ALLOC(ofd, sizeof(*ofd));
-                if (!ofd)
-                        GOTO(out, rc = -ENOMEM);
-                igrab(inode);
-                INODE_PRIVATE_DATA(inode) = ofd;
-                ofd->ofd_epoch = ioepoch;
-        }
-        /* the decision to write a record is now made, unlock */
-        UNLOCK_INODE_MUTEX(inode);
+       mutex_lock(&inode->i_mutex);
+       ofd = inode->i_private;
+
+       if (ofd && ofd->ofd_epoch >= ioepoch) {
+               if (ofd->ofd_epoch > ioepoch)
+                       CERROR("client sent old epoch %d for obj ino %ld\n",
+                              ioepoch, inode->i_ino);
+               mutex_unlock(&inode->i_mutex);
+               RETURN(0);
+       }
+
+       if (ofd && ofd->ofd_epoch < ioepoch) {
+               ofd->ofd_epoch = ioepoch;
+       } else if (!ofd) {
+               OBD_ALLOC(ofd, sizeof(*ofd));
+               if (!ofd)
+                       GOTO(out, rc = -ENOMEM);
+               igrab(inode);
+               inode->i_private = ofd;
+               ofd->ofd_epoch = ioepoch;
+       }
+       /* the decision to write a record is now made, unlock */
+       mutex_unlock(&inode->i_mutex);
 
         OBD_ALLOC(lsc, sizeof(*lsc));
         if (lsc == NULL)
@@ -94,7 +94,7 @@ int filter_log_sz_change(struct llog_handle *cathandle,
         lsc->lsc_fid = *mds_fid;
         lsc->lsc_ioepoch = ioepoch;
 
-        rc = llog_cat_add_rec(cathandle, &lsc->lsc_hdr, logcookie, NULL);
+       rc = llog_cat_add_rec(NULL, cathandle, &lsc->lsc_hdr, logcookie, NULL);
         OBD_FREE(lsc, sizeof(*lsc));
 
         if (rc > 0) {
@@ -137,7 +137,7 @@ void filter_cancel_cookies_cb(struct obd_device *obd, __u64 transno,
 
         OBD_FAIL_TIMEOUT(OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT, 30);
 
-        rc = llog_cancel(ctxt, NULL, 1, cookie, 0);
+       rc = llog_cancel(NULL, ctxt, NULL, 1, cookie, 0);
         if (rc)
                 CERROR("error cancelling log cookies: rc = %d\n", rc);
         llog_ctxt_put(ctxt);
@@ -215,21 +215,18 @@ static int filter_recov_log_setattr_cb(struct llog_ctxt *ctxt,
         if (oinfo.oi_oa == NULL)
                 RETURN(-ENOMEM);
 
-        if (rec->lrh_type == MDS_SETATTR_REC) {
-                struct llog_setattr_rec *lsr = (struct llog_setattr_rec *)rec;
-
-                oinfo.oi_oa->o_id = lsr->lsr_oid;
-                oinfo.oi_oa->o_seq = lsr->lsr_oseq;
-                oinfo.oi_oa->o_uid = lsr->lsr_uid;
-                oinfo.oi_oa->o_gid = lsr->lsr_gid;
-        } else {
+       if (rec->lrh_type == MDS_SETATTR64_REC) {
                 struct llog_setattr64_rec *lsr = (struct llog_setattr64_rec *)rec;
 
                 oinfo.oi_oa->o_id = lsr->lsr_oid;
                 oinfo.oi_oa->o_seq = lsr->lsr_oseq;
                 oinfo.oi_oa->o_uid = lsr->lsr_uid;
                 oinfo.oi_oa->o_gid = lsr->lsr_gid;
-        }
+       } else {
+               CERROR("%s: wrong llog type %#x\n", obd->obd_name,
+                      rec->lrh_type);
+               RETURN(-EINVAL);
+       }
 
         oinfo.oi_oa->o_valid |= (OBD_MD_FLID | OBD_MD_FLUID | OBD_MD_FLGID |
                                  OBD_MD_FLCOOKIE);
@@ -242,7 +239,7 @@ static int filter_recov_log_setattr_cb(struct llog_ctxt *ctxt,
 
         if (rc == -ENOENT) {
                 CDEBUG(D_RPCTRACE, "object already removed, send cookie\n");
-                llog_cancel(ctxt, NULL, 1, cookie, 0);
+               llog_cancel(NULL, ctxt, NULL, 1, cookie, 0);
                 RETURN(0);
         }
 
@@ -252,8 +249,9 @@ static int filter_recov_log_setattr_cb(struct llog_ctxt *ctxt,
         RETURN(rc);
 }
 
-int filter_recov_log_mds_ost_cb(struct llog_handle *llh,
-                                struct llog_rec_hdr *rec, void *data)
+int filter_recov_log_mds_ost_cb(const struct lu_env *env,
+                               struct llog_handle *llh,
+                               struct llog_rec_hdr *rec, void *data)
 {
         struct llog_ctxt *ctxt = llh->lgh_ctxt;
         struct llog_cookie cookie;
@@ -284,18 +282,18 @@ int filter_recov_log_mds_ost_cb(struct llog_handle *llh,
         case MDS_UNLINK_REC:
                 rc = filter_recov_log_unlink_cb(ctxt, rec, &cookie);
                 break;
-        case MDS_SETATTR_REC:
         case MDS_SETATTR64_REC:
                 rc = filter_recov_log_setattr_cb(ctxt, rec, &cookie);
                 break;
         case LLOG_GEN_REC: {
                 struct llog_gen_rec *lgr = (struct llog_gen_rec *)rec;
+
                 if (llog_gen_lt(lgr->lgr_gen, ctxt->loc_gen))
                         rc = 0;
                 else
                         rc = LLOG_PROC_BREAK;
                 CDEBUG(D_HA, "fetch generation log, send cookie\n");
-                llog_cancel(ctxt, NULL, 1, &cookie, 0);
+               llog_cancel(NULL, ctxt, NULL, 1, &cookie, 0);
                 RETURN(rc);
                 }
                 break;