Merge git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus
[linux-2.6.git] / fs / jbd / recovery.c
index 445eed6..5b43e96 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * linux/fs/recovery.c
+ * linux/fs/jbd/recovery.c
  *
  * Written by Stephen C. Tweedie <sct@redhat.com>, 1999
  *
@@ -20,7 +20,6 @@
 #include <linux/fs.h>
 #include <linux/jbd.h>
 #include <linux/errno.h>
-#include <linux/slab.h>
 #endif
 
 /*
@@ -46,7 +45,7 @@ static int scan_revoke_records(journal_t *, struct buffer_head *,
 #ifdef __KERNEL__
 
 /* Release readahead buffers after use */
-void journal_brelse_array(struct buffer_head *b[], int n)
+static void journal_brelse_array(struct buffer_head *b[], int n)
 {
        while (--n >= 0)
                brelse (b[n]);
@@ -70,7 +69,7 @@ static int do_readahead(journal_t *journal, unsigned int start)
 {
        int err;
        unsigned int max, nbufs, next;
-       unsigned long blocknr;
+       unsigned int blocknr;
        struct buffer_head *bh;
 
        struct buffer_head * bufs[MAXBUF];
@@ -132,7 +131,7 @@ static int jread(struct buffer_head **bhp, journal_t *journal,
                 unsigned int offset)
 {
        int err;
-       unsigned long blocknr;
+       unsigned int blocknr;
        struct buffer_head *bh;
 
        *bhp = NULL;
@@ -223,7 +222,7 @@ do {                                                                        \
  */
 int journal_recover(journal_t *journal)
 {
-       int                     err;
+       int                     err, err2;
        journal_superblock_t *  sb;
 
        struct recovery_info    info;
@@ -250,10 +249,10 @@ int journal_recover(journal_t *journal)
        if (!err)
                err = do_one_pass(journal, &info, PASS_REPLAY);
 
-       jbd_debug(0, "JBD: recovery, exit status %d, "
+       jbd_debug(1, "JBD: recovery, exit status %d, "
                  "recovered transactions %u to %u\n",
                  err, info.start_transaction, info.end_transaction);
-       jbd_debug(0, "JBD: Replayed %d and revoked %d/%d blocks\n",
+       jbd_debug(1, "JBD: Replayed %d and revoked %d/%d blocks\n",
                  info.nr_replays, info.nr_revoke_hits, info.nr_revokes);
 
        /* Restart the log at the next transaction ID, thus invalidating
@@ -261,7 +260,10 @@ int journal_recover(journal_t *journal)
        journal->j_transaction_sequence = ++info.end_transaction;
 
        journal_clear_revoke(journal);
-       sync_blockdev(journal->j_fs_dev);
+       err2 = sync_blockdev(journal->j_fs_dev);
+       if (!err)
+               err = err2;
+
        return err;
 }
 
@@ -281,12 +283,9 @@ int journal_recover(journal_t *journal)
 int journal_skip_recovery(journal_t *journal)
 {
        int                     err;
-       journal_superblock_t *  sb;
-
        struct recovery_info    info;
 
        memset (&info, 0, sizeof(info));
-       sb = journal->j_superblock;
 
        err = do_one_pass(journal, &info, PASS_SCAN);
 
@@ -295,11 +294,12 @@ int journal_skip_recovery(journal_t *journal)
                ++journal->j_transaction_sequence;
        } else {
 #ifdef CONFIG_JBD_DEBUG
-               int dropped = info.end_transaction - be32_to_cpu(sb->s_sequence);
-#endif
-               jbd_debug(0,
+               int dropped = info.end_transaction -
+                             be32_to_cpu(journal->j_superblock->s_sequence);
+               jbd_debug(1,
                          "JBD: ignoring %d transaction%s from the journal.\n",
                          dropped, (dropped == 1) ? "" : "s");
+#endif
                journal->j_transaction_sequence = ++info.end_transaction;
        }
 
@@ -311,7 +311,7 @@ static int do_one_pass(journal_t *journal,
                        struct recovery_info *info, enum passtype pass)
 {
        unsigned int            first_commit_ID, next_commit_ID;
-       unsigned long           next_log_block;
+       unsigned int            next_log_block;
        int                     err, success = 0;
        journal_superblock_t *  sb;
        journal_header_t *      tmp;
@@ -319,11 +319,6 @@ static int do_one_pass(journal_t *journal,
        unsigned int            sequence;
        int                     blocktype;
 
-       /* Precompute the maximum metadata descriptors in a descriptor block */
-       int                     MAX_BLOCKS_PER_DESC;
-       MAX_BLOCKS_PER_DESC = ((journal->j_blocksize-sizeof(journal_header_t))
-                              / sizeof(journal_block_tag_t));
-
        /*
         * First thing is to establish what we expect to find in the log
         * (in terms of transaction IDs), and where (in terms of log
@@ -354,7 +349,7 @@ static int do_one_pass(journal_t *journal,
                struct buffer_head *    obh;
                struct buffer_head *    nbh;
 
-               cond_resched();         /* We're under lock_kernel() */
+               cond_resched();
 
                /* If we already know where to stop the log traversal,
                 * check right now that we haven't gone past the end of
@@ -364,14 +359,14 @@ static int do_one_pass(journal_t *journal,
                        if (tid_geq(next_commit_ID, info->end_transaction))
                                break;
 
-               jbd_debug(2, "Scanning for sequence ID %u at %lu/%lu\n",
+               jbd_debug(2, "Scanning for sequence ID %u at %u/%u\n",
                          next_commit_ID, next_log_block, journal->j_last);
 
                /* Skip over each chunk of the transaction looking
                 * either the next descriptor block or the final commit
                 * record. */
 
-               jbd_debug(3, "JBD: checking block %ld\n", next_log_block);
+               jbd_debug(3, "JBD: checking block %u\n", next_log_block);
                err = jread(&bh, journal, next_log_block);
                if (err)
                        goto failed;
@@ -426,7 +421,7 @@ static int do_one_pass(journal_t *journal,
                        tagp = &bh->b_data[sizeof(journal_header_t)];
                        while ((tagp - bh->b_data +sizeof(journal_block_tag_t))
                               <= journal->j_blocksize) {
-                               unsigned long io_block;
+                               unsigned int io_block;
 
                                tag = (journal_block_tag_t *) tagp;
                                flags = be32_to_cpu(tag->t_flags);
@@ -440,10 +435,10 @@ static int do_one_pass(journal_t *journal,
                                        success = err;
                                        printk (KERN_ERR
                                                "JBD: IO error %d recovering "
-                                               "block %ld in log\n",
+                                               "block %u in log\n",
                                                err, io_block);
                                } else {
-                                       unsigned long blocknr;
+                                       unsigned int blocknr;
 
                                        J_ASSERT(obh != NULL);
                                        blocknr = be32_to_cpu(tag->t_blocknr);
@@ -478,7 +473,7 @@ static int do_one_pass(journal_t *journal,
                                        memcpy(nbh->b_data, obh->b_data,
                                                        journal->j_blocksize);
                                        if (flags & JFS_FLAG_ESCAPE) {
-                                               *((__be32 *)bh->b_data) =
+                                               *((__be32 *)nbh->b_data) =
                                                cpu_to_be32(JFS_MAGIC_NUMBER);
                                        }
 
@@ -578,7 +573,7 @@ static int scan_revoke_records(journal_t *journal, struct buffer_head *bh,
        max = be32_to_cpu(header->r_count);
 
        while (offset < max) {
-               unsigned long blocknr;
+               unsigned int blocknr;
                int err;
 
                blocknr = be32_to_cpu(* ((__be32 *) (bh->b_data+offset)));