]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blobdiff - fs/gfs2/meta_io.c
[GFS2] Update copyright date to 2006
[mirror_ubuntu-zesty-kernel.git] / fs / gfs2 / meta_io.c
index 8bbe118552237084a202d6d97295ca05d9b3679f..b9895bbd5feb5ace0428b3cf2fa8eac8b1360ab6 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * 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
 #include <linux/writeback.h>
 #include <linux/swap.h>
 #include <linux/delay.h>
-#include <asm/semaphore.h>
+#include <linux/gfs2_ondisk.h>
 
 #include "gfs2.h"
+#include "lm_interface.h"
+#include "incore.h"
 #include "glock.h"
 #include "glops.h"
 #include "inode.h"
@@ -28,6 +30,7 @@
 #include "meta_io.h"
 #include "rgrp.h"
 #include "trans.h"
+#include "util.h"
 
 #define buffer_busy(bh) \
 ((bh)->b_state & ((1ul << BH_Dirty) | (1ul << BH_Lock) | (1ul << BH_Pinned)))
@@ -37,7 +40,7 @@
 static int aspace_get_block(struct inode *inode, sector_t lblock,
                            struct buffer_head *bh_result, int create)
 {
-       gfs2_assert_warn(get_v2sdp(inode->i_sb), 0);
+       gfs2_assert_warn(inode->i_sb->s_fs_info, 0);
        return -EOPNOTSUPP;
 }
 
@@ -55,15 +58,16 @@ static int gfs2_aspace_writepage(struct page *page,
 
 static void stuck_releasepage(struct buffer_head *bh)
 {
-       struct gfs2_sbd *sdp = get_v2sdp(bh->b_page->mapping->host->i_sb);
-       struct gfs2_bufdata *bd = get_v2bd(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()\n");
+       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, "get_v2bd(bh) = %s\n", (bd) ? "!NULL" : "NULL");
+       fs_warn(sdp, "bh->b_private = %s\n", (bd) ? "!NULL" : "NULL");
 
        if (!bd)
                return;
@@ -78,7 +82,7 @@ static void stuck_releasepage(struct buffer_head *bh)
                (list_empty(&bd->bd_le.le_list)) ? "no" : "yes");
 
        if (gl->gl_ops == &gfs2_inode_glops) {
-               struct gfs2_inode *ip = get_gl2ip(gl);
+               struct gfs2_inode *ip = gl->gl_object;
                unsigned int x;
 
                if (!ip)
@@ -110,7 +114,7 @@ static void stuck_releasepage(struct buffer_head *bh)
 static int gfs2_aspace_releasepage(struct page *page, gfp_t gfp_mask)
 {
        struct inode *aspace = page->mapping->host;
-       struct gfs2_sbd *sdp = get_v2sdp(aspace->i_sb);
+       struct gfs2_sbd *sdp = aspace->i_sb->s_fs_info;
        struct buffer_head *bh, *head;
        struct gfs2_bufdata *bd;
        unsigned long t;
@@ -139,15 +143,14 @@ static int gfs2_aspace_releasepage(struct page *page, gfp_t gfp_mask)
 
                gfs2_assert_warn(sdp, !buffer_pinned(bh));
 
-               bd = get_v2bd(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);
-                       atomic_dec(&sdp->sd_bufdata_count);
-                       set_v2bd(bh, NULL);
+                       bh->b_private = NULL;
                }
 
                bh = bh->b_this_page;
@@ -185,10 +188,9 @@ struct inode *gfs2_aspace_get(struct gfs2_sbd *sdp)
                mapping_set_gfp_mask(aspace->i_mapping, GFP_KERNEL);
                aspace->i_mapping->a_ops = &aspace_aops;
                aspace->i_size = ~0ULL;
-               set_v2ip(aspace, NULL);
+               aspace->u.generic_ip = NULL;
                insert_inode_hash(aspace);
        }
-
        return aspace;
 }
 
@@ -211,6 +213,8 @@ void gfs2_ail1_start_one(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
        struct buffer_head *bh;
        int retry;
 
+       BUG_ON(!spin_is_locked(&sdp->sd_log_lock));
+
        do {
                retry = 0;
 
@@ -221,8 +225,11 @@ void gfs2_ail1_start_one(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
                        gfs2_assert(sdp, bd->bd_ail == ai);
 
                        if (!buffer_busy(bh)) {
-                               if (!buffer_uptodate(bh))
+                               if (!buffer_uptodate(bh)) {
+                                       gfs2_log_unlock(sdp);
                                        gfs2_io_error_bh(sdp, bh);
+                                       gfs2_log_lock(sdp);
+                               }
                                list_move(&bd->bd_ail_st_list,
                                          &ai->ai_ail2_list);
                                continue;
@@ -350,7 +357,7 @@ void gfs2_ail_empty_gl(struct gfs2_glock *gl)
        gfs2_log_unlock(sdp);
 
        gfs2_trans_end(sdp);
-       gfs2_log_flush(sdp);
+       gfs2_log_flush(sdp, NULL);
 }
 
 /**
@@ -524,7 +531,7 @@ int gfs2_meta_reread(struct gfs2_sbd *sdp, struct buffer_head *bh, int flags)
                wait_on_buffer(bh);
 
                if (!buffer_uptodate(bh)) {
-                       struct gfs2_trans *tr = get_transaction;
+                       struct gfs2_trans *tr = current->journal_info;
                        if (tr && tr->tr_touched)
                                gfs2_io_error_bh(sdp, bh);
                        return -EIO;
@@ -537,49 +544,55 @@ int gfs2_meta_reread(struct gfs2_sbd *sdp, struct buffer_head *bh, int flags)
 }
 
 /**
- * gfs2_meta_attach_bufdata - attach a struct gfs2_bufdata structure to a buffer
+ * gfs2_attach_bufdata - attach a struct gfs2_bufdata structure to a buffer
  * @gl: the glock the buffer belongs to
  * @bh: The buffer to be attached to
- *
+ * @meta: Flag to indicate whether its metadata or not
  */
 
-void gfs2_meta_attach_bufdata(struct gfs2_glock *gl, struct buffer_head *bh)
+void gfs2_attach_bufdata(struct gfs2_glock *gl, struct buffer_head *bh,
+                        int meta)
 {
        struct gfs2_bufdata *bd;
 
-       lock_page(bh->b_page);
+       if (meta)
+               lock_page(bh->b_page);
 
-       if (get_v2bd(bh)) {
-               unlock_page(bh->b_page);
+       if (bh->b_private) {
+               if (meta)
+                       unlock_page(bh->b_page);
                return;
        }
 
-       bd = kmem_cache_alloc(gfs2_bufdata_cachep, GFP_KERNEL | __GFP_NOFAIL),
-       atomic_inc(&gl->gl_sbd->sd_bufdata_count);
-
+       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;
 
        INIT_LIST_HEAD(&bd->bd_list_tr);
-       lops_init_le(&bd->bd_le, &gfs2_buf_lops);
-
-       set_v2bd(bh, bd);
+       if (meta) {
+               lops_init_le(&bd->bd_le, &gfs2_buf_lops);
+       } else {
+               lops_init_le(&bd->bd_le, &gfs2_databuf_lops);
+               get_bh(bh);
+       }
+       bh->b_private = bd;
 
-       unlock_page(bh->b_page);
+       if (meta)
+               unlock_page(bh->b_page);
 }
 
 /**
- * gfs2_meta_pin - Pin a metadata buffer in memory
+ * gfs2_pin - Pin a buffer in memory
  * @sdp: the filesystem the buffer belongs to
  * @bh: The buffer to be pinned
  *
  */
 
-void gfs2_meta_pin(struct gfs2_sbd *sdp, struct buffer_head *bh)
+void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh)
 {
-       struct gfs2_bufdata *bd = get_v2bd(bh);
+       struct gfs2_bufdata *bd = bh->b_private;
 
        gfs2_assert_withdraw(sdp, test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags));
 
@@ -606,17 +619,17 @@ void gfs2_meta_pin(struct gfs2_sbd *sdp, struct buffer_head *bh)
 }
 
 /**
- * gfs2_meta_unpin - Unpin a buffer
+ * gfs2_unpin - Unpin a buffer
  * @sdp: the filesystem the buffer belongs to
  * @bh: The buffer to unpin
  * @ai:
  *
  */
 
-void gfs2_meta_unpin(struct gfs2_sbd *sdp, struct buffer_head *bh,
-                    struct gfs2_ail *ai)
+void gfs2_unpin(struct gfs2_sbd *sdp, struct buffer_head *bh,
+               struct gfs2_ail *ai)
 {
-       struct gfs2_bufdata *bd = get_v2bd(bh);
+       struct gfs2_bufdata *bd = bh->b_private;
 
        gfs2_assert_withdraw(sdp, buffer_uptodate(bh));
 
@@ -657,15 +670,16 @@ void gfs2_meta_wipe(struct gfs2_inode *ip, uint64_t bstart, uint32_t blen)
        while (blen) {
                bh = getbuf(sdp, aspace, bstart, NO_CREATE);
                if (bh) {
-                       struct gfs2_bufdata *bd = get_v2bd(bh);
+                       struct gfs2_bufdata *bd = bh->b_private;
 
                        if (test_clear_buffer_pinned(bh)) {
+                               struct gfs2_trans *tr = current->journal_info;
                                gfs2_log_lock(sdp);
                                list_del_init(&bd->bd_le.le_list);
                                gfs2_assert_warn(sdp, sdp->sd_log_num_buf);
                                sdp->sd_log_num_buf--;
                                gfs2_log_unlock(sdp);
-                               get_transaction->tr_num_buf_rm++;
+                               tr->tr_num_buf_rm++;
                                brelse(bh);
                        }
                        if (bd) {
@@ -814,7 +828,8 @@ void gfs2_meta_ra(struct gfs2_glock *gl, uint64_t dblock, uint32_t extlen)
        struct gfs2_sbd *sdp = gl->gl_sbd;
        struct inode *aspace = gl->gl_aspace;
        struct buffer_head *first_bh, *bh;
-       uint32_t max_ra = gfs2_tune_get(sdp, gt_max_readahead) >> sdp->sd_sb.sb_bsize_shift;
+       uint32_t max_ra = gfs2_tune_get(sdp, gt_max_readahead) >>
+                         sdp->sd_sb.sb_bsize_shift;
        int error;
 
        if (!extlen || !max_ra)
@@ -865,12 +880,12 @@ void gfs2_meta_ra(struct gfs2_glock *gl, uint64_t dblock, uint32_t extlen)
 
 void gfs2_meta_syncfs(struct gfs2_sbd *sdp)
 {
-       gfs2_log_flush(sdp);
+       gfs2_log_flush(sdp, NULL);
        for (;;) {
                gfs2_ail1_start(sdp, DIO_ALL);
                if (gfs2_ail1_empty(sdp, DIO_ALL))
                        break;
-               msleep(100);
+               msleep(10);
        }
 }