[GFS2] Add generation number
[pandora-kernel.git] / fs / gfs2 / meta_io.c
index b9895bb..cad44fd 100644 (file)
@@ -31,6 +31,7 @@
 #include "rgrp.h"
 #include "trans.h"
 #include "util.h"
+#include "ops_address.h"
 
 #define buffer_busy(bh) \
 ((bh)->b_state & ((1ul << BH_Dirty) | (1ul << BH_Lock) | (1ul << BH_Pinned)))
@@ -50,120 +51,9 @@ static int gfs2_aspace_writepage(struct page *page,
        return block_write_full_page(page, aspace_get_block, wbc);
 }
 
-/**
- * stuck_releasepage - We're stuck in gfs2_releasepage().  Print stuff out.
- * @bh: the buffer we're stuck on
- *
- */
-
-static void stuck_releasepage(struct buffer_head *bh)
-{
-       struct inode *inode = bh->b_page->mapping->host;
-       struct gfs2_sbd *sdp = inode->i_sb->s_fs_info;
-       struct gfs2_bufdata *bd = bh->b_private;
-       struct gfs2_glock *gl;
-
-       fs_warn(sdp, "stuck in gfs2_releasepage() %p\n", inode);
-       fs_warn(sdp, "blkno = %llu, bh->b_count = %d\n",
-               (uint64_t)bh->b_blocknr, atomic_read(&bh->b_count));
-       fs_warn(sdp, "pinned = %u\n", buffer_pinned(bh));
-       fs_warn(sdp, "bh->b_private = %s\n", (bd) ? "!NULL" : "NULL");
-
-       if (!bd)
-               return;
-
-       gl = bd->bd_gl;
-
-       fs_warn(sdp, "gl = (%u, %llu)\n", 
-               gl->gl_name.ln_type, gl->gl_name.ln_number);
-
-       fs_warn(sdp, "bd_list_tr = %s, bd_le.le_list = %s\n",
-               (list_empty(&bd->bd_list_tr)) ? "no" : "yes",
-               (list_empty(&bd->bd_le.le_list)) ? "no" : "yes");
-
-       if (gl->gl_ops == &gfs2_inode_glops) {
-               struct gfs2_inode *ip = gl->gl_object;
-               unsigned int x;
-
-               if (!ip)
-                       return;
-
-               fs_warn(sdp, "ip = %llu %llu\n",
-                       ip->i_num.no_formal_ino, ip->i_num.no_addr);
-               fs_warn(sdp, "ip->i_count = %d, ip->i_vnode = %s\n",
-                       atomic_read(&ip->i_count),
-                       (ip->i_vnode) ? "!NULL" : "NULL");
-
-               for (x = 0; x < GFS2_MAX_META_HEIGHT; x++)
-                       fs_warn(sdp, "ip->i_cache[%u] = %s\n",
-                               x, (ip->i_cache[x]) ? "!NULL" : "NULL");
-       }
-}
-
-/**
- * gfs2_aspace_releasepage - free the metadata associated with a page
- * @page: the page that's being released
- * @gfp_mask: passed from Linux VFS, ignored by us
- *
- * Call try_to_free_buffers() if the buffers in this page can be
- * released.
- *
- * Returns: 0
- */
-
-static int gfs2_aspace_releasepage(struct page *page, gfp_t gfp_mask)
-{
-       struct inode *aspace = page->mapping->host;
-       struct gfs2_sbd *sdp = aspace->i_sb->s_fs_info;
-       struct buffer_head *bh, *head;
-       struct gfs2_bufdata *bd;
-       unsigned long t;
-
-       if (!page_has_buffers(page))
-               goto out;
-
-       head = bh = page_buffers(page);
-       do {
-               t = jiffies;
-
-               while (atomic_read(&bh->b_count)) {
-                       if (atomic_read(&aspace->i_writecount)) {
-                               if (time_after_eq(jiffies, t +
-                                   gfs2_tune_get(sdp, gt_stall_secs) * HZ)) {
-                                       stuck_releasepage(bh);
-                                       t = jiffies;
-                               }
-
-                               yield();
-                               continue;
-                       }
-
-                       return 0;
-               }
-
-               gfs2_assert_warn(sdp, !buffer_pinned(bh));
-
-               bd = bh->b_private;
-               if (bd) {
-                       gfs2_assert_warn(sdp, bd->bd_bh == bh);
-                       gfs2_assert_warn(sdp, list_empty(&bd->bd_list_tr));
-                       gfs2_assert_warn(sdp, list_empty(&bd->bd_le.le_list));
-                       gfs2_assert_warn(sdp, !bd->bd_ail);
-                       kmem_cache_free(gfs2_bufdata_cachep, bd);
-                       bh->b_private = NULL;
-               }
-
-               bh = bh->b_this_page;
-       }
-       while (bh != head);
-
- out:
-       return try_to_free_buffers(page);
-}
-
-static struct address_space_operations aspace_aops = {
+static const struct address_space_operations aspace_aops = {
        .writepage = gfs2_aspace_writepage,
-       .releasepage = gfs2_aspace_releasepage,
+       .releasepage = gfs2_releasepage,
 };
 
 /**
@@ -566,7 +456,6 @@ void gfs2_attach_bufdata(struct gfs2_glock *gl, struct buffer_head *bh,
 
        bd = kmem_cache_alloc(gfs2_bufdata_cachep, GFP_NOFS | __GFP_NOFAIL),
        memset(bd, 0, sizeof(struct gfs2_bufdata));
-
        bd->bd_bh = bh;
        bd->bd_gl = gl;
 
@@ -663,7 +552,7 @@ void gfs2_unpin(struct gfs2_sbd *sdp, struct buffer_head *bh,
 
 void gfs2_meta_wipe(struct gfs2_inode *ip, uint64_t bstart, uint32_t blen)
 {
-       struct gfs2_sbd *sdp = ip->i_sbd;
+       struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
        struct inode *aspace = ip->i_gl->gl_aspace;
        struct buffer_head *bh;
 
@@ -769,7 +658,7 @@ int gfs2_meta_indirect_buffer(struct gfs2_inode *ip, int height, uint64_t num,
                if (new)
                        meta_prep_new(bh);
                else {
-                       error = gfs2_meta_reread(ip->i_sbd, bh,
+                       error = gfs2_meta_reread(GFS2_SB(&ip->i_inode), bh,
                                                 DIO_START | DIO_WAIT);
                        if (error) {
                                brelse(bh);
@@ -796,7 +685,7 @@ int gfs2_meta_indirect_buffer(struct gfs2_inode *ip, int height, uint64_t num,
        }
 
        if (new) {
-               if (gfs2_assert_warn(ip->i_sbd, height)) {
+               if (gfs2_assert_warn(GFS2_SB(&ip->i_inode), height)) {
                        brelse(bh);
                        return -EIO;
                }
@@ -804,7 +693,7 @@ int gfs2_meta_indirect_buffer(struct gfs2_inode *ip, int height, uint64_t num,
                gfs2_metatype_set(bh, GFS2_METATYPE_IN, GFS2_FORMAT_IN);
                gfs2_buffer_clear_tail(bh, sizeof(struct gfs2_meta_header));
 
-       } else if (gfs2_metatype_check(ip->i_sbd, bh,
+       } else if (gfs2_metatype_check(GFS2_SB(&ip->i_inode), bh,
                             (height) ? GFS2_METATYPE_IN : GFS2_METATYPE_DI)) {
                brelse(bh);
                return -EIO;