RETURN(rc);
}
+
+static bool is_project_state_change(const struct lu_attr *oattr,
+ struct lu_attr *la)
+{
+ if (la->la_valid & LA_PROJID &&
+ oattr->la_projid != la->la_projid)
+ return true;
+
+ if ((la->la_valid & LA_FLAGS) &&
+ (la->la_flags & LUSTRE_PROJINHERIT_FL) !=
+ (oattr->la_flags & LUSTRE_PROJINHERIT_FL))
+ return true;
+
+ return false;
+}
+
/*
* This gives the same functionality as the code between
* sys_chmod and inode_setattr
*/
static int mdd_fix_attr(const struct lu_env *env, struct mdd_object *obj,
const struct lu_attr *oattr, struct lu_attr *la,
- const unsigned long flags)
+ const struct md_attr *ma)
{
struct lu_ucred *uc;
int rc = 0;
+ const unsigned long flags = ma->ma_attr_flags;
+
ENTRY;
if (!la->la_valid)
if (uc == NULL)
RETURN(0);
+ if (is_project_state_change(oattr, la)) {
+ if (!md_capable(uc, CFS_CAP_SYS_RESOURCE) &&
+ !lustre_in_group_p(uc, ma->ma_enable_chprojid_gid) &&
+ !(ma->ma_enable_chprojid_gid == -1 &&
+ mdd_permission_internal(env, obj, oattr, MAY_WRITE)))
+ RETURN(-EPERM);
+ }
+
if (la->la_valid == LA_CTIME) {
if (!(flags & MDS_PERM_BYPASS))
/* This is only for set ctime when rename's source is
RETURN(rc);
*la_copy = ma->ma_attr;
- rc = mdd_fix_attr(env, mdd_obj, attr, la_copy, ma->ma_attr_flags);
+ rc = mdd_fix_attr(env, mdd_obj, attr, la_copy, ma);
if (rc)
RETURN(rc);
/* no need to setattr anymore */
if (la_copy->la_valid == 0) {
- CDEBUG(D_INODE, "%s: no valid attribute on "DFID", previous"
- "valid is %#llx\n", mdd2obd_dev(mdd)->obd_name,
+ CDEBUG(D_INODE,
+ "%s: no valid attribute on "DFID", previous valid is %#llx\n",
+ mdd2obd_dev(mdd)->obd_name,
PFID(mdo2fid(mdd_obj)), la->la_valid);
RETURN(0);
*
* \param[in] xattr_name Full extended attribute name.
*
- * \return The type of changelog to use, or -1 if no changelog is to be emitted.
+ * \return type of changelog to use, or CL_NONE if no changelog is to be emitted
*/
static enum changelog_rec_type
mdd_xattr_changelog_type(const struct lu_env *env, struct mdd_device *mdd,
{
/* Layout changes systematically recorded */
if (strcmp(XATTR_NAME_LOV, xattr_name) == 0 ||
- strncmp(XATTR_LUSTRE_LOV, xattr_name,
- strlen(XATTR_LUSTRE_LOV)) == 0)
+ strcmp(XATTR_LUSTRE_LOV, xattr_name) == 0 ||
+ allowed_lustre_lov(xattr_name))
return CL_LAYOUT;
/* HSM information changes systematically recorded */
ENTRY;
- CLASSERT(ARRAY_SIZE(info->mti_buf) >= 4);
+ BUILD_BUG_ON(ARRAY_SIZE(info->mti_buf) < 4);
memset(info->mti_buf, 0, sizeof(info->mti_buf));
/* we have to sort the 2 obj, so locking will always