summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Whitehouse <steve@chygwyn.com>2006-01-18 10:57:10 +0000
committerSteven Whitehouse <steve@chygwyn.com>2006-01-18 10:57:10 +0000
commitb96ca4fa4e3b510d528a093a5bac0befbc2ba46d (patch)
treee4ac82f1d0472d46c8ac30d351b044f1fb3f34d2
parent3bd7662c4de28522d4709ab5a56033e3c33e1d4a (diff)
[GFS2] Update init_dinode() to reduce stack usage
We no longer allocate a dinode on the stack in init_dinode() and we no longer use gfs2_dinode_out (eliminating one copy) and gfs2_meta_header_in (eliminating another copy). The meta_header_in fucntion is now no longer referenced from outside gfs2_ondisk.c, so make it static. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
-rw-r--r--fs/gfs2/inode.c45
-rw-r--r--fs/gfs2/ondisk.c4
-rw-r--r--include/linux/gfs2_ondisk.h2
3 files changed, 31 insertions, 20 deletions
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 73922dba5398..aa5311ef7ba7 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -993,37 +993,50 @@ static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
unsigned int uid, unsigned int gid)
{
struct gfs2_sbd *sdp = dip->i_sbd;
- struct gfs2_dinode di;
+ struct gfs2_dinode *di;
struct buffer_head *dibh;
dibh = gfs2_meta_new(gl, inum->no_addr);
gfs2_trans_add_bh(gl, dibh);
gfs2_metatype_set(dibh, GFS2_METATYPE_DI, GFS2_FORMAT_DI);
gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
-
- memset(&di, 0, sizeof(struct gfs2_dinode));
- gfs2_meta_header_in(&di.di_header, dibh->b_data);
- di.di_num = *inum;
- di.di_mode = mode;
- di.di_uid = uid;
- di.di_gid = gid;
- di.di_blocks = 1;
- di.di_atime = di.di_mtime = di.di_ctime = get_seconds();
- di.di_goal_meta = di.di_goal_data = inum->no_addr;
+ di = (struct gfs2_dinode *)dibh->b_data;
+
+ di->di_num = *inum;
+ di->di_mode = cpu_to_be32(mode);
+ di->di_uid = cpu_to_be32(uid);
+ di->di_gid = cpu_to_be32(gid);
+ di->di_nlink = cpu_to_be32(0);
+ di->di_size = cpu_to_be64(0);
+ di->di_blocks = cpu_to_be64(1);
+ di->di_atime = di->di_mtime = di->di_ctime = cpu_to_be64(get_seconds());
+ di->di_major = di->di_minor = cpu_to_be32(0);
+ di->di_goal_meta = di->di_goal_data = cpu_to_be64(inum->no_addr);
+ di->__pad[0] = di->__pad[1] = 0;
+ di->di_flags = cpu_to_be32(0);
if (S_ISREG(mode)) {
if ((dip->i_di.di_flags & GFS2_DIF_INHERIT_JDATA) ||
gfs2_tune_get(sdp, gt_new_files_jdata))
- di.di_flags |= GFS2_DIF_JDATA;
+ di->di_flags |= cpu_to_be32(GFS2_DIF_JDATA);
if ((dip->i_di.di_flags & GFS2_DIF_INHERIT_DIRECTIO) ||
gfs2_tune_get(sdp, gt_new_files_directio))
- di.di_flags |= GFS2_DIF_DIRECTIO;
+ di->di_flags |= cpu_to_be32(GFS2_DIF_DIRECTIO);
} else if (S_ISDIR(mode)) {
- di.di_flags |= (dip->i_di.di_flags & GFS2_DIF_INHERIT_DIRECTIO);
- di.di_flags |= (dip->i_di.di_flags & GFS2_DIF_INHERIT_JDATA);
+ di->di_flags |= cpu_to_be32(dip->i_di.di_flags & GFS2_DIF_INHERIT_DIRECTIO);
+ di->di_flags |= cpu_to_be32(dip->i_di.di_flags & GFS2_DIF_INHERIT_JDATA);
}
- gfs2_dinode_out(&di, dibh->b_data);
+ di->__pad1 = 0;
+ di->di_height = cpu_to_be32(0);
+ di->__pad2 = 0;
+ di->__pad3 = 0;
+ di->di_depth = cpu_to_be16(0);
+ di->di_entries = cpu_to_be32(0);
+ memset(&di->__pad4, 0, sizeof(di->__pad4));
+ di->di_eattr = cpu_to_be64(0);
+ memset(&di->di_reserved, 0, sizeof(di->di_reserved));
+
brelse(dibh);
}
diff --git a/fs/gfs2/ondisk.c b/fs/gfs2/ondisk.c
index 0d54e082e62b..854b5049b8d5 100644
--- a/fs/gfs2/ondisk.c
+++ b/fs/gfs2/ondisk.c
@@ -77,7 +77,7 @@ void gfs2_inum_print(struct gfs2_inum *no)
pv(no, no_addr, "%llu");
}
-void gfs2_meta_header_in(struct gfs2_meta_header *mh, char *buf)
+static void gfs2_meta_header_in(struct gfs2_meta_header *mh, char *buf)
{
struct gfs2_meta_header *str = (struct gfs2_meta_header *)buf;
@@ -86,7 +86,7 @@ void gfs2_meta_header_in(struct gfs2_meta_header *mh, char *buf)
mh->mh_format = be16_to_cpu(str->mh_format);
}
-void gfs2_meta_header_out(struct gfs2_meta_header *mh, char *buf)
+static void gfs2_meta_header_out(struct gfs2_meta_header *mh, char *buf)
{
struct gfs2_meta_header *str = (struct gfs2_meta_header *)buf;
diff --git a/include/linux/gfs2_ondisk.h b/include/linux/gfs2_ondisk.h
index 8354b9c4f408..f1302e2616da 100644
--- a/include/linux/gfs2_ondisk.h
+++ b/include/linux/gfs2_ondisk.h
@@ -404,8 +404,6 @@ struct gfs2_quota_change {
extern void gfs2_inum_in(struct gfs2_inum *no, char *buf);
extern void gfs2_inum_out(struct gfs2_inum *no, char *buf);
-extern void gfs2_meta_header_in(struct gfs2_meta_header *mh, char *buf);
-extern void gfs2_meta_header_out(struct gfs2_meta_header *mh, char *buf);
extern void gfs2_sb_in(struct gfs2_sb *sb, char *buf);
extern void gfs2_rindex_in(struct gfs2_rindex *ri, char *buf);
extern void gfs2_rindex_out(struct gfs2_rindex *ri, char *buf);