-static inline int mdt_remote_permission_check(struct mdt_thread_info *info)
-{
- struct lu_ucred *uc = mdt_ucred(info);
- struct mdt_device *mdt = info->mti_mdt;
-
- if (!md_capable(uc, CFS_CAP_SYS_ADMIN)) {
- if (uc->uc_gid != mdt->mdt_enable_remote_dir_gid &&
- mdt->mdt_enable_remote_dir_gid != -1)
- return -EPERM;
- }
-
- return 0;
-}
-
-/**
- * mdt_remote_permission: Check whether the remote operation is permitted,
- *
- * Only sysadmin can create remote directory / striped directory,
- * migrate directory and set default stripedEA on directory, unless
- *
- * lctl set_param mdt.*.enable_remote_dir_gid=allow_gid.
- *
- * param[in] info: mdt_thread_info.
- *
- * retval = 0 remote operation is allowed.
- * < 0 remote operation is denied.
- */
-int mdt_remote_permission(struct mdt_thread_info *info)
-{
- struct md_op_spec *spec = &info->mti_spec;
- struct lu_attr *attr = &info->mti_attr.ma_attr;
- struct obd_export *exp = mdt_info_req(info)->rq_export;
- int rc;
-
- if (info->mti_rr.rr_opcode == REINT_MIGRATE) {
- rc = mdt_remote_permission_check(info);
- if (rc != 0)
- return rc;
- }
-
- if (info->mti_rr.rr_opcode == REINT_CREATE &&
- (S_ISDIR(attr->la_mode) && spec->u.sp_ea.eadata != NULL &&
- spec->u.sp_ea.eadatalen != 0)) {
- const struct lmv_user_md *lum = spec->u.sp_ea.eadata;
-
- /* Only new clients can create remote dir( >= 2.4) and
- * striped dir(>= 2.6), old client will return -ENOTSUPP */
- if (!mdt_is_dne_client(exp))
- return -ENOTSUPP;
-
- if (le32_to_cpu(lum->lum_stripe_count) > 1 &&
- !mdt_is_striped_client(exp))
- return -ENOTSUPP;
-
- rc = mdt_remote_permission_check(info);
- if (rc != 0)
- return rc;
- }
-
- if (info->mti_rr.rr_opcode == REINT_SETATTR) {
- struct md_attr *ma = &info->mti_attr;
-
- if ((ma->ma_valid & MA_LMV)) {
- rc = mdt_remote_permission_check(info);
- if (rc != 0)
- return rc;
- }
- }
-
- return 0;
-}
-