Merge master.kernel.org:/pub/scm/linux/kernel/git/steve/gfs2-2.6-nmw
[pandora-kernel.git] / fs / gfs2 / recovery.c
index 0a8a4b8..d0c806b 100644 (file)
@@ -132,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;
 
@@ -143,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 ||
@@ -174,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;
@@ -205,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 (;;) {
@@ -245,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;
 
@@ -320,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);
@@ -363,7 +364,7 @@ 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);
@@ -372,11 +373,12 @@ static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
        u32 hash;
        struct buffer_head *bh;
        int error;
-       struct buffer_head bh_map;
+       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, 0, &bh_map, 1);
+       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 (!bh_map.b_blocknr) {
@@ -424,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;