Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5731e191 authored by Ryusuke Konishi's avatar Ryusuke Konishi
Browse files

nilfs2: add size option of private object to metadata file allocator



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: default avatarRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
parent 9cb4e0d2
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -212,9 +212,10 @@ void nilfs_destroy_gccache(struct the_nilfs *nilfs)
static struct inode *alloc_gcinode(struct the_nilfs *nilfs, ino_t ino,
static struct inode *alloc_gcinode(struct the_nilfs *nilfs, ino_t ino,
				   __u64 cno)
				   __u64 cno)
{
{
	struct inode *inode = nilfs_mdt_new_common(nilfs, NULL, ino, GFP_NOFS);
	struct inode *inode;
	struct nilfs_inode_info *ii;
	struct nilfs_inode_info *ii;


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


+14 −5
Original line number Original line Diff line number Diff line
@@ -445,9 +445,17 @@ static const struct file_operations def_mdt_fops;
 * longer than those of the super block structs; they may continue for
 * longer than those of the super block structs; they may continue for
 * several consecutive mounts/umounts.  This would need discussions.
 * 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 *
struct inode *
nilfs_mdt_new_common(struct the_nilfs *nilfs, struct super_block *sb,
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);
	struct inode *inode = nilfs_alloc_inode_common(nilfs);


@@ -455,8 +463,9 @@ nilfs_mdt_new_common(struct the_nilfs *nilfs, struct super_block *sb,
		return NULL;
		return NULL;
	else {
	else {
		struct address_space * const mapping = &inode->i_data;
		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) {
		if (!mi) {
			nilfs_destroy_inode(inode);
			nilfs_destroy_inode(inode);
			return NULL;
			return NULL;
@@ -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,
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,
	struct inode *inode;
						   NILFS_MDT_GFP);


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


+3 −2
Original line number Original line Diff line number Diff line
@@ -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_mark_block_dirty(struct inode *, unsigned long);
int nilfs_mdt_fetch_dirty(struct inode *);
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 *,
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_destroy(struct inode *);
void nilfs_mdt_clear(struct inode *);
void nilfs_mdt_clear(struct inode *);
void nilfs_mdt_set_entry_size(struct inode *, unsigned, unsigned);
void nilfs_mdt_set_entry_size(struct inode *, unsigned, unsigned);
+1 −1
Original line number Original line Diff line number Diff line
@@ -363,7 +363,7 @@ int nilfs_attach_checkpoint(struct nilfs_sb_info *sbi, __u64 cno)
	list_add(&sbi->s_list, &nilfs->ns_supers);
	list_add(&sbi->s_list, &nilfs->ns_supers);
	up_write(&nilfs->ns_super_sem);
	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)
	if (!sbi->s_ifile)
		return -ENOMEM;
		return -ENOMEM;


+4 −4
Original line number Original line Diff line number Diff line
@@ -187,19 +187,19 @@ static int nilfs_load_super_root(struct the_nilfs *nilfs,
	inode_size = nilfs->ns_inode_size;
	inode_size = nilfs->ns_inode_size;


	err = -ENOMEM;
	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))
	if (unlikely(!nilfs->ns_dat))
		goto failed;
		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))
	if (unlikely(!nilfs->ns_gc_dat))
		goto failed_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))
	if (unlikely(!nilfs->ns_cpfile))
		goto failed_gc_dat;
		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))
	if (unlikely(!nilfs->ns_sufile))
		goto failed_cpfile;
		goto failed_cpfile;