]> 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 d916817fb6e3c2cb2e2604f91b41a6fc15488477..0a8a4b87dcc643038b36f3d56b2f6eb1f56d35f7 100644 (file)
@@ -1,10 +1,10 @@
 /*
  * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
- * Copyright (C) 2004-2005 Red Hat, Inc.  All rights reserved.
+ * Copyright (C) 2004-2006 Red Hat, Inc.  All rights reserved.
  *
  * 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>
 #include <linux/buffer_head.h>
 #include <linux/gfs2_ondisk.h>
 #include <linux/crc32.h>
-#include <asm/semaphore.h>
+#include <linux/lm_interface.h>
 
 #include "gfs2.h"
-#include "lm_interface.h"
 #include "incore.h"
 #include "bmap.h"
 #include "glock.h"
 int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk,
                           struct buffer_head **bh)
 {
-       struct gfs2_inode *ip = jd->jd_inode->u.generic_ip;
+       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_block_map(ip, blk, &new, &dblock,
-                              &extlen);
+       error = gfs2_extent_map(&ip->i_inode, blk, &new, &dblock, &extlen);
        if (error)
                return error;
        if (!dblock) {
@@ -49,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;
@@ -84,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;
@@ -139,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);
@@ -155,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;
@@ -192,7 +188,7 @@ static int find_good_lh(struct gfs2_jdesc *jd, unsigned int *blk,
                        *blk = 0;
 
                if (*blk == orig_blk) {
-                       gfs2_consist_inode(jd->jd_inode->u.generic_ip);
+                       gfs2_consist_inode(GFS2_I(jd->jd_inode));
                        return -EIO;
                }
        }
@@ -226,7 +222,7 @@ static int jhead_scan(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
                        continue;
 
                if (lh.lh_sequence == head->lh_sequence) {
-                       gfs2_consist_inode(jd->jd_inode->u.generic_ip);
+                       gfs2_consist_inode(GFS2_I(jd->jd_inode));
                        return -EIO;
                }
                if (lh.lh_sequence < head->lh_sequence)
@@ -252,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;
@@ -302,16 +298,15 @@ int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
 static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start,
                              unsigned int end, int pass)
 {
-       struct gfs2_inode *ip = jd->jd_inode->u.generic_ip;
-       struct gfs2_sbd *sdp = ip->i_sbd;
+       struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
        struct buffer_head *bh;
        struct gfs2_log_descriptor *ld;
        int error = 0;
        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);
@@ -329,10 +324,11 @@ 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) {
-                               gfs2_consist_inode(jd->jd_inode->u.generic_ip);
+                               gfs2_consist_inode(GFS2_I(jd->jd_inode));
                                error = -EIO;
                        }
                        brelse(bh);
@@ -369,27 +365,26 @@ static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start,
 
 static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
 {
-       struct gfs2_inode *ip = jd->jd_inode->u.generic_ip;
-       struct gfs2_sbd *sdp = ip->i_sbd;
+       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;
-       
+       struct buffer_head bh_map;
+
        lblock = head->lh_blkno;
        gfs2_replay_incr_blk(sdp, &lblock);
-       error = gfs2_block_map(ip, lblock, &new, &dblock, NULL);
+       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);
@@ -399,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);
@@ -427,8 +422,8 @@ static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
 
 int gfs2_recover_journal(struct gfs2_jdesc *jd)
 {
-       struct gfs2_inode *ip = jd->jd_inode->u.generic_ip;
-       struct gfs2_sbd *sdp = ip->i_sbd;
+       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_holder j_gh, ji_gh, t_gh;
        unsigned long t;
@@ -449,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;
                };
@@ -484,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;