void mdt_pack_attr2body(struct mdt_thread_info *info, struct mdt_body *b,
const struct lu_attr *attr, const struct lu_fid *fid)
{
- struct md_attr *ma = &info->mti_attr;
- struct obd_export *exp = info->mti_exp;
- struct lu_nodemap *nodemap = exp->exp_target_data.ted_nodemap;
+ struct md_attr *ma = &info->mti_attr;
+ struct obd_export *exp = info->mti_exp;
+ struct lu_nodemap *nodemap = NULL;
LASSERT(ma->ma_valid & MA_INODE);
b->mbo_nlink = attr->la_nlink;
b->mbo_valid |= OBD_MD_FLNLINK;
}
+ if (attr->la_valid & (LA_UID|LA_GID)) {
+ nodemap = nodemap_get_from_exp(exp);
+ if (IS_ERR(nodemap))
+ goto out;
+ }
if (attr->la_valid & LA_UID) {
b->mbo_uid = nodemap_map_id(nodemap, NODEMAP_UID,
NODEMAP_FS_TO_CLIENT,
attr->la_gid);
b->mbo_valid |= OBD_MD_FLGID;
}
+
b->mbo_mode = attr->la_mode;
if (attr->la_valid & LA_MODE)
b->mbo_valid |= OBD_MD_FLMODE;
if (fid != NULL && (b->mbo_valid & OBD_MD_FLSIZE))
CDEBUG(D_VFSTRACE, DFID": returning size %llu\n",
PFID(fid), (unsigned long long)b->mbo_size);
+
+out:
+ if (!IS_ERR_OR_NULL(nodemap))
+ nodemap_putref(nodemap);
}
static inline int mdt_body_has_lov(const struct lu_attr *la,
struct mdt_body *repbody;
struct lu_buf *buffer = &info->mti_buf;
struct obd_export *exp = info->mti_exp;
- struct lu_nodemap *nodemap = exp->exp_target_data.ted_nodemap;
int rc;
int is_root;
ENTRY;
}
#ifdef CONFIG_FS_POSIX_ACL
else if ((exp_connect_flags(req->rq_export) & OBD_CONNECT_ACL) &&
- (reqbody->mbo_valid & OBD_MD_FLACL))
+ (reqbody->mbo_valid & OBD_MD_FLACL)) {
+ struct lu_nodemap *nodemap = nodemap_get_from_exp(exp);
+ if (IS_ERR(nodemap))
+ RETURN(PTR_ERR(nodemap));
+
rc = mdt_pack_acl2body(info, repbody, o, nodemap);
+ nodemap_putref(nodemap);
+ }
#endif
out:
int id, rc;
struct mdt_device *mdt = mdt_exp2dev(exp);
struct lu_device *qmt = mdt->mdt_qmt_dev;
- struct lu_nodemap *nodemap = exp->exp_target_data.ted_nodemap;
+ struct lu_nodemap *nodemap;
ENTRY;
oqctl = req_capsule_client_get(pill, &RMF_OBD_QUOTACTL);
if (rc)
RETURN(err_serious(rc));
+ nodemap = nodemap_get_from_exp(exp);
+ if (IS_ERR(nodemap))
+ RETURN(PTR_ERR(nodemap));
+
switch (oqctl->qc_cmd) {
/* master quotactl */
case Q_SETINFO:
case Q_SETQUOTA:
if (!nodemap_can_setquota(nodemap))
- RETURN(-EPERM);
+ GOTO(out_nodemap, rc = -EPERM);
case Q_GETINFO:
case Q_GETQUOTA:
if (qmt == NULL)
- RETURN(-EOPNOTSUPP);
+ GOTO(out_nodemap, rc = -EOPNOTSUPP);
/* slave quotactl */
case Q_GETOINFO:
case Q_GETOQUOTA:
break;
default:
CERROR("Unsupported quotactl command: %d\n", oqctl->qc_cmd);
- RETURN(-EFAULT);
+ GOTO(out_nodemap, rc = -EFAULT);
}
/* map uid/gid for remote client */
if (unlikely(oqctl->qc_cmd != Q_GETQUOTA &&
oqctl->qc_cmd != Q_GETINFO))
- RETURN(-EPERM);
+ GOTO(out_nodemap, rc = -EPERM);
if (oqctl->qc_type == USRQUOTA)
id = lustre_idmap_lookup_uid(NULL, idmap, 0,
id = lustre_idmap_lookup_gid(NULL, idmap, 0,
oqctl->qc_id);
else
- RETURN(-EINVAL);
+ GOTO(out_nodemap, rc = -EINVAL);
if (id == CFS_IDMAP_NOTFOUND) {
CDEBUG(D_QUOTA, "no mapping for id %u\n", oqctl->qc_id);
- RETURN(-EACCES);
+ GOTO(out_nodemap, rc = -EACCES);
}
}
repoqc = req_capsule_server_get(pill, &RMF_OBD_QUOTACTL);
if (repoqc == NULL)
- RETURN(err_serious(-EFAULT));
+ GOTO(out_nodemap, rc = err_serious(-EFAULT));
if (oqctl->qc_id != id)
swap(oqctl->qc_id, id);
default:
CERROR("Unsupported quotactl command: %d\n", oqctl->qc_cmd);
- RETURN(-EFAULT);
+ GOTO(out_nodemap, rc = -EFAULT);
}
if (oqctl->qc_id != id)
swap(oqctl->qc_id, id);
*repoqc = *oqctl;
- RETURN(rc);
+
+ EXIT;
+
+out_nodemap:
+ nodemap_putref(nodemap);
+
+ return rc;
}
/** clone llog ctxt from child (mdd)