21#include "jfs_compat.h"
23#define jfs_debug jbd_debug
37#define journal_oom_retry 1
39#define jbdlock_t FAST_MUTEX
41static inline void jbd_lock_init(jbdlock_t *
lock)
46static inline void jbd_lock(jbdlock_t *
lock)
51static inline void jbd_unlock(jbdlock_t *
lock)
56static inline int assert_jbd_locked(jbdlock_t *
lock)
76#undef JBD_PARANOID_IOFAIL
81#define JBD_DEFAULT_MAX_COMMIT_AGE 5
83#ifdef CONFIG_JBD_DEBUG
89#define JBD_EXPENSIVE_CHECKING
90extern u8 journal_enable_debug;
92#define jbd_debug(n, f, a...) \
94 if ((n) <= journal_enable_debug) { \
95 printk (KERN_DEBUG "(%s, %d): %s: ", \
96 __FILE__, __LINE__, __FUNCTION__); \
110static inline void jbd_free(
void *
ptr,
size_t size)
118#define JFS_MIN_JOURNAL_BLOCKS 1024
152typedef struct journal_s journal_t;
159#define JFS_MAGIC_NUMBER 0xc03b3998U
169#define JFS_DESCRIPTOR_BLOCK 1
170#define JFS_COMMIT_BLOCK 2
171#define JFS_SUPERBLOCK_V1 3
172#define JFS_SUPERBLOCK_V2 4
173#define JFS_REVOKE_BLOCK 5
207#define JFS_FLAG_ESCAPE 1
208#define JFS_FLAG_SAME_UUID 2
209#define JFS_FLAG_DELETED 4
210#define JFS_FLAG_LAST_TAG 8
261#define JFS_HAS_COMPAT_FEATURE(j,mask) \
262 ((j)->j_format_version >= 2 && \
263 ((j)->j_superblock->s_feature_compat & cpu_to_be32((mask))))
264#define JFS_HAS_RO_COMPAT_FEATURE(j,mask) \
265 ((j)->j_format_version >= 2 && \
266 ((j)->j_superblock->s_feature_ro_compat & cpu_to_be32((mask))))
267#define JFS_HAS_INCOMPAT_FEATURE(j,mask) \
268 ((j)->j_format_version >= 2 && \
269 ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask))))
271#define JFS_FEATURE_INCOMPAT_REVOKE 0x00000001
274#define JFS_KNOWN_COMPAT_FEATURES 0
275#define JFS_KNOWN_ROCOMPAT_FEATURES 0
276#define JFS_KNOWN_INCOMPAT_FEATURES JFS_FEATURE_INCOMPAT_REVOKE
283#define J_ASSERT ASSERT
285#if defined(CONFIG_BUFFER_DEBUG)
286void buffer_assertion_failure(
struct buffer_head *bh);
287#define J_ASSERT_BH(bh, expr) \
290 buffer_assertion_failure(bh); \
293#define J_ASSERT_JH(jh, expr) J_ASSERT_BH(jh2bh(jh), expr)
295#define J_ASSERT_BH(bh, expr) J_ASSERT(expr)
296#define J_ASSERT_JH(jh, expr) J_ASSERT(expr)
299#if defined(JBD_PARANOID_IOFAIL)
300#define J_EXPECT(expr, why...) J_ASSERT(expr)
301#define J_EXPECT_BH(bh, expr, why...) J_ASSERT_BH(bh, expr)
302#define J_EXPECT_JH(jh, expr, why...) J_ASSERT_JH(jh, expr)
305#define __journal_expect(expr, why...) \
310 "EXT3-fs unexpected failure: %s;\n",# expr); \
311 printk(KERN_ERR why "\n"); \
315#define J_EXPECT(expr, why...) __journal_expect(expr, ## why)
316#define J_EXPECT_BH(bh, expr, why...) __journal_expect(expr, ## why)
317#define J_EXPECT_JH(jh, expr, why...) __journal_expect(expr, ## why)
319#define __journal_expect
360static inline void jbd_lock_bh_state(
struct buffer_head *bh)
365static inline int jbd_trylock_bh_state(
struct buffer_head *bh)
370static inline int jbd_is_locked_bh_state(
struct buffer_head *bh)
375static inline void jbd_unlock_bh_state(
struct buffer_head *bh)
380static inline void jbd_lock_bh_journal_head(
struct buffer_head *bh)
385static inline void jbd_unlock_bh_journal_head(
struct buffer_head *bh)
415 int h_buffer_credits;
429unsigned int h_aborted:
432#ifdef CONFIG_DEBUG_LOCK_ALLOC
433 struct lockdep_map h_lockdep_map;
477 journal_t *t_journal;
502 unsigned long t_log_start;
572 jbdlock_t t_handle_lock;
584 int t_outstanding_credits;
596 unsigned long t_expires;
672 unsigned long j_flags;
685 int j_format_version;
690 jbdlock_t j_state_lock;
698 struct mutex j_barrier;
740 struct mutex j_checkpoint_mutex;
746 unsigned long j_head;
752 unsigned long j_tail;
758 unsigned long j_free;
764 unsigned long j_first;
765 unsigned long j_last;
773 unsigned long j_blk_offset;
782 unsigned int j_maxlen;
787 jbdlock_t j_list_lock;
792 struct inode *j_inode;
797 tid_t j_tail_sequence;
802 tid_t j_transaction_sequence;
808 tid_t j_commit_sequence;
814 tid_t j_commit_request;
831 int j_max_transaction_buffers;
836 unsigned long j_commit_interval;
845 jbdlock_t j_revoke_lock;
855 pid_t j_last_sync_writer;
867#define JFS_UNMOUNT 0x001
868#define JFS_ABORT 0x002
869#define JFS_ACK_ERR 0x004
870#define JFS_FLUSHED 0x008
871#define JFS_LOADED 0x010
872#define JFS_BARRIER 0x020
882extern void __journal_refile_buffer(
struct journal_head *);
883extern void journal_refile_buffer(journal_t *,
struct journal_head *);
885extern void __journal_free_buffer(
struct journal_head *bh);
887extern void __journal_clean_data_list(
transaction_t *transaction);
894extern void journal_commit_transaction(journal_t *);
897int __journal_clean_checkpoint_list(journal_t *journal);
906 unsigned long blocknr);
909extern void __wait_on_journal (journal_t *);
922static inline handle_t *journal_current_handle(
void)
927#pragma message("WARNINGS: journal_current_handle NOT implemented")
937extern handle_t *journal_start(journal_t *,
int nblocks);
938extern int journal_restart (
handle_t *,
int nblocks);
939extern int journal_extend (
handle_t *,
int nblocks);
947extern void journal_sync_buffer (
struct buffer_head *);
948extern void journal_invalidatepage(journal_t *,
949 struct page *,
unsigned long);
950extern int journal_try_to_free_buffers(journal_t *,
struct page *,
gfp_t);
952extern int journal_flush (journal_t *);
953extern void journal_lock_updates (journal_t *);
954extern void journal_unlock_updates (journal_t *);
956extern journal_t * journal_init_dev(
struct block_device *bdev,
962 (journal_t *,
unsigned long,
unsigned long,
unsigned long);
964 (journal_t *,
unsigned long,
unsigned long,
unsigned long);
966 (journal_t *,
unsigned long,
unsigned long,
unsigned long);
967extern int journal_create (journal_t *);
978extern int journal_bmap(journal_t *,
unsigned long,
unsigned long *);
979extern int journal_force_commit(journal_t *);
1008#define JOURNAL_REVOKE_DEFAULT_HASH 256
1014extern int journal_revoke (
handle_t *,
1017extern void journal_write_revoke_records(journal_t *,
transaction_t *);
1023extern void journal_switch_revoke_table(journal_t *journal);
1032int __log_space_left(journal_t *);
1035int journal_start_commit(journal_t *journal,
tid_t *
tid);
1036int journal_force_commit_nested(journal_t *journal);
1037int log_wait_commit(journal_t *journal,
tid_t tid);
1038int log_do_checkpoint(journal_t *journal);
1040void __log_wait_for_space(journal_t *journal);
1041extern void __journal_drop_transaction(journal_t *,
transaction_t *);
1042extern int cleanup_journal_tail(journal_t *);
1046#define jbd_ENOSYS() \
1048 printk (KERN_ERR "JBD unimplemented function %s\n", __FUNCTION__); \
1049 current->state = TASK_UNINTERRUPTIBLE; \
1063static inline int is_journal_aborted(journal_t *journal)
1065 return journal->j_flags & JFS_ABORT;
1072 return is_journal_aborted(
handle->h_transaction->t_journal);
1087 int difference = (
x -
y);
1088 return (difference > 0);
1093 int difference = (
x -
y);
1094 return (difference >= 0);
1105 int nblocks = journal->j_max_transaction_buffers;
1106 if (journal->j_committing_transaction)
1107 nblocks += journal->j_committing_transaction->
1108 t_outstanding_credits;
1118#define BJ_SyncData 1
1119#define BJ_Metadata 2
1124#define BJ_Reserved 7
1132#define buffer_trace_init(bh) do {} while (0)
1133#define print_buffer_fields(bh) do {} while (0)
1134#define print_buffer_trace(bh) do {} while (0)
1135#define BUFFER_TRACE(bh, info) do {} while (0)
1136#define BUFFER_TRACE2(bh, bh2, info) do {} while (0)
1137#define JBUFFER_TRACE(jh, info) do {} while (0)
static void bit_spin_lock(int bitnum, unsigned long *addr)
static int bit_spin_trylock(int bitnum, unsigned long *addr)
static void bit_spin_unlock(int bitnum, unsigned long *addr)
static int bit_spin_is_locked(int bitnum, unsigned long *addr)
int journal_skip_recovery(journal_t *journal)
int journal_recover(journal_t *journal)
GLint GLint GLint GLint GLint x
GLint GLint GLint GLint GLint GLint y
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
BOOLEAN FASTCALL ExTryToAcquireFastMutex(IN PFAST_MUTEX FastMutex)
struct journal_revoke_header_s journal_revoke_header_t
struct journal_block_tag_s journal_block_tag_t
static int tid_gt(tid_t x, tid_t y)
struct journal_superblock_s journal_superblock_t
struct journal_header_s journal_header_t
int jbd_blocks_per_page(struct inode *inode)
static int tid_geq(tid_t x, tid_t y)
static int jbd_space_needed(journal_t *journal)
int journal_blocks_per_page(struct inode *inode)
struct transaction_s transaction_t
#define kmalloc(size, gfp)
void kmem_cache_free(kmem_cache_t *kc, void *p)
#define TAS_BUFFER_FNS(bit, name)
void * kmem_cache_alloc(kmem_cache_t *kc, int flags)
#define BUFFER_FNS(bit, name)
int __log_start_commit(journal_t *journal, tid_t target)
struct journal_head * journal_grab_journal_head(struct buffer_head *bh)
struct journal_head * journal_get_descriptor_buffer(journal_t *journal)
struct journal_head * journal_add_journal_head(struct buffer_head *bh)
int journal_load(journal_t *journal)
int journal_set_features(journal_t *journal, unsigned long compat, unsigned long ro, unsigned long incompat)
journal_t * journal_init_inode(struct inode *inode)
int journal_forget(handle_t *handle, struct buffer_head *bh)
int journal_bmap(journal_t *journal, unsigned long blocknr, unsigned long *retp)
int journal_clear_err(journal_t *journal)
void journal_file_buffer(struct journal_head *jh, transaction_t *transaction, int jlist)
void journal_release_buffer(handle_t *handle, struct buffer_head *bh)
void journal_unfile_buffer(journal_t *journal, struct journal_head *jh)
int journal_update_format(journal_t *journal)
int journal_next_log_block(journal_t *journal, unsigned long *retp)
struct kmem_cache * jbd_handle_cache
int log_start_commit(journal_t *journal, tid_t tid)
void journal_update_superblock(journal_t *journal, int wait)
void journal_put_journal_head(struct journal_head *jh)
int journal_check_available_features(journal_t *journal, unsigned long compat, unsigned long ro, unsigned long incompat)
void journal_wipe_recovery(journal_t *journal)
void __journal_file_buffer(struct journal_head *jh, transaction_t *transaction, int jlist)
void journal_ack_err(journal_t *journal)
int journal_wipe(journal_t *journal, int write)
void journal_remove_journal_head(struct buffer_head *bh)
int journal_errno(journal_t *journal)
void journal_destroy(journal_t *journal)
void __journal_unfile_buffer(struct journal_head *jh)
int journal_check_used_features(journal_t *journal, unsigned long compat, unsigned long ro, unsigned long incompat)
void journal_abort(journal_t *journal, int err)
void journal_destroy_revoke_caches(void)
void journal_destroy_revoke(journal_t *journal)
void journal_clear_revoke(journal_t *journal)
int __init journal_init_revoke_caches(void)
int journal_init_revoke(journal_t *journal, int hash_size)
int journal_set_revoke(journal_t *journal, unsigned long blocknr, tid_t sequence)
int journal_test_revoke(journal_t *journal, unsigned long blocknr, tid_t sequence)
struct buffer_head * b_bh
__be32 s_feature_incompat
__be32 s_feature_ro_compat
journal_header_t s_header
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)