sdio: add new function for RAW (Read after Write) operation
[safe/jmp/linux-2.6] / include / linux / jbd2.h
index fe89444..a4d2e9f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * linux/include/linux/jbd.h
+ * linux/include/linux/jbd2.h
  *
  * Written by Stephen C. Tweedie <sct@redhat.com>
  *
  * filesystem journaling support.
  */
 
-#ifndef _LINUX_JBD_H
-#define _LINUX_JBD_H
+#ifndef _LINUX_JBD2_H
+#define _LINUX_JBD2_H
 
 /* Allow this file to be included directly into e2fsprogs */
 #ifndef __KERNEL__
 #include "jfs_compat.h"
-#define JFS_DEBUG
+#define JBD2_DEBUG
 #define jfs_debug jbd_debug
 #else
 
 #include <linux/bit_spinlock.h>
 #include <linux/mutex.h>
 #include <linux/timer.h>
-
-#include <asm/semaphore.h>
+#include <linux/slab.h>
 #endif
 
 #define journal_oom_retry 1
 
 /*
- * Define JBD_PARANIOD_IOFAIL to cause a kernel BUG() if ext3 finds
+ * Define JBD2_PARANIOD_IOFAIL to cause a kernel BUG() if ext4 finds
  * certain classes of error which can occur due to failed IOs.  Under
- * normal use we want ext3 to continue after such errors, because
+ * normal use we want ext4 to continue after such errors, because
  * hardware _can_ fail, but for debugging purposes when running tests on
  * known-good hardware we may want to trap these errors.
  */
-#undef JBD_PARANOID_IOFAIL
+#undef JBD2_PARANOID_IOFAIL
 
 /*
  * The default maximum commit age, in seconds.
  */
-#define JBD_DEFAULT_MAX_COMMIT_AGE 5
+#define JBD2_DEFAULT_MAX_COMMIT_AGE 5
 
-#ifdef CONFIG_JBD_DEBUG
+#ifdef CONFIG_JBD2_DEBUG
 /*
- * Define JBD_EXPENSIVE_CHECKING to enable more expensive internal
+ * Define JBD2_EXPENSIVE_CHECKING to enable more expensive internal
  * consistency checks.  By default we don't do this unless
- * CONFIG_JBD_DEBUG is on.
+ * CONFIG_JBD2_DEBUG is on.
  */
-#define JBD_EXPENSIVE_CHECKING
-extern int journal_enable_debug;
+#define JBD2_EXPENSIVE_CHECKING
+extern u8 jbd2_journal_enable_debug;
 
 #define jbd_debug(n, f, a...)                                          \
        do {                                                            \
-               if ((n) <= journal_enable_debug) {                      \
+               if ((n) <= jbd2_journal_enable_debug) {                 \
                        printk (KERN_DEBUG "(%s, %d): %s: ",            \
-                               __FILE__, __LINE__, __FUNCTION__);      \
+                               __FILE__, __LINE__, __func__);  \
                        printk (f, ## a);                               \
                }                                                       \
        } while (0)
@@ -71,16 +70,10 @@ extern int journal_enable_debug;
 #define jbd_debug(f, a...)     /**/
 #endif
 
-extern void * __jbd_kmalloc (const char *where, size_t size, gfp_t flags, int retry);
-extern void * jbd_slab_alloc(size_t size, gfp_t flags);
-extern void jbd_slab_free(void *ptr, size_t size);
-
-#define jbd_kmalloc(size, flags) \
-       __jbd_kmalloc(__FUNCTION__, (size), (flags), journal_oom_retry)
-#define jbd_rep_kmalloc(size, flags) \
-       __jbd_kmalloc(__FUNCTION__, (size), (flags), 1)
+extern void *jbd2_alloc(size_t size, gfp_t flags);
+extern void jbd2_free(void *ptr, size_t size);
 
-#define JFS_MIN_JOURNAL_BLOCKS 1024
+#define JBD2_MIN_JOURNAL_BLOCKS 1024
 
 #ifdef __KERNEL__
 
@@ -122,7 +115,7 @@ typedef struct journal_s    journal_t;      /* Journal control structure */
  * Internal structures used by the logging mechanism:
  */
 
-#define JFS_MAGIC_NUMBER 0xc03b3998U /* The first 4 bytes of /dev/random! */
+#define JBD2_MAGIC_NUMBER 0xc03b3998U /* The first 4 bytes of /dev/random! */
 
 /*
  * On-disk structures
@@ -132,11 +125,11 @@ typedef struct journal_s  journal_t;      /* Journal control structure */
  * Descriptor block types:
  */
 
-#define JFS_DESCRIPTOR_BLOCK   1
-#define JFS_COMMIT_BLOCK       2
-#define JFS_SUPERBLOCK_V1      3
-#define JFS_SUPERBLOCK_V2      4
-#define JFS_REVOKE_BLOCK       5
+#define JBD2_DESCRIPTOR_BLOCK  1
+#define JBD2_COMMIT_BLOCK      2
+#define JBD2_SUPERBLOCK_V1     3
+#define JBD2_SUPERBLOCK_V2     4
+#define JBD2_REVOKE_BLOCK      5
 
 /*
  * Standard header for all descriptor blocks:
@@ -148,32 +141,63 @@ typedef struct journal_header_s
        __be32          h_sequence;
 } journal_header_t;
 
+/*
+ * Checksum types.
+ */
+#define JBD2_CRC32_CHKSUM   1
+#define JBD2_MD5_CHKSUM     2
+#define JBD2_SHA1_CHKSUM    3
 
+#define JBD2_CRC32_CHKSUM_SIZE 4
+
+#define JBD2_CHECKSUM_BYTES (32 / sizeof(u32))
 /*
- * The block tag: used to describe a single buffer in the journal
+ * Commit block header for storing transactional checksums:
+ */
+struct commit_header {
+       __be32          h_magic;
+       __be32          h_blocktype;
+       __be32          h_sequence;
+       unsigned char   h_chksum_type;
+       unsigned char   h_chksum_size;
+       unsigned char   h_padding[2];
+       __be32          h_chksum[JBD2_CHECKSUM_BYTES];
+       __be64          h_commit_sec;
+       __be32          h_commit_nsec;
+};
+
+/*
+ * The block tag: used to describe a single buffer in the journal.
+ * t_blocknr_high is only used if INCOMPAT_64BIT is set, so this
+ * raw struct shouldn't be used for pointer math or sizeof() - use
+ * journal_tag_bytes(journal) instead to compute this.
  */
 typedef struct journal_block_tag_s
 {
        __be32          t_blocknr;      /* The on-disk block number */
        __be32          t_flags;        /* See below */
+       __be32          t_blocknr_high; /* most-significant high 32bits. */
 } journal_block_tag_t;
 
+#define JBD2_TAG_SIZE32 (offsetof(journal_block_tag_t, t_blocknr_high))
+#define JBD2_TAG_SIZE64 (sizeof(journal_block_tag_t))
+
 /*
  * The revoke descriptor: used on disk to describe a series of blocks to
  * be revoked from the log
  */
-typedef struct journal_revoke_header_s
+typedef struct jbd2_journal_revoke_header_s
 {
        journal_header_t r_header;
        __be32           r_count;       /* Count of bytes used in the block */
-} journal_revoke_header_t;
+} jbd2_journal_revoke_header_t;
 
 
 /* Definitions for the journal tag flags word: */
-#define JFS_FLAG_ESCAPE                1       /* on-disk block is escaped */
-#define JFS_FLAG_SAME_UUID     2       /* block has same uuid as previous */
-#define JFS_FLAG_DELETED       4       /* block deleted by this transaction */
-#define JFS_FLAG_LAST_TAG      8       /* last tag in this descriptor block */
+#define JBD2_FLAG_ESCAPE               1       /* on-disk block is escaped */
+#define JBD2_FLAG_SAME_UUID    2       /* block has same uuid as previous */
+#define JBD2_FLAG_DELETED      4       /* block deleted by this transaction */
+#define JBD2_FLAG_LAST_TAG     8       /* last tag in this descriptor block */
 
 
 /*
@@ -196,7 +220,7 @@ typedef struct journal_superblock_s
        __be32  s_start;                /* blocknr of start of log */
 
 /* 0x0020 */
-       /* Error value, as set by journal_abort(). */
+       /* Error value, as set by jbd2_journal_abort(). */
        __be32  s_errno;
 
 /* 0x0024 */
@@ -224,59 +248,40 @@ typedef struct journal_superblock_s
 /* 0x0400 */
 } journal_superblock_t;
 
-#define JFS_HAS_COMPAT_FEATURE(j,mask)                                 \
+#define JBD2_HAS_COMPAT_FEATURE(j,mask)                                        \
        ((j)->j_format_version >= 2 &&                                  \
         ((j)->j_superblock->s_feature_compat & cpu_to_be32((mask))))
-#define JFS_HAS_RO_COMPAT_FEATURE(j,mask)                              \
+#define JBD2_HAS_RO_COMPAT_FEATURE(j,mask)                             \
        ((j)->j_format_version >= 2 &&                                  \
         ((j)->j_superblock->s_feature_ro_compat & cpu_to_be32((mask))))
-#define JFS_HAS_INCOMPAT_FEATURE(j,mask)                               \
+#define JBD2_HAS_INCOMPAT_FEATURE(j,mask)                              \
        ((j)->j_format_version >= 2 &&                                  \
         ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask))))
 
-#define JFS_FEATURE_INCOMPAT_REVOKE    0x00000001
+#define JBD2_FEATURE_COMPAT_CHECKSUM   0x00000001
+
+#define JBD2_FEATURE_INCOMPAT_REVOKE           0x00000001
+#define JBD2_FEATURE_INCOMPAT_64BIT            0x00000002
+#define JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT     0x00000004
 
 /* Features known to this kernel version: */
-#define JFS_KNOWN_COMPAT_FEATURES      0
-#define JFS_KNOWN_ROCOMPAT_FEATURES    0
-#define JFS_KNOWN_INCOMPAT_FEATURES    JFS_FEATURE_INCOMPAT_REVOKE
+#define JBD2_KNOWN_COMPAT_FEATURES     JBD2_FEATURE_COMPAT_CHECKSUM
+#define JBD2_KNOWN_ROCOMPAT_FEATURES   0
+#define JBD2_KNOWN_INCOMPAT_FEATURES   (JBD2_FEATURE_INCOMPAT_REVOKE | \
+                                       JBD2_FEATURE_INCOMPAT_64BIT | \
+                                       JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)
 
 #ifdef __KERNEL__
 
 #include <linux/fs.h>
 #include <linux/sched.h>
 
-#define JBD_ASSERTIONS
-#ifdef JBD_ASSERTIONS
-#define J_ASSERT(assert)                                               \
-do {                                                                   \
-       if (!(assert)) {                                                \
-               printk (KERN_EMERG                                      \
-                       "Assertion failure in %s() at %s:%d: \"%s\"\n", \
-                       __FUNCTION__, __FILE__, __LINE__, # assert);    \
-               BUG();                                                  \
-       }                                                               \
-} while (0)
-
-#if defined(CONFIG_BUFFER_DEBUG)
-void buffer_assertion_failure(struct buffer_head *bh);
-#define J_ASSERT_BH(bh, expr)                                          \
-       do {                                                            \
-               if (!(expr))                                            \
-                       buffer_assertion_failure(bh);                   \
-               J_ASSERT(expr);                                         \
-       } while (0)
-#define J_ASSERT_JH(jh, expr)  J_ASSERT_BH(jh2bh(jh), expr)
-#else
+#define J_ASSERT(assert)       BUG_ON(!(assert))
+
 #define J_ASSERT_BH(bh, expr)  J_ASSERT(expr)
 #define J_ASSERT_JH(jh, expr)  J_ASSERT(expr)
-#endif
 
-#else
-#define J_ASSERT(assert)       do { } while (0)
-#endif         /* JBD_ASSERTIONS */
-
-#if defined(JBD_PARANOID_IOFAIL)
+#if defined(JBD2_PARANOID_IOFAIL)
 #define J_EXPECT(expr, why...)         J_ASSERT(expr)
 #define J_EXPECT_BH(bh, expr, why...)  J_ASSERT_BH(bh, expr)
 #define J_EXPECT_JH(jh, expr, why...)  J_ASSERT_JH(jh, expr)
@@ -286,7 +291,8 @@ void buffer_assertion_failure(struct buffer_head *bh);
                int val = (expr);                                            \
                if (!val) {                                                  \
                        printk(KERN_ERR                                      \
-                               "EXT3-fs unexpected failure: %s;\n",# expr); \
+                              "JBD2 unexpected failure: %s: %s;\n",         \
+                              __func__, #expr);                             \
                        printk(KERN_ERR why "\n");                           \
                }                                                            \
                val;                                                         \
@@ -307,6 +313,7 @@ enum jbd_state_bits {
        BH_State,               /* Pins most journal_head state */
        BH_JournalHead,         /* Pins bh->b_private and jh->b_bh */
        BH_Unshadow,            /* Dummy bit, for BJ_Shadow wakeup filtering */
+       BH_JBDPrivateStart,     /* First bit available for private use by FS */
 };
 
 BUFFER_FNS(JBD, jbd)
@@ -359,7 +366,39 @@ static inline void jbd_unlock_bh_journal_head(struct buffer_head *bh)
        bit_spin_unlock(BH_JournalHead, &bh->b_state);
 }
 
-struct jbd_revoke_table_s;
+/* Flags in jbd_inode->i_flags */
+#define __JI_COMMIT_RUNNING 0
+/* Commit of the inode data in progress. We use this flag to protect us from
+ * concurrent deletion of inode. We cannot use reference to inode for this
+ * since we cannot afford doing last iput() on behalf of kjournald
+ */
+#define JI_COMMIT_RUNNING (1 << __JI_COMMIT_RUNNING)
+
+/**
+ * struct jbd_inode is the structure linking inodes in ordered mode
+ *   present in a transaction so that we can sync them during commit.
+ */
+struct jbd2_inode {
+       /* Which transaction does this inode belong to? Either the running
+        * transaction or the committing one. [j_list_lock] */
+       transaction_t *i_transaction;
+
+       /* Pointer to the running transaction modifying inode's data in case
+        * there is already a committing transaction touching it. [j_list_lock] */
+       transaction_t *i_next_transaction;
+
+       /* List of inodes in the i_transaction [j_list_lock] */
+       struct list_head i_list;
+
+       /* VFS inode this inode belongs to [constant during the lifetime
+        * of the structure] */
+       struct inode *i_vfs_inode;
+
+       /* Flags of inode [j_list_lock] */
+       unsigned int i_flags;
+};
+
+struct jbd2_revoke_table_s;
 
 /**
  * struct handle_s - The handle_s type is the concrete type associated with
@@ -396,9 +435,23 @@ struct handle_s
        unsigned int    h_sync:         1;      /* sync-on-close */
        unsigned int    h_jdata:        1;      /* force data journaling */
        unsigned int    h_aborted:      1;      /* fatal error on handle */
+
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+       struct lockdep_map      h_lockdep_map;
+#endif
 };
 
 
+/*
+ * Some stats for checkpoint phase
+ */
+struct transaction_chp_stats_s {
+       unsigned long           cs_chp_time;
+       __u32                   cs_forced_to_close;
+       __u32                   cs_written;
+       __u32                   cs_dropped;
+};
+
 /* The transaction_t type is the guts of the journaling mechanism.  It
  * tracks a compound transaction through its various states:
  *
@@ -445,7 +498,9 @@ struct transaction_s
 
        /*
         * Transaction's current state
-        * [no locking - only kjournald alters this]
+        * [no locking - only kjournald2 alters this]
+        * [j_list_lock] guards transition of a transaction into T_FINISHED
+        * state and subsequent call of __jbd2_journal_drop_transaction()
         * FIXME: needs barriers
         * KLUDGE: [use j_state_lock]
         */
@@ -473,24 +528,12 @@ struct transaction_s
        struct journal_head     *t_reserved_list;
 
        /*
-        * Doubly-linked circular list of all buffers under writeout during
-        * commit [j_list_lock]
-        */
-       struct journal_head     *t_locked_list;
-
-       /*
         * Doubly-linked circular list of all metadata buffers owned by this
         * transaction [j_list_lock]
         */
        struct journal_head     *t_buffers;
 
        /*
-        * Doubly-linked circular list of all data buffers still to be
-        * flushed before this transaction can be committed [j_list_lock]
-        */
-       struct journal_head     *t_sync_datalist;
-
-       /*
         * Doubly-linked circular list of all forget buffers (superseded
         * buffers which we can un-checkpoint once this transaction commits)
         * [j_list_lock]
@@ -529,11 +572,32 @@ struct transaction_s
        struct journal_head     *t_log_list;
 
        /*
+        * List of inodes whose data we've modified in data=ordered mode.
+        * [j_list_lock]
+        */
+       struct list_head        t_inode_list;
+
+       /*
         * Protects info related to handles
         */
        spinlock_t              t_handle_lock;
 
        /*
+        * Longest time some handle had to wait for running transaction
+        */
+       unsigned long           t_max_wait;
+
+       /*
+        * When transaction started
+        */
+       unsigned long           t_start;
+
+       /*
+        * Checkpointing stats [j_checkpoint_sem]
+        */
+       struct transaction_chp_stats_s t_chp_stats;
+
+       /*
         * Number of outstanding updates running on this transaction
         * [t_handle_lock]
         */
@@ -558,12 +622,57 @@ struct transaction_s
        unsigned long           t_expires;
 
        /*
+        * When this transaction started, in nanoseconds [no locking]
+        */
+       ktime_t                 t_start_time;
+
+       /*
         * How many handles used this transaction? [t_handle_lock]
         */
        int t_handle_count;
 
+       /*
+        * This transaction is being forced and some process is
+        * waiting for it to finish.
+        */
+       unsigned int t_synchronous_commit:1;
+       unsigned int t_flushed_data_blocks:1;
+
+       /*
+        * For use by the filesystem to store fs-specific data
+        * structures associated with the transaction
+        */
+       struct list_head        t_private_list;
+};
+
+struct transaction_run_stats_s {
+       unsigned long           rs_wait;
+       unsigned long           rs_running;
+       unsigned long           rs_locked;
+       unsigned long           rs_flushing;
+       unsigned long           rs_logging;
+
+       __u32                   rs_handle_count;
+       __u32                   rs_blocks;
+       __u32                   rs_blocks_logged;
+};
+
+struct transaction_stats_s {
+       unsigned long           ts_tid;
+       struct transaction_run_stats_s run;
 };
 
+static inline unsigned long
+jbd2_time_diff(unsigned long start, unsigned long end)
+{
+       if (end >= start)
+               return end - start;
+
+       return end + (MAX_JIFFY_OFFSET - start);
+}
+
+#define JBD2_NR_BATCH  64
+
 /**
  * struct journal_s - The journal_s type is the concrete type associated with
  *     journal_t.
@@ -621,10 +730,16 @@ struct transaction_s
  * @j_revoke: The revoke table - maintains the list of revoked blocks in the
  *     current transaction.
  * @j_revoke_table: alternate revoke tables for j_revoke
- * @j_wbuf: array of buffer_heads for journal_commit_transaction
+ * @j_wbuf: array of buffer_heads for jbd2_journal_commit_transaction
  * @j_wbufsize: maximum number of buffer_heads allowed in j_wbuf, the
  *     number that will fit in j_blocksize
  * @j_last_sync_writer: most recent pid which did a synchronous write
+ * @j_history: Buffer storing the transactions statistics history
+ * @j_history_max: Maximum number of transactions in the statistics history
+ * @j_history_cur: Current number of transactions in the statistics history
+ * @j_history_lock: Protect the transactions statistics history
+ * @j_proc_entry: procfs entry for the jbd statistics directory
+ * @j_stats: Overall statistics
  * @j_private: An opaque pointer to fs-private information.
  */
 
@@ -702,6 +817,14 @@ struct journal_s
        struct mutex            j_checkpoint_mutex;
 
        /*
+        * List of buffer heads used by the checkpoint routine.  This
+        * was moved from jbd2_log_do_checkpoint() to reduce stack
+        * usage.  Access to this array is controlled by the
+        * j_checkpoint_mutex.  [j_checkpoint_mutex]
+        */
+       struct buffer_head      *j_chkpt_bhs[JBD2_NR_BATCH];
+       
+       /*
         * Journal head: identifies the first unused block in the journal.
         * [j_state_lock]
         */
@@ -732,7 +855,8 @@ struct journal_s
         */
        struct block_device     *j_dev;
        int                     j_blocksize;
-       unsigned long           j_blk_offset;
+       unsigned long long      j_blk_offset;
+       char                    j_devname[BDEVNAME_SIZE+24];
 
        /*
         * Device which holds the client fs.  For internal journal this will be
@@ -805,18 +929,50 @@ struct journal_s
         * current transaction.  [j_revoke_lock]
         */
        spinlock_t              j_revoke_lock;
-       struct jbd_revoke_table_s *j_revoke;
-       struct jbd_revoke_table_s *j_revoke_table[2];
+       struct jbd2_revoke_table_s *j_revoke;
+       struct jbd2_revoke_table_s *j_revoke_table[2];
 
        /*
-        * array of bhs for journal_commit_transaction
+        * array of bhs for jbd2_journal_commit_transaction
         */
        struct buffer_head      **j_wbuf;
        int                     j_wbufsize;
 
+       /*
+        * this is the pid of hte last person to run a synchronous operation
+        * through the journal
+        */
        pid_t                   j_last_sync_writer;
 
        /*
+        * the average amount of time in nanoseconds it takes to commit a
+        * transaction to disk. [j_state_lock]
+        */
+       u64                     j_average_commit_time;
+
+       /*
+        * minimum and maximum times that we should wait for
+        * additional filesystem operations to get batched into a
+        * synchronous handle in microseconds
+        */
+       u32                     j_min_batch_time;
+       u32                     j_max_batch_time;
+
+       /* This function is called when a transaction is closed */
+       void                    (*j_commit_callback)(journal_t *,
+                                                    transaction_t *);
+
+       /*
+        * Journal statistics
+        */
+       spinlock_t              j_history_lock;
+       struct proc_dir_entry   *j_proc_entry;
+       struct transaction_stats_s j_stats;
+
+       /* Failed journal commit ID */
+       unsigned int            j_failed_commit;
+
+       /*
         * An opaque pointer to fs-private information.  ext3 puts its
         * superblock pointer here
         */
@@ -826,12 +982,15 @@ struct journal_s
 /*
  * Journal flag definitions
  */
-#define JFS_UNMOUNT    0x001   /* Journal thread is being destroyed */
-#define JFS_ABORT      0x002   /* Journaling has been aborted for errors. */
-#define JFS_ACK_ERR    0x004   /* The errno in the sb has been acked */
-#define JFS_FLUSHED    0x008   /* The journal superblock has been flushed */
-#define JFS_LOADED     0x010   /* The journal superblock has been loaded */
-#define JFS_BARRIER    0x020   /* Use IDE barriers */
+#define JBD2_UNMOUNT   0x001   /* Journal thread is being destroyed */
+#define JBD2_ABORT     0x002   /* Journaling has been aborted for errors. */
+#define JBD2_ACK_ERR   0x004   /* The errno in the sb has been acked */
+#define JBD2_FLUSHED   0x008   /* The journal superblock has been flushed */
+#define JBD2_LOADED    0x010   /* The journal superblock has been loaded */
+#define JBD2_BARRIER   0x020   /* Use IDE barriers */
+#define JBD2_ABORT_ON_SYNCDATA_ERR     0x040   /* Abort the journal on file
+                                                * data write error in ordered
+                                                * mode */
 
 /*
  * Function declarations for the journaling transaction and buffer
@@ -839,34 +998,62 @@ struct journal_s
  */
 
 /* Filing buffers */
-extern void __journal_temp_unlink_buffer(struct journal_head *jh);
-extern void journal_unfile_buffer(journal_t *, struct journal_head *);
-extern void __journal_unfile_buffer(struct journal_head *);
-extern void __journal_refile_buffer(struct journal_head *);
-extern void journal_refile_buffer(journal_t *, struct journal_head *);
-extern void __journal_file_buffer(struct journal_head *, transaction_t *, int);
+extern void jbd2_journal_unfile_buffer(journal_t *, struct journal_head *);
+extern void __jbd2_journal_unfile_buffer(struct journal_head *);
+extern void __jbd2_journal_refile_buffer(struct journal_head *);
+extern void jbd2_journal_refile_buffer(journal_t *, struct journal_head *);
+extern void __jbd2_journal_file_buffer(struct journal_head *, transaction_t *, int);
 extern void __journal_free_buffer(struct journal_head *bh);
-extern void journal_file_buffer(struct journal_head *, transaction_t *, int);
+extern void jbd2_journal_file_buffer(struct journal_head *, transaction_t *, int);
 extern void __journal_clean_data_list(transaction_t *transaction);
 
 /* Log buffer allocation */
-extern struct journal_head * journal_get_descriptor_buffer(journal_t *);
-int journal_next_log_block(journal_t *, unsigned long *);
+extern struct journal_head * jbd2_journal_get_descriptor_buffer(journal_t *);
+int jbd2_journal_next_log_block(journal_t *, unsigned long long *);
 
 /* Commit management */
-extern void journal_commit_transaction(journal_t *);
+extern void jbd2_journal_commit_transaction(journal_t *);
 
 /* Checkpoint list management */
-int __journal_clean_checkpoint_list(journal_t *journal);
-int __journal_remove_checkpoint(struct journal_head *);
-void __journal_insert_checkpoint(struct journal_head *, transaction_t *);
+int __jbd2_journal_clean_checkpoint_list(journal_t *journal);
+int __jbd2_journal_remove_checkpoint(struct journal_head *);
+void __jbd2_journal_insert_checkpoint(struct journal_head *, transaction_t *);
+
+
+/*
+ * Triggers
+ */
+
+struct jbd2_buffer_trigger_type {
+       /*
+        * Fired just before a buffer is written to the journal.
+        * mapped_data is a mapped buffer that is the frozen data for
+        * commit.
+        */
+       void (*t_commit)(struct jbd2_buffer_trigger_type *type,
+                        struct buffer_head *bh, void *mapped_data,
+                        size_t size);
+
+       /*
+        * Fired during journal abort for dirty buffers that will not be
+        * committed.
+        */
+       void (*t_abort)(struct jbd2_buffer_trigger_type *type,
+                       struct buffer_head *bh);
+};
+
+extern void jbd2_buffer_commit_trigger(struct journal_head *jh,
+                                      void *mapped_data,
+                                      struct jbd2_buffer_trigger_type *triggers);
+extern void jbd2_buffer_abort_trigger(struct journal_head *jh,
+                                     struct jbd2_buffer_trigger_type *triggers);
 
 /* Buffer IO */
 extern int
-journal_write_metadata_buffer(transaction_t      *transaction,
+jbd2_journal_write_metadata_buffer(transaction_t         *transaction,
                              struct journal_head  *jh_in,
                              struct journal_head **jh_out,
-                             unsigned long        blocknr);
+                             unsigned long long   blocknr);
 
 /* Transaction locking */
 extern void            __wait_on_journal (journal_t *);
@@ -893,91 +1080,98 @@ static inline handle_t *journal_current_handle(void)
  * Register buffer modifications against the current transaction.
  */
 
-extern handle_t *journal_start(journal_t *, int nblocks);
-extern int      journal_restart (handle_t *, int nblocks);
-extern int      journal_extend (handle_t *, int nblocks);
-extern int      journal_get_write_access(handle_t *, struct buffer_head *);
-extern int      journal_get_create_access (handle_t *, struct buffer_head *);
-extern int      journal_get_undo_access(handle_t *, struct buffer_head *);
-extern int      journal_dirty_data (handle_t *, struct buffer_head *);
-extern int      journal_dirty_metadata (handle_t *, struct buffer_head *);
-extern void     journal_release_buffer (handle_t *, struct buffer_head *);
-extern int      journal_forget (handle_t *, struct buffer_head *);
+extern handle_t *jbd2_journal_start(journal_t *, int nblocks);
+extern int      jbd2_journal_restart (handle_t *, int nblocks);
+extern int      jbd2_journal_extend (handle_t *, int nblocks);
+extern int      jbd2_journal_get_write_access(handle_t *, struct buffer_head *);
+extern int      jbd2_journal_get_create_access (handle_t *, struct buffer_head *);
+extern int      jbd2_journal_get_undo_access(handle_t *, struct buffer_head *);
+void            jbd2_journal_set_triggers(struct buffer_head *,
+                                          struct jbd2_buffer_trigger_type *type);
+extern int      jbd2_journal_dirty_metadata (handle_t *, struct buffer_head *);
+extern void     jbd2_journal_release_buffer (handle_t *, struct buffer_head *);
+extern int      jbd2_journal_forget (handle_t *, struct buffer_head *);
 extern void     journal_sync_buffer (struct buffer_head *);
-extern void     journal_invalidatepage(journal_t *,
+extern void     jbd2_journal_invalidatepage(journal_t *,
                                struct page *, unsigned long);
-extern int      journal_try_to_free_buffers(journal_t *, struct page *, gfp_t);
-extern int      journal_stop(handle_t *);
-extern int      journal_flush (journal_t *);
-extern void     journal_lock_updates (journal_t *);
-extern void     journal_unlock_updates (journal_t *);
+extern int      jbd2_journal_try_to_free_buffers(journal_t *, struct page *, gfp_t);
+extern int      jbd2_journal_stop(handle_t *);
+extern int      jbd2_journal_flush (journal_t *);
+extern void     jbd2_journal_lock_updates (journal_t *);
+extern void     jbd2_journal_unlock_updates (journal_t *);
 
-extern journal_t * journal_init_dev(struct block_device *bdev,
+extern journal_t * jbd2_journal_init_dev(struct block_device *bdev,
                                struct block_device *fs_dev,
-                               int start, int len, int bsize);
-extern journal_t * journal_init_inode (struct inode *);
-extern int        journal_update_format (journal_t *);
-extern int        journal_check_used_features
+                               unsigned long long start, int len, int bsize);
+extern journal_t * jbd2_journal_init_inode (struct inode *);
+extern int        jbd2_journal_update_format (journal_t *);
+extern int        jbd2_journal_check_used_features
                   (journal_t *, unsigned long, unsigned long, unsigned long);
-extern int        journal_check_available_features
+extern int        jbd2_journal_check_available_features
                   (journal_t *, unsigned long, unsigned long, unsigned long);
-extern int        journal_set_features
+extern int        jbd2_journal_set_features
                   (journal_t *, unsigned long, unsigned long, unsigned long);
-extern int        journal_create     (journal_t *);
-extern int        journal_load       (journal_t *journal);
-extern void       journal_destroy    (journal_t *);
-extern int        journal_recover    (journal_t *journal);
-extern int        journal_wipe       (journal_t *, int);
-extern int        journal_skip_recovery        (journal_t *);
-extern void       journal_update_superblock    (journal_t *, int);
-extern void       __journal_abort_hard (journal_t *);
-extern void       journal_abort      (journal_t *, int);
-extern int        journal_errno      (journal_t *);
-extern void       journal_ack_err    (journal_t *);
-extern int        journal_clear_err  (journal_t *);
-extern int        journal_bmap(journal_t *, unsigned long, unsigned long *);
-extern int        journal_force_commit(journal_t *);
+extern void       jbd2_journal_clear_features
+                  (journal_t *, unsigned long, unsigned long, unsigned long);
+extern int        jbd2_journal_load       (journal_t *journal);
+extern int        jbd2_journal_destroy    (journal_t *);
+extern int        jbd2_journal_recover    (journal_t *journal);
+extern int        jbd2_journal_wipe       (journal_t *, int);
+extern int        jbd2_journal_skip_recovery   (journal_t *);
+extern void       jbd2_journal_update_superblock       (journal_t *, int);
+extern void       __jbd2_journal_abort_hard    (journal_t *);
+extern void       jbd2_journal_abort      (journal_t *, int);
+extern int        jbd2_journal_errno      (journal_t *);
+extern void       jbd2_journal_ack_err    (journal_t *);
+extern int        jbd2_journal_clear_err  (journal_t *);
+extern int        jbd2_journal_bmap(journal_t *, unsigned long, unsigned long long *);
+extern int        jbd2_journal_force_commit(journal_t *);
+extern int        jbd2_journal_file_inode(handle_t *handle, struct jbd2_inode *inode);
+extern int        jbd2_journal_begin_ordered_truncate(journal_t *journal,
+                               struct jbd2_inode *inode, loff_t new_size);
+extern void       jbd2_journal_init_jbd_inode(struct jbd2_inode *jinode, struct inode *inode);
+extern void       jbd2_journal_release_jbd_inode(journal_t *journal, struct jbd2_inode *jinode);
 
 /*
  * journal_head management
  */
-struct journal_head *journal_add_journal_head(struct buffer_head *bh);
-struct journal_head *journal_grab_journal_head(struct buffer_head *bh);
-void journal_remove_journal_head(struct buffer_head *bh);
-void journal_put_journal_head(struct journal_head *jh);
+struct journal_head *jbd2_journal_add_journal_head(struct buffer_head *bh);
+struct journal_head *jbd2_journal_grab_journal_head(struct buffer_head *bh);
+void jbd2_journal_remove_journal_head(struct buffer_head *bh);
+void jbd2_journal_put_journal_head(struct journal_head *jh);
 
 /*
  * handle management
  */
-extern kmem_cache_t *jbd_handle_cache;
+extern struct kmem_cache *jbd2_handle_cache;
 
-static inline handle_t *jbd_alloc_handle(gfp_t gfp_flags)
+static inline handle_t *jbd2_alloc_handle(gfp_t gfp_flags)
 {
-       return kmem_cache_alloc(jbd_handle_cache, gfp_flags);
+       return kmem_cache_alloc(jbd2_handle_cache, gfp_flags);
 }
 
-static inline void jbd_free_handle(handle_t *handle)
+static inline void jbd2_free_handle(handle_t *handle)
 {
-       kmem_cache_free(jbd_handle_cache, handle);
+       kmem_cache_free(jbd2_handle_cache, handle);
 }
 
 /* Primary revoke support */
 #define JOURNAL_REVOKE_DEFAULT_HASH 256
-extern int        journal_init_revoke(journal_t *, int);
-extern void       journal_destroy_revoke_caches(void);
-extern int        journal_init_revoke_caches(void);
+extern int        jbd2_journal_init_revoke(journal_t *, int);
+extern void       jbd2_journal_destroy_revoke_caches(void);
+extern int        jbd2_journal_init_revoke_caches(void);
 
-extern void       journal_destroy_revoke(journal_t *);
-extern int        journal_revoke (handle_t *,
-                               unsigned long, struct buffer_head *);
-extern int        journal_cancel_revoke(handle_t *, struct journal_head *);
-extern void       journal_write_revoke_records(journal_t *, transaction_t *);
+extern void       jbd2_journal_destroy_revoke(journal_t *);
+extern int        jbd2_journal_revoke (handle_t *, unsigned long long, struct buffer_head *);
+extern int        jbd2_journal_cancel_revoke(handle_t *, struct journal_head *);
+extern void       jbd2_journal_write_revoke_records(journal_t *,
+                                                    transaction_t *, int);
 
 /* Recovery revoke support */
-extern int     journal_set_revoke(journal_t *, unsigned long, tid_t);
-extern int     journal_test_revoke(journal_t *, unsigned long, tid_t);
-extern void    journal_clear_revoke(journal_t *);
-extern void    journal_switch_revoke_table(journal_t *journal);
+extern int     jbd2_journal_set_revoke(journal_t *, unsigned long long, tid_t);
+extern int     jbd2_journal_test_revoke(journal_t *, unsigned long long, tid_t);
+extern void    jbd2_journal_clear_revoke(journal_t *);
+extern void    jbd2_journal_switch_revoke_table(journal_t *journal);
 
 /*
  * The log thread user interface:
@@ -986,23 +1180,23 @@ extern void      journal_switch_revoke_table(journal_t *journal);
  * transitions on demand.
  */
 
-int __log_space_left(journal_t *); /* Called with journal locked */
-int log_start_commit(journal_t *journal, tid_t tid);
-int __log_start_commit(journal_t *journal, tid_t tid);
-int journal_start_commit(journal_t *journal, tid_t *tid);
-int journal_force_commit_nested(journal_t *journal);
-int log_wait_commit(journal_t *journal, tid_t tid);
-int log_do_checkpoint(journal_t *journal);
+int __jbd2_log_space_left(journal_t *); /* Called with journal locked */
+int jbd2_log_start_commit(journal_t *journal, tid_t tid);
+int __jbd2_log_start_commit(journal_t *journal, tid_t tid);
+int jbd2_journal_start_commit(journal_t *journal, tid_t *tid);
+int jbd2_journal_force_commit_nested(journal_t *journal);
+int jbd2_log_wait_commit(journal_t *journal, tid_t tid);
+int jbd2_log_do_checkpoint(journal_t *journal);
 
-void __log_wait_for_space(journal_t *journal);
-extern void    __journal_drop_transaction(journal_t *, transaction_t *);
-extern int     cleanup_journal_tail(journal_t *);
+void __jbd2_log_wait_for_space(journal_t *journal);
+extern void __jbd2_journal_drop_transaction(journal_t *, transaction_t *);
+extern int jbd2_cleanup_journal_tail(journal_t *);
 
 /* Debugging code only: */
 
 #define jbd_ENOSYS() \
 do {                                                                      \
-       printk (KERN_ERR "JBD unimplemented function %s\n", __FUNCTION__); \
+       printk (KERN_ERR "JBD unimplemented function %s\n", __func__); \
        current->state = TASK_UNINTERRUPTIBLE;                             \
        schedule();                                                        \
 } while (1)
@@ -1010,7 +1204,7 @@ do {                                                                         \
 /*
  * is_journal_abort
  *
- * Simple test wrapper function to test the JFS_ABORT state flag.  This
+ * Simple test wrapper function to test the JBD2_ABORT state flag.  This
  * bit, when set, indicates that we have had a fatal error somewhere,
  * either inside the journaling layer or indicated to us by the client
  * (eg. ext3), and that we and should not commit any further
@@ -1019,7 +1213,7 @@ do {                                                                         \
 
 static inline int is_journal_aborted(journal_t *journal)
 {
-       return journal->j_flags & JFS_ABORT;
+       return journal->j_flags & JBD2_ABORT;
 }
 
 static inline int is_handle_aborted(handle_t *handle)
@@ -1029,7 +1223,7 @@ static inline int is_handle_aborted(handle_t *handle)
        return is_journal_aborted(handle->h_transaction->t_journal);
 }
 
-static inline void journal_abort_handle(handle_t *handle)
+static inline void jbd2_journal_abort_handle(handle_t *handle)
 {
        handle->h_aborted = 1;
 }
@@ -1051,7 +1245,8 @@ static inline int tid_geq(tid_t x, tid_t y)
        return (difference >= 0);
 }
 
-extern int journal_blocks_per_page(struct inode *inode);
+extern int jbd2_journal_blocks_per_page(struct inode *inode);
+extern size_t journal_tag_bytes(journal_t *journal);
 
 /*
  * Return the minimum number of blocks which must be free in the journal
@@ -1072,15 +1267,13 @@ static inline int jbd_space_needed(journal_t *journal)
 
 /* journaling buffer types */
 #define BJ_None                0       /* Not journaled */
-#define BJ_SyncData    1       /* Normal data: flush before commit */
-#define BJ_Metadata    2       /* Normal journaled metadata */
-#define BJ_Forget      3       /* Buffer superseded by this transaction */
-#define BJ_IO          4       /* Buffer is for temporary IO use */
-#define BJ_Shadow      5       /* Buffer contents being shadowed to the log */
-#define BJ_LogCtl      6       /* Buffer contains log descriptors */
-#define BJ_Reserved    7       /* Buffer is reserved for access by journal */
-#define BJ_Locked      8       /* Locked for I/O during commit */
-#define BJ_Types       9
+#define BJ_Metadata    1       /* Normal journaled metadata */
+#define BJ_Forget      2       /* Buffer superseded by this transaction */
+#define BJ_IO          3       /* Buffer is for temporary IO use */
+#define BJ_Shadow      4       /* Buffer contents being shadowed to the log */
+#define BJ_LogCtl      5       /* Buffer contains log descriptors */
+#define BJ_Reserved    6       /* Buffer is reserved for access by journal */
+#define BJ_Types       7
 
 extern int jbd_blocks_per_page(struct inode *inode);
 
@@ -1093,6 +1286,12 @@ extern int jbd_blocks_per_page(struct inode *inode);
 #define BUFFER_TRACE2(bh, bh2, info)   do {} while (0)
 #define JBUFFER_TRACE(jh, info)        do {} while (0)
 
+/* 
+ * jbd2_dev_to_name is a utility function used by the jbd2 and ext4 
+ * tracing infrastructure to map a dev_t to a device name.
+ */
+extern const char *jbd2_dev_to_name(dev_t device);
+
 #endif /* __KERNEL__ */
 
-#endif /* _LINUX_JBD_H */
+#endif /* _LINUX_JBD2_H */