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

Commit 79739565 authored by Ryusuke Konishi's avatar Ryusuke Konishi
Browse files

nilfs2: separate constructor of metadata files



This will displace nilfs_mdt_new() constructor with individual
metadata file constructors like nilfs_dat_new(), new_sufile_new(),
nilfs_cpfile_new(), and nilfs_ifile_new().

This makes it possible for each metadata file to have own
intialization code.

Signed-off-by: default avatarRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
parent 5731e191
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -926,3 +926,19 @@ int nilfs_cpfile_get_stat(struct inode *cpfile, struct nilfs_cpstat *cpstat)
	up_read(&NILFS_MDT(cpfile)->mi_sem);
	return ret;
}

/**
 * nilfs_cpfile_new - create cpfile
 * @nilfs: nilfs object
 * @cpsize: size of a checkpoint entry
 */
struct inode *nilfs_cpfile_new(struct the_nilfs *nilfs, size_t cpsize)
{
	struct inode *cpfile;

	cpfile = nilfs_mdt_new(nilfs, NULL, NILFS_CPFILE_INO, 0);
	if (cpfile)
		nilfs_mdt_set_entry_size(cpfile, cpsize,
					 sizeof(struct nilfs_cpfile_header));
	return cpfile;
}
+2 −0
Original line number Diff line number Diff line
@@ -40,4 +40,6 @@ int nilfs_cpfile_get_stat(struct inode *, struct nilfs_cpstat *);
ssize_t nilfs_cpfile_get_cpinfo(struct inode *, __u64 *, int, void *, unsigned,
				size_t);

struct inode *nilfs_cpfile_new(struct the_nilfs *nilfs, size_t cpsize);

#endif	/* _NILFS_CPFILE_H */
+23 −0
Original line number Diff line number Diff line
@@ -425,3 +425,26 @@ ssize_t nilfs_dat_get_vinfo(struct inode *dat, void *buf, unsigned visz,

	return nvi;
}

/**
 * nilfs_dat_new - create dat file
 * @nilfs: nilfs object
 * @entry_size: size of a dat entry
 */
struct inode *nilfs_dat_new(struct the_nilfs *nilfs, size_t entry_size)
{
	static struct lock_class_key dat_lock_key;
	struct inode *dat;
	int err;

	dat = nilfs_mdt_new(nilfs, NULL, NILFS_DAT_INO, 0);
	if (dat) {
		err = nilfs_palloc_init_blockgroup(dat, entry_size);
		if (unlikely(err)) {
			nilfs_mdt_destroy(dat);
			return NULL;
		}
		lockdep_set_class(&NILFS_MDT(dat)->mi_sem, &dat_lock_key);
	}
	return dat;
}
+2 −0
Original line number Diff line number Diff line
@@ -53,4 +53,6 @@ int nilfs_dat_freev(struct inode *, __u64 *, size_t);
int nilfs_dat_move(struct inode *, __u64, sector_t);
ssize_t nilfs_dat_get_vinfo(struct inode *, void *, unsigned, size_t);

struct inode *nilfs_dat_new(struct the_nilfs *nilfs, size_t entry_size);

#endif	/* _NILFS_DAT_H */
+21 −0
Original line number Diff line number Diff line
@@ -148,3 +148,24 @@ int nilfs_ifile_get_inode_block(struct inode *ifile, ino_t ino,
	}
	return err;
}

/**
 * nilfs_ifile_new - create inode file
 * @sbi: nilfs_sb_info struct
 * @inode_size: size of an inode
 */
struct inode *nilfs_ifile_new(struct nilfs_sb_info *sbi, size_t inode_size)
{
	struct inode *ifile;
	int err;

	ifile = nilfs_mdt_new(sbi->s_nilfs, sbi->s_super, NILFS_IFILE_INO, 0);
	if (ifile) {
		err = nilfs_palloc_init_blockgroup(ifile, inode_size);
		if (unlikely(err)) {
			nilfs_mdt_destroy(ifile);
			return NULL;
		}
	}
	return ifile;
}
Loading