[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>
This commit is contained in:
Steven Whitehouse 2006-01-18 10:57:10 +00:00
parent 3bd7662c4d
commit b96ca4fa4e
3 changed files with 30 additions and 19 deletions

View File

@ -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));
di = (struct gfs2_dinode *)dibh->b_data;
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->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);
}

View File

@ -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;

View File

@ -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);