[GFS2] Change argument of gfs2_dinode_out
[deliverable/linux.git] / fs / gfs2 / bmap.c
index 92eef825167d5bd5b4b4464c844b9d17c23ad463..8c092ab2b4ba77400253e6626d2940a0d28af9e9 100644 (file)
@@ -38,8 +38,8 @@ struct metapath {
 };
 
 typedef int (*block_call_t) (struct gfs2_inode *ip, struct buffer_head *dibh,
-                            struct buffer_head *bh, u64 *top,
-                            u64 *bottom, unsigned int height,
+                            struct buffer_head *bh, __be64 *top,
+                            __be64 *bottom, unsigned int height,
                             void *data);
 
 struct strip_mine {
@@ -121,6 +121,7 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh,
 int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)
 {
        struct buffer_head *bh, *dibh;
+       struct gfs2_dinode *di;
        u64 block = 0;
        int isdir = gfs2_is_dir(ip);
        int error;
@@ -141,8 +142,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)
                        error = gfs2_dir_get_new_buffer(ip, block, &bh);
                        if (error)
                                goto out_brelse;
-                       gfs2_buffer_copy_tail(bh,
-                                             sizeof(struct gfs2_meta_header),
+                       gfs2_buffer_copy_tail(bh, sizeof(struct gfs2_meta_header),
                                              dibh, sizeof(struct gfs2_dinode));
                        brelse(bh);
                } else {
@@ -157,18 +157,17 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)
        /*  Set up the pointer to the new block  */
 
        gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-
+       di = (struct gfs2_dinode *)dibh->b_data;
        gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
 
        if (ip->i_di.di_size) {
-               *(u64 *)(dibh->b_data + sizeof(struct gfs2_dinode)) =
-                       cpu_to_be64(block);
+               *(__be64 *)(di + 1) = cpu_to_be64(block);
                ip->i_di.di_blocks++;
+               di->di_blocks = cpu_to_be64(ip->i_di.di_blocks);
        }
 
        ip->i_di.di_height = 1;
-
-       gfs2_dinode_out(&ip->i_di, dibh->b_data);
+       di->di_height = cpu_to_be16(1);
 
 out_brelse:
        brelse(dibh);
@@ -229,8 +228,9 @@ static int build_height(struct inode *inode, unsigned height)
        unsigned new_height = height - ip->i_di.di_height;
        struct buffer_head *dibh;
        struct buffer_head *blocks[GFS2_MAX_META_HEIGHT];
+       struct gfs2_dinode *di;
        int error;
-       u64 *bp;
+       __be64 *bp;
        u64 bn;
        unsigned n;
 
@@ -255,7 +255,7 @@ static int build_height(struct inode *inode, unsigned height)
                                          GFS2_FORMAT_IN);
                        gfs2_buffer_clear_tail(blocks[n],
                                               sizeof(struct gfs2_meta_header));
-                       bp = (u64 *)(blocks[n]->b_data +
+                       bp = (__be64 *)(blocks[n]->b_data +
                                     sizeof(struct gfs2_meta_header));
                        *bp = cpu_to_be64(blocks[n+1]->b_blocknr);
                        brelse(blocks[n]);
@@ -267,12 +267,13 @@ static int build_height(struct inode *inode, unsigned height)
                              dibh, sizeof(struct gfs2_dinode));
        brelse(blocks[n]);
        gfs2_trans_add_bh(ip->i_gl, dibh, 1);
+       di = (struct gfs2_dinode *)dibh->b_data;
        gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
-       bp = (u64 *)(dibh->b_data + sizeof(struct gfs2_dinode));
-       *bp = cpu_to_be64(bn);
+       *(__be64 *)(di + 1) = cpu_to_be64(bn);
        ip->i_di.di_height += new_height;
        ip->i_di.di_blocks += new_height;
-       gfs2_dinode_out(&ip->i_di, dibh->b_data);
+       di->di_height = cpu_to_be16(ip->i_di.di_height);
+       di->di_blocks = cpu_to_be64(ip->i_di.di_blocks);
        brelse(dibh);
        return error;
 }
@@ -359,15 +360,15 @@ static void find_metapath(struct gfs2_inode *ip, u64 block,
  * metadata tree.
  */
 
-static inline u64 *metapointer(struct buffer_head *bh, int *boundary,
+static inline __be64 *metapointer(struct buffer_head *bh, int *boundary,
                               unsigned int height, const struct metapath *mp)
 {
        unsigned int head_size = (height > 0) ?
                sizeof(struct gfs2_meta_header) : sizeof(struct gfs2_dinode);
-       u64 *ptr;
+       __be64 *ptr;
        *boundary = 0;
-       ptr = ((u64 *)(bh->b_data + head_size)) + mp->mp_list[height];
-       if (ptr + 1 == (u64 *)(bh->b_data + bh->b_size))
+       ptr = ((__be64 *)(bh->b_data + head_size)) + mp->mp_list[height];
+       if (ptr + 1 == (__be64 *)(bh->b_data + bh->b_size))
                *boundary = 1;
        return ptr;
 }
@@ -393,7 +394,7 @@ static int lookup_block(struct gfs2_inode *ip, struct buffer_head *bh,
                        int *new, u64 *block)
 {
        int boundary;
-       u64 *ptr = metapointer(bh, &boundary, height, mp);
+       __be64 *ptr = metapointer(bh, &boundary, height, mp);
 
        if (*ptr) {
                *block = be64_to_cpu(*ptr);
@@ -433,8 +434,7 @@ static int lookup_block(struct gfs2_inode *ip, struct buffer_head *bh,
  */
 
 static int gfs2_block_pointers(struct inode *inode, u64 lblock, int create,
-                              struct buffer_head *bh_map, struct metapath *mp,
-                              unsigned int maxlen)
+                              struct buffer_head *bh_map, struct metapath *mp)
 {
        struct gfs2_inode *ip = GFS2_I(inode);
        struct gfs2_sbd *sdp = GFS2_SB(inode);
@@ -447,6 +447,7 @@ static int gfs2_block_pointers(struct inode *inode, u64 lblock, int create,
        int new = 0;
        u64 dblock = 0;
        int boundary;
+       unsigned int maxlen = bh_map->b_size >> inode->i_blkbits;
 
        BUG_ON(maxlen == 0);
 
@@ -497,7 +498,7 @@ static int gfs2_block_pointers(struct inode *inode, u64 lblock, int create,
                        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);
                        }
                        set_buffer_new(bh_map);
@@ -540,13 +541,13 @@ static inline void bmap_unlock(struct inode *inode, int create)
 }
 
 int gfs2_block_map(struct inode *inode, u64 lblock, int create,
-                  struct buffer_head *bh, unsigned int maxlen)
+                  struct buffer_head *bh)
 {
        struct metapath mp;
        int ret;
 
        bmap_lock(inode, create);
-       ret = gfs2_block_pointers(inode, lblock, create, bh, &mp, maxlen);
+       ret = gfs2_block_pointers(inode, lblock, create, bh, &mp);
        bmap_unlock(inode, create);
        return ret;
 }
@@ -554,7 +555,7 @@ int gfs2_block_map(struct inode *inode, u64 lblock, int create,
 int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsigned *extlen)
 {
        struct metapath mp;
-       struct buffer_head bh = { .b_state = 0, .b_blocknr = 0, .b_size = 0 };
+       struct buffer_head bh = { .b_state = 0, .b_blocknr = 0 };
        int ret;
        int create = *new;
 
@@ -562,8 +563,9 @@ int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsi
        BUG_ON(!dblock);
        BUG_ON(!new);
 
+       bh.b_size = 1 << (inode->i_blkbits + 5);
        bmap_lock(inode, create);
-       ret = gfs2_block_pointers(inode, lblock, create, &bh, &mp, 32);
+       ret = gfs2_block_pointers(inode, lblock, create, &bh, &mp);
        bmap_unlock(inode, create);
        *extlen = bh.b_size >> inode->i_blkbits;
        *dblock = bh.b_blocknr;
@@ -598,7 +600,7 @@ static int recursive_scan(struct gfs2_inode *ip, struct buffer_head *dibh,
 {
        struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
        struct buffer_head *bh = NULL;
-       u64 *top, *bottom;
+       __be64 *top, *bottom;
        u64 bn;
        int error;
        int mh_size = sizeof(struct gfs2_meta_header);
@@ -609,17 +611,17 @@ static int recursive_scan(struct gfs2_inode *ip, struct buffer_head *dibh,
                        return error;
                dibh = bh;
 
-               top = (u64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + mp->mp_list[0];
-               bottom = (u64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + sdp->sd_diptrs;
+               top = (__be64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + mp->mp_list[0];
+               bottom = (__be64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + sdp->sd_diptrs;
        } else {
                error = gfs2_meta_indirect_buffer(ip, height, block, 0, &bh);
                if (error)
                        return error;
 
-               top = (u64 *)(bh->b_data + mh_size) +
+               top = (__be64 *)(bh->b_data + mh_size) +
                                  (first ? mp->mp_list[height] : 0);
 
-               bottom = (u64 *)(bh->b_data + mh_size) + sdp->sd_inptrs;
+               bottom = (__be64 *)(bh->b_data + mh_size) + sdp->sd_inptrs;
        }
 
        error = bc(ip, dibh, bh, top, bottom, height, data);
@@ -658,7 +660,7 @@ out:
  */
 
 static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
-                   struct buffer_head *bh, u64 *top, u64 *bottom,
+                   struct buffer_head *bh, __be64 *top, __be64 *bottom,
                    unsigned int height, void *data)
 {
        struct strip_mine *sm = data;
@@ -666,7 +668,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
        struct gfs2_rgrp_list rlist;
        u64 bn, bstart;
        u32 blen;
-       u64 *p;
+       __be64 *p;
        unsigned int rg_blocks = 0;
        int metadata;
        unsigned int revokes = 0;
@@ -778,7 +780,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
 
        ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds();
 
-       gfs2_dinode_out(&ip->i_di, dibh->b_data);
+       gfs2_dinode_out(ip, dibh->b_data);
 
        up_write(&ip->i_rw_mutex);
 
@@ -858,7 +860,7 @@ static int do_grow(struct gfs2_inode *ip, u64 size)
                goto out_end_trans;
 
        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:
@@ -968,7 +970,7 @@ static int trunc_start(struct gfs2_inode *ip, u64 size)
                ip->i_di.di_size = size;
                ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds();
                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);
                gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode) + size);
                error = 1;
 
@@ -981,7 +983,7 @@ static int trunc_start(struct gfs2_inode *ip, u64 size)
                        ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds();
                        ip->i_di.di_flags |= GFS2_DIF_TRUNC_IN_PROG;
                        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);
                }
        }
 
@@ -1055,7 +1057,7 @@ static int trunc_end(struct gfs2_inode *ip)
        ip->i_di.di_flags &= ~GFS2_DIF_TRUNC_IN_PROG;
 
        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:
This page took 0.028961 seconds and 5 git commands to generate.