Skip to content

Commit

Permalink
nilfs2: add size option of private object to metadata file allocator
Browse files Browse the repository at this point in the history
This adds an optional "object size" argument to nilfs_mdt_new_common()
function; the argument specifies the size of private object attached
to a newly allocated metadata file inode.

This will afford space to keep local variables for meta data files.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
  • Loading branch information
Ryusuke Konishi committed Nov 20, 2009
1 parent 9cb4e0d commit 5731e19
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
3 changes: 2 additions & 1 deletion fs/nilfs2/gcinode.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,10 @@ void nilfs_destroy_gccache(struct the_nilfs *nilfs)
static struct inode *alloc_gcinode(struct the_nilfs *nilfs, ino_t ino,
__u64 cno)
{
struct inode *inode = nilfs_mdt_new_common(nilfs, NULL, ino, GFP_NOFS);
struct inode *inode;
struct nilfs_inode_info *ii;

inode = nilfs_mdt_new_common(nilfs, NULL, ino, GFP_NOFS, 0);
if (!inode)
return NULL;

Expand Down
19 changes: 14 additions & 5 deletions fs/nilfs2/mdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,18 +445,27 @@ static const struct file_operations def_mdt_fops;
* longer than those of the super block structs; they may continue for
* several consecutive mounts/umounts. This would need discussions.
*/
/**
* nilfs_mdt_new_common - allocate a pseudo inode for metadata file
* @nilfs: nilfs object
* @sb: super block instance the metadata file belongs to
* @ino: inode number
* @gfp_mask: gfp mask for data pages
* @objsz: size of the private object attached to inode->i_private
*/
struct inode *
nilfs_mdt_new_common(struct the_nilfs *nilfs, struct super_block *sb,
ino_t ino, gfp_t gfp_mask)
ino_t ino, gfp_t gfp_mask, size_t objsz)
{
struct inode *inode = nilfs_alloc_inode_common(nilfs);

if (!inode)
return NULL;
else {
struct address_space * const mapping = &inode->i_data;
struct nilfs_mdt_info *mi = kzalloc(sizeof(*mi), GFP_NOFS);
struct nilfs_mdt_info *mi;

mi = kzalloc(max(sizeof(*mi), objsz), GFP_NOFS);
if (!mi) {
nilfs_destroy_inode(inode);
return NULL;
Expand Down Expand Up @@ -513,11 +522,11 @@ nilfs_mdt_new_common(struct the_nilfs *nilfs, struct super_block *sb,
}

struct inode *nilfs_mdt_new(struct the_nilfs *nilfs, struct super_block *sb,
ino_t ino)
ino_t ino, size_t objsz)
{
struct inode *inode = nilfs_mdt_new_common(nilfs, sb, ino,
NILFS_MDT_GFP);
struct inode *inode;

inode = nilfs_mdt_new_common(nilfs, sb, ino, NILFS_MDT_GFP, objsz);
if (!inode)
return NULL;

Expand Down
5 changes: 3 additions & 2 deletions fs/nilfs2/mdt.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ int nilfs_mdt_forget_block(struct inode *, unsigned long);
int nilfs_mdt_mark_block_dirty(struct inode *, unsigned long);
int nilfs_mdt_fetch_dirty(struct inode *);

struct inode *nilfs_mdt_new(struct the_nilfs *, struct super_block *, ino_t);
struct inode *nilfs_mdt_new(struct the_nilfs *, struct super_block *, ino_t,
size_t);
struct inode *nilfs_mdt_new_common(struct the_nilfs *, struct super_block *,
ino_t, gfp_t);
ino_t, gfp_t, size_t);
void nilfs_mdt_destroy(struct inode *);
void nilfs_mdt_clear(struct inode *);
void nilfs_mdt_set_entry_size(struct inode *, unsigned, unsigned);
Expand Down
2 changes: 1 addition & 1 deletion fs/nilfs2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ int nilfs_attach_checkpoint(struct nilfs_sb_info *sbi, __u64 cno)
list_add(&sbi->s_list, &nilfs->ns_supers);
up_write(&nilfs->ns_super_sem);

sbi->s_ifile = nilfs_mdt_new(nilfs, sbi->s_super, NILFS_IFILE_INO);
sbi->s_ifile = nilfs_mdt_new(nilfs, sbi->s_super, NILFS_IFILE_INO, 0);
if (!sbi->s_ifile)
return -ENOMEM;

Expand Down
8 changes: 4 additions & 4 deletions fs/nilfs2/the_nilfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,19 +187,19 @@ static int nilfs_load_super_root(struct the_nilfs *nilfs,
inode_size = nilfs->ns_inode_size;

err = -ENOMEM;
nilfs->ns_dat = nilfs_mdt_new(nilfs, NULL, NILFS_DAT_INO);
nilfs->ns_dat = nilfs_mdt_new(nilfs, NULL, NILFS_DAT_INO, 0);
if (unlikely(!nilfs->ns_dat))
goto failed;

nilfs->ns_gc_dat = nilfs_mdt_new(nilfs, NULL, NILFS_DAT_INO);
nilfs->ns_gc_dat = nilfs_mdt_new(nilfs, NULL, NILFS_DAT_INO, 0);
if (unlikely(!nilfs->ns_gc_dat))
goto failed_dat;

nilfs->ns_cpfile = nilfs_mdt_new(nilfs, NULL, NILFS_CPFILE_INO);
nilfs->ns_cpfile = nilfs_mdt_new(nilfs, NULL, NILFS_CPFILE_INO, 0);
if (unlikely(!nilfs->ns_cpfile))
goto failed_gc_dat;

nilfs->ns_sufile = nilfs_mdt_new(nilfs, NULL, NILFS_SUFILE_INO);
nilfs->ns_sufile = nilfs_mdt_new(nilfs, NULL, NILFS_SUFILE_INO, 0);
if (unlikely(!nilfs->ns_sufile))
goto failed_cpfile;

Expand Down

0 comments on commit 5731e19

Please sign in to comment.