]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/gfs2/super.c
[PATCH] ufs endianness annotations
[linux-2.6-omap-h63xx.git] / fs / gfs2 / super.c
index a943a505bc5ab6147494314b0187a1171740834c..6a78b1b32e25597fac6a2ef0e0f13d7a2c3be78e 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>
 #include <linux/buffer_head.h>
 #include <linux/crc32.h>
 #include <linux/gfs2_ondisk.h>
+#include <linux/bio.h>
+#include <linux/lm_interface.h>
 
 #include "gfs2.h"
-#include "lm_interface.h"
 #include "incore.h"
 #include "bmap.h"
 #include "dir.h"
-#include "format.h"
 #include "glock.h"
 #include "glops.h"
 #include "inode.h"
 #include "rgrp.h"
 #include "super.h"
 #include "trans.h"
-#include "unlinked.h"
 #include "util.h"
 
+static const u32 gfs2_old_fs_formats[] = {
+        0
+};
+
+static const u32 gfs2_old_multihost_formats[] = {
+        0
+};
+
 /**
  * gfs2_tune_init - Fill a gfs2_tune structure with default values
  * @gt: tune
@@ -55,7 +62,6 @@ void gfs2_tune_init(struct gfs2_tune *gt)
        gt->gt_recoverd_secs = 60;
        gt->gt_logd_secs = 1;
        gt->gt_quotad_secs = 5;
-       gt->gt_inoded_secs = 15;
        gt->gt_quota_simul_sync = 64;
        gt->gt_quota_warn_period = 10;
        gt->gt_quota_scale_num = 1;
@@ -159,6 +165,56 @@ int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb *sb, int silent)
        return 0;
 }
 
+
+static int end_bio_io_page(struct bio *bio, unsigned int bytes_done, int error)
+{
+       struct page *page = bio->bi_private;
+       if (bio->bi_size)
+               return 1;
+
+       if (!error)
+               SetPageUptodate(page);
+       else
+               printk(KERN_WARNING "gfs2: error %d reading superblock\n", error);
+       unlock_page(page);
+       return 0;
+}
+
+struct page *gfs2_read_super(struct super_block *sb, sector_t sector)
+{
+       struct page *page;
+       struct bio *bio;
+
+       page = alloc_page(GFP_KERNEL);
+       if (unlikely(!page))
+               return NULL;
+
+       ClearPageUptodate(page);
+       ClearPageDirty(page);
+       lock_page(page);
+
+       bio = bio_alloc(GFP_KERNEL, 1);
+       if (unlikely(!bio)) {
+               __free_page(page);
+               return NULL;
+       }
+
+       bio->bi_sector = sector;
+       bio->bi_bdev = sb->s_bdev;
+       bio_add_page(bio, page, PAGE_SIZE, 0);
+
+       bio->bi_end_io = end_bio_io_page;
+       bio->bi_private = page;
+       submit_bio(READ_SYNC | (1 << BIO_RW_META), bio);
+       wait_on_page_locked(page);
+       bio_put(bio);
+       if (!PageUptodate(page)) {
+               __free_page(page);
+               return NULL;
+       }
+       return page;
+}
+
 /**
  * gfs2_read_sb - Read super block
  * @sdp: The GFS2 superblock
@@ -169,23 +225,23 @@ int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb *sb, int silent)
 
 int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent)
 {
-       struct buffer_head *bh;
-       uint32_t hash_blocks, ind_blocks, leaf_blocks;
-       uint32_t tmp_blocks;
+       u32 hash_blocks, ind_blocks, leaf_blocks;
+       u32 tmp_blocks;
        unsigned int x;
        int error;
+       struct page *page;
+       char *sb;
 
-       error = gfs2_meta_read(gl, GFS2_SB_ADDR >> sdp->sd_fsb2bb_shift,
-                              DIO_FORCE | DIO_START | DIO_WAIT, &bh);
-       if (error) {
+       page = gfs2_read_super(sdp->sd_vfs, GFS2_SB_ADDR >> sdp->sd_fsb2bb_shift);
+       if (!page) {
                if (!silent)
                        fs_err(sdp, "can't read superblock\n");
-               return error;
+               return -EIO;
        }
-
-       gfs2_assert(sdp, sizeof(struct gfs2_sb) <= bh->b_size);
-       gfs2_sb_in(&sdp->sd_sb, bh->b_data);
-       brelse(bh);
+       sb = kmap(page);
+       gfs2_sb_in(&sdp->sd_sb, sb);
+       kunmap(page);
+       __free_page(page);
 
        error = gfs2_check_sb(sdp, &sdp->sd_sb, silent);
        if (error)
@@ -195,23 +251,20 @@ int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent)
                               GFS2_BASIC_BLOCK_SHIFT;
        sdp->sd_fsb2bb = 1 << sdp->sd_fsb2bb_shift;
        sdp->sd_diptrs = (sdp->sd_sb.sb_bsize -
-                         sizeof(struct gfs2_dinode)) / sizeof(uint64_t);
+                         sizeof(struct gfs2_dinode)) / sizeof(u64);
        sdp->sd_inptrs = (sdp->sd_sb.sb_bsize -
-                         sizeof(struct gfs2_meta_header)) / sizeof(uint64_t);
+                         sizeof(struct gfs2_meta_header)) / sizeof(u64);
        sdp->sd_jbsize = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header);
        sdp->sd_hash_bsize = sdp->sd_sb.sb_bsize / 2;
        sdp->sd_hash_bsize_shift = sdp->sd_sb.sb_bsize_shift - 1;
-       sdp->sd_hash_ptrs = sdp->sd_hash_bsize / sizeof(uint64_t);
-       sdp->sd_ut_per_block = (sdp->sd_sb.sb_bsize -
-                               sizeof(struct gfs2_meta_header)) /
-                              sizeof(struct gfs2_unlinked_tag);
+       sdp->sd_hash_ptrs = sdp->sd_hash_bsize / sizeof(u64);
        sdp->sd_qc_per_block = (sdp->sd_sb.sb_bsize -
                                sizeof(struct gfs2_meta_header)) /
-                              sizeof(struct gfs2_quota_change);
+                               sizeof(struct gfs2_quota_change);
 
        /* Compute maximum reservation required to add a entry to a directory */
 
-       hash_blocks = DIV_ROUND_UP(sizeof(uint64_t) * (1 << GFS2_DIR_MAX_DEPTH),
+       hash_blocks = DIV_ROUND_UP(sizeof(u64) * (1 << GFS2_DIR_MAX_DEPTH),
                             sdp->sd_jbsize);
 
        ind_blocks = 0;
@@ -228,8 +281,8 @@ int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent)
                                sizeof(struct gfs2_dinode);
        sdp->sd_heightsize[1] = sdp->sd_sb.sb_bsize * sdp->sd_diptrs;
        for (x = 2;; x++) {
-               uint64_t space, d;
-               uint32_t m;
+               u64 space, d;
+               u32 m;
 
                space = sdp->sd_heightsize[x - 1] * sdp->sd_inptrs;
                d = space;
@@ -246,8 +299,8 @@ int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent)
                                 sizeof(struct gfs2_dinode);
        sdp->sd_jheightsize[1] = sdp->sd_jbsize * sdp->sd_diptrs;
        for (x = 2;; x++) {
-               uint64_t space, d;
-               uint32_t m;
+               u64 space, d;
+               u32 m;
 
                space = sdp->sd_jheightsize[x - 1] * sdp->sd_inptrs;
                d = space;
@@ -277,7 +330,7 @@ int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent)
 
 int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh)
 {
-       struct gfs2_inode *dip = sdp->sd_jindex->u.generic_ip;
+       struct gfs2_inode *dip = GFS2_I(sdp->sd_jindex);
        struct qstr name;
        char buf[20];
        struct gfs2_jdesc *jd;
@@ -296,8 +349,7 @@ int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh)
                name.len = sprintf(buf, "journal%u", sdp->sd_journals);
                name.hash = gfs2_disk_hash(name.name, name.len);
 
-               error = gfs2_dir_search(sdp->sd_jindex,
-                                       &name, NULL, NULL);
+               error = gfs2_dir_search(sdp->sd_jindex, &name, NULL, NULL);
                if (error == -ENOENT) {
                        error = 0;
                        break;
@@ -423,22 +475,19 @@ struct gfs2_jdesc *gfs2_jdesc_find_dirty(struct gfs2_sbd *sdp)
 
 int gfs2_jdesc_check(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);
        int ar;
        int error;
 
-       if (ip->i_di.di_size < (8 << 20) ||
-           ip->i_di.di_size > (1 << 30) ||
+       if (ip->i_di.di_size < (8 << 20) || ip->i_di.di_size > (1 << 30) ||
            (ip->i_di.di_size & (sdp->sd_sb.sb_bsize - 1))) {
                gfs2_consist_inode(ip);
                return -EIO;
        }
        jd->jd_blocks = ip->i_di.di_size >> sdp->sd_sb.sb_bsize_shift;
 
-       error = gfs2_write_alloc_required(ip,
-                                         0, ip->i_di.di_size,
-                                         &ar);
+       error = gfs2_write_alloc_required(ip, 0, ip->i_di.di_size, &ar);
        if (!error && ar) {
                gfs2_consist_inode(ip);
                error = -EIO;
@@ -456,7 +505,7 @@ int gfs2_jdesc_check(struct gfs2_jdesc *jd)
 
 int gfs2_make_fs_rw(struct gfs2_sbd *sdp)
 {
-       struct gfs2_inode *ip = sdp->sd_jdesc->jd_inode->u.generic_ip;
+       struct gfs2_inode *ip = GFS2_I(sdp->sd_jdesc->jd_inode);
        struct gfs2_glock *j_gl = ip->i_gl;
        struct gfs2_holder t_gh;
        struct gfs2_log_header head;
@@ -484,12 +533,9 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp)
        sdp->sd_log_sequence = head.lh_sequence + 1;
        gfs2_log_pointers_init(sdp, head.lh_blkno);
 
-       error = gfs2_unlinked_init(sdp);
-       if (error)
-               goto fail;
        error = gfs2_quota_init(sdp);
        if (error)
-               goto fail_unlinked;
+               goto fail;
 
        set_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags);
 
@@ -497,10 +543,7 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp)
 
        return 0;
 
- fail_unlinked:
-       gfs2_unlinked_cleanup(sdp);
-
- fail:
+fail:
        t_gh.gh_flags |= GL_NOCACHE;
        gfs2_glock_dq_uninit(&t_gh);
 
@@ -519,7 +562,6 @@ int gfs2_make_fs_ro(struct gfs2_sbd *sdp)
        struct gfs2_holder t_gh;
        int error;
 
-       gfs2_unlinked_dealloc(sdp);
        gfs2_quota_sync(sdp);
        gfs2_statfs_sync(sdp);
 
@@ -537,7 +579,6 @@ int gfs2_make_fs_ro(struct gfs2_sbd *sdp)
        if (t_gh.gh_gl)
                gfs2_glock_dq_uninit(&t_gh);
 
-       gfs2_unlinked_cleanup(sdp);
        gfs2_quota_cleanup(sdp);
 
        return error;
@@ -545,9 +586,9 @@ int gfs2_make_fs_ro(struct gfs2_sbd *sdp)
 
 int gfs2_statfs_init(struct gfs2_sbd *sdp)
 {
-       struct gfs2_inode *m_ip = sdp->sd_statfs_inode->u.generic_ip;
+       struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
        struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master;
-       struct gfs2_inode *l_ip = sdp->sd_sc_inode->u.generic_ip;
+       struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode);
        struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local;
        struct buffer_head *m_bh, *l_bh;
        struct gfs2_holder gh;
@@ -582,19 +623,17 @@ int gfs2_statfs_init(struct gfs2_sbd *sdp)
                brelse(l_bh);
        }
 
- out_m_bh:
+out_m_bh:
        brelse(m_bh);
-
- out:
+out:
        gfs2_glock_dq_uninit(&gh);
-
        return 0;
 }
 
-void gfs2_statfs_change(struct gfs2_sbd *sdp, int64_t total, int64_t free,
-                       int64_t dinodes)
+void gfs2_statfs_change(struct gfs2_sbd *sdp, s64 total, s64 free,
+                       s64 dinodes)
 {
-       struct gfs2_inode *l_ip = sdp->sd_sc_inode->u.generic_ip;
+       struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode);
        struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local;
        struct buffer_head *l_bh;
        int error;
@@ -611,8 +650,7 @@ void gfs2_statfs_change(struct gfs2_sbd *sdp, int64_t total, int64_t free,
        l_sc->sc_total += total;
        l_sc->sc_free += free;
        l_sc->sc_dinodes += dinodes;
-       gfs2_statfs_change_out(l_sc, l_bh->b_data +
-                              sizeof(struct gfs2_dinode));     
+       gfs2_statfs_change_out(l_sc, l_bh->b_data + sizeof(struct gfs2_dinode));
        spin_unlock(&sdp->sd_statfs_spin);
 
        brelse(l_bh);
@@ -620,8 +658,8 @@ void gfs2_statfs_change(struct gfs2_sbd *sdp, int64_t total, int64_t free,
 
 int gfs2_statfs_sync(struct gfs2_sbd *sdp)
 {
-       struct gfs2_inode *m_ip = sdp->sd_statfs_inode->u.generic_ip;
-       struct gfs2_inode *l_ip = sdp->sd_sc_inode->u.generic_ip;
+       struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
+       struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode);
        struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master;
        struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local;
        struct gfs2_holder gh;
@@ -639,7 +677,7 @@ int gfs2_statfs_sync(struct gfs2_sbd *sdp)
 
        spin_lock(&sdp->sd_statfs_spin);
        gfs2_statfs_change_in(m_sc, m_bh->b_data +
-                             sizeof(struct gfs2_dinode));      
+                             sizeof(struct gfs2_dinode));
        if (!l_sc->sc_total && !l_sc->sc_free && !l_sc->sc_dinodes) {
                spin_unlock(&sdp->sd_statfs_spin);
                goto out_bh;
@@ -672,15 +710,12 @@ int gfs2_statfs_sync(struct gfs2_sbd *sdp)
 
        gfs2_trans_end(sdp);
 
- out_bh2:
+out_bh2:
        brelse(l_bh);
-
- out_bh:
+out_bh:
        brelse(m_bh);
-
- out:
+out:
        gfs2_glock_dq_uninit(&gh);
-
        return error;
 }
 
@@ -810,9 +845,8 @@ int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc)
 
        gfs2_glock_dq_uninit(&ri_gh);
 
- out:
+out:
        kfree(gha);
-
        return error;
 }
 
@@ -852,10 +886,8 @@ static int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp,
                        error = -ENOMEM;
                        goto out;
                }
-               ip = jd->jd_inode->u.generic_ip;
-               error = gfs2_glock_nq_init(ip->i_gl,
-                                          LM_ST_SHARED, 0,
-                                          &lfcc->gh);
+               ip = GFS2_I(jd->jd_inode);
+               error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &lfcc->gh);
                if (error) {
                        kfree(lfcc);
                        goto out;
@@ -883,7 +915,7 @@ static int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp,
        if (error)
                gfs2_glock_dq_uninit(t_gh);
 
- out:
+out:
        while (!list_empty(&list)) {
                lfcc = list_entry(list.next, struct lfcc, list);
                list_del(&lfcc->list);
@@ -891,7 +923,6 @@ static int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp,
                kfree(lfcc);
        }
        gfs2_glock_dq_uninit(&ji_gh);
-
        return error;
 }