#define DEBUG_SUBSYSTEM S_LOG
-#ifndef __KERNEL__
-#include <liblustre.h>
-#endif
#include <obd_class.h>
#include <lustre_log.h>
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;
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:
}
}
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",
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);
return 0;
}
-#ifdef __KERNEL__
static int llog_process_thread_daemonize(void *arg)
{
struct llog_process_info *lpi = arg;
complete(&lpi->lpi_completion);
return rc;
}
-#endif
int llog_process_or_fork(const struct lu_env *env,
struct llog_handle *loghandle,
lpi->lpi_cbdata = data;
lpi->lpi_catdata = catdata;
-#ifdef __KERNEL__
if (fork) {
struct task_struct *task;
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);
}
}
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)
{
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);