]> 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 22a4f038e3b9eb497fa600566d7d58952bac2829..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
@@ -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,
@@ -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++;
@@ -642,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 */
@@ -665,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;
@@ -716,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,