]> err.no Git - linux-2.6/blobdiff - fs/gfs2/lops.c
[GFS2] Fix to list_del in lops.c
[linux-2.6] / fs / gfs2 / lops.c
index 9d40e21f6ead1cd36050138a33b3e259de17e65b..82dfc96c4f599b992fda6e2796921fb6d0d47c48 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
@@ -13,7 +13,6 @@
 #include <linux/completion.h>
 #include <linux/buffer_head.h>
 #include <linux/gfs2_ondisk.h>
-#include <asm/semaphore.h>
 
 #include "gfs2.h"
 #include "lm_interface.h"
@@ -130,11 +129,12 @@ static void buf_lo_before_commit(struct gfs2_sbd *sdp)
                if (total > limit)
                        num = limit;
                bh = gfs2_log_get_buf(sdp);
+               sdp->sd_log_num_hdrs++;
                ld = (struct gfs2_log_descriptor *)bh->b_data;
                ptr = (__be64 *)(bh->b_data + offset);
                ld->ld_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
-               ld->ld_header.mh_type = cpu_to_be16(GFS2_METATYPE_LD);
-               ld->ld_header.mh_format = cpu_to_be16(GFS2_FORMAT_LD);
+               ld->ld_header.mh_type = cpu_to_be32(GFS2_METATYPE_LD);
+               ld->ld_header.mh_format = cpu_to_be32(GFS2_FORMAT_LD);
                ld->ld_type = cpu_to_be32(GFS2_LOG_DESC_METADATA);
                ld->ld_length = cpu_to_be32(num + 1);
                ld->ld_data1 = cpu_to_be32(num);
@@ -184,8 +184,7 @@ static void buf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
 static void buf_lo_before_scan(struct gfs2_jdesc *jd,
                               struct gfs2_log_header *head, 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);
 
        if (pass != 0)
                return;
@@ -198,8 +197,8 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
                                struct gfs2_log_descriptor *ld, __be64 *ptr,
                                int pass)
 {
-       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_glock *gl = ip->i_gl;
        unsigned int blks = be32_to_cpu(ld->ld_data1);
        struct buffer_head *bh_log, *bh_ip;
@@ -245,8 +244,8 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
 
 static void buf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
 {
-       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);
 
        if (error) {
                gfs2_meta_sync(ip->i_gl,
@@ -291,8 +290,8 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
        bh = gfs2_log_get_buf(sdp);
        ld = (struct gfs2_log_descriptor *)bh->b_data;
        ld->ld_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
-       ld->ld_header.mh_type = cpu_to_be16(GFS2_METATYPE_LD);
-       ld->ld_header.mh_format = cpu_to_be16(GFS2_FORMAT_LD);
+       ld->ld_header.mh_type = cpu_to_be32(GFS2_METATYPE_LD);
+       ld->ld_header.mh_format = cpu_to_be32(GFS2_FORMAT_LD);
        ld->ld_type = cpu_to_be32(GFS2_LOG_DESC_REVOKE);
        ld->ld_length = cpu_to_be32(gfs2_struct2blk(sdp, sdp->sd_log_num_revoke,
                                                    sizeof(uint64_t)));
@@ -313,8 +312,8 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
                        bh = gfs2_log_get_buf(sdp);
                        mh = (struct gfs2_meta_header *)bh->b_data;
                        mh->mh_magic = cpu_to_be32(GFS2_MAGIC);
-                       mh->mh_type = cpu_to_be16(GFS2_METATYPE_LB);
-                       mh->mh_format = cpu_to_be16(GFS2_FORMAT_LB);
+                       mh->mh_type = cpu_to_be32(GFS2_METATYPE_LB);
+                       mh->mh_format = cpu_to_be32(GFS2_FORMAT_LB);
                        offset = sizeof(struct gfs2_meta_header);
                }
 
@@ -332,8 +331,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
 static void revoke_lo_before_scan(struct gfs2_jdesc *jd,
                                  struct gfs2_log_header *head, 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);
 
        if (pass != 0)
                return;
@@ -346,8 +344,7 @@ static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
                                   struct gfs2_log_descriptor *ld, __be64 *ptr,
                                   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);
        unsigned int blks = be32_to_cpu(ld->ld_length);
        unsigned int revokes = be32_to_cpu(ld->ld_data1);
        struct buffer_head *bh;
@@ -393,8 +390,7 @@ static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
 
 static void revoke_lo_after_scan(struct gfs2_jdesc *jd, int error, 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);
 
        if (error) {
                gfs2_revoke_clean(sdp);
@@ -465,19 +461,19 @@ static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
        struct gfs2_bufdata *bd = container_of(le, struct gfs2_bufdata, bd_le);
        struct gfs2_trans *tr = current->journal_info;
        struct address_space *mapping = bd->bd_bh->b_page->mapping;
-       struct gfs2_inode *ip = mapping->host->u.generic_ip;
+       struct gfs2_inode *ip = GFS2_I(mapping->host);
 
        tr->tr_touched = 1;
-       if (!list_empty(&bd->bd_list_tr) &&
+       if (list_empty(&bd->bd_list_tr) &&
            (ip->i_di.di_flags & GFS2_DIF_JDATA)) {
                tr->tr_num_buf++;
-               gfs2_trans_add_gl(bd->bd_gl);
                list_add(&bd->bd_list_tr, &tr->tr_list_buf);
                gfs2_pin(sdp, bd->bd_bh);
                tr->tr_num_buf_new++;
        }
+       gfs2_trans_add_gl(bd->bd_gl);
        gfs2_log_lock(sdp);
-       if (!list_empty(&le->le_list)) {
+       if (list_empty(&le->le_list)) {
                if (ip->i_di.di_flags & GFS2_DIF_JDATA)
                        sdp->sd_log_num_jdata++;
                sdp->sd_log_num_databuf++;
@@ -570,15 +566,16 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
                                gfs2_log_unlock(sdp);
                                if (!bh) {
                                        bh = gfs2_log_get_buf(sdp);
+                                       sdp->sd_log_num_hdrs++;
                                        ld = (struct gfs2_log_descriptor *)
                                             bh->b_data;
                                        ptr = (__be64 *)(bh->b_data + offset);
                                        ld->ld_header.mh_magic =
                                                cpu_to_be32(GFS2_MAGIC);
                                        ld->ld_header.mh_type =
-                                               cpu_to_be16(GFS2_METATYPE_LD);
+                                               cpu_to_be32(GFS2_METATYPE_LD);
                                        ld->ld_header.mh_format =
-                                               cpu_to_be16(GFS2_FORMAT_LD);
+                                               cpu_to_be32(GFS2_FORMAT_LD);
                                        ld->ld_type =
                                                cpu_to_be32(GFS2_LOG_DESC_JDATA);
                                        ld->ld_length = cpu_to_be32(num + 1);
@@ -641,19 +638,19 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
                gfs2_log_lock(sdp);
                bd1 = list_entry(started.next, struct gfs2_bufdata,
                                 bd_le.le_list);
-               list_del(&bd1->bd_le.le_list);
+               list_del_init(&bd1->bd_le.le_list);
                sdp->sd_log_num_databuf--;
-
                bh = bd1->bd_bh;
                if (bh) {
                        bh->b_private = NULL;
+                       get_bh(bh);
                        gfs2_log_unlock(sdp);
                        wait_on_buffer(bh);
                        brelse(bh);
                } else
                        gfs2_log_unlock(sdp);
 
-               kfree(bd1);
+               kmem_cache_free(gfs2_bufdata_cachep, bd1);
        }
 
        /* We've removed all the ordered write bufs here, so only jdata left */
@@ -664,8 +661,8 @@ static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
                                    struct gfs2_log_descriptor *ld,
                                    __be64 *ptr, int pass)
 {
-       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_glock *gl = ip->i_gl;
        unsigned int blks = be32_to_cpu(ld->ld_data1);
        struct buffer_head *bh_log, *bh_ip;
@@ -715,8 +712,8 @@ static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
 
 static void databuf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
 {
-       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);
 
        if (error) {
                gfs2_meta_sync(ip->i_gl,
@@ -750,13 +747,13 @@ static void databuf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
 }
 
 
-struct gfs2_log_operations gfs2_glock_lops = {
+const struct gfs2_log_operations gfs2_glock_lops = {
        .lo_add = glock_lo_add,
        .lo_after_commit = glock_lo_after_commit,
        .lo_name = "glock"
 };
 
-struct gfs2_log_operations gfs2_buf_lops = {
+const struct gfs2_log_operations gfs2_buf_lops = {
        .lo_add = buf_lo_add,
        .lo_incore_commit = buf_lo_incore_commit,
        .lo_before_commit = buf_lo_before_commit,
@@ -767,7 +764,7 @@ struct gfs2_log_operations gfs2_buf_lops = {
        .lo_name = "buf"
 };
 
-struct gfs2_log_operations gfs2_revoke_lops = {
+const struct gfs2_log_operations gfs2_revoke_lops = {
        .lo_add = revoke_lo_add,
        .lo_before_commit = revoke_lo_before_commit,
        .lo_before_scan = revoke_lo_before_scan,
@@ -776,13 +773,13 @@ struct gfs2_log_operations gfs2_revoke_lops = {
        .lo_name = "revoke"
 };
 
-struct gfs2_log_operations gfs2_rg_lops = {
+const struct gfs2_log_operations gfs2_rg_lops = {
        .lo_add = rg_lo_add,
        .lo_after_commit = rg_lo_after_commit,
        .lo_name = "rg"
 };
 
-struct gfs2_log_operations gfs2_databuf_lops = {
+const struct gfs2_log_operations gfs2_databuf_lops = {
        .lo_add = databuf_lo_add,
        .lo_incore_commit = buf_lo_incore_commit,
        .lo_before_commit = databuf_lo_before_commit,
@@ -792,7 +789,7 @@ struct gfs2_log_operations gfs2_databuf_lops = {
        .lo_name = "databuf"
 };
 
-struct gfs2_log_operations *gfs2_log_ops[] = {
+const struct gfs2_log_operations *gfs2_log_ops[] = {
        &gfs2_glock_lops,
        &gfs2_buf_lops,
        &gfs2_revoke_lops,