示例#1
0
struct dentry * lzfs_fh_to_dentry(struct super_block *sb, struct fid *fid,
                                 int fh_len, int fh_type)
{
	lzfs_fid_t  *lzfid = (lzfs_fid_t *)fid;
	vfs_t *vfsp = sb->s_fs_info;
	vnode_t *vp;
	int error = 0;
	struct dentry *dentry = NULL;

	SENTRY;
	if (fh_len < 2) {
		return NULL;
	}

	switch (fh_type) {
		case LZFS_FILEID_INO64_GEN :
		case LZFS_FILEID_INO64_GEN_PARENT :
			error = zfs_vget( vfsp, &vp, lzfid);
			break;
	}

	tsd_exit();
	SEXIT;
	if (error) {
		printk(KERN_WARNING "Unable to get vnode \n");
		return NULL;
	}

	if (LZFS_VTOI(vp))
		dentry = d_obtain_alias(LZFS_VTOI(vp));
	return dentry;
}
示例#2
0
struct dentry *lzfs_get_parent(struct dentry *child)
{
	vnode_t *vcp = LZFS_ITOV(child->d_inode);
	vnode_t *vp;
	int error = 0;
	struct dentry *dentry = NULL;
	const struct cred *cred = get_current_cred();

	SENTRY;
	error = zfs_lookup(vcp, "..", &vp, NULL, 0 , NULL,
			(struct cred *) cred, NULL, NULL, NULL);

	put_cred(cred);
	tsd_exit();
	SEXIT;
	if (error) {
		if (error == ENOENT) {
			printk(KERN_WARNING "Try to get new dentry \n");
			return d_splice_alias(NULL, dentry);
		} else {
			printk(KERN_WARNING "Unable to get dentry \n");
			return ERR_PTR(-error);
		}
	}

	if (LZFS_VTOI(vp))
		dentry = d_obtain_alias(LZFS_VTOI(vp));
	return dentry;
}
示例#3
0
void
lzfs_zfsctl_destroy(vfs_t *vfsp)
{
	drop_nlink(LZFS_VTOI(vfsp->vfs_snap_dir));
	mutex_destroy(&(vfsp->vfs_snap_dir->v_lock));
	dput(vfsp->snap_dir_dentry);
	zfsctl_dir_destroy(vfsp->vfs_data);
	dput(vfsp->zfsctl_dir_dentry);
}
示例#4
0
void
zfsctl_dir_destroy(void *ptr)
{
	zfsvfs_t *zfsvfs = NULL;
   
	ASSERT(ptr);
	zfsvfs = (zfsvfs_t *) ptr;
	drop_nlink(LZFS_VTOI(zfsvfs->z_ctldir));
	mutex_destroy(&(zfsvfs->z_ctldir->v_lock));
}
示例#5
0
void
lzfs_zfsctl_create(vfs_t *vfsp)
{
	vnode_t *vp_zfsctl_dir = NULL, *vp_snap_dir = NULL;
	struct dentry *zfsctl_dir_dentry = NULL, *snap_dir_dentry = NULL;
	struct inode *inode_ctldir = NULL, *inode_snapdir = NULL;
	timestruc_t now;

	inode_ctldir = iget_locked(vfsp->vfs_super, LZFS_ZFSCTL_INO_ROOT);
	ASSERT(inode_ctldir != NULL);
	vp_zfsctl_dir = LZFS_ITOV(inode_ctldir);
	gethrestime(&now);
	ASSERT(inode_ctldir->i_state & I_NEW);
	mutex_enter(&vp_zfsctl_dir->v_lock);
	vp_zfsctl_dir->v_count = 1;
	VN_SET_VFS_TYPE_DEV(vp_zfsctl_dir, vfsp, VDIR, 0);
	bcopy(&now, &(vp_zfsctl_dir->v_inode.i_ctime), 
			sizeof (timestruc_t));
	bcopy(&now, &(vp_zfsctl_dir->v_inode.i_atime),
	      sizeof (timestruc_t));
	bcopy(&now,&(vp_zfsctl_dir->v_inode.i_mtime),sizeof (timestruc_t));
#ifdef HAVE_CRED_STRUCT
	inode_ctldir->i_uid = current->cred->uid;
	inode_ctldir->i_gid = current->cred->gid;
#else
	inode_ctldir->i_uid = current->uid;
	inode_ctldir->i_gid = current->gid;
#endif
	inode_ctldir->i_version = 1;
	inode_ctldir->i_mode |= (S_IFDIR | S_IRWXU);
	inode_ctldir->i_op = &zfsctl_dir_inode_operations;
	inode_ctldir->i_fop = &zfsctl_dir_file_operations;
	ASSERT(vfsp);
	inode_ctldir->i_sb = vfsp->vfs_super;
	ASSERT(vfsp->vfs_super);
	ASSERT(vfsp->vfs_super->s_root);
	unlock_new_inode(inode_ctldir);
	zfsctl_dir_dentry = d_alloc_name(vfsp->vfs_super->s_root, 
					 ZFS_CTLDIR_NAME);
	if (zfsctl_dir_dentry) {
	  d_add(zfsctl_dir_dentry, LZFS_VTOI(vp_zfsctl_dir));
	  vfsp->zfsctl_dir_dentry = zfsctl_dir_dentry;
	} else {
		goto dentry_out;
	}
	set_zfsvfs_ctldir(vfsp->vfs_data, vp_zfsctl_dir);
	mutex_exit(&vp_zfsctl_dir->v_lock);
	inode_snapdir = iget_locked(vfsp->vfs_super, LZFS_ZFSCTL_INO_SNAPDIR);
	ASSERT(inode_snapdir != NULL);
	ASSERT(inode_snapdir->i_state & I_NEW);
	vp_snap_dir = LZFS_ITOV(inode_snapdir);
	gethrestime(&now);
	vfsp->vfs_snap_dir = vp_snap_dir;
	mutex_enter(&vp_snap_dir->v_lock);
	vp_snap_dir->v_count = 1;
	VN_SET_VFS_TYPE_DEV(vp_snap_dir, vfsp, VDIR, 0);
	bcopy(&now,&(vp_snap_dir->v_inode.i_ctime),sizeof (timestruc_t));
	bcopy(&now,&(vp_snap_dir->v_inode.i_atime),sizeof (timestruc_t));
	bcopy(&now,&(vp_snap_dir->v_inode.i_mtime),sizeof (timestruc_t));
#ifdef HAVE_CRED_STRUCT
	inode_snapdir->i_uid = current->cred->uid;
	inode_snapdir->i_gid = current->cred->gid;
#else
	inode_snapdir->i_uid = current->uid;
	inode_snapdir->i_gid = current->gid;
#endif
	inode_snapdir->i_version = 1;
	inode_snapdir->i_mode |= (S_IFDIR | S_IRWXU);
	inode_snapdir->i_op = &snap_dir_inode_operations;
	inode_snapdir->i_fop = &snap_dir_file_operations;
	inode_snapdir->i_sb = vfsp->vfs_super;
	unlock_new_inode(inode_snapdir);
	ASSERT(zfsctl_dir_dentry);
	snap_dir_dentry = d_alloc_name(zfsctl_dir_dentry, ZFS_SNAPDIR_NAME);
	if (snap_dir_dentry) {
		d_add(snap_dir_dentry, LZFS_VTOI(vp_snap_dir));
		vfsp->snap_dir_dentry = snap_dir_dentry;
		mutex_exit(&vp_snap_dir->v_lock);
	} else {
		goto dentry_out;
	}
	return;
dentry_out:
	// free vnode
	vn_free(vp_zfsctl_dir);
	ASSERT(0 && "TODO");
}