static const char dotdot[] = "..";
static struct lu_name lname_dotdot = {
- (char *) dotdot,
- sizeof(dotdot) - 1
+ .ln_name = (char *) dotdot,
+ .ln_namelen = sizeof(dotdot) - 1,
};
static inline int
if (rc != 0)
return rc;
- if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_MORE_NLINK)) {
- rc = mdo_declare_ref_add(env, c, handle);
- if (rc != 0)
- return rc;
- }
-
la->la_valid = LA_CTIME | LA_MTIME;
rc = mdo_declare_attr_set(env, p, la, handle);
if (rc != 0)
if (rc != 0)
RETURN(rc);
+ /*
+ * If we are using project inheritance, we only allow hard link
+ * creation in our tree when the project IDs are the same;
+ * otherwise the tree quota mechanism could be circumvented.
+ */
+ if ((tattr->la_flags & LUSTRE_PROJINHERIT_FL) &&
+ (tattr->la_projid != cattr->la_projid))
+ RETURN(-EXDEV);
+
handle = mdd_trans_create(env, mdd);
if (IS_ERR(handle))
GOTO(out_pending, rc = PTR_ERR(handle));
GOTO(out_unlock, rc);
}
- if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_MORE_NLINK)) {
- rc = mdo_ref_add(env, mdd_sobj, handle);
- if (rc != 0)
- GOTO(out_unlock, rc);
- }
-
*tfid = *mdo2fid(mdd_sobj);
if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_DANGLING3))
tfid->f_oid = cfs_fail_val;
}
}
+ /* Inherit project ID from parent directory */
+ if (pattr->la_flags & LUSTRE_PROJINHERIT_FL) {
+ cattr->la_projid = pattr->la_projid;
+ if (S_ISDIR(cattr->la_mode)) {
+ cattr->la_flags |= LUSTRE_PROJINHERIT_FL;
+ cattr->la_valid |= LA_FLAGS;
+ }
+ cattr->la_valid |= LA_PROJID;
+ }
+
rc = mdd_name_check(m, lname);
if (rc < 0)
RETURN(rc);
* before mdd_rename and enable MDS_PERM_BYPASS. */
LASSERT(sobj);
+ /*
+ * If we are using project inheritance, we only allow renames
+ * into our tree when the project IDs are the same; otherwise
+ * tree quota mechanism would be circumvented.
+ */
+ if (((tpattr->la_flags & LUSTRE_PROJINHERIT_FL) &&
+ tpattr->la_projid != cattr->la_projid) ||
+ ((pattr->la_flags & LUSTRE_PROJINHERIT_FL) &&
+ (pattr->la_projid != tpattr->la_projid)))
+ RETURN(-EXDEV);
+
rc = mdd_may_delete(env, src_pobj, pattr, sobj, cattr, NULL, 1, 0);
if (rc)
RETURN(rc);