#include <obd_support.h>
#include <obd_class.h>
#include <uapi/linux/lustre/lustre_ioctl.h>
-#include <uapi/linux/llcrypt.h>
#include <lustre_lib.h>
#include <lustre_dlm.h>
#include <lustre_fid.h>
/* Always remove the page for striped dir, because the page is
* built from temporarily in LMV layer */
- if (inode && ll_dir_striped(inode)) {
+ if (inode && S_ISDIR(inode->i_mode) &&
+ lmv_dir_striped(ll_i2info(inode)->lli_lsm_md)) {
__free_page(page);
return;
}
if (lump->lum_magic != LMV_MAGIC_FOREIGN) {
CDEBUG(D_VFSTRACE,
- "VFS Op:inode="DFID"(%p) name %s stripe_offset %d, stripe_count: %u\n",
+ "VFS Op:inode="DFID"(%p) name=%s stripe_offset=%d stripe_count=%u, hash_type=%x\n",
PFID(ll_inode2fid(parent)), parent, dirname,
- (int)lump->lum_stripe_offset, lump->lum_stripe_count);
+ (int)lump->lum_stripe_offset, lump->lum_stripe_count,
+ lump->lum_hash_type);
} else {
struct lmv_foreign_md *lfm = (struct lmv_foreign_md *)lump;
/* MDS < 2.14 doesn't support 'crush' hash type, and cannot handle
* unknown hash if client doesn't set a valid one. switch to fnv_1a_64.
*/
- if (!(exp_connect_flags2(sbi->ll_md_exp) & OBD_CONNECT2_CRUSH)) {
+ if (CFS_FAIL_CHECK(OBD_FAIL_LMV_UNKNOWN_STRIPE)) {
+ lump->lum_hash_type = cfs_fail_val;
+ } else if (!(exp_connect_flags2(sbi->ll_md_exp) & OBD_CONNECT2_CRUSH)) {
enum lmv_hash_type type = lump->lum_hash_type &
LMV_HASH_TYPE_MASK;
- if (type == LMV_HASH_TYPE_CRUSH ||
+ if (type >= LMV_HASH_TYPE_CRUSH ||
type == LMV_HASH_TYPE_UNKNOWN)
lump->lum_hash_type = (lump->lum_hash_type ^ type) |
LMV_HASH_TYPE_FNV_1A_64;
if (ll_sbi_has_encrypt(sbi) &&
(IS_ENCRYPTED(parent) ||
- unlikely(llcrypt_dummy_context_enabled(parent)))) {
+ unlikely(ll_sb_has_test_dummy_encryption(parent->i_sb)))) {
err = llcrypt_get_encryption_info(parent);
if (err)
GOTO(out_op_data, err);
case LOV_USER_MAGIC_COMP_V1:
lum_size = ((struct lov_comp_md_v1 *)lump)->lcm_size;
break;
- case LMV_USER_MAGIC:
- if (lump->lmm_magic != cpu_to_le32(LMV_USER_MAGIC))
- lustre_swab_lmv_user_md(
- (struct lmv_user_md *)lump);
- lum_size = sizeof(struct lmv_user_md);
+ case LMV_USER_MAGIC: {
+ struct lmv_user_md *lmv = (struct lmv_user_md *)lump;
+
+ /* MDS < 2.14 doesn't support 'crush' hash type, and
+ * cannot handle unknown hash if client doesn't set a
+ * valid one. switch to fnv_1a_64.
+ */
+ if (!(exp_connect_flags2(sbi->ll_md_exp) &
+ OBD_CONNECT2_CRUSH)) {
+ enum lmv_hash_type type = lmv->lum_hash_type &
+ LMV_HASH_TYPE_MASK;
+
+ if (type >= LMV_HASH_TYPE_CRUSH ||
+ type == LMV_HASH_TYPE_UNKNOWN)
+ lmv->lum_hash_type =
+ (lmv->lum_hash_type ^ type) |
+ LMV_HASH_TYPE_FNV_1A_64;
+ }
+ if (lmv->lum_magic != cpu_to_le32(LMV_USER_MAGIC))
+ lustre_swab_lmv_user_md(lmv);
+ lum_size = sizeof(*lmv);
break;
+ }
case LOV_USER_MAGIC_SPECIFIC: {
struct lov_user_md_v3 *v3 =
(struct lov_user_md_v3 *)lump;
RETURN(rc);
}
-static int ll_dir_get_default_layout(struct inode *inode, void **plmm,
- int *plmm_size,
- struct ptlrpc_request **request, u64 valid,
- enum get_default_layout_type type)
+int ll_dir_get_default_layout(struct inode *inode, void **plmm, int *plmm_size,
+ struct ptlrpc_request **request, u64 valid,
+ enum get_default_layout_type type)
{
struct ll_sb_info *sbi = ll_i2sbi(inode);
struct mdt_body *body;
struct lov_mds_md *lmm = NULL;
struct ptlrpc_request *req = NULL;
- int rc, lmm_size;
+ int lmm_size = OBD_MAX_DEFAULT_EA_SIZE;
struct md_op_data *op_data;
struct lu_fid fid;
- ENTRY;
+ int rc;
- rc = ll_get_default_mdsize(sbi, &lmm_size);
- if (rc)
- RETURN(rc);
+ ENTRY;
- op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL,
- 0, lmm_size, LUSTRE_OPC_ANY,
- NULL);
+ op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, lmm_size,
+ LUSTRE_OPC_ANY, NULL);
if (IS_ERR(op_data))
RETURN(PTR_ERR(op_data));
rc = ll_dir_get_default_layout(inode, (void **)&lmm, &lmm_size,
&req, valid, 0);
if (rc == -ENODATA && !fid_is_root(ll_inode2fid(inode)) &&
- !(valid & (OBD_MD_MEA|OBD_MD_DEFAULT_MEA)) && root_request != NULL){
+ !(valid & OBD_MD_MEA) && root_request != NULL) {
int rc2 = ll_dir_get_default_layout(inode, (void **)&lmm,
&lmm_size, &root_req, valid,
GET_DEFAULT_LAYOUT_ROOT);
case LUSTRE_Q_SETQUOTAPOOL:
case LUSTRE_Q_SETINFOPOOL:
case LUSTRE_Q_SETDEFAULT_POOL:
+ case LUSTRE_Q_DELETEQID:
if (!capable(CAP_SYS_ADMIN))
RETURN(-EPERM);
else
RETURN(-EINVAL);
- switch (valid) {
- case QC_MDTIDX:
- rc = obd_iocontrol(OBD_IOC_QUOTACTL, sbi->ll_md_exp,
- sizeof(*qctl), qctl, NULL);
- break;
- case QC_OSTIDX:
- rc = obd_iocontrol(OBD_IOC_QUOTACTL, sbi->ll_dt_exp,
- sizeof(*qctl), qctl, NULL);
- break;
- case QC_UUID:
- rc = obd_iocontrol(OBD_IOC_QUOTACTL, sbi->ll_md_exp,
- sizeof(*qctl), qctl, NULL);
- if (rc == -EAGAIN)
- rc = obd_iocontrol(OBD_IOC_QUOTACTL,
- sbi->ll_dt_exp,
- sizeof(*qctl), qctl, NULL);
- break;
- default:
- rc = -EINVAL;
- break;
- }
-
- if (rc)
- RETURN(rc);
+ switch (valid) {
+ case QC_MDTIDX:
+ rc = obd_iocontrol(OBD_IOC_QUOTACTL, sbi->ll_md_exp,
+ sizeof(*qctl), qctl, NULL);
+ break;
+ case QC_OSTIDX:
+ rc = obd_iocontrol(OBD_IOC_QUOTACTL, sbi->ll_dt_exp,
+ sizeof(*qctl), qctl, NULL);
+ break;
+ case QC_UUID:
+ rc = obd_iocontrol(OBD_IOC_QUOTACTL, sbi->ll_md_exp,
+ sizeof(*qctl), qctl, NULL);
+ if (rc == -EAGAIN)
+ rc = obd_iocontrol(OBD_IOC_QUOTACTL,
+ sbi->ll_dt_exp,
+ sizeof(*qctl), qctl, NULL);
+ break;
+ default:
+ rc = -EINVAL;
+ break;
+ }
- qctl->qc_cmd = cmd;
- } else {
- struct obd_quotactl *oqctl;
+ qctl->qc_cmd = cmd;
+ if (rc)
+ RETURN(rc);
+ } else {
+ struct obd_quotactl *oqctl;
int oqctl_len = sizeof(*oqctl);
if (LUSTRE_Q_CMD_IS_POOL(cmd))
if (lmmsize > sizeof(*ulmv))
GOTO(finish_req, rc = -EINVAL);
+ if (root_request != NULL) {
+ struct lmv_user_md *lum;
+ struct ll_inode_info *lli;
+
+ lum = (struct lmv_user_md *)lmm;
+ lli = ll_i2info(inode);
+ if (lum->lum_max_inherit !=
+ LMV_INHERIT_UNLIMITED) {
+ if (lum->lum_max_inherit ==
+ LMV_INHERIT_NONE ||
+ lum->lum_max_inherit <
+ LMV_INHERIT_END ||
+ lum->lum_max_inherit >
+ LMV_INHERIT_MAX ||
+ lum->lum_max_inherit <
+ lli->lli_dir_depth)
+ GOTO(finish_req, rc = -ENODATA);
+
+ if (lum->lum_max_inherit ==
+ lli->lli_dir_depth) {
+ lum->lum_max_inherit =
+ LMV_INHERIT_NONE;
+ lum->lum_max_inherit_rr =
+ LMV_INHERIT_RR_NONE;
+ goto out_copy;
+ }
+
+ lum->lum_max_inherit -=
+ lli->lli_dir_depth;
+ }
+
+ if (lum->lum_max_inherit_rr !=
+ LMV_INHERIT_RR_UNLIMITED) {
+ if (lum->lum_max_inherit_rr ==
+ LMV_INHERIT_NONE ||
+ lum->lum_max_inherit_rr <
+ LMV_INHERIT_RR_END ||
+ lum->lum_max_inherit_rr >
+ LMV_INHERIT_RR_MAX ||
+ lum->lum_max_inherit_rr <=
+ lli->lli_dir_depth) {
+ lum->lum_max_inherit_rr =
+ LMV_INHERIT_RR_NONE;
+ goto out_copy;
+ }
+
+ if (lum->lum_max_inherit_rr >
+ lli->lli_dir_depth)
+ lum->lum_max_inherit_rr -=
+ lli->lli_dir_depth;
+ }
+ }
+out_copy:
if (copy_to_user(ulmv, lmm, lmmsize))
GOTO(finish_req, rc = -EFAULT);
}
rc = quotactl_ioctl(inode->i_sb, qctl);
- if (rc == 0 &&
+ if ((rc == 0 || rc == -ENODATA) &&
copy_to_user((void __user *)arg, qctl, sizeof(*qctl)))
rc = -EFAULT;
RETURN(rc);
}
case OBD_IOC_GETNAME_OLD:
- /* fall through */
case OBD_IOC_GETDTNAME:
- /* fall through */
case OBD_IOC_GETMDNAME:
RETURN(ll_get_obd_name(inode, cmd, arg));
case LL_IOC_FLUSHCTX:
if (!S_ISREG(inode2->i_mode))
GOTO(out_iput, rc = -EINVAL);
- if (!inode_owner_or_capable(inode2))
+ if (!inode_owner_or_capable(&init_user_ns, inode2))
GOTO(out_iput, rc = -EPERM);
rc = pcc_ioctl_detach(inode2, detach->pccd_opt);