int cl_sb_fini(struct super_block *sb) { struct ll_sb_info *sbi; struct lu_env *env; struct cl_device *cld; int refcheck; int result; sbi = ll_s2sbi(sb); env = cl_env_get(&refcheck); if (!IS_ERR(env)) { cld = sbi->ll_cl; if (cld != NULL) { cl_stack_fini(env, cld); sbi->ll_cl = NULL; sbi->ll_site = NULL; } cl_env_put(env, &refcheck); result = 0; } else { CERROR("Cannot cleanup cl-stack due to memory shortage.\n"); result = PTR_ERR(env); } /* * If mount failed (sbi->ll_cl == NULL), and this there are no other * mounts, stop device types manually (this usually happens * automatically when last device is destroyed). */ lu_types_stop(); return result; }
int cl_sb_fini(struct super_block *sb) { struct ll_sb_info *sbi; struct lu_env *env; struct cl_device *cld; u16 refcheck; int result; sbi = ll_s2sbi(sb); env = cl_env_get(&refcheck); if (!IS_ERR(env)) { cld = sbi->ll_cl; if (cld) { cl_stack_fini(env, cld); sbi->ll_cl = NULL; sbi->ll_site = NULL; } cl_env_put(env, &refcheck); result = 0; } else { CERROR("Cannot cleanup cl-stack due to memory shortage.\n"); result = PTR_ERR(env); } return result; }
static struct inode *ll_alloc_inode(struct super_block *sb) { struct ll_inode_info *lli; ll_stats_ops_tally(ll_s2sbi(sb), LPROC_LL_ALLOC_INODE, 1); OBD_SLAB_ALLOC_PTR_GFP(lli, ll_inode_cachep, CFS_ALLOC_IO); if (lli == NULL) return NULL; inode_init_once(&lli->lli_vfs_inode); return &lli->lli_vfs_inode; }
static struct inode *ll_alloc_inode(struct super_block *sb) { struct ll_inode_info *lli; ll_stats_ops_tally(ll_s2sbi(sb), LPROC_LL_ALLOC_INODE, 1); lli = kmem_cache_zalloc(ll_inode_cachep, GFP_NOFS); if (!lli) return NULL; inode_init_once(&lli->lli_vfs_inode); return &lli->lli_vfs_inode; }
struct inode *search_inode_for_lustre(struct super_block *sb, const struct lu_fid *fid) { struct ll_sb_info *sbi = ll_s2sbi(sb); struct ptlrpc_request *req = NULL; struct inode *inode = NULL; int eadatalen = 0; unsigned long hash = cl_fid_build_ino(fid, ll_need_32bit_api(sbi)); struct md_op_data *op_data; int rc; CDEBUG(D_INFO, "searching inode for:(%lu,"DFID")\n", hash, PFID(fid)); inode = ilookup5(sb, hash, ll_nfs_test_inode, (void *)fid); if (inode) return inode; rc = ll_get_default_mdsize(sbi, &eadatalen); if (rc) return ERR_PTR(rc); /* Because inode is NULL, ll_prep_md_op_data can not * be used here. So we allocate op_data ourselves */ op_data = kzalloc(sizeof(*op_data), GFP_NOFS); if (!op_data) return ERR_PTR(-ENOMEM); op_data->op_fid1 = *fid; op_data->op_mode = eadatalen; op_data->op_valid = OBD_MD_FLEASIZE; /* mds_fid2dentry ignores f_type */ rc = md_getattr(sbi->ll_md_exp, op_data, &req); kfree(op_data); if (rc) { CERROR("can't get object attrs, fid "DFID", rc %d\n", PFID(fid), rc); return ERR_PTR(rc); } rc = ll_prep_inode(&inode, req, sb, NULL); ptlrpc_req_finished(req); if (rc) return ERR_PTR(rc); return inode; }
int cl_sb_init(struct super_block *sb) { struct ll_sb_info *sbi; struct cl_device *cl; struct lu_env *env; int rc = 0; u16 refcheck; sbi = ll_s2sbi(sb); env = cl_env_get(&refcheck); if (!IS_ERR(env)) { cl = cl_type_setup(env, NULL, &vvp_device_type, sbi->ll_dt_exp->exp_obd->obd_lu_dev); if (!IS_ERR(cl)) { sbi->ll_cl = cl; sbi->ll_site = cl2lu_dev(cl)->ld_site; } cl_env_put(env, &refcheck); } else { rc = PTR_ERR(env); } return rc; }
static int ll_get_name(struct dentry *dentry, char *name, struct dentry *child) { struct inode *dir = d_inode(dentry); int rc; struct ll_getname_data lgd = { .lgd_name = name, .lgd_fid = ll_i2info(d_inode(child))->lli_fid, .ctx.actor = ll_nfs_get_name_filldir, }; if (!dir || !S_ISDIR(dir->i_mode)) { rc = -ENOTDIR; goto out; } if (!dir->i_fop) { rc = -EINVAL; goto out; } mutex_lock(&dir->i_mutex); rc = ll_dir_read(dir, &lgd.ctx); mutex_unlock(&dir->i_mutex); if (!rc && !lgd.lgd_found) rc = -ENOENT; out: return rc; } static struct dentry *ll_fh_to_dentry(struct super_block *sb, struct fid *fid, int fh_len, int fh_type) { struct lustre_nfs_fid *nfs_fid = (struct lustre_nfs_fid *)fid; if (fh_type != LUSTRE_NFS_FID) return ERR_PTR(-EPROTO); return ll_iget_for_nfs(sb, &nfs_fid->lnf_child, &nfs_fid->lnf_parent); } static struct dentry *ll_fh_to_parent(struct super_block *sb, struct fid *fid, int fh_len, int fh_type) { struct lustre_nfs_fid *nfs_fid = (struct lustre_nfs_fid *)fid; if (fh_type != LUSTRE_NFS_FID) return ERR_PTR(-EPROTO); return ll_iget_for_nfs(sb, &nfs_fid->lnf_parent, NULL); } static struct dentry *ll_get_parent(struct dentry *dchild) { struct ptlrpc_request *req = NULL; struct inode *dir = d_inode(dchild); struct ll_sb_info *sbi; struct dentry *result = NULL; struct mdt_body *body; static char dotdot[] = ".."; struct md_op_data *op_data; int rc; int lmmsize; LASSERT(dir && S_ISDIR(dir->i_mode)); sbi = ll_s2sbi(dir->i_sb); CDEBUG(D_INFO, "getting parent for (%lu,"DFID")\n", dir->i_ino, PFID(ll_inode2fid(dir))); rc = ll_get_default_mdsize(sbi, &lmmsize); if (rc != 0) return ERR_PTR(rc); op_data = ll_prep_md_op_data(NULL, dir, NULL, dotdot, strlen(dotdot), lmmsize, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) return (void *)op_data; rc = md_getattr_name(sbi->ll_md_exp, op_data, &req); ll_finish_md_op_data(op_data); if (rc) { CERROR("failure %d inode %lu get parent\n", rc, dir->i_ino); return ERR_PTR(rc); } body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); LASSERT(body->valid & OBD_MD_FLID); CDEBUG(D_INFO, "parent for "DFID" is "DFID"\n", PFID(ll_inode2fid(dir)), PFID(&body->fid1)); result = ll_iget_for_nfs(dir->i_sb, &body->fid1, NULL); ptlrpc_req_finished(req); return result; } struct export_operations lustre_export_operations = { .get_parent = ll_get_parent, .encode_fh = ll_encode_fh, .get_name = ll_get_name, .fh_to_dentry = ll_fh_to_dentry, .fh_to_parent = ll_fh_to_parent, };