]> git.ipfire.org Git - thirdparty/kernel/stable.git/blobdiff - fs/jbd2/journal.c
jbd2: introduce jbd2_inode dirty range scoping
[thirdparty/kernel/stable.git] / fs / jbd2 / journal.c
index 37e16d969925683bfc03d9a020396cbe2ec55756..17f679aeba7c7a6ae0c6eeb6003cd68bac560228 100644 (file)
@@ -94,6 +94,8 @@ EXPORT_SYMBOL(jbd2_journal_try_to_free_buffers);
 EXPORT_SYMBOL(jbd2_journal_force_commit);
 EXPORT_SYMBOL(jbd2_journal_inode_add_write);
 EXPORT_SYMBOL(jbd2_journal_inode_add_wait);
+EXPORT_SYMBOL(jbd2_journal_inode_ranged_write);
+EXPORT_SYMBOL(jbd2_journal_inode_ranged_wait);
 EXPORT_SYMBOL(jbd2_journal_init_jbd_inode);
 EXPORT_SYMBOL(jbd2_journal_release_jbd_inode);
 EXPORT_SYMBOL(jbd2_journal_begin_ordered_truncate);
@@ -203,7 +205,7 @@ loop:
        if (journal->j_flags & JBD2_UNMOUNT)
                goto end_loop;
 
-       jbd_debug(1, "commit_sequence=%d, commit_request=%d\n",
+       jbd_debug(1, "commit_sequence=%u, commit_request=%u\n",
                journal->j_commit_sequence, journal->j_commit_request);
 
        if (journal->j_commit_sequence != journal->j_commit_request) {
@@ -324,7 +326,7 @@ static void journal_kill_thread(journal_t *journal)
  * IO is in progress. do_get_write_access() handles this.
  *
  * The function returns a pointer to the buffer_head to be used for IO.
- * 
+ *
  *
  * Return value:
  *  <0: Error
@@ -500,7 +502,7 @@ int __jbd2_log_start_commit(journal_t *journal, tid_t target)
                 */
 
                journal->j_commit_request = target;
-               jbd_debug(1, "JBD2: requesting commit %d/%d\n",
+               jbd_debug(1, "JBD2: requesting commit %u/%u\n",
                          journal->j_commit_request,
                          journal->j_commit_sequence);
                journal->j_running_transaction->t_requested = jiffies;
@@ -513,7 +515,7 @@ int __jbd2_log_start_commit(journal_t *journal, tid_t target)
                WARN_ONCE(1, "JBD2: bad log_start_commit: %u %u %u %u\n",
                          journal->j_commit_request,
                          journal->j_commit_sequence,
-                         target, journal->j_running_transaction ? 
+                         target, journal->j_running_transaction ?
                          journal->j_running_transaction->t_tid : 0);
        return 0;
 }
@@ -698,12 +700,12 @@ int jbd2_log_wait_commit(journal_t *journal, tid_t tid)
 #ifdef CONFIG_JBD2_DEBUG
        if (!tid_geq(journal->j_commit_request, tid)) {
                printk(KERN_ERR
-                      "%s: error: j_commit_request=%d, tid=%d\n",
+                      "%s: error: j_commit_request=%u, tid=%u\n",
                       __func__, journal->j_commit_request, tid);
        }
 #endif
        while (tid_gt(tid, journal->j_commit_sequence)) {
-               jbd_debug(1, "JBD2: want %d, j_commit_sequence=%d\n",
+               jbd_debug(1, "JBD2: want %u, j_commit_sequence=%u\n",
                                  tid, journal->j_commit_sequence);
                read_unlock(&journal->j_state_lock);
                wake_up(&journal->j_wait_commit);
@@ -944,7 +946,7 @@ int __jbd2_update_log_tail(journal_t *journal, tid_t tid, unsigned long block)
 
        trace_jbd2_update_log_tail(journal, tid, block, freed);
        jbd_debug(1,
-                 "Cleaning journal tail from %d to %d (offset %lu), "
+                 "Cleaning journal tail from %u to %u (offset %lu), "
                  "freeing %lu\n",
                  journal->j_tail_sequence, tid, block, freed);
 
@@ -1318,7 +1320,7 @@ static int journal_reset(journal_t *journal)
         */
        if (sb->s_start == 0) {
                jbd_debug(1, "JBD2: Skipping superblock update on recovered sb "
-                       "(start %ld, seq %d, errno %d)\n",
+                       "(start %ld, seq %u, errno %d)\n",
                        journal->j_tail, journal->j_tail_sequence,
                        journal->j_errno);
                journal->j_flags |= JBD2_FLUSHED;
@@ -1453,7 +1455,7 @@ static void jbd2_mark_journal_empty(journal_t *journal, int write_op)
                return;
        }
 
-       jbd_debug(1, "JBD2: Marking journal as empty (seq %d)\n",
+       jbd_debug(1, "JBD2: Marking journal as empty (seq %u)\n",
                  journal->j_tail_sequence);
 
        sb->s_sequence = cpu_to_be32(journal->j_tail_sequence);
@@ -2375,22 +2377,19 @@ static struct kmem_cache *jbd2_journal_head_cache;
 static atomic_t nr_journal_heads = ATOMIC_INIT(0);
 #endif
 
-static int jbd2_journal_init_journal_head_cache(void)
+static int __init jbd2_journal_init_journal_head_cache(void)
 {
-       int retval;
-
-       J_ASSERT(jbd2_journal_head_cache == NULL);
+       J_ASSERT(!jbd2_journal_head_cache);
        jbd2_journal_head_cache = kmem_cache_create("jbd2_journal_head",
                                sizeof(struct journal_head),
                                0,              /* offset */
                                SLAB_TEMPORARY | SLAB_TYPESAFE_BY_RCU,
                                NULL);          /* ctor */
-       retval = 0;
        if (!jbd2_journal_head_cache) {
-               retval = -ENOMEM;
                printk(KERN_EMERG "JBD2: no memory for journal_head cache\n");
+               return -ENOMEM;
        }
-       return retval;
+       return 0;
 }
 
 static void jbd2_journal_destroy_journal_head_cache(void)
@@ -2577,6 +2576,8 @@ void jbd2_journal_init_jbd_inode(struct jbd2_inode *jinode, struct inode *inode)
        jinode->i_next_transaction = NULL;
        jinode->i_vfs_inode = inode;
        jinode->i_flags = 0;
+       jinode->i_dirty_start = 0;
+       jinode->i_dirty_end = 0;
        INIT_LIST_HEAD(&jinode->i_list);
 }
 
@@ -2636,28 +2637,38 @@ static void __exit jbd2_remove_jbd_stats_proc_entry(void)
 
 struct kmem_cache *jbd2_handle_cache, *jbd2_inode_cache;
 
+static int __init jbd2_journal_init_inode_cache(void)
+{
+       J_ASSERT(!jbd2_inode_cache);
+       jbd2_inode_cache = KMEM_CACHE(jbd2_inode, 0);
+       if (!jbd2_inode_cache) {
+               pr_emerg("JBD2: failed to create inode cache\n");
+               return -ENOMEM;
+       }
+       return 0;
+}
+
 static int __init jbd2_journal_init_handle_cache(void)
 {
+       J_ASSERT(!jbd2_handle_cache);
        jbd2_handle_cache = KMEM_CACHE(jbd2_journal_handle, SLAB_TEMPORARY);
-       if (jbd2_handle_cache == NULL) {
+       if (!jbd2_handle_cache) {
                printk(KERN_EMERG "JBD2: failed to create handle cache\n");
                return -ENOMEM;
        }
-       jbd2_inode_cache = KMEM_CACHE(jbd2_inode, 0);
-       if (jbd2_inode_cache == NULL) {
-               printk(KERN_EMERG "JBD2: failed to create inode cache\n");
-               kmem_cache_destroy(jbd2_handle_cache);
-               return -ENOMEM;
-       }
        return 0;
 }
 
+static void jbd2_journal_destroy_inode_cache(void)
+{
+       kmem_cache_destroy(jbd2_inode_cache);
+       jbd2_inode_cache = NULL;
+}
+
 static void jbd2_journal_destroy_handle_cache(void)
 {
        kmem_cache_destroy(jbd2_handle_cache);
        jbd2_handle_cache = NULL;
-       kmem_cache_destroy(jbd2_inode_cache);
-       jbd2_inode_cache = NULL;
 }
 
 /*
@@ -2668,11 +2679,15 @@ static int __init journal_init_caches(void)
 {
        int ret;
 
-       ret = jbd2_journal_init_revoke_caches();
+       ret = jbd2_journal_init_revoke_record_cache();
+       if (ret == 0)
+               ret = jbd2_journal_init_revoke_table_cache();
        if (ret == 0)
                ret = jbd2_journal_init_journal_head_cache();
        if (ret == 0)
                ret = jbd2_journal_init_handle_cache();
+       if (ret == 0)
+               ret = jbd2_journal_init_inode_cache();
        if (ret == 0)
                ret = jbd2_journal_init_transaction_cache();
        return ret;
@@ -2680,9 +2695,11 @@ static int __init journal_init_caches(void)
 
 static void jbd2_journal_destroy_caches(void)
 {
-       jbd2_journal_destroy_revoke_caches();
+       jbd2_journal_destroy_revoke_record_cache();
+       jbd2_journal_destroy_revoke_table_cache();
        jbd2_journal_destroy_journal_head_cache();
        jbd2_journal_destroy_handle_cache();
+       jbd2_journal_destroy_inode_cache();
        jbd2_journal_destroy_transaction_cache();
        jbd2_journal_destroy_slabs();
 }