Whamcloud - gitweb
LU-5003 llog: do not fix remote llogs
[fs/lustre-release.git] / lustre / obdclass / llog.c
index 7146001..932b384 100644 (file)
@@ -47,9 +47,6 @@
 
 #define DEBUG_SUBSYSTEM S_LOG
 
-#ifndef __KERNEL__
-#include <liblustre.h>
-#endif
 
 #include <obd_class.h>
 #include <lustre_log.h>
@@ -69,7 +66,7 @@ struct llog_handle *llog_alloc_handle(void)
 
        init_rwsem(&loghandle->lgh_lock);
        spin_lock_init(&loghandle->lgh_hdr_lock);
-       CFS_INIT_LIST_HEAD(&loghandle->u.phd.phd_entry);
+       INIT_LIST_HEAD(&loghandle->u.phd.phd_entry);
        atomic_set(&loghandle->lgh_refcount, 1);
 
        return loghandle;
@@ -87,9 +84,9 @@ void llog_free_handle(struct llog_handle *loghandle)
                goto out;
 
        if (loghandle->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN)
-               LASSERT(cfs_list_empty(&loghandle->u.phd.phd_entry));
+               LASSERT(list_empty(&loghandle->u.phd.phd_entry));
        else if (loghandle->lgh_hdr->llh_flags & LLOG_F_IS_CAT)
-               LASSERT(cfs_list_empty(&loghandle->u.chd.chd_head));
+               LASSERT(list_empty(&loghandle->u.chd.chd_head));
        LASSERT(sizeof(*(loghandle->lgh_hdr)) == LLOG_CHUNK_SIZE);
        OBD_FREE(loghandle->lgh_hdr, LLOG_CHUNK_SIZE);
 out:
@@ -252,8 +249,8 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle,
                }
        }
        if (flags & LLOG_F_IS_CAT) {
-               LASSERT(cfs_list_empty(&handle->u.chd.chd_head));
-               CFS_INIT_LIST_HEAD(&handle->u.chd.chd_head);
+               LASSERT(list_empty(&handle->u.chd.chd_head));
+               INIT_LIST_HEAD(&handle->u.chd.chd_head);
                llh->llh_size = sizeof(struct llog_logid_rec);
        } else if (!(flags & LLOG_F_IS_PLAIN)) {
                CERROR("%s: unknown flags: %#x (expected %#x or %#x)\n",
@@ -399,12 +396,12 @@ out:
         if (cd != NULL)
                 cd->lpcd_last_idx = last_called_index;
 
-       if (unlikely(rc == -EIO)) {
-               /* something bad happened to the processing, probably I/O
-                * error or the log got corrupted..
+       if (unlikely(rc == -EIO && loghandle->lgh_obj != NULL)) {
+               /* something bad happened to the processing of a local
+                * llog file, probably I/O error or the log got corrupted..
                 * to be able to finally release the log we discard any
                 * remaining bits in the header */
-               CERROR("llog found corrupted\n");
+               CERROR("Local llog found corrupted\n");
                while (index <= last_index) {
                        if (ext2_test_bit(index, llh->llh_bitmap) != 0)
                                llog_cancel_rec(lpi->lpi_env, loghandle, index);
@@ -418,7 +415,6 @@ out:
         return 0;
 }
 
-#ifdef __KERNEL__
 static int llog_process_thread_daemonize(void *arg)
 {
        struct llog_process_info        *lpi = arg;
@@ -440,7 +436,6 @@ out:
        complete(&lpi->lpi_completion);
        return rc;
 }
-#endif
 
 int llog_process_or_fork(const struct lu_env *env,
                         struct llog_handle *loghandle,
@@ -461,7 +456,6 @@ int llog_process_or_fork(const struct lu_env *env,
         lpi->lpi_cbdata    = data;
         lpi->lpi_catdata   = catdata;
 
-#ifdef __KERNEL__
        if (fork) {
                struct task_struct *task;
 
@@ -482,15 +476,9 @@ int llog_process_or_fork(const struct lu_env *env,
                lpi->lpi_env = env;
                llog_process_thread(lpi);
        }
-#else
-       lpi->lpi_env = env;
-       llog_process_thread(lpi);
-#endif
        rc = lpi->lpi_rc;
 
-#ifdef __KERNEL__
 out_lpi:
-#endif
        OBD_FREE_PTR(lpi);
        RETURN(rc);
 }
@@ -942,6 +930,17 @@ out:
 }
 EXPORT_SYMBOL(llog_close);
 
+/**
+ * Helper function to get the llog size in records. It is used by MGS
+ * mostly to check that config llog exists and contains data.
+ *
+ * \param[in] env      execution environment
+ * \param[in] ctxt     llog context
+ * \param[in] name     llog name
+ *
+ * \retval             true if there are records in llog besides a header
+ * \retval             false on error or llog without records
+ */
 int llog_is_empty(const struct lu_env *env, struct llog_ctxt *ctxt,
                  char *name)
 {
@@ -963,7 +962,8 @@ int llog_is_empty(const struct lu_env *env, struct llog_ctxt *ctxt,
 out_close:
        llog_close(env, llh);
 out:
-       /* header is record 1 */
+       /* The header is record 1, the llog is still considered as empty
+        * if there is only header */
        return (rc <= 1);
 }
 EXPORT_SYMBOL(llog_is_empty);