GFS2: Fix incorrent statfs consistency check
[safe/jmp/linux-2.6] / fs / gfs2 / eattr.c
index f5169a4..07ea952 100644 (file)
@@ -4,10 +4,9 @@
  *
  * This copyrighted material is made available to anyone wishing to use,
  * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU General Public License v.2.
+ * of the GNU General Public License version 2.
  */
 
-#include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/completion.h>
@@ -17,7 +16,6 @@
 #include <asm/uaccess.h>
 
 #include "gfs2.h"
-#include "lm_interface.h"
 #include "incore.h"
 #include "acl.h"
 #include "eaops.h"
@@ -68,11 +66,9 @@ static int ea_check_size(struct gfs2_sbd *sdp, struct gfs2_ea_request *er)
        return 0;
 }
 
-typedef int (*ea_call_t) (struct gfs2_inode *ip,
-                         struct buffer_head *bh,
+typedef int (*ea_call_t) (struct gfs2_inode *ip, struct buffer_head *bh,
                          struct gfs2_ea_header *ea,
-                         struct gfs2_ea_header *prev,
-                         void *private);
+                         struct gfs2_ea_header *prev, void *private);
 
 static int ea_foreach_i(struct gfs2_inode *ip, struct buffer_head *bh,
                        ea_call_t ea_call, void *data)
@@ -80,15 +76,14 @@ static int ea_foreach_i(struct gfs2_inode *ip, struct buffer_head *bh,
        struct gfs2_ea_header *ea, *prev = NULL;
        int error = 0;
 
-       if (gfs2_metatype_check(ip->i_sbd, bh, GFS2_METATYPE_EA))
+       if (gfs2_metatype_check(GFS2_SB(&ip->i_inode), bh, GFS2_METATYPE_EA))
                return -EIO;
 
        for (ea = GFS2_EA_BH2FIRST(bh);; prev = ea, ea = GFS2_EA2NEXT(ea)) {
                if (!GFS2_EA_REC_LEN(ea))
                        goto fail;
-               if (!(bh->b_data <= (char *)ea &&
-                     (char *)GFS2_EA2NEXT(ea) <=
-                     bh->b_data + bh->b_size))
+               if (!(bh->b_data <= (char *)ea && (char *)GFS2_EA2NEXT(ea) <=
+                                                 bh->b_data + bh->b_size))
                        goto fail;
                if (!GFS2_EATYPE_VALID(ea->ea_type))
                        goto fail;
@@ -107,7 +102,7 @@ static int ea_foreach_i(struct gfs2_inode *ip, struct buffer_head *bh,
 
        return error;
 
- fail:
+fail:
        gfs2_consist_inode(ip);
        return -EIO;
 }
@@ -115,36 +110,34 @@ static int ea_foreach_i(struct gfs2_inode *ip, struct buffer_head *bh,
 static int ea_foreach(struct gfs2_inode *ip, ea_call_t ea_call, void *data)
 {
        struct buffer_head *bh, *eabh;
-       uint64_t *eablk, *end;
+       __be64 *eablk, *end;
        int error;
 
-       error = gfs2_meta_read(ip->i_gl, ip->i_di.di_eattr,
-                              DIO_START | DIO_WAIT, &bh);
+       error = gfs2_meta_read(ip->i_gl, ip->i_eattr, DIO_WAIT, &bh);
        if (error)
                return error;
 
-       if (!(ip->i_di.di_flags & GFS2_DIF_EA_INDIRECT)) {
+       if (!(ip->i_diskflags & GFS2_DIF_EA_INDIRECT)) {
                error = ea_foreach_i(ip, bh, ea_call, data);
                goto out;
        }
 
-       if (gfs2_metatype_check(ip->i_sbd, bh, GFS2_METATYPE_IN)) {
+       if (gfs2_metatype_check(GFS2_SB(&ip->i_inode), bh, GFS2_METATYPE_IN)) {
                error = -EIO;
                goto out;
        }
 
-       eablk = (uint64_t *)(bh->b_data + sizeof(struct gfs2_meta_header));
-       end = eablk + ip->i_sbd->sd_inptrs;
+       eablk = (__be64 *)(bh->b_data + sizeof(struct gfs2_meta_header));
+       end = eablk + GFS2_SB(&ip->i_inode)->sd_inptrs;
 
        for (; eablk < end; eablk++) {
-               uint64_t bn;
+               u64 bn;
 
                if (!*eablk)
                        break;
                bn = be64_to_cpu(*eablk);
 
-               error = gfs2_meta_read(ip->i_gl, bn, DIO_START | DIO_WAIT,
-                                      &eabh);
+               error = gfs2_meta_read(ip->i_gl, bn, DIO_WAIT, &eabh);
                if (error)
                        break;
                error = ea_foreach_i(ip, eabh, ea_call, data);
@@ -152,9 +145,8 @@ static int ea_foreach(struct gfs2_inode *ip, ea_call_t ea_call, void *data)
                if (error)
                        break;
        }
- out:
+out:
        brelse(bh);
-
        return error;
 }
 
@@ -185,12 +177,6 @@ static int ea_find_i(struct gfs2_inode *ip, struct buffer_head *bh,
                }
        }
 
-#if 0
-       else if ((ip->i_di.di_flags & GFS2_DIF_EA_PACKED) &&
-                er->er_type == GFS2_EATYPE_SYS)
-               return 1;
-#endif
-
        return 0;
 }
 
@@ -232,12 +218,13 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
                                struct gfs2_ea_header *prev, void *private)
 {
        int *leave = private;
-       struct gfs2_sbd *sdp = ip->i_sbd;
+       struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
        struct gfs2_rgrpd *rgd;
        struct gfs2_holder rg_gh;
        struct buffer_head *dibh;
-       uint64_t *dataptrs, bn = 0;
-       uint64_t bstart = 0;
+       __be64 *dataptrs;
+       u64 bn = 0;
+       u64 bstart = 0;
        unsigned int blen = 0;
        unsigned int blks = 0;
        unsigned int x;
@@ -247,11 +234,12 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
                return 0;
 
        dataptrs = GFS2_EA2DATAPTRS(ea);
-       for (x = 0; x < ea->ea_num_ptrs; x++, dataptrs++)
+       for (x = 0; x < ea->ea_num_ptrs; x++, dataptrs++) {
                if (*dataptrs) {
                        blks++;
                        bn = be64_to_cpu(*dataptrs);
                }
+       }
        if (!blks)
                return 0;
 
@@ -265,9 +253,8 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
        if (error)
                return error;
 
-       error = gfs2_trans_begin(sdp, rgd->rd_ri.ri_length +
-                                RES_DINODE + RES_EATTR + RES_STATFS +
-                                RES_QUOTA, blks);
+       error = gfs2_trans_begin(sdp, rgd->rd_length + RES_DINODE +
+                                RES_EATTR + RES_STATFS + RES_QUOTA, blks);
        if (error)
                goto out_gunlock;
 
@@ -289,15 +276,13 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
                }
 
                *dataptrs = 0;
-               if (!ip->i_di.di_blocks)
-                       gfs2_consist_inode(ip);
-               ip->i_di.di_blocks--;
+               gfs2_add_inode_blocks(&ip->i_inode, -1);
        }
        if (bstart)
                gfs2_free_meta(ip, bstart, blen);
 
        if (prev && !leave) {
-               uint32_t len;
+               u32 len;
 
                len = GFS2_EA_REC_LEN(prev) + GFS2_EA_REC_LEN(ea);
                prev->ea_rec_len = cpu_to_be32(len);
@@ -311,17 +296,16 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
 
        error = gfs2_meta_inode_buffer(ip, &dibh);
        if (!error) {
-               ip->i_di.di_ctime = get_seconds();
+               ip->i_inode.i_ctime = CURRENT_TIME;
                gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-               gfs2_dinode_out(&ip->i_di, dibh->b_data);
+               gfs2_dinode_out(ip, dibh->b_data);
                brelse(dibh);
        }
 
        gfs2_trans_end(sdp);
 
- out_gunlock:
+out_gunlock:
        gfs2_glock_dq_uninit(&rg_gh);
-
        return error;
 }
 
@@ -333,27 +317,25 @@ static int ea_remove_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
        int error;
 
        al = gfs2_alloc_get(ip);
+       if (!al)
+               return -ENOMEM;
 
        error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
        if (error)
                goto out_alloc;
 
-       error = gfs2_rindex_hold(ip->i_sbd, &al->al_ri_gh);
+       error = gfs2_rindex_hold(GFS2_SB(&ip->i_inode), &al->al_ri_gh);
        if (error)
                goto out_quota;
 
-       error = ea_dealloc_unstuffed(ip,
-                                    bh, ea, prev,
-                                    (leave) ? &error : NULL);
+       error = ea_dealloc_unstuffed(ip, bh, ea, prev, (leave) ? &error : NULL);
 
        gfs2_glock_dq_uninit(&al->al_ri_gh);
 
- out_quota:
+out_quota:
        gfs2_quota_unhold(ip);
-
- out_alloc:
+out_alloc:
        gfs2_alloc_put(ip);
-
        return error;
 }
 
@@ -368,35 +350,40 @@ static int ea_list_i(struct gfs2_inode *ip, struct buffer_head *bh,
 {
        struct ea_list *ei = private;
        struct gfs2_ea_request *er = ei->ei_er;
-       unsigned int ea_size = GFS2_EA_STRLEN(ea);
+       unsigned int ea_size = gfs2_ea_strlen(ea);
 
        if (ea->ea_type == GFS2_EATYPE_UNUSED)
                return 0;
 
        if (er->er_data_len) {
-               char *prefix;
-               unsigned int l;
+               char *prefix = NULL;
+               unsigned int l = 0;
                char c = 0;
 
                if (ei->ei_size + ea_size > er->er_data_len)
                        return -ERANGE;
 
-               if (ea->ea_type == GFS2_EATYPE_USR) {
+               switch (ea->ea_type) {
+               case GFS2_EATYPE_USR:
                        prefix = "user.";
                        l = 5;
-               } else {
+                       break;
+               case GFS2_EATYPE_SYS:
                        prefix = "system.";
                        l = 7;
+                       break;
+               case GFS2_EATYPE_SECURITY:
+                       prefix = "security.";
+                       l = 9;
+                       break;
                }
 
-               memcpy(er->er_data + ei->ei_size,
-                      prefix, l);
-               memcpy(er->er_data + ei->ei_size + l,
-                      GFS2_EA2NAME(ea),
+               BUG_ON(l == 0);
+
+               memcpy(er->er_data + ei->ei_size, prefix, l);
+               memcpy(er->er_data + ei->ei_size + l, GFS2_EA2NAME(ea),
                       ea->ea_name_len);
-               memcpy(er->er_data + ei->ei_size +
-                      ea_size - 1,
-                      &c, 1);
+               memcpy(er->er_data + ei->ei_size + ea_size - 1, &c, 1);
        }
 
        ei->ei_size += ea_size;
@@ -422,13 +409,11 @@ int gfs2_ea_list(struct gfs2_inode *ip, struct gfs2_ea_request *er)
                er->er_data_len = 0;
        }
 
-       error = gfs2_glock_nq_init(ip->i_gl,
-                                 LM_ST_SHARED, LM_FLAG_ANY,
-                                 &i_gh);
+       error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh);
        if (error)
                return error;
 
-       if (ip->i_di.di_eattr) {
+       if (ip->i_eattr) {
                struct ea_list ei = { .ei_er = er, .ei_size = 0 };
 
                error = ea_foreach(ip, ea_list_i, &ei);
@@ -444,9 +429,9 @@ int gfs2_ea_list(struct gfs2_inode *ip, struct gfs2_ea_request *er)
 /**
  * ea_get_unstuffed - actually copies the unstuffed data into the
  *                    request buffer
- * @ip:
- * @ea:
- * @data:
+ * @ip: The GFS2 inode
+ * @ea: The extended attribute header structure
+ * @data: The data to be copied
  *
  * Returns: errno
  */
@@ -454,21 +439,21 @@ int gfs2_ea_list(struct gfs2_inode *ip, struct gfs2_ea_request *er)
 static int ea_get_unstuffed(struct gfs2_inode *ip, struct gfs2_ea_header *ea,
                            char *data)
 {
-       struct gfs2_sbd *sdp = ip->i_sbd;
+       struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
        struct buffer_head **bh;
        unsigned int amount = GFS2_EA_DATA_LEN(ea);
        unsigned int nptrs = DIV_ROUND_UP(amount, sdp->sd_jbsize);
-       uint64_t *dataptrs = GFS2_EA2DATAPTRS(ea);
+       __be64 *dataptrs = GFS2_EA2DATAPTRS(ea);
        unsigned int x;
        int error = 0;
 
-       bh = kcalloc(nptrs, sizeof(struct buffer_head *), GFP_KERNEL);
+       bh = kcalloc(nptrs, sizeof(struct buffer_head *), GFP_NOFS);
        if (!bh)
                return -ENOMEM;
 
        for (x = 0; x < nptrs; x++) {
-               error = gfs2_meta_read(ip->i_gl, be64_to_cpu(*dataptrs),
-                                      DIO_START, bh + x);
+               error = gfs2_meta_read(ip->i_gl, be64_to_cpu(*dataptrs), 0,
+                                      bh + x);
                if (error) {
                        while (x--)
                                brelse(bh[x]);
@@ -478,7 +463,7 @@ static int ea_get_unstuffed(struct gfs2_inode *ip, struct gfs2_ea_header *ea,
        }
 
        for (x = 0; x < nptrs; x++) {
-               error = gfs2_meta_reread(sdp, bh[x], DIO_WAIT);
+               error = gfs2_meta_wait(sdp, bh[x]);
                if (error) {
                        for (; x < nptrs; x++)
                                brelse(bh[x]);
@@ -491,8 +476,7 @@ static int ea_get_unstuffed(struct gfs2_inode *ip, struct gfs2_ea_header *ea,
                        goto out;
                }
 
-               memcpy(data,
-                      bh[x]->b_data + sizeof(struct gfs2_meta_header),
+               memcpy(data, bh[x]->b_data + sizeof(struct gfs2_meta_header),
                       (sdp->sd_jbsize > amount) ? amount : sdp->sd_jbsize);
 
                amount -= sdp->sd_jbsize;
@@ -501,9 +485,8 @@ static int ea_get_unstuffed(struct gfs2_inode *ip, struct gfs2_ea_header *ea,
                brelse(bh[x]);
        }
 
- out:
+out:
        kfree(bh);
-
        return error;
 }
 
@@ -511,9 +494,7 @@ int gfs2_ea_get_copy(struct gfs2_inode *ip, struct gfs2_ea_location *el,
                     char *data)
 {
        if (GFS2_EA_IS_STUFFED(el->el_ea)) {
-               memcpy(data,
-                      GFS2_EA2DATA(el->el_ea),
-                      GFS2_EA_DATA_LEN(el->el_ea));
+               memcpy(data, GFS2_EA2DATA(el->el_ea), GFS2_EA_DATA_LEN(el->el_ea));
                return 0;
        } else
                return ea_get_unstuffed(ip, el->el_ea, data);
@@ -521,8 +502,8 @@ int gfs2_ea_get_copy(struct gfs2_inode *ip, struct gfs2_ea_location *el,
 
 /**
  * gfs2_ea_get_i -
- * @ip:
- * @er:
+ * @ip: The GFS2 inode
+ * @er: The request structure
  *
  * Returns: actual size of data on success, -errno on error
  */
@@ -532,7 +513,7 @@ int gfs2_ea_get_i(struct gfs2_inode *ip, struct gfs2_ea_request *er)
        struct gfs2_ea_location el;
        int error;
 
-       if (!ip->i_di.di_eattr)
+       if (!ip->i_eattr)
                return -ENODATA;
 
        error = gfs2_ea_find(ip, er, &el);
@@ -557,8 +538,8 @@ int gfs2_ea_get_i(struct gfs2_inode *ip, struct gfs2_ea_request *er)
 
 /**
  * gfs2_ea_get -
- * @ip:
- * @er:
+ * @ip: The GFS2 inode
+ * @er: The request structure
  *
  * Returns: actual size of data on success, -errno on error
  */
@@ -576,9 +557,7 @@ int gfs2_ea_get(struct gfs2_inode *ip, struct gfs2_ea_request *er)
                er->er_data_len = 0;
        }
 
-       error = gfs2_glock_nq_init(ip->i_gl,
-                                 LM_ST_SHARED, LM_FLAG_ANY,
-                                 &i_gh);
+       error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh);
        if (error)
                return error;
 
@@ -592,19 +571,23 @@ int gfs2_ea_get(struct gfs2_inode *ip, struct gfs2_ea_request *er)
 /**
  * ea_alloc_blk - allocates a new block for extended attributes.
  * @ip: A pointer to the inode that's getting extended attributes
- * @bhp:
+ * @bhp: Pointer to pointer to a struct buffer_head
  *
  * Returns: errno
  */
 
 static int ea_alloc_blk(struct gfs2_inode *ip, struct buffer_head **bhp)
 {
-       struct gfs2_sbd *sdp = ip->i_sbd;
+       struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
        struct gfs2_ea_header *ea;
-       uint64_t block;
-
-       block = gfs2_alloc_meta(ip);
+       unsigned int n = 1;
+       u64 block;
+       int error;
 
+       error = gfs2_alloc_block(ip, &block, &n);
+       if (error)
+               return error;
+       gfs2_trans_add_unrevoke(sdp, block, 1);
        *bhp = gfs2_meta_new(ip->i_gl, block);
        gfs2_trans_add_bh(ip->i_gl, *bhp, 1);
        gfs2_metatype_set(*bhp, GFS2_METATYPE_EA, GFS2_FORMAT_EA);
@@ -616,7 +599,7 @@ static int ea_alloc_blk(struct gfs2_inode *ip, struct buffer_head **bhp)
        ea->ea_flags = GFS2_EAFLAG_LAST;
        ea->ea_num_ptrs = 0;
 
-       ip->i_di.di_blocks++;
+       gfs2_add_inode_blocks(&ip->i_inode, 1);
 
        return 0;
 }
@@ -624,8 +607,8 @@ static int ea_alloc_blk(struct gfs2_inode *ip, struct buffer_head **bhp)
 /**
  * ea_write - writes the request info to an ea, creating new blocks if
  *            necessary
- * @ip:  inode that is being modified
- * @ea:  the location of the new ea in a block
+ * @ip: inode that is being modified
+ * @ea: the location of the new ea in a block
  * @er: the write request
  *
  * Note: does not update ea_rec_len or the GFS2_EAFLAG_LAST bin of ea_flags
@@ -636,7 +619,8 @@ static int ea_alloc_blk(struct gfs2_inode *ip, struct buffer_head **bhp)
 static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea,
                    struct gfs2_ea_request *er)
 {
-       struct gfs2_sbd *sdp = ip->i_sbd;
+       struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
+       int error;
 
        ea->ea_data_len = cpu_to_be32(er->er_data_len);
        ea->ea_name_len = er->er_name_len;
@@ -649,7 +633,7 @@ static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea,
                ea->ea_num_ptrs = 0;
                memcpy(GFS2_EA2DATA(ea), er->er_data, er->er_data_len);
        } else {
-               uint64_t *dataptr = GFS2_EA2DATAPTRS(ea);
+               __be64 *dataptr = GFS2_EA2DATAPTRS(ea);
                const char *data = er->er_data;
                unsigned int data_len = er->er_data_len;
                unsigned int copy;
@@ -658,25 +642,28 @@ static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea,
                ea->ea_num_ptrs = DIV_ROUND_UP(er->er_data_len, sdp->sd_jbsize);
                for (x = 0; x < ea->ea_num_ptrs; x++) {
                        struct buffer_head *bh;
-                       uint64_t block;
+                       u64 block;
                        int mh_size = sizeof(struct gfs2_meta_header);
+                       unsigned int n = 1;
 
-                       block = gfs2_alloc_meta(ip);
-
+                       error = gfs2_alloc_block(ip, &block, &n);
+                       if (error)
+                               return error;
+                       gfs2_trans_add_unrevoke(sdp, block, 1);
                        bh = gfs2_meta_new(ip->i_gl, block);
                        gfs2_trans_add_bh(ip->i_gl, bh, 1);
                        gfs2_metatype_set(bh, GFS2_METATYPE_ED, GFS2_FORMAT_ED);
 
-                       ip->i_di.di_blocks++;
+                       gfs2_add_inode_blocks(&ip->i_inode, 1);
 
-                       copy = (data_len > sdp->sd_jbsize) ? sdp->sd_jbsize :
-                                                            data_len;
+                       copy = data_len > sdp->sd_jbsize ? sdp->sd_jbsize :
+                                                          data_len;
                        memcpy(bh->b_data + mh_size, data, copy);
                        if (copy < sdp->sd_jbsize)
                                memset(bh->b_data + mh_size + copy, 0,
                                       sdp->sd_jbsize - copy);
 
-                       *dataptr++ = cpu_to_be64((uint64_t)bh->b_blocknr);
+                       *dataptr++ = cpu_to_be64(bh->b_blocknr);
                        data += copy;
                        data_len -= copy;
 
@@ -690,36 +677,32 @@ static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea,
 }
 
 typedef int (*ea_skeleton_call_t) (struct gfs2_inode *ip,
-                                  struct gfs2_ea_request *er,
-                                  void *private);
+                                  struct gfs2_ea_request *er, void *private);
 
 static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er,
                             unsigned int blks,
-                            ea_skeleton_call_t skeleton_call,
-                            void *private)
+                            ea_skeleton_call_t skeleton_call, void *private)
 {
        struct gfs2_alloc *al;
        struct buffer_head *dibh;
        int error;
 
        al = gfs2_alloc_get(ip);
+       if (!al)
+               return -ENOMEM;
 
-       error = gfs2_quota_lock(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
+       error = gfs2_quota_lock_check(ip);
        if (error)
                goto out;
 
-       error = gfs2_quota_check(ip, ip->i_di.di_uid, ip->i_di.di_gid);
-       if (error)
-               goto out_gunlock_q;
-
        al->al_requested = blks;
 
        error = gfs2_inplace_reserve(ip);
        if (error)
                goto out_gunlock_q;
 
-       error = gfs2_trans_begin(ip->i_sbd,
-                                blks + al->al_rgd->rd_ri.ri_length +
+       error = gfs2_trans_begin(GFS2_SB(&ip->i_inode),
+                                blks + al->al_rgd->rd_length +
                                 RES_DINODE + RES_STATFS + RES_QUOTA, 0);
        if (error)
                goto out_ipres;
@@ -731,29 +714,25 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er,
        error = gfs2_meta_inode_buffer(ip, &dibh);
        if (!error) {
                if (er->er_flags & GFS2_ERF_MODE) {
-                       gfs2_assert_withdraw(ip->i_sbd,
-                                           (ip->i_di.di_mode & S_IFMT) ==
+                       gfs2_assert_withdraw(GFS2_SB(&ip->i_inode),
+                                           (ip->i_inode.i_mode & S_IFMT) ==
                                            (er->er_mode & S_IFMT));
-                       ip->i_di.di_mode = er->er_mode;
+                       ip->i_inode.i_mode = er->er_mode;
                }
-               ip->i_di.di_ctime = get_seconds();
+               ip->i_inode.i_ctime = CURRENT_TIME;
                gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-               gfs2_dinode_out(&ip->i_di, dibh->b_data);
+               gfs2_dinode_out(ip, dibh->b_data);
                brelse(dibh);
        }
 
- out_end_trans:
-       gfs2_trans_end(ip->i_sbd);
-
- out_ipres:
+out_end_trans:
+       gfs2_trans_end(GFS2_SB(&ip->i_inode));
+out_ipres:
        gfs2_inplace_release(ip);
-
- out_gunlock_q:
+out_gunlock_q:
        gfs2_quota_unlock(ip);
-
- out:
+out:
        gfs2_alloc_put(ip);
-
        return error;
 }
 
@@ -767,7 +746,7 @@ static int ea_init_i(struct gfs2_inode *ip, struct gfs2_ea_request *er,
        if (error)
                return error;
 
-       ip->i_di.di_eattr = bh->b_blocknr;
+       ip->i_eattr = bh->b_blocknr;
        error = ea_write(ip, GFS2_EA_BH2FIRST(bh), er);
 
        brelse(bh);
@@ -785,7 +764,7 @@ static int ea_init_i(struct gfs2_inode *ip, struct gfs2_ea_request *er,
 
 static int ea_init(struct gfs2_inode *ip, struct gfs2_ea_request *er)
 {
-       unsigned int jbsize = ip->i_sbd->sd_jbsize;
+       unsigned int jbsize = GFS2_SB(&ip->i_inode)->sd_jbsize;
        unsigned int blks = 1;
 
        if (GFS2_EAREQ_SIZE_STUFFED(er) > jbsize)
@@ -796,10 +775,10 @@ static int ea_init(struct gfs2_inode *ip, struct gfs2_ea_request *er)
 
 static struct gfs2_ea_header *ea_split_ea(struct gfs2_ea_header *ea)
 {
-       uint32_t ea_size = GFS2_EA_SIZE(ea);
+       u32 ea_size = GFS2_EA_SIZE(ea);
        struct gfs2_ea_header *new = (struct gfs2_ea_header *)((char *)ea +
                                     ea_size);
-       uint32_t new_size = GFS2_EA_REC_LEN(ea) - ea_size;
+       u32 new_size = GFS2_EA_REC_LEN(ea) - ea_size;
        int last = ea->ea_flags & GFS2_EAFLAG_LAST;
 
        ea->ea_rec_len = cpu_to_be32(ea_size);
@@ -816,7 +795,7 @@ static void ea_set_remove_stuffed(struct gfs2_inode *ip,
 {
        struct gfs2_ea_header *ea = el->el_ea;
        struct gfs2_ea_header *prev = el->el_prev;
-       uint32_t len;
+       u32 len;
 
        gfs2_trans_add_bh(ip->i_gl, el->el_bh, 1);
 
@@ -825,7 +804,7 @@ static void ea_set_remove_stuffed(struct gfs2_inode *ip,
                return;
        } else if (GFS2_EA2NEXT(prev) != ea) {
                prev = GFS2_EA2NEXT(prev);
-               gfs2_assert_withdraw(ip->i_sbd, GFS2_EA2NEXT(prev) == ea);
+               gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), GFS2_EA2NEXT(prev) == ea);
        }
 
        len = GFS2_EA_REC_LEN(prev) + GFS2_EA_REC_LEN(ea);
@@ -852,7 +831,7 @@ static int ea_set_simple_noalloc(struct gfs2_inode *ip, struct buffer_head *bh,
        struct buffer_head *dibh;
        int error;
 
-       error = gfs2_trans_begin(ip->i_sbd, RES_DINODE + 2 * RES_EATTR, 0);
+       error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), RES_DINODE + 2 * RES_EATTR, 0);
        if (error)
                return error;
 
@@ -871,17 +850,16 @@ static int ea_set_simple_noalloc(struct gfs2_inode *ip, struct buffer_head *bh,
                goto out;
 
        if (er->er_flags & GFS2_ERF_MODE) {
-               gfs2_assert_withdraw(ip->i_sbd,
-                       (ip->i_di.di_mode & S_IFMT) == (er->er_mode & S_IFMT));
-               ip->i_di.di_mode = er->er_mode;
+               gfs2_assert_withdraw(GFS2_SB(&ip->i_inode),
+                       (ip->i_inode.i_mode & S_IFMT) == (er->er_mode & S_IFMT));
+               ip->i_inode.i_mode = er->er_mode;
        }
-       ip->i_di.di_ctime = get_seconds();
+       ip->i_inode.i_ctime = CURRENT_TIME;
        gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-       gfs2_dinode_out(&ip->i_di, dibh->b_data);
+       gfs2_dinode_out(ip, dibh->b_data);
        brelse(dibh);
- out:
-       gfs2_trans_end(ip->i_sbd);
-
+out:
+       gfs2_trans_end(GFS2_SB(&ip->i_inode));
        return error;
 }
 
@@ -916,7 +894,7 @@ static int ea_set_simple(struct gfs2_inode *ip, struct buffer_head *bh,
        int stuffed;
        int error;
 
-       stuffed = ea_calc_size(ip->i_sbd, es->es_er, &size);
+       stuffed = ea_calc_size(GFS2_SB(&ip->i_inode), es->es_er, &size);
 
        if (ea->ea_type == GFS2_EATYPE_UNUSED) {
                if (GFS2_EA_REC_LEN(ea) < size)
@@ -942,7 +920,7 @@ static int ea_set_simple(struct gfs2_inode *ip, struct buffer_head *bh,
                es->es_bh = bh;
                es->es_ea = ea;
                blks = 2 + DIV_ROUND_UP(es->es_er->er_data_len,
-                                       ip->i_sbd->sd_jbsize);
+                                       GFS2_SB(&ip->i_inode)->sd_jbsize);
 
                error = ea_alloc_skeleton(ip, es->es_er, blks,
                                          ea_set_simple_alloc, es);
@@ -956,17 +934,17 @@ static int ea_set_simple(struct gfs2_inode *ip, struct buffer_head *bh,
 static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er,
                        void *private)
 {
-       struct gfs2_sbd *sdp = ip->i_sbd;
+       struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
        struct buffer_head *indbh, *newbh;
-       uint64_t *eablk;
+       __be64 *eablk;
        int error;
        int mh_size = sizeof(struct gfs2_meta_header);
 
-       if (ip->i_di.di_flags & GFS2_DIF_EA_INDIRECT) {
-               uint64_t *end;
+       if (ip->i_diskflags & GFS2_DIF_EA_INDIRECT) {
+               __be64 *end;
 
-               error = gfs2_meta_read(ip->i_gl, ip->i_di.di_eattr,
-                                      DIO_START | DIO_WAIT, &indbh);
+               error = gfs2_meta_read(ip->i_gl, ip->i_eattr, DIO_WAIT,
+                                      &indbh);
                if (error)
                        return error;
 
@@ -975,7 +953,7 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er,
                        goto out;
                }
 
-               eablk = (uint64_t *)(indbh->b_data + mh_size);
+               eablk = (__be64 *)(indbh->b_data + mh_size);
                end = eablk + sdp->sd_inptrs;
 
                for (; eablk < end; eablk++)
@@ -989,20 +967,22 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er,
 
                gfs2_trans_add_bh(ip->i_gl, indbh, 1);
        } else {
-               uint64_t blk;
-
-               blk = gfs2_alloc_meta(ip);
-
+               u64 blk;
+               unsigned int n = 1;
+               error = gfs2_alloc_block(ip, &blk, &n);
+               if (error)
+                       return error;
+               gfs2_trans_add_unrevoke(sdp, blk, 1);
                indbh = gfs2_meta_new(ip->i_gl, blk);
                gfs2_trans_add_bh(ip->i_gl, indbh, 1);
                gfs2_metatype_set(indbh, GFS2_METATYPE_IN, GFS2_FORMAT_IN);
                gfs2_buffer_clear_tail(indbh, mh_size);
 
-               eablk = (uint64_t *)(indbh->b_data + mh_size);
-               *eablk = cpu_to_be64(ip->i_di.di_eattr);
-               ip->i_di.di_eattr = blk;
-               ip->i_di.di_flags |= GFS2_DIF_EA_INDIRECT;
-               ip->i_di.di_blocks++;
+               eablk = (__be64 *)(indbh->b_data + mh_size);
+               *eablk = cpu_to_be64(ip->i_eattr);
+               ip->i_eattr = blk;
+               ip->i_diskflags |= GFS2_DIF_EA_INDIRECT;
+               gfs2_add_inode_blocks(&ip->i_inode, 1);
 
                eablk++;
        }
@@ -1011,18 +991,17 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er,
        if (error)
                goto out;
 
-       *eablk = cpu_to_be64((uint64_t)newbh->b_blocknr);
+       *eablk = cpu_to_be64((u64)newbh->b_blocknr);
        error = ea_write(ip, GFS2_EA_BH2FIRST(newbh), er);
        brelse(newbh);
        if (error)
                goto out;
 
        if (private)
-               ea_set_remove_stuffed(ip, (struct gfs2_ea_location *)private);
+               ea_set_remove_stuffed(ip, private);
 
- out:
+out:
        brelse(indbh);
-
        return error;
 }
 
@@ -1043,10 +1022,10 @@ static int ea_set_i(struct gfs2_inode *ip, struct gfs2_ea_request *er,
        if (error)
                return error;
 
-       if (!(ip->i_di.di_flags & GFS2_DIF_EA_INDIRECT))
+       if (!(ip->i_diskflags & GFS2_DIF_EA_INDIRECT))
                blks++;
-       if (GFS2_EAREQ_SIZE_STUFFED(er) > ip->i_sbd->sd_jbsize)
-               blks += DIV_ROUND_UP(er->er_data_len, ip->i_sbd->sd_jbsize);
+       if (GFS2_EAREQ_SIZE_STUFFED(er) > GFS2_SB(&ip->i_inode)->sd_jbsize)
+               blks += DIV_ROUND_UP(er->er_data_len, GFS2_SB(&ip->i_inode)->sd_jbsize);
 
        return ea_alloc_skeleton(ip, er, blks, ea_set_block, el);
 }
@@ -1056,7 +1035,7 @@ static int ea_set_remove_unstuffed(struct gfs2_inode *ip,
 {
        if (el->el_prev && GFS2_EA2NEXT(el->el_prev) != el->el_ea) {
                el->el_prev = GFS2_EA2NEXT(el->el_prev);
-               gfs2_assert_withdraw(ip->i_sbd,
+               gfs2_assert_withdraw(GFS2_SB(&ip->i_inode),
                                     GFS2_EA2NEXT(el->el_prev) == el->el_ea);
        }
 
@@ -1068,7 +1047,7 @@ int gfs2_ea_set_i(struct gfs2_inode *ip, struct gfs2_ea_request *er)
        struct gfs2_ea_location el;
        int error;
 
-       if (!ip->i_di.di_eattr) {
+       if (!ip->i_eattr) {
                if (er->er_flags & XATTR_REPLACE)
                        return -ENODATA;
                return ea_init(ip, er);
@@ -1079,7 +1058,7 @@ int gfs2_ea_set_i(struct gfs2_inode *ip, struct gfs2_ea_request *er)
                return error;
 
        if (el.el_ea) {
-               if (ip->i_di.di_flags & GFS2_DIF_APPENDONLY) {
+               if (ip->i_diskflags & GFS2_DIF_APPENDONLY) {
                        brelse(el.el_bh);
                        return -EPERM;
                }
@@ -1107,14 +1086,13 @@ int gfs2_ea_set(struct gfs2_inode *ip, struct gfs2_ea_request *er)
        struct gfs2_holder i_gh;
        int error;
 
-       if (!er->er_name_len ||
-           er->er_name_len > GFS2_EA_MAX_NAME_LEN)
+       if (!er->er_name_len || er->er_name_len > GFS2_EA_MAX_NAME_LEN)
                return -EINVAL;
        if (!er->er_data || !er->er_data_len) {
                er->er_data = NULL;
                er->er_data_len = 0;
        }
-       error = ea_check_size(ip->i_sbd, er);
+       error = ea_check_size(GFS2_SB(&ip->i_inode), er);
        if (error)
                return error;
 
@@ -1122,7 +1100,7 @@ int gfs2_ea_set(struct gfs2_inode *ip, struct gfs2_ea_request *er)
        if (error)
                return error;
 
-       if (IS_IMMUTABLE(ip->i_vnode))
+       if (IS_IMMUTABLE(&ip->i_inode))
                error = -EPERM;
        else
                error = gfs2_ea_ops[er->er_type]->eo_set(ip, er);
@@ -1139,14 +1117,14 @@ static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el)
        struct buffer_head *dibh;
        int error;
 
-       error = gfs2_trans_begin(ip->i_sbd, RES_DINODE + RES_EATTR, 0);
+       error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), RES_DINODE + RES_EATTR, 0);
        if (error)
                return error;
 
        gfs2_trans_add_bh(ip->i_gl, el->el_bh, 1);
 
        if (prev) {
-               uint32_t len;
+               u32 len;
 
                len = GFS2_EA_REC_LEN(prev) + GFS2_EA_REC_LEN(ea);
                prev->ea_rec_len = cpu_to_be32(len);
@@ -1158,13 +1136,13 @@ static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el)
 
        error = gfs2_meta_inode_buffer(ip, &dibh);
        if (!error) {
-               ip->i_di.di_ctime = get_seconds();
+               ip->i_inode.i_ctime = CURRENT_TIME;
                gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-               gfs2_dinode_out(&ip->i_di, dibh->b_data);
+               gfs2_dinode_out(ip, dibh->b_data);
                brelse(dibh);
-       }       
+       }
 
-       gfs2_trans_end(ip->i_sbd);
+       gfs2_trans_end(GFS2_SB(&ip->i_inode));
 
        return error;
 }
@@ -1174,7 +1152,7 @@ int gfs2_ea_remove_i(struct gfs2_inode *ip, struct gfs2_ea_request *er)
        struct gfs2_ea_location el;
        int error;
 
-       if (!ip->i_di.di_eattr)
+       if (!ip->i_eattr)
                return -ENODATA;
 
        error = gfs2_ea_find(ip, er, &el);
@@ -1214,7 +1192,7 @@ int gfs2_ea_remove(struct gfs2_inode *ip, struct gfs2_ea_request *er)
        if (error)
                return error;
 
-       if (IS_IMMUTABLE(ip->i_vnode) || IS_APPEND(ip->i_vnode))
+       if (IS_IMMUTABLE(&ip->i_inode) || IS_APPEND(&ip->i_inode))
                error = -EPERM;
        else
                error = gfs2_ea_ops[er->er_type]->eo_remove(ip, er);
@@ -1227,15 +1205,15 @@ int gfs2_ea_remove(struct gfs2_inode *ip, struct gfs2_ea_request *er)
 static int ea_acl_chmod_unstuffed(struct gfs2_inode *ip,
                                  struct gfs2_ea_header *ea, char *data)
 {
-       struct gfs2_sbd *sdp = ip->i_sbd;
+       struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
        struct buffer_head **bh;
        unsigned int amount = GFS2_EA_DATA_LEN(ea);
        unsigned int nptrs = DIV_ROUND_UP(amount, sdp->sd_jbsize);
-       uint64_t *dataptrs = GFS2_EA2DATAPTRS(ea);
+       __be64 *dataptrs = GFS2_EA2DATAPTRS(ea);
        unsigned int x;
        int error;
 
-       bh = kcalloc(nptrs, sizeof(struct buffer_head *), GFP_KERNEL);
+       bh = kcalloc(nptrs, sizeof(struct buffer_head *), GFP_NOFS);
        if (!bh)
                return -ENOMEM;
 
@@ -1244,8 +1222,8 @@ static int ea_acl_chmod_unstuffed(struct gfs2_inode *ip,
                goto out;
 
        for (x = 0; x < nptrs; x++) {
-               error = gfs2_meta_read(ip->i_gl, be64_to_cpu(*dataptrs),
-                                      DIO_START, bh + x);
+               error = gfs2_meta_read(ip->i_gl, be64_to_cpu(*dataptrs), 0,
+                                      bh + x);
                if (error) {
                        while (x--)
                                brelse(bh[x]);
@@ -1255,7 +1233,7 @@ static int ea_acl_chmod_unstuffed(struct gfs2_inode *ip,
        }
 
        for (x = 0; x < nptrs; x++) {
-               error = gfs2_meta_reread(sdp, bh[x], DIO_WAIT);
+               error = gfs2_meta_wait(sdp, bh[x]);
                if (error) {
                        for (; x < nptrs; x++)
                                brelse(bh[x]);
@@ -1270,8 +1248,7 @@ static int ea_acl_chmod_unstuffed(struct gfs2_inode *ip,
 
                gfs2_trans_add_bh(ip->i_gl, bh[x], 1);
 
-               memcpy(bh[x]->b_data + sizeof(struct gfs2_meta_header),
-                      data,
+               memcpy(bh[x]->b_data + sizeof(struct gfs2_meta_header), data,
                       (sdp->sd_jbsize > amount) ? amount : sdp->sd_jbsize);
 
                amount -= sdp->sd_jbsize;
@@ -1280,15 +1257,13 @@ static int ea_acl_chmod_unstuffed(struct gfs2_inode *ip,
                brelse(bh[x]);
        }
 
- out:
+out:
        kfree(bh);
-
        return error;
 
- fail:
+fail:
        gfs2_trans_end(sdp);
        kfree(bh);
-
        return error;
 }
 
@@ -1299,13 +1274,12 @@ int gfs2_ea_acl_chmod(struct gfs2_inode *ip, struct gfs2_ea_location *el,
        int error;
 
        if (GFS2_EA_IS_STUFFED(el->el_ea)) {
-               error = gfs2_trans_begin(ip->i_sbd, RES_DINODE + RES_EATTR, 0);
+               error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), RES_DINODE + RES_EATTR, 0);
                if (error)
                        return error;
 
                gfs2_trans_add_bh(ip->i_gl, el->el_bh, 1);
-               memcpy(GFS2_EA2DATA(el->el_ea),
-                      data,
+               memcpy(GFS2_EA2DATA(el->el_ea), data,
                       GFS2_EA_DATA_LEN(el->el_ea));
        } else
                error = ea_acl_chmod_unstuffed(ip, el->el_ea, data);
@@ -1315,27 +1289,26 @@ int gfs2_ea_acl_chmod(struct gfs2_inode *ip, struct gfs2_ea_location *el,
 
        error = gfs2_meta_inode_buffer(ip, &dibh);
        if (!error) {
-               error = inode_setattr(ip->i_vnode, attr);
-               gfs2_assert_warn(ip->i_sbd, !error);
-               gfs2_inode_attr_out(ip);
+               error = inode_setattr(&ip->i_inode, attr);
+               gfs2_assert_warn(GFS2_SB(&ip->i_inode), !error);
                gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-               gfs2_dinode_out(&ip->i_di, dibh->b_data);
+               gfs2_dinode_out(ip, dibh->b_data);
                brelse(dibh);
        }
 
-       gfs2_trans_end(ip->i_sbd);
+       gfs2_trans_end(GFS2_SB(&ip->i_inode));
 
        return error;
 }
 
 static int ea_dealloc_indirect(struct gfs2_inode *ip)
 {
-       struct gfs2_sbd *sdp = ip->i_sbd;
+       struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
        struct gfs2_rgrp_list rlist;
        struct buffer_head *indbh, *dibh;
-       uint64_t *eablk, *end;
+       __be64 *eablk, *end;
        unsigned int rg_blocks = 0;
-       uint64_t bstart = 0;
+       u64 bstart = 0;
        unsigned int blen = 0;
        unsigned int blks = 0;
        unsigned int x;
@@ -1343,8 +1316,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
 
        memset(&rlist, 0, sizeof(struct gfs2_rgrp_list));
 
-       error = gfs2_meta_read(ip->i_gl, ip->i_di.di_eattr,
-                              DIO_START | DIO_WAIT, &indbh);
+       error = gfs2_meta_read(ip->i_gl, ip->i_eattr, DIO_WAIT, &indbh);
        if (error)
                return error;
 
@@ -1353,11 +1325,11 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
                goto out;
        }
 
-       eablk = (uint64_t *)(indbh->b_data + sizeof(struct gfs2_meta_header));
+       eablk = (__be64 *)(indbh->b_data + sizeof(struct gfs2_meta_header));
        end = eablk + sdp->sd_inptrs;
 
        for (; eablk < end; eablk++) {
-               uint64_t bn;
+               u64 bn;
 
                if (!*eablk)
                        break;
@@ -1378,32 +1350,31 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
        else
                goto out;
 
-       gfs2_rlist_alloc(&rlist, LM_ST_EXCLUSIVE, 0);
+       gfs2_rlist_alloc(&rlist, LM_ST_EXCLUSIVE);
 
        for (x = 0; x < rlist.rl_rgrps; x++) {
                struct gfs2_rgrpd *rgd;
                rgd = rlist.rl_ghs[x].gh_gl->gl_object;
-               rg_blocks += rgd->rd_ri.ri_length;
+               rg_blocks += rgd->rd_length;
        }
 
        error = gfs2_glock_nq_m(rlist.rl_rgrps, rlist.rl_ghs);
        if (error)
                goto out_rlist_free;
 
-       error = gfs2_trans_begin(sdp, rg_blocks + RES_DINODE +
-                                RES_INDIRECT + RES_STATFS +
-                                RES_QUOTA, blks);
+       error = gfs2_trans_begin(sdp, rg_blocks + RES_DINODE + RES_INDIRECT +
+                                RES_STATFS + RES_QUOTA, blks);
        if (error)
                goto out_gunlock;
 
        gfs2_trans_add_bh(ip->i_gl, indbh, 1);
 
-       eablk = (uint64_t *)(indbh->b_data + sizeof(struct gfs2_meta_header));
+       eablk = (__be64 *)(indbh->b_data + sizeof(struct gfs2_meta_header));
        bstart = 0;
        blen = 0;
 
        for (; eablk < end; eablk++) {
-               uint64_t bn;
+               u64 bn;
 
                if (!*eablk)
                        break;
@@ -1419,45 +1390,40 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
                }
 
                *eablk = 0;
-               if (!ip->i_di.di_blocks)
-                       gfs2_consist_inode(ip);
-               ip->i_di.di_blocks--;
+               gfs2_add_inode_blocks(&ip->i_inode, -1);
        }
        if (bstart)
                gfs2_free_meta(ip, bstart, blen);
 
-       ip->i_di.di_flags &= ~GFS2_DIF_EA_INDIRECT;
+       ip->i_diskflags &= ~GFS2_DIF_EA_INDIRECT;
 
        error = gfs2_meta_inode_buffer(ip, &dibh);
        if (!error) {
                gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-               gfs2_dinode_out(&ip->i_di, dibh->b_data);
+               gfs2_dinode_out(ip, dibh->b_data);
                brelse(dibh);
        }
 
        gfs2_trans_end(sdp);
 
- out_gunlock:
+out_gunlock:
        gfs2_glock_dq_m(rlist.rl_rgrps, rlist.rl_ghs);
-
- out_rlist_free:
+out_rlist_free:
        gfs2_rlist_free(&rlist);
-
- out:
+out:
        brelse(indbh);
-
        return error;
 }
 
 static int ea_dealloc_block(struct gfs2_inode *ip)
 {
-       struct gfs2_sbd *sdp = ip->i_sbd;
-       struct gfs2_alloc *al = &ip->i_alloc;
+       struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
+       struct gfs2_alloc *al = ip->i_alloc;
        struct gfs2_rgrpd *rgd;
        struct buffer_head *dibh;
        int error;
 
-       rgd = gfs2_blk2rgrpd(sdp, ip->i_di.di_eattr);
+       rgd = gfs2_blk2rgrpd(sdp, ip->i_eattr);
        if (!rgd) {
                gfs2_consist_inode(ip);
                return -EIO;
@@ -1468,30 +1434,27 @@ static int ea_dealloc_block(struct gfs2_inode *ip)
        if (error)
                return error;
 
-       error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_DINODE +
-                                RES_STATFS + RES_QUOTA, 1);
+       error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_DINODE + RES_STATFS +
+                                RES_QUOTA, 1);
        if (error)
                goto out_gunlock;
 
-       gfs2_free_meta(ip, ip->i_di.di_eattr, 1);
+       gfs2_free_meta(ip, ip->i_eattr, 1);
 
-       ip->i_di.di_eattr = 0;
-       if (!ip->i_di.di_blocks)
-               gfs2_consist_inode(ip);
-       ip->i_di.di_blocks--;
+       ip->i_eattr = 0;
+       gfs2_add_inode_blocks(&ip->i_inode, -1);
 
        error = gfs2_meta_inode_buffer(ip, &dibh);
        if (!error) {
                gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-               gfs2_dinode_out(&ip->i_di, dibh->b_data);
+               gfs2_dinode_out(ip, dibh->b_data);
                brelse(dibh);
        }
 
        gfs2_trans_end(sdp);
 
- out_gunlock:
+out_gunlock:
        gfs2_glock_dq_uninit(&al->al_rgd_gh);
-
        return error;
 }
 
@@ -1508,12 +1471,14 @@ int gfs2_ea_dealloc(struct gfs2_inode *ip)
        int error;
 
        al = gfs2_alloc_get(ip);
+       if (!al)
+               return -ENOMEM;
 
        error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
        if (error)
                goto out_alloc;
 
-       error = gfs2_rindex_hold(ip->i_sbd, &al->al_ri_gh);
+       error = gfs2_rindex_hold(GFS2_SB(&ip->i_inode), &al->al_ri_gh);
        if (error)
                goto out_quota;
 
@@ -1521,7 +1486,7 @@ int gfs2_ea_dealloc(struct gfs2_inode *ip)
        if (error)
                goto out_rindex;
 
-       if (ip->i_di.di_flags & GFS2_DIF_EA_INDIRECT) {
+       if (ip->i_diskflags & GFS2_DIF_EA_INDIRECT) {
                error = ea_dealloc_indirect(ip);
                if (error)
                        goto out_rindex;
@@ -1529,15 +1494,12 @@ int gfs2_ea_dealloc(struct gfs2_inode *ip)
 
        error = ea_dealloc_block(ip);
 
- out_rindex:
+out_rindex:
        gfs2_glock_dq_uninit(&al->al_ri_gh);
-
- out_quota:
+out_quota:
        gfs2_quota_unhold(ip);
-
- out_alloc:
+out_alloc:
        gfs2_alloc_put(ip);
-
        return error;
 }