uc = lu_ucred(env);
uc_cap_save = uc->uc_cap;
- uc->uc_cap |= BIT(CFS_CAP_DAC_OVERRIDE);
+ uc->uc_cap |= BIT(CAP_DAC_OVERRIDE);
rc = mdo_create(env, mdt_object_child(local_root), &lname,
mdt_object_child(obj), spec, attr);
uc->uc_cap = uc_cap_save;
/* The orphan has root ownership so we need to raise
* CAP_FOWNER to set the HSM attributes. */
cap = uc->uc_cap;
- uc->uc_cap |= MD_CAP_TO_MASK(CFS_CAP_FOWNER);
+ uc->uc_cap |= MD_CAP_TO_MASK(CAP_FOWNER);
rc = mo_xattr_set(info->mti_env, mdt_object_child(orphan), buf,
XATTR_NAME_HSM, 0);
uc->uc_cap = cap;
struct mdt_lock_handle *lh2 = &info->mti_lh[MDT_LH_OLD];
struct close_data *data;
struct ldlm_lock *lease;
- struct mdt_object *o1 = o, *o2;
+ struct mdt_object *o1 = o, *o2 = NULL;
bool lease_broken;
bool swap_objects;
int rc;
if (IS_ERR(o2))
GOTO(out_lease, rc = PTR_ERR(o2));
- if (!S_ISREG(lu_object_attr(&o2->mot_obj))) {
- swap_objects = false; /* not swapped yet */
+ if (!mdt_object_exists(o2))
+ GOTO(out_obj, rc = -ENOENT);
+
+ if (!S_ISREG(lu_object_attr(&o2->mot_obj)))
GOTO(out_obj, rc = -EINVAL);
- }
if (swap_objects)
swap(o1, o2);
}
out_obj:
- mdt_object_put(info->mti_env, swap_objects ? o1 : o2);
+ /* Callee takes care of o, we must put the other one. We know
+ * that o1 != o2 from check of lu_fid_cmp() above. */
+ mdt_object_put(info->mti_env, o1 != o ? o1 : o2);
ldlm_reprocess_all(lease->l_resource, lease);