初探lustre文件创建的过程

2022-08-17 13:14:33 浏览数 (1)

lustre中inode的operations

  • 不论是本地文件系统还是分布式文件系统,每个inode会有一些operations.针对上层的posix语义的实现。我们这里着重讨论文件的create操作,create涉及的file_operationll_file_operations_flockll_file_operations.
代码语言:javascript复制
// lustre客户端的file_oepration的函数
const struct file_operations *ll_select_file_operations(struct ll_sb_info *sbi)
{
	const struct file_operations *fops = &ll_file_operations_noflock;

	if (sbi->ll_flags & LL_SBI_FLOCK)
		fops = &ll_file_operations_flock;
	else if (sbi->ll_flags & LL_SBI_LOCALFLOCK)
		fops = &ll_file_operations;

	return fops;
}

int ll_read_inode2(struct inode *inode, void *opaque)
{
        struct lustre_md *md = opaque;
        struct ll_inode_info *lli = ll_i2info(inode);
		inode->i_mapping->backing_dev_info = &s2lsi(inode->i_sb)->lsi_bdi;
        if (S_ISREG(inode->i_mode)) {
            struct ll_sb_info *sbi = ll_i2sbi(inode);
            inode->i_op = &ll_file_inode_operations;
            inode->i_fop = sbi->ll_fop;
            inode->i_mapping->a_ops = (struct address_space_operations *)&ll_aops;
        } else if (S_ISDIR(inode->i_mode)) {
            inode->i_op = &ll_dir_inode_operations;
            inode->i_fop = &ll_dir_operations;
        } else if (S_ISLNK(inode->i_mode)) {
            inode->i_op = &ll_fast_symlink_inode_operations;
        } else {
            inode->i_op = &ll_special_inode_operations;
        }

	return 0;
}
  • linux内核中针对creat语义定义SYSCALL_DEFINE2(creat....),实际是调用的是内核的ksys_open函数来执行。creat函数最终还是

    0 人点赞