[GFS2] Add generation number
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / gfs2 / lops.c
index 4d90eb3114977372e45f855c3c7cb9119dcee02c..af03bf380f46330c2c6ad691b7dfe6ed210ed712 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"
@@ -185,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;
@@ -199,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;
@@ -246,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,
@@ -333,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;
@@ -347,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;
@@ -394,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);
@@ -466,17 +461,17 @@ 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) &&
            (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 (ip->i_di.di_flags & GFS2_DIF_JDATA)
@@ -655,7 +650,7 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
                } 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 */
@@ -666,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;
@@ -717,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,