@@ -196,7 +196,7 @@ static int vvp_object_glimpse(const struct lu_env *env,
static void vvp_req_attr_set(const struct lu_env *env, struct cl_object *obj,
struct cl_req_attr *attr)
{
- u64 valid_flags = OBD_MD_FLTYPE;
+ u64 valid_flags = OBD_MD_FLTYPE | OBD_MD_FLUID | OBD_MD_FLGID;
struct inode *inode;
struct obdo *oa;
@@ -204,8 +204,7 @@ static void vvp_req_attr_set(const struct lu_env *env, struct cl_object *obj,
inode = vvp_object_inode(obj);
if (attr->cra_type == CRT_WRITE) {
- valid_flags |= OBD_MD_FLMTIME | OBD_MD_FLCTIME |
- OBD_MD_FLUID | OBD_MD_FLGID;
+ valid_flags |= OBD_MD_FLMTIME | OBD_MD_FLCTIME;
obdo_set_o_projid(oa, ll_i2info(inode)->lli_projid);
}
obdo_from_inode(oa, inode, valid_flags & attr->cra_flags);
@@ -144,6 +144,11 @@ void lustre_set_wire_obdo(const struct obd_connect_data *ocd,
if (!ocd)
return;
+ if (!(wobdo->o_valid & OBD_MD_FLUID))
+ wobdo->o_uid = from_kuid(&init_user_ns, current_uid());
+ if (!(wobdo->o_valid & OBD_MD_FLGID))
+ wobdo->o_gid = from_kgid(&init_user_ns, current_gid());
+
if (unlikely(!(ocd->ocd_connect_flags & OBD_CONNECT_FID)) &&
fid_seq_is_echo(ostid_seq(&lobdo->o_oi))) {
/*
@@ -1184,6 +1184,16 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
lustre_set_wire_obdo(&req->rq_import->imp_connect_data, &body->oa, oa);
+ /* For READ and WRITE, we can't fill o_uid and o_gid using from_kuid()
+ * and from_kgid(), because they are asynchronous. Fortunately, variable
+ * oa contains valid o_uid and o_gid in these two operations.
+ * Besides, filling o_uid and o_gid is enough for nrs-tbf, see LU-9658.
+ * OBD_MD_FLUID and OBD_MD_FLUID is not set in order to avoid breaking
+ * other process logic
+ */
+ body->oa.o_uid = oa->o_uid;
+ body->oa.o_gid = oa->o_gid;
+
obdo_to_ioobj(oa, ioobj);
ioobj->ioo_bufcnt = niocount;
/* The high bits of ioo_max_brw tells server _maximum_ number of bulks