21 #include "jfs_compat.h"
23 #define jfs_debug jbd_debug
26 #include <linux/types.h>
29 #include <linux/stddef.h>
34 #include <linux/slab.h>
36 #define journal_oom_retry 1
45 #undef JBD_PARANOID_IOFAIL
50 #define JBD_DEFAULT_MAX_COMMIT_AGE 5
52 #ifdef CONFIG_JBD_DEBUG
58 #define JBD_EXPENSIVE_CHECKING
59 extern u8 journal_enable_debug;
61 #define jbd_debug(n, f, a...) \
63 if ((n) <= journal_enable_debug) { \
64 printk (KERN_DEBUG "(%s, %d): %s: ", \
65 __FILE__, __LINE__, __func__); \
70 #define jbd_debug(f, a...)
78 static inline void jbd_free(
void *
ptr,
size_t size)
83 #define JFS_MIN_JOURNAL_BLOCKS 1024
103 typedef struct handle_s handle_t;
117 typedef struct journal_s journal_t;
124 #define JFS_MAGIC_NUMBER 0xc03b3998U
134 #define JFS_DESCRIPTOR_BLOCK 1
135 #define JFS_COMMIT_BLOCK 2
136 #define JFS_SUPERBLOCK_V1 3
137 #define JFS_SUPERBLOCK_V2 4
138 #define JFS_REVOKE_BLOCK 5
172 #define JFS_FLAG_ESCAPE 1
173 #define JFS_FLAG_SAME_UUID 2
174 #define JFS_FLAG_DELETED 4
175 #define JFS_FLAG_LAST_TAG 8
226 #define JFS_HAS_COMPAT_FEATURE(j,mask) \
227 ((j)->j_format_version >= 2 && \
228 ((j)->j_superblock->s_feature_compat & cpu_to_be32((mask))))
229 #define JFS_HAS_RO_COMPAT_FEATURE(j,mask) \
230 ((j)->j_format_version >= 2 && \
231 ((j)->j_superblock->s_feature_ro_compat & cpu_to_be32((mask))))
232 #define JFS_HAS_INCOMPAT_FEATURE(j,mask) \
233 ((j)->j_format_version >= 2 && \
234 ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask))))
236 #define JFS_FEATURE_INCOMPAT_REVOKE 0x00000001
239 #define JFS_KNOWN_COMPAT_FEATURES 0
240 #define JFS_KNOWN_ROCOMPAT_FEATURES 0
241 #define JFS_KNOWN_INCOMPAT_FEATURES JFS_FEATURE_INCOMPAT_REVOKE
245 #include <linux/fs.h>
246 #include <linux/sched.h>
249 #define J_ASSERT(assert) BUG_ON(!(assert))
251 #define J_ASSERT_BH(bh, expr) J_ASSERT(expr)
252 #define J_ASSERT_JH(jh, expr) J_ASSERT(expr)
254 #if defined(JBD_PARANOID_IOFAIL)
255 #define J_EXPECT(expr, why...) J_ASSERT(expr)
256 #define J_EXPECT_BH(bh, expr, why...) J_ASSERT_BH(bh, expr)
257 #define J_EXPECT_JH(jh, expr, why...) J_ASSERT_JH(jh, expr)
259 #define __journal_expect(expr, why...) \
264 "EXT3-fs unexpected failure: %s;\n",# expr); \
265 printk(KERN_ERR why "\n"); \
269 #define J_EXPECT(expr, why...) __journal_expect(expr, ## why)
270 #define J_EXPECT_BH(bh, expr, why...) __journal_expect(expr, ## why)
271 #define J_EXPECT_JH(jh, expr, why...) __journal_expect(expr, ## why)
293 int h_buffer_credits;
303 unsigned int h_sync: 1;
304 unsigned int h_jdata: 1;
305 unsigned int h_aborted: 1;
307 #ifdef CONFIG_DEBUG_LOCK_ALLOC
308 struct lockdep_map h_lockdep_map;
352 journal_t *t_journal;
377 unsigned int t_log_start;
459 int t_outstanding_credits;
471 unsigned long t_expires;
553 unsigned long j_flags;
562 struct buffer_head *j_sb_buffer;
566 int j_format_version;
618 struct mutex j_checkpoint_mutex;
642 unsigned int j_first;
651 unsigned int j_blk_offset;
660 unsigned int j_maxlen;
670 struct inode *j_inode;
675 tid_t j_tail_sequence;
680 tid_t j_transaction_sequence;
686 tid_t j_commit_sequence;
692 tid_t j_commit_request;
699 tid_t j_commit_waited;
716 int j_max_transaction_buffers;
721 unsigned long j_commit_interval;
737 struct buffer_head **j_wbuf;
744 pid_t j_last_sync_writer;
750 u64 j_average_commit_time;
762 #define JFS_UNMOUNT 0x001
763 #define JFS_ABORT 0x002
764 #define JFS_ACK_ERR 0x004
765 #define JFS_FLUSHED 0x008
766 #define JFS_LOADED 0x010
767 #define JFS_BARRIER 0x020
768 #define JFS_ABORT_ON_SYNCDATA_ERR 0x040
783 extern void __journal_free_buffer(
struct journal_head *bh);
807 extern void __wait_on_journal (journal_t *);
820 static inline handle_t *journal_current_handle(
void)
841 extern void journal_sync_buffer (
struct buffer_head *);
843 struct page *,
unsigned long);
852 int start,
int len,
int bsize);
856 (journal_t *,
unsigned long,
unsigned long,
unsigned long);
858 (journal_t *,
unsigned long,
unsigned long,
unsigned long);
860 (journal_t *,
unsigned long,
unsigned long,
unsigned long);
873 extern int journal_bmap(journal_t *,
unsigned int,
unsigned int *);
888 static inline handle_t *jbd_alloc_handle(
gfp_t gfp_flags)
893 static inline void jbd_free_handle(handle_t *
handle)
899 #define JOURNAL_REVOKE_DEFAULT_HASH 256
905 extern int journal_revoke (handle_t *,
906 unsigned int,
struct buffer_head *);
907 extern int journal_cancel_revoke(handle_t *,
struct journal_head *);
908 extern void journal_write_revoke_records(journal_t *,
915 extern void journal_switch_revoke_table(journal_t *journal);
916 extern void journal_clear_buffer_revoked_flags(journal_t *journal);
940 #define jbd_ENOSYS() \
942 printk (KERN_ERR "JBD unimplemented function %s\n", __func__); \
943 current->state = TASK_UNINTERRUPTIBLE; \
957 static inline int is_journal_aborted(journal_t *journal)
959 return journal->j_flags & JFS_ABORT;
962 static inline int is_handle_aborted(handle_t *
handle)
964 if (handle->h_aborted)
966 return is_journal_aborted(handle->h_transaction->t_journal);
969 static inline void journal_abort_handle(handle_t *handle)
971 handle->h_aborted = 1;
981 int difference = (x -
y);
982 return (difference > 0);
987 int difference = (x -
y);
988 return (difference >= 0);
997 static inline int jbd_space_needed(journal_t *journal)
999 int nblocks = journal->j_max_transaction_buffers;
1000 if (journal->j_committing_transaction)
1001 nblocks += journal->j_committing_transaction->
1002 t_outstanding_credits;
1012 #define BJ_SyncData 1
1013 #define BJ_Metadata 2
1018 #define BJ_Reserved 7
1026 #define buffer_trace_init(bh) do {} while (0)
1027 #define print_buffer_fields(bh) do {} while (0)
1028 #define print_buffer_trace(bh) do {} while (0)
1029 #define BUFFER_TRACE(bh, info) do {} while (0)
1030 #define BUFFER_TRACE2(bh, bh2, info) do {} while (0)
1031 #define JBUFFER_TRACE(jh, info) do {} while (0)