[sheepdog] [PATCH v4 1/2] sheep: move journal_descriptor from journal.c to internal_proto.h
Hitoshi Mitake
mitake.hitoshi at lab.ntt.co.jp
Fri Jul 5 05:06:47 CEST 2013
The definition of struct journal_descriptor has to be shared by
DynamoRIO based fault injector because the test interprets internal
data structs and injects faults at critical timings.
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
include/internal_proto.h | 40 ++++++++++++++++++++++++++++++++++++++++
sheep/journal.c | 31 -------------------------------
2 files changed, 40 insertions(+), 31 deletions(-)
diff --git a/include/internal_proto.h b/include/internal_proto.h
index 24d5519..43e60e9 100644
--- a/include/internal_proto.h
+++ b/include/internal_proto.h
@@ -20,6 +20,8 @@
#include <stdint.h>
#include <netinet/in.h>
+#include "sheepdog_proto.h"
+
#define SD_SHEEP_PROTO_VER 0x07
#define SD_DEFAULT_COPIES 3
@@ -209,4 +211,42 @@ static inline __attribute__((used)) void __sd_epoch_format_build_bug_ons(void)
BUILD_BUG_ON(sizeof(struct sd_node) != SD_NODE_SIZE);
}
+/*
+ * stuff related to the journaling subsystem
+ *
+ * these are moved from journal.c to here for sharing between the
+ * subsystem and DR based fault injector (look at tests/dynamorio/journaling/)
+ */
+
+struct journal_descriptor {
+ uint32_t magic;
+ uint16_t flag;
+ uint16_t reserved;
+ union {
+ uint32_t epoch;
+ uint64_t oid;
+ };
+ uint64_t offset;
+ uint64_t size;
+ uint8_t create;
+ uint8_t pad[475];
+} __packed;
+
+/* JOURNAL_DESC + JOURNAL_MARKER must be 512 algined for DIO */
+#define JOURNAL_DESC_MAGIC 0xfee1900d
+#define JOURNAL_DESC_SIZE 508
+#define JOURNAL_MARKER_SIZE 4 /* Use marker to detect partial write */
+#define JOURNAL_META_SIZE (JOURNAL_DESC_SIZE + JOURNAL_MARKER_SIZE)
+
+#define JOURNAL_END_MARKER 0xdeadbeef
+
+#define JF_STORE 0
+#define JF_REMOVE_OBJ 2
+
+static inline __attribute__((used)) void journaling_build_bug_ons(void)
+{
+ /* never called, only for checking BUILD_BUG_ON()s */
+ BUILD_BUG_ON(sizeof(struct journal_descriptor) != JOURNAL_DESC_SIZE);
+}
+
#endif /* __INTERNAL_PROTO_H__ */
diff --git a/sheep/journal.c b/sheep/journal.c
index 8380849..d6748f9 100644
--- a/sheep/journal.c
+++ b/sheep/journal.c
@@ -28,31 +28,6 @@ struct journal_file {
uatomic_bool in_commit;
};
-struct journal_descriptor {
- uint32_t magic;
- uint16_t flag;
- uint16_t reserved;
- union {
- uint32_t epoch;
- uint64_t oid;
- };
- uint64_t offset;
- uint64_t size;
- uint8_t create;
- uint8_t pad[475];
-} __packed;
-
-/* JOURNAL_DESC + JOURNAL_MARKER must be 512 algined for DIO */
-#define JOURNAL_DESC_MAGIC 0xfee1900d
-#define JOURNAL_DESC_SIZE 508
-#define JOURNAL_MARKER_SIZE 4 /* Use marker to detect partial write */
-#define JOURNAL_META_SIZE (JOURNAL_DESC_SIZE + JOURNAL_MARKER_SIZE)
-
-#define JOURNAL_END_MARKER 0xdeadbeef
-
-#define JF_STORE 0
-#define JF_REMOVE_OBJ 2
-
static const char *jfile_name[2] = { "journal_file0", "journal_file1", };
static int jfile_fds[2];
static size_t jfile_size;
@@ -430,9 +405,3 @@ int journal_remove_object(uint64_t oid)
jd.oid = oid;
return journal_file_write(&jd, NULL);
}
-
-static __attribute__((used)) void journal_c_build_bug_ons(void)
-{
- /* never called, only for checking BUILD_BUG_ON()s */
- BUILD_BUG_ON(sizeof(struct journal_descriptor) != JOURNAL_DESC_SIZE);
-}
--
1.7.10.4
More information about the sheepdog
mailing list