+/*
+ * @log: the log we are replaying.
+ * @entry: entry to be replayed.
+ *
+ * @return: 0 if we should replay the entry, > 0 if we should skip it.
+ *
+ * Should we skip the entry in our log or replay onto the replay device.
+ */
+int log_should_skip(struct log *log, struct log_write_entry *entry)
+{
+ u64 sector = le64_to_cpu(entry->sector);
+ u64 nr_sectors = le64_to_cpu(entry->nr_sectors);
+
+ if (!nr_sectors)
+ return 0;
+ if (sector + nr_sectors <= log->start_sector ||
+ sector > log->end_sector)
+ return 1;
+ return 0;
+}
+
+/*
+ * @entry: entry to be replayed.
+ *
+ * @return: 1 if the entry is sane, 0 if it is invalid.
+ *
+ * Check if this is a sane log entry.
+ */
+int log_entry_valid(struct log_write_entry *entry)
+{
+ u64 flags = le64_to_cpu(entry->flags);
+
+ /* Suspect all zeroes entry */
+ if (!flags && !entry->nr_sectors)
+ return 0;
+ /* Suspect non zero padded entry */
+ if (flags != LOG_MARK_FLAG && entry->data[0] != 0)
+ return 0;
+ return 1;
+}
+