#include <linux/buffer_head.h>
#include <linux/gfs2_ondisk.h>
#include <linux/crc32.h>
+#include <linux/lm_interface.h>
#include "gfs2.h"
-#include "lm_interface.h"
#include "incore.h"
#include "bmap.h"
#include "glock.h"
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;
error = gfs2_meta_inode_buffer(ip, &dibh);
if (error)
goto out;
-
+
if (ip->i_di.di_size) {
/* Get a free block, fill it with the stuffed data,
and write it out to disk */
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 {
/* 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);
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;
u64 bn;
blocks[n] = gfs2_meta_new(ip->i_gl, bn);
gfs2_trans_add_bh(ip->i_gl, blocks[n], 1);
}
-
+
n = 0;
bn = blocks[0]->b_blocknr;
if (new_height > 1) {
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;
}
u64 dblock = 0;
int boundary;
+ BUG_ON(maxlen == 0);
+
if (gfs2_assert_warn(sdp, !gfs2_is_stuffed(ip)))
return 0;
BUG_ON(!new);
bmap_lock(inode, create);
- ret = gfs2_block_pointers(inode, lblock, create, &bh, &mp, *extlen);
+ ret = gfs2_block_pointers(inode, lblock, create, &bh, &mp, 32);
bmap_unlock(inode, create);
*extlen = bh.b_size >> inode->i_blkbits;
*dblock = bh.b_blocknr;