[GFS2] Fix Kconfig
[safe/jmp/linux-2.6] / fs / gfs2 / recovery.c
index ab55191..d0c806b 100644 (file)
@@ -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"
@@ -47,8 +47,7 @@ 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;
 }
@@ -133,10 +132,11 @@ void gfs2_revoke_clean(struct gfs2_sbd *sdp)
  */
 
 static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk,
-                         struct gfs2_log_header *head)
+                         struct gfs2_log_header_host *head)
 {
        struct buffer_head *bh;
-       struct gfs2_log_header lh;
+       struct gfs2_log_header_host lh;
+       const u32 nothing = 0;
        u32 hash;
        int error;
 
@@ -144,11 +144,11 @@ static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk,
        if (error)
                return error;
 
-       memcpy(&lh, bh->b_data, sizeof(struct gfs2_log_header));
-       lh.lh_hash = 0;
-       hash = gfs2_disk_hash((char *)&lh, sizeof(struct gfs2_log_header));
+       hash = crc32_le((u32)~0, bh->b_data, sizeof(struct gfs2_log_header) -
+                                            sizeof(u32));
+       hash = crc32_le(hash, (unsigned char const *)&nothing, sizeof(nothing));
+       hash ^= (u32)~0;
        gfs2_log_header_in(&lh, bh->b_data);
-
        brelse(bh);
 
        if (lh.lh_header.mh_magic != GFS2_MAGIC ||
@@ -175,7 +175,7 @@ static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk,
  */
 
 static int find_good_lh(struct gfs2_jdesc *jd, unsigned int *blk,
-                       struct gfs2_log_header *head)
+                       struct gfs2_log_header_host *head)
 {
        unsigned int orig_blk = *blk;
        int error;
@@ -206,10 +206,10 @@ static int find_good_lh(struct gfs2_jdesc *jd, unsigned int *blk,
  * Returns: errno
  */
 
-static int jhead_scan(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
+static int jhead_scan(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head)
 {
        unsigned int blk = head->lh_blkno;
-       struct gfs2_log_header lh;
+       struct gfs2_log_header_host lh;
        int error;
 
        for (;;) {
@@ -246,9 +246,9 @@ static int jhead_scan(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
  * Returns: errno
  */
 
-int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
+int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head)
 {
-       struct gfs2_log_header lh_1, lh_m;
+       struct gfs2_log_header_host lh_1, lh_m;
        u32 blk_1, blk_2, blk_m;
        int error;
 
@@ -306,8 +306,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);
@@ -321,7 +321,7 @@ static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start,
                length = be32_to_cpu(ld->ld_length);
 
                if (be32_to_cpu(ld->ld_header.mh_type) == GFS2_METATYPE_LH) {
-                       struct gfs2_log_header lh;
+                       struct gfs2_log_header_host lh;
                        error = get_log_header(jd, start, &lh);
                        if (!error) {
                                gfs2_replay_incr_blk(sdp, &start);
@@ -364,30 +364,29 @@ static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start,
  * Returns: errno
  */
 
-static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
+static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header_host *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;
-       u64 dblock;
        struct gfs2_log_header *lh;
        u32 hash;
        struct buffer_head *bh;
        int error;
-       int boundary;
+       struct buffer_head bh_map = { .b_state = 0, .b_blocknr = 0 };
 
        lblock = head->lh_blkno;
        gfs2_replay_incr_blk(sdp, &lblock);
-       error = gfs2_block_map(&ip->i_inode, lblock, &new, &dblock, &boundary);
+       bh_map.b_size = 1 << ip->i_inode.i_blkbits;
+       error = gfs2_block_map(&ip->i_inode, lblock, 0, &bh_map);
        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);
@@ -427,7 +426,7 @@ int gfs2_recover_journal(struct gfs2_jdesc *jd)
 {
        struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
        struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
-       struct gfs2_log_header head;
+       struct gfs2_log_header_host head;
        struct gfs2_holder j_gh, ji_gh, t_gh;
        unsigned long t;
        int ro = 0;
@@ -447,11 +446,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;
                };