]> err.no Git - linux-2.6/blobdiff - fs/gfs2/recovery.c
Merge branch 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus
[linux-2.6] / fs / gfs2 / recovery.c
index 7aabc03e4abdfc3da6c37ffe6ad42f6348cc353c..0a8a4b87dcc643038b36f3d56b2f6eb1f56d35f7 100644 (file)
@@ -4,7 +4,7 @@
  *
  * This copyrighted material is made available to anyone wishing to use,
  * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU General Public License v.2.
+ * of the GNU General Public License version 2.
  */
 
 #include <linux/sched.h>
@@ -14,9 +14,9 @@
 #include <linux/buffer_head.h>
 #include <linux/gfs2_ondisk.h>
 #include <linux/crc32.h>
+#include <linux/lm_interface.h>
 
 #include "gfs2.h"
-#include "lm_interface.h"
 #include "incore.h"
 #include "bmap.h"
 #include "glock.h"
@@ -35,8 +35,8 @@ int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk,
        struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
        struct gfs2_glock *gl = ip->i_gl;
        int new = 0;
-       uint64_t dblock;
-       uint32_t extlen;
+       u64 dblock;
+       u32 extlen;
        int error;
 
        error = gfs2_extent_map(&ip->i_inode, blk, &new, &dblock, &extlen);
@@ -47,13 +47,12 @@ int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk,
                return -EIO;
        }
 
-       gfs2_meta_ra(gl, dblock, extlen);
-       error = gfs2_meta_read(gl, dblock, DIO_START | DIO_WAIT, bh);
+       *bh = gfs2_meta_ra(gl, dblock, extlen);
 
        return error;
 }
 
-int gfs2_revoke_add(struct gfs2_sbd *sdp, uint64_t blkno, unsigned int where)
+int gfs2_revoke_add(struct gfs2_sbd *sdp, u64 blkno, unsigned int where)
 {
        struct list_head *head = &sdp->sd_revoke_list;
        struct gfs2_revoke_replay *rr;
@@ -82,7 +81,7 @@ int gfs2_revoke_add(struct gfs2_sbd *sdp, uint64_t blkno, unsigned int where)
        return 1;
 }
 
-int gfs2_revoke_check(struct gfs2_sbd *sdp, uint64_t blkno, unsigned int where)
+int gfs2_revoke_check(struct gfs2_sbd *sdp, u64 blkno, unsigned int where)
 {
        struct gfs2_revoke_replay *rr;
        int wrap, a, b, revoke;
@@ -137,7 +136,7 @@ static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk,
 {
        struct buffer_head *bh;
        struct gfs2_log_header lh;
-       uint32_t hash;
+       u32 hash;
        int error;
 
        error = gfs2_replay_read_block(jd, blk, &bh);
@@ -153,8 +152,7 @@ static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk,
 
        if (lh.lh_header.mh_magic != GFS2_MAGIC ||
            lh.lh_header.mh_type != GFS2_METATYPE_LH ||
-           lh.lh_blkno != blk ||
-           lh.lh_hash != hash)
+           lh.lh_blkno != blk || lh.lh_hash != hash)
                return 1;
 
        *head = lh;
@@ -250,7 +248,7 @@ static int jhead_scan(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
 int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
 {
        struct gfs2_log_header lh_1, lh_m;
-       uint32_t blk_1, blk_2, blk_m;
+       u32 blk_1, blk_2, blk_m;
        int error;
 
        blk_1 = 0;
@@ -307,8 +305,8 @@ static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start,
        u32 length;
        __be64 *ptr;
        unsigned int offset = sizeof(struct gfs2_log_descriptor);
-       offset += (sizeof(__be64)-1);
-       offset &= ~(sizeof(__be64)-1);
+       offset += sizeof(__be64) - 1;
+       offset &= ~(sizeof(__be64) - 1);
 
        while (start != end) {
                error = gfs2_replay_read_block(jd, start, &bh);
@@ -326,6 +324,7 @@ static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start,
                        error = get_log_header(jd, start, &lh);
                        if (!error) {
                                gfs2_replay_incr_blk(sdp, &start);
+                               brelse(bh);
                                continue;
                        }
                        if (error == 1) {
@@ -369,25 +368,23 @@ static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
        struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
        struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
        unsigned int lblock;
-       int new = 0;
-       uint64_t dblock;
        struct gfs2_log_header *lh;
-       uint32_t hash;
+       u32 hash;
        struct buffer_head *bh;
        int error;
-       int boundary;
+       struct buffer_head bh_map;
 
        lblock = head->lh_blkno;
        gfs2_replay_incr_blk(sdp, &lblock);
-       error = gfs2_block_map(&ip->i_inode, lblock, &new, &dblock, &boundary);
+       error = gfs2_block_map(&ip->i_inode, lblock, 0, &bh_map, 1);
        if (error)
                return error;
-       if (!dblock) {
+       if (!bh_map.b_blocknr) {
                gfs2_consist_inode(ip);
                return -EIO;
        }
 
-       bh = sb_getblk(sdp->sd_vfs, dblock);
+       bh = sb_getblk(sdp->sd_vfs, bh_map.b_blocknr);
        lock_buffer(bh);
        memset(bh->b_data, 0, bh->b_size);
        set_buffer_uptodate(bh);
@@ -397,7 +394,7 @@ static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
        lh = (struct gfs2_log_header *)bh->b_data;
        memset(lh, 0, sizeof(struct gfs2_log_header));
        lh->lh_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
-       lh->lh_header.mh_type = cpu_to_be16(GFS2_METATYPE_LH);
+       lh->lh_header.mh_type = cpu_to_be32(GFS2_METATYPE_LH);
        lh->lh_header.mh_format = cpu_to_be32(GFS2_FORMAT_LH);
        lh->lh_sequence = cpu_to_be64(head->lh_sequence + 1);
        lh->lh_flags = cpu_to_be32(GFS2_LOG_HEAD_UNMOUNT);
@@ -447,11 +444,11 @@ int gfs2_recover_journal(struct gfs2_jdesc *jd)
                switch (error) {
                case 0:
                        break;
-       
+
                case GLR_TRYFAILED:
                        fs_info(sdp, "jid=%u: Busy\n", jd->jd_jid);
                        error = 0;
-       
+
                default:
                        goto fail;
                };
@@ -482,11 +479,9 @@ int gfs2_recover_journal(struct gfs2_jdesc *jd)
 
                /* Acquire a shared hold on the transaction lock */
 
-               error = gfs2_glock_nq_init(sdp->sd_trans_gl,
-                                          LM_ST_SHARED,
+               error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_SHARED,
                                           LM_FLAG_NOEXP | LM_FLAG_PRIORITY |
-                                          GL_NOCANCEL | GL_NOCACHE,
-                                          &t_gh);
+                                          GL_NOCANCEL | GL_NOCACHE, &t_gh);
                if (error)
                        goto fail_gunlock_ji;