10 #ifndef FS_LOGFS_LOGFS_H
11 #define FS_LOGFS_LOGFS_H
13 #undef __CHECK_ENDIAN__
14 #define __CHECK_ENDIAN__
19 #include <linux/kernel.h>
25 #define LOGFS_DEBUG_SUPER (0x0001)
26 #define LOGFS_DEBUG_SEGMENT (0x0002)
27 #define LOGFS_DEBUG_JOURNAL (0x0004)
28 #define LOGFS_DEBUG_DIR (0x0008)
29 #define LOGFS_DEBUG_FILE (0x0010)
30 #define LOGFS_DEBUG_INODE (0x0020)
31 #define LOGFS_DEBUG_READWRITE (0x0040)
32 #define LOGFS_DEBUG_GC (0x0080)
33 #define LOGFS_DEBUG_GC_NOISY (0x0100)
34 #define LOGFS_DEBUG_ALIASES (0x0200)
35 #define LOGFS_DEBUG_BLOCKMOVE (0x0400)
36 #define LOGFS_DEBUG_ALL (0xffffffff)
38 #define LOGFS_DEBUG (0x01)
44 #define LOGFS_DEBUG (0)
47 #define log_cond(cond, fmt, arg...) do { \
49 printk(KERN_DEBUG fmt, ##arg); \
52 #define log_super(fmt, arg...) \
53 log_cond(LOGFS_DEBUG & LOGFS_DEBUG_SUPER, fmt, ##arg)
54 #define log_segment(fmt, arg...) \
55 log_cond(LOGFS_DEBUG & LOGFS_DEBUG_SEGMENT, fmt, ##arg)
56 #define log_journal(fmt, arg...) \
57 log_cond(LOGFS_DEBUG & LOGFS_DEBUG_JOURNAL, fmt, ##arg)
58 #define log_dir(fmt, arg...) \
59 log_cond(LOGFS_DEBUG & LOGFS_DEBUG_DIR, fmt, ##arg)
60 #define log_file(fmt, arg...) \
61 log_cond(LOGFS_DEBUG & LOGFS_DEBUG_FILE, fmt, ##arg)
62 #define log_inode(fmt, arg...) \
63 log_cond(LOGFS_DEBUG & LOGFS_DEBUG_INODE, fmt, ##arg)
64 #define log_readwrite(fmt, arg...) \
65 log_cond(LOGFS_DEBUG & LOGFS_DEBUG_READWRITE, fmt, ##arg)
66 #define log_gc(fmt, arg...) \
67 log_cond(LOGFS_DEBUG & LOGFS_DEBUG_GC, fmt, ##arg)
68 #define log_gc_noisy(fmt, arg...) \
69 log_cond(LOGFS_DEBUG & LOGFS_DEBUG_GC_NOISY, fmt, ##arg)
70 #define log_aliases(fmt, arg...) \
71 log_cond(LOGFS_DEBUG & LOGFS_DEBUG_ALIASES, fmt, ##arg)
72 #define log_blockmove(fmt, arg...) \
73 log_cond(LOGFS_DEBUG & LOGFS_DEBUG_BLOCKMOVE, fmt, ##arg)
75 #define PG_pre_locked PG_owner_priv_1
76 #define PagePreLocked(page) test_bit(PG_pre_locked, &(page)->flags)
77 #define SetPagePreLocked(page) set_bit(PG_pre_locked, &(page)->flags)
78 #define ClearPagePreLocked(page) clear_bit(PG_pre_locked, &(page)->flags)
81 #define LOGFS_LINK_MAX (1<<30)
84 #define LOGFS_SB_FLAG_RO 0x0001
85 #define LOGFS_SB_FLAG_DIRTY 0x0002
86 #define LOGFS_SB_FLAG_OBJ_ALIAS 0x0004
87 #define LOGFS_SB_FLAG_SHUTDOWN 0x0008
92 #define WF_DELETE 0x04
97 #define LEVEL(level) ((__force level_t)(level))
98 #define GC_LEVEL(gc_level) ((__force gc_level_t)(gc_level))
100 #define SUBLEVEL(level) ( (void)((level) == LEVEL(1)), \
101 (__force level_t)((__force u8)(level) - 1) )
291 #define BLOCK_INDIRECT 1
292 #define BLOCK_INODE 2
321 #define MAX_JOURNAL_ENTRIES 256
463 #define journal_for_each(__i) for (__i = 0; __i < LOGFS_JOURNAL_SEGS; __i++)
464 #define for_each_area(__i) for (__i = 0; __i < LOGFS_NO_AREAS; __i++)
465 #define for_each_area_down(__i) for (__i = LOGFS_NO_AREAS - 1; __i >= 0; __i--)
477 const char *devname);
577 __be64 *array,
int page_is_empty);
608 static inline int logfs_buf_write(
struct logfs_area *area,
u64 ofs,
609 void *
buf,
size_t len)
614 static inline int logfs_buf_recover(
struct logfs_area *area,
u64 ofs,
615 void *
buf,
size_t len)
643 #define LOGFS_BUG(sb) do { \
644 struct super_block *__sb = sb; \
645 logfs_crash_dump(__sb); \
646 logfs_super(__sb)->s_flags |= LOGFS_SB_FLAG_RO; \
650 #define LOGFS_BUG_ON(condition, sb) \
651 do { if (unlikely(condition)) LOGFS_BUG((sb)); } while (0)
653 static inline __be32 logfs_crc32(
void *
data,
size_t len,
size_t skip)
660 return (inode->
i_mode >> 12) & 15;
721 return ~0ull << logfs_block_shift(sb, level);