ext4 / jbd2: add fast commit initialization
[linux-2.6-microblaze.git] / include / linux / jbd2.h
index 08f9049..008629b 100644 (file)
@@ -289,6 +289,7 @@ typedef struct journal_superblock_s
 #define JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT     0x00000004
 #define JBD2_FEATURE_INCOMPAT_CSUM_V2          0x00000008
 #define JBD2_FEATURE_INCOMPAT_CSUM_V3          0x00000010
+#define JBD2_FEATURE_INCOMPAT_FAST_COMMIT      0x00000020
 
 /* See "journal feature predicate functions" below */
 
@@ -299,7 +300,8 @@ typedef struct journal_superblock_s
                                        JBD2_FEATURE_INCOMPAT_64BIT | \
                                        JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT | \
                                        JBD2_FEATURE_INCOMPAT_CSUM_V2 | \
-                                       JBD2_FEATURE_INCOMPAT_CSUM_V3)
+                                       JBD2_FEATURE_INCOMPAT_CSUM_V3 | \
+                                       JBD2_FEATURE_INCOMPAT_FAST_COMMIT)
 
 #ifdef __KERNEL__
 
@@ -452,8 +454,8 @@ struct jbd2_inode {
 struct jbd2_revoke_table_s;
 
 /**
- * struct handle_s - The handle_s type is the concrete type associated with
- *     handle_t.
+ * struct jbd2_journal_handle - The jbd2_journal_handle type is the concrete
+ *     type associated with handle_t.
  * @h_transaction: Which compound transaction is this update a part of?
  * @h_journal: Which journal handle belongs to - used iff h_reserved set.
  * @h_rsv_handle: Handle reserved for finishing the logical operation.
@@ -629,7 +631,9 @@ struct transaction_s
        struct journal_head     *t_shadow_list;
 
        /*
-        * List of inodes whose data we've modified in data=ordered mode.
+        * List of inodes associated with the transaction; e.g., ext4 uses
+        * this to track inodes in data=ordered and data=journal mode that
+        * need special handling on transaction commit; also used by ocfs2.
         * [j_list_lock]
         */
        struct list_head        t_inode_list;
@@ -914,6 +918,30 @@ struct journal_s
         */
        unsigned long           j_last;
 
+       /**
+        * @j_fc_first:
+        *
+        * The block number of the first fast commit block in the journal
+        * [j_state_lock].
+        */
+       unsigned long           j_fc_first;
+
+       /**
+        * @j_fc_off:
+        *
+        * Number of fast commit blocks currently allocated.
+        * [j_state_lock].
+        */
+       unsigned long           j_fc_off;
+
+       /**
+        * @j_fc_last:
+        *
+        * The block number one beyond the last fast commit block in the journal
+        * [j_state_lock].
+        */
+       unsigned long           j_fc_last;
+
        /**
         * @j_dev: Device where we store the journal.
         */
@@ -1064,6 +1092,12 @@ struct journal_s
         */
        struct buffer_head      **j_wbuf;
 
+       /**
+        * @j_fc_wbuf: Array of fast commit bhs for
+        * jbd2_journal_commit_transaction.
+        */
+       struct buffer_head      **j_fc_wbuf;
+
        /**
         * @j_wbufsize:
         *
@@ -1071,6 +1105,13 @@ struct journal_s
         */
        int                     j_wbufsize;
 
+       /**
+        * @j_fc_wbufsize:
+        *
+        * Size of @j_fc_wbuf array.
+        */
+       int                     j_fc_wbufsize;
+
        /**
         * @j_last_sync_writer:
         *
@@ -1111,6 +1152,27 @@ struct journal_s
        void                    (*j_commit_callback)(journal_t *,
                                                     transaction_t *);
 
+       /**
+        * @j_submit_inode_data_buffers:
+        *
+        * This function is called for all inodes associated with the
+        * committing transaction marked with JI_WRITE_DATA flag
+        * before we start to write out the transaction to the journal.
+        */
+       int                     (*j_submit_inode_data_buffers)
+                                       (struct jbd2_inode *);
+
+       /**
+        * @j_finish_inode_data_buffers:
+        *
+        * This function is called for all inodes associated with the
+        * committing transaction marked with JI_WAIT_DATA flag
+        * after we have written the transaction to the journal
+        * but before we write out the commit block.
+        */
+       int                     (*j_finish_inode_data_buffers)
+                                       (struct jbd2_inode *);
+
        /*
         * Journal statistics
         */
@@ -1240,6 +1302,7 @@ JBD2_FEATURE_INCOMPAT_FUNCS(64bit,                64BIT)
 JBD2_FEATURE_INCOMPAT_FUNCS(async_commit,      ASYNC_COMMIT)
 JBD2_FEATURE_INCOMPAT_FUNCS(csum2,             CSUM_V2)
 JBD2_FEATURE_INCOMPAT_FUNCS(csum3,             CSUM_V3)
+JBD2_FEATURE_INCOMPAT_FUNCS(fast_commit,       FAST_COMMIT)
 
 /*
  * Journal flag definitions
@@ -1421,6 +1484,10 @@ extern int          jbd2_journal_inode_ranged_write(handle_t *handle,
 extern int        jbd2_journal_inode_ranged_wait(handle_t *handle,
                        struct jbd2_inode *inode, loff_t start_byte,
                        loff_t length);
+extern int        jbd2_journal_submit_inode_data_buffers(
+                       struct jbd2_inode *jinode);
+extern int        jbd2_journal_finish_inode_data_buffers(
+                       struct jbd2_inode *jinode);
 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);
@@ -1505,6 +1572,8 @@ 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 *);
 
+/* Fast commit related APIs */
+int jbd2_fc_init(journal_t *journal, int num_fc_blks);
 /*
  * is_journal_abort
  *