Whamcloud - gitweb
LU-2059 llog: MGC to use OSD API for backup logs
[fs/lustre-release.git] / lustre / include / lustre_log.h
index e9d3f2c..708d7c8 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2012, 2013, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -97,38 +97,30 @@ static inline void logid_to_fid(struct llog_logid *id, struct lu_fid *fid)
        /* For compatibility purposes we identify pre-OSD (~< 2.3.51 MDS)
         * logid's by non-zero ogen (inode generation) and convert them
         * into IGIF */
-       if (id->lgl_ogen == 0)
-               ostid_to_fid(fid, &id->lgl_oi, 0);
-       else
-               lu_igif_build(fid, ostid_id(&id->lgl_oi), id->lgl_ogen);
+       if (id->lgl_ogen == 0) {
+               fid->f_seq = id->lgl_oi.oi.oi_seq;
+               fid->f_oid = id->lgl_oi.oi.oi_id;
+               fid->f_ver = 0;
+       } else {
+               lu_igif_build(fid, id->lgl_oi.oi.oi_id, id->lgl_ogen);
+       }
 }
 
 static inline void fid_to_logid(struct lu_fid *fid, struct llog_logid *id)
 {
-       if (fid_is_igif(fid)) {
-               /* See above lu_igif_build */
-               ostid_set_id(&id->lgl_oi, fid->f_seq);
-               id->lgl_ogen = fid->f_oid;
-       } else {
-               fid_to_ostid(fid, &id->lgl_oi);
-               id->lgl_ogen = 0;
-       }
+       id->lgl_oi.oi.oi_seq = fid->f_seq;
+       id->lgl_oi.oi.oi_id = fid->f_oid;
+       id->lgl_ogen = 0;
 }
 
 static inline void logid_set_id(struct llog_logid *log_id, __u64 id)
 {
-       if (log_id->lgl_ogen == 0)
-               ostid_set_id(&log_id->lgl_oi, id);
-       else
-               log_id->lgl_oi.oi.oi_id = id;
+       log_id->lgl_oi.oi.oi_id = id;
 }
 
 static inline __u64 logid_id(struct llog_logid *log_id)
 {
-       if (log_id->lgl_ogen == 0)
-               return ostid_id(&log_id->lgl_oi);
-       else
-               return log_id->lgl_oi.oi.oi_id;
+       return log_id->lgl_oi.oi.oi_id;
 }
 
 struct llog_handle;
@@ -152,7 +144,11 @@ int llog_open(const struct lu_env *env, struct llog_ctxt *ctxt,
              struct llog_handle **lgh, struct llog_logid *logid,
              char *name, enum llog_open_param open_param);
 int llog_close(const struct lu_env *env, struct llog_handle *cathandle);
-int llog_get_size(struct llog_handle *loghandle);
+int llog_is_empty(const struct lu_env *env, struct llog_ctxt *ctxt,
+                 char *name);
+int llog_backup(const struct lu_env *env, struct obd_device *obd,
+               struct llog_ctxt *ctxt, struct llog_ctxt *bak_ctxt,
+               char *name, char *backup);
 
 /* llog_process flags */
 #define LLOG_FLAG_NODEAMON 0x0001
@@ -398,6 +394,13 @@ static inline int llog_data_len(int len)
         return cfs_size_round(len);
 }
 
+static inline int llog_get_size(struct llog_handle *loghandle)
+{
+       if (loghandle && loghandle->lgh_hdr)
+               return loghandle->lgh_hdr->llh_count;
+       return 0;
+}
+
 static inline struct llog_ctxt *llog_ctxt_get(struct llog_ctxt *ctxt)
 {
         cfs_atomic_inc(&ctxt->loc_refcount);