Whamcloud - gitweb
LU-17166 ptlrpc: add pb_projid field in ptlrpc_body 20/54920/10
authorEtienne AUJAMES <eaujames@ddn.com>
Mon, 10 Mar 2025 17:26:42 +0000 (13:26 -0400)
committerOleg Drokin <green@whamcloud.com>
Fri, 25 Apr 2025 00:52:14 +0000 (00:52 +0000)
This patch "tags" ptlrpc requests with projid (with pb_projid field in
ptlrpc_body). This will enable to add server projid stats and TBF
scheduling based on projid.

The projid comes from the inode (struct ll_inode_info::lli_projid).
For MDT request by name (lookup/create), if the parent have the projid
inherit flag ("LLIF_PROJECT_INHERIT"), the request will be "tag" with
the parent projid.

To build an OSC request, cl_req_projid_set() is added to retrieve the
projid from the VPP layer.

Signed-off-by: Etienne AUJAMES <eaujames@ddn.com>
Signed-off-by: Qian Yingjin <qian@ddn.com>
Change-Id: I98a73023268a5f24549e3204d6d42a3f057a0798
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54920
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
29 files changed:
lustre/include/cl_object.h
lustre/include/lustre_net.h
lustre/include/obd.h
lustre/include/obd_class.h
lustre/include/uapi/linux/lustre/lustre_idl.h
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/llite/acl.c
lustre/llite/crypto.c
lustre/llite/file.c
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/llite/vvp_object.c
lustre/llite/xattr.c
lustre/lmv/lmv_obd.c
lustre/lov/lovsub_object.c
lustre/mdc/mdc_internal.h
lustre/mdc/mdc_lib.c
lustre/mdc/mdc_locks.c
lustre/mdc/mdc_request.c
lustre/obdclass/cl_object.c
lustre/osc/osc_internal.h
lustre/osc/osc_io.c
lustre/osc/osc_lock.c
lustre/osc/osc_request.c
lustre/ptlrpc/pack_generic.c
lustre/ptlrpc/wiretest.c
lustre/utils/lfs.c
lustre/utils/wirecheck.c
lustre/utils/wiretest.c

index bd63a16..d05d302 100644 (file)
@@ -431,6 +431,11 @@ struct cl_object_operations {
         */
        int (*coo_inode_ops)(const struct lu_env *env, struct cl_object *obj,
                             enum coo_inode_opc opc, void *data);
+       /**
+        * Get ProjID for a request.
+        */
+       void (*coo_req_projid_set)(const struct lu_env *env,
+                                  struct cl_object *obj, __u32 *projid);
 };
 
 /**
@@ -1987,7 +1992,7 @@ struct cl_req_attr {
        /** Generic attributes for the server consumption. */
        struct obdo     *cra_oa;
        /** process jobid/uid/gid performing the io */
-       struct job_info cra_jobinfo;
+       struct job_info cra_jobinfo;
 };
 
 enum cache_stats_item {
@@ -2158,7 +2163,8 @@ int cl_object_flush(const struct lu_env *env, struct cl_object *obj,
                    struct ldlm_lock *lock);
 int cl_object_inode_ops(const struct lu_env *env, struct cl_object *obj,
                        enum coo_inode_opc opc, void *data);
-
+void cl_req_projid_set(const struct lu_env *env, struct cl_object *obj,
+                      __u32 *projid);
 
 /**
  * Returns true, iff \a o0 and \a o1 are slices of the same object.
index c608124..40fa065 100644 (file)
@@ -2365,6 +2365,7 @@ __u32 lustre_msg_get_conn_cnt(struct lustre_msg *msg);
 __u32 lustre_msg_get_magic(struct lustre_msg *msg);
 timeout_t lustre_msg_get_timeout(struct lustre_msg *msg);
 timeout_t lustre_msg_get_service_timeout(struct lustre_msg *msg);
+int lustre_msg_get_projid(struct lustre_msg *msg, __u32 *projid);
 int lustre_msg_get_uid_gid(struct lustre_msg *msg, __u32 *uid, __u32 *gid);
 char *lustre_msg_get_jobid(struct lustre_msg *msg);
 __u32 lustre_msg_get_cksum(struct lustre_msg *msg);
@@ -2395,6 +2396,7 @@ struct job_info {
 };
 
 void lustre_msg_set_jobinfo(struct lustre_msg *msg, const struct job_info *ji);
+void lustre_msg_set_projid(struct lustre_msg *msg, __u32 projid);
 void lustre_msg_set_cksum(struct lustre_msg *msg, __u32 cksum);
 void lustre_msg_set_mbits(struct lustre_msg *msg, __u64 mbits);
 
index af7e508..92b8588 100644 (file)
@@ -1304,11 +1304,11 @@ struct md_ops {
        int (*m_setxattr)(struct obd_export *exp, const struct lu_fid *fid,
                          u64 obd_md_valid, const char *name, const void *value,
                          size_t value_size, unsigned int xattr_flags,
-                         u32 suppgid, struct ptlrpc_request **req);
+                         u32 suppgid, u32 projid, struct ptlrpc_request **req);
 
        int (*m_getxattr)(struct obd_export *exp, const struct lu_fid *fid,
                          u64 obd_md_valid, const char *name, size_t buf_size,
-                         struct ptlrpc_request **req);
+                         u32 projid, struct ptlrpc_request **req);
 
        int (*m_intent_getattr_async)(struct obd_export *exp,
                                      struct md_op_item *item);
index fb156d3..a76f687 100644 (file)
@@ -1731,7 +1731,7 @@ static inline int md_merge_attr(struct obd_export *exp,
 static inline int md_setxattr(struct obd_export *exp, const struct lu_fid *fid,
                              u64 obd_md_valid, const char *name,
                              const void *value, size_t value_size,
-                             unsigned int xattr_flags, u32 suppgid,
+                             unsigned int xattr_flags, u32 suppgid, u32 projid,
                              struct ptlrpc_request **req)
 {
        int rc;
@@ -1748,13 +1748,14 @@ static inline int md_setxattr(struct obd_export *exp, const struct lu_fid *fid,
                                                              name, value,
                                                              value_size,
                                                              xattr_flags,
-                                                             suppgid,
+                                                             suppgid, projid,
                                                              req);
 }
 
 static inline int md_getxattr(struct obd_export *exp, const struct lu_fid *fid,
                              u64 obd_md_valid, const char *name,
-                             size_t buf_size, struct ptlrpc_request **req)
+                             size_t buf_size, u32 projid,
+                             struct ptlrpc_request **req)
 {
        int rc;
 
@@ -1768,7 +1769,7 @@ static inline int md_getxattr(struct obd_export *exp, const struct lu_fid *fid,
        return exp->exp_obd->obd_type->typ_md_ops->m_getxattr(exp, fid,
                                                              obd_md_valid,
                                                              name, buf_size,
-                                                             req);
+                                                             projid, req);
 }
 
 static inline int md_set_open_replay_data(struct obd_export *exp,
index 3bd8dca..c1f98e9 100644 (file)
@@ -644,6 +644,7 @@ enum lustre_msg_version {
 #define MSG_CONNECT_NEXT_VER   0x00000080 /* use next version of lustre_msg */
 #define MSG_CONNECT_TRANSNO    0x00000100 /* client sent transno in replay */
 #define MSG_PACK_UID_GID       0x00000200 /* thread UID/GID in ptlrpc_body */
+#define MSG_PACK_PROJID                0x00000400 /* thread PROJID in ptlrpc_body */
 
 /* number of previous object versions in pb_pre_versions[] */
 #define PTLRPC_NUM_VERSIONS     4
@@ -657,7 +658,7 @@ struct ptlrpc_body_v3 {
        __u64 pb_last_xid;      /* highest replied XID w/o lower unreplied XID*/
        __u16 pb_tag;           /* multiple modifying RPCs virtual slot index */
        __u16 pb_padding0;
-       __u32 pb_padding1;
+       __u32 pb_projid;        /* req: inode projid, use by tbf rules */
        __u64 pb_last_committed;/* rep: highest pb_transno committed to disk */
        __u64 pb_transno;       /* server-assigned transno for modifying RPCs */
        __u32 pb_flags;         /* req: MSG_* flags */
@@ -688,7 +689,7 @@ struct ptlrpc_body_v2 {
        __u64 pb_last_xid; /* highest replied XID without lower unreplied XID */
        __u16 pb_tag;      /* virtual slot idx for multiple modifying RPCs */
        __u16 pb_padding0;
-       __u32 pb_padding1;
+       __u32 pb_projid;   /* req: inode projid, use by tbf rules */
        __u64 pb_last_committed;
        __u64 pb_transno;
        __u32 pb_flags;
index 1481235..e0b2566 100644 (file)
@@ -28,6 +28,7 @@
 # define __USE_GNU      1
 # define __USE_XOPEN2K8  1
 # define FILEID_LUSTRE 0x97 /* for name_to_handle_at() (and llapi_fd2fid()) */
+# define U32_MAX       UINT32_MAX
 #endif /* !__KERNEL__ */
 
 #include <linux/fs.h>
@@ -722,6 +723,9 @@ struct fsxattr {
 #define FS_XFLAG_PROJINHERIT           0x00000200
 #endif
 
+#define MDT_INVALID_UID                U32_MAX
+#define MDT_INVALID_GID                U32_MAX
+#define MDT_INVALID_PROJID     U32_MAX
 
 #define LL_STATFS_LMV          1
 #define LL_STATFS_LOV          2
index 39945e1..82de041 100644 (file)
@@ -162,7 +162,9 @@ int ll_set_acl(struct mnt_idmap *map,
 
        rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode),
                         value ? OBD_MD_FLXATTR : OBD_MD_FLXATTRRM,
-                        name, value, value_size, 0, 0, &req);
+                        name, value, value_size, 0, 0, ll_i2projid(inode),
+                        &req);
+
        if (!rc)
                ll_i2info(inode)->lli_synced_to_mds = false;
 
index da2b66d..11824d5 100644 (file)
@@ -65,7 +65,6 @@ static int ll_set_context(struct inode *inode, const void *ctx, size_t len,
                          void *fs_data)
 {
        struct ptlrpc_request *req = NULL;
-       struct ll_sb_info *sbi;
        int rc;
 
        if (inode == NULL) {
@@ -86,13 +85,13 @@ static int ll_set_context(struct inode *inode, const void *ctx, size_t len,
        if (is_root_inode(inode))
                return -EPERM;
 
-       sbi = ll_i2sbi(inode);
        /* Send setxattr request to lower layers directly instead of going
         * through the VFS, as there is no xattr handler for "encryption.".
         */
-       rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode),
-                        OBD_MD_FLXATTR, xattr_for_enc(inode),
-                        ctx, len, XATTR_CREATE, ll_i2suppgid(inode), &req);
+       rc = md_setxattr(ll_i2mdexp(inode), ll_inode2fid(inode), OBD_MD_FLXATTR,
+                        xattr_for_enc(inode), ctx, len, XATTR_CREATE,
+                        ll_i2suppgid(inode), ll_i2projid(inode), &req);
+
        if (rc)
                return rc;
        ptlrpc_req_put(req);
index e3b4a90..57cab07 100644 (file)
@@ -6888,7 +6888,7 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock)
                RETURN(rc);
 
        rc = md_getxattr(sbi->ll_md_exp, ll_inode2fid(inode), OBD_MD_FLXATTR,
-                        XATTR_NAME_LOV, lmmsize, &req);
+                        XATTR_NAME_LOV, lmmsize, ll_i2projid(inode), &req);
        if (rc < 0) {
                if (rc == -ENODATA)
                        GOTO(out, rc = 0); /* empty layout */
index 006bfc0..d54961c 100644 (file)
@@ -1186,6 +1186,11 @@ static inline struct inode *ll_info2i(struct ll_inode_info *lli)
        return &lli->lli_vfs_inode;
 }
 
+static inline __u32 ll_i2projid(struct inode *inode)
+{
+       return ll_i2info(inode)->lli_projid;
+}
+
 __u32 ll_i2suppgid(struct inode *i);
 void ll_i2gids(__u32 *suppgids, struct inode *i1, struct inode *i2);
 
index 57fef33..386d5e7 100644 (file)
@@ -3807,6 +3807,28 @@ void ll_unlock_md_op_lsm(struct md_op_data *op_data)
        lmv_stripe_object_put(&op_data->op_default_lso1);
 }
 
+
+/*
+ * This function determines projid value to pack in metadata requests. This
+ * value is used to "tag" the requests (for TBF purpose).
+ */
+static inline __u32 ll_get_inode_projid(struct inode *i1, struct inode *i2)
+{
+       struct ll_inode_info *lli = NULL;
+
+       if (i2) {
+               lli = ll_i2info(i2);
+       } else if (i1 && S_ISDIR(i1->i_mode)) {
+               /* lookup case, this is a guess (not always true) */
+               if (test_bit(LLIF_PROJECT_INHERIT, &ll_i2info(i1)->lli_flags))
+                       lli = ll_i2info(i1);
+       } else if (i1) {
+               lli = ll_i2info(i1);
+       }
+
+       return lli ? lli->lli_projid : 0;
+}
+
 /* this function prepares md_op_data hint for passing it down to MD stack. */
 struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data,
                                      struct inode *i1, struct inode *i2,
@@ -3943,6 +3965,7 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data,
        op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid());
        op_data->op_cap = current_cap();
        op_data->op_mds = 0;
+       op_data->op_projid = ll_get_inode_projid(i1, i2);
        if ((opc == LUSTRE_OPC_CREATE) && (name != NULL) &&
             filename_is_volatile(name, namelen, &op_data->op_mds)) {
                op_data->op_bias |= MDS_CREATE_VOLATILE;
index 6b73cbe..4d67be6 100644 (file)
@@ -196,7 +196,7 @@ static void vvp_req_attr_set(const struct lu_env *env, struct cl_object *obj,
 
        if (attr->cra_type == CRT_WRITE) {
                valid_flags |= OBD_MD_FLMTIME | OBD_MD_FLCTIME;
-               obdo_set_o_projid(oa, ll_i2info(inode)->lli_projid);
+               obdo_set_o_projid(oa, lli->lli_projid);
        } else if (attr->cra_type == CRT_READ) {
                valid_flags |= OBD_MD_FLATIME;
        }
@@ -205,6 +205,8 @@ static void vvp_req_attr_set(const struct lu_env *env, struct cl_object *obj,
        if (CFS_FAIL_CHECK(OBD_FAIL_LFSCK_INVALID_PFID))
                oa->o_parent_oid++;
 
+       /* Store ProjID any way for server-side TBF schedule. */
+       oa->o_projid = lli->lli_projid;
        lli_jobinfo_cpy(lli, &attr->cra_jobinfo);
 }
 
@@ -249,6 +251,14 @@ static int vvp_inode_ops(const struct lu_env *env, struct cl_object *obj,
        RETURN(rc);
 }
 
+static void vvp_req_projid_set(const struct lu_env *env, struct cl_object *obj,
+                              __u32 *projid)
+{
+       struct inode *inode = vvp_object_inode(obj);
+
+       *projid = ll_i2projid(inode);
+}
+
 static const struct cl_object_operations vvp_ops = {
        .coo_page_init    = vvp_page_init,
        .coo_io_init      = vvp_io_init,
@@ -260,6 +270,7 @@ static const struct cl_object_operations vvp_ops = {
        .coo_glimpse      = vvp_object_glimpse,
        .coo_req_attr_set = vvp_req_attr_set,
        .coo_inode_ops    = vvp_inode_ops,
+       .coo_req_projid_set = vvp_req_projid_set,
 };
 
 static int vvp_object_init0(const struct lu_env *env,
index e69aeac..731c3f2 100644 (file)
@@ -183,7 +183,8 @@ static int ll_xattr_set_common(const struct xattr_handler *handler,
                GOTO(out, rc = -ENOMEM);
 
        rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), valid, fullname,
-                        pv, size, flags, ll_i2suppgid(inode), &req);
+                        pv, size, flags, ll_i2suppgid(inode),
+                        ll_i2projid(inode), &req);
        kfree(fullname);
        if (rc) {
                if (rc == -EOPNOTSUPP && handler->flags == XATTR_USER_T) {
@@ -479,7 +480,7 @@ int ll_xattr_list(struct inode *inode, const char *name, int type, void *buffer,
        } else {
 getxattr_nocache:
                rc = md_getxattr(sbi->ll_md_exp, ll_inode2fid(inode), valid,
-                                name, size, &req);
+                                name, size, ll_i2projid(inode), &req);
                if (rc < 0)
                        GOTO(out_xattr, rc);
 
index 17856fd..c438afb 100644 (file)
@@ -1544,7 +1544,7 @@ static int lmv_get_root(struct obd_export *exp, const char *fileset,
 
 static int lmv_getxattr(struct obd_export *exp, const struct lu_fid *fid,
                        u64 obd_md_valid, const char *name, size_t buf_size,
-                       struct ptlrpc_request **req)
+                       u32 projid, struct ptlrpc_request **req)
 {
        struct obd_device *obd = exp->exp_obd;
        struct lmv_obd *lmv = &obd->u.lmv;
@@ -1557,16 +1557,16 @@ static int lmv_getxattr(struct obd_export *exp, const struct lu_fid *fid,
        if (IS_ERR(tgt))
                RETURN(PTR_ERR(tgt));
 
-       rc = md_getxattr(tgt->ltd_exp, fid, obd_md_valid, name, buf_size, req);
+       rc = md_getxattr(tgt->ltd_exp, fid, obd_md_valid, name, buf_size,
+                        projid, req);
 
        RETURN(rc);
 }
 
 static int lmv_setxattr(struct obd_export *exp, const struct lu_fid *fid,
-                       u64 obd_md_valid, const char *name,
-                       const void *value, size_t value_size,
-                       unsigned int xattr_flags, u32 suppgid,
-                       struct ptlrpc_request **req)
+                       u64 obd_md_valid, const char *name, const void *value,
+                       size_t value_size, unsigned int xattr_flags,
+                       u32 suppgid, u32 projid, struct ptlrpc_request **req)
 {
        struct obd_device *obd = exp->exp_obd;
        struct lmv_obd *lmv = &obd->u.lmv;
@@ -1579,8 +1579,8 @@ static int lmv_setxattr(struct obd_export *exp, const struct lu_fid *fid,
        if (IS_ERR(tgt))
                RETURN(PTR_ERR(tgt));
 
-       rc = md_setxattr(tgt->ltd_exp, fid, obd_md_valid, name,
-                        value, value_size, xattr_flags, suppgid, req);
+       rc = md_setxattr(tgt->ltd_exp, fid, obd_md_valid, name, value,
+                        value_size, xattr_flags, suppgid, projid, req);
 
        RETURN(rc);
 }
index 336aa85..155919d 100644 (file)
@@ -141,10 +141,21 @@ static void lovsub_req_attr_set(const struct lu_env *env, struct cl_object *obj,
        EXIT;
 }
 
+static void lovsub_req_projid_set(const struct lu_env *env,
+                                 struct cl_object *obj, __u32 *projid)
+{
+       struct lovsub_object *subobj = cl2lovsub(obj);
+
+       ENTRY;
+       cl_req_projid_set(env, &subobj->lso_super->lo_cl, projid);
+       EXIT;
+}
+
 static const struct cl_object_operations lovsub_ops = {
-       .coo_attr_update  = lovsub_attr_update,
-       .coo_glimpse      = lovsub_object_glimpse,
-       .coo_req_attr_set = lovsub_req_attr_set
+       .coo_attr_update        = lovsub_attr_update,
+       .coo_glimpse            = lovsub_object_glimpse,
+       .coo_req_attr_set       = lovsub_req_attr_set,
+       .coo_req_projid_set     = lovsub_req_projid_set,
 };
 
 static const struct lu_object_operations lovsub_lu_obj_ops = {
index 281a864..f412576 100644 (file)
@@ -19,7 +19,8 @@
 int mdc_tunables_init(struct obd_device *obd);
 
 void mdc_pack_body(struct req_capsule *pill, const struct lu_fid *fid,
-                  u64 valid, size_t ea_size, u32 suppgid, u32 flags);
+                  u64 valid, size_t ea_size, u32 suppgid, u32 flags,
+                  u32 projid);
 void mdc_swap_layouts_pack(struct req_capsule *pill,
                           struct md_op_data *op_data);
 void mdc_readdir_pack(struct req_capsule *pill, __u64 pgoff, size_t size,
index 8fed24a..c4e99fc 100644 (file)
@@ -60,9 +60,11 @@ void mdc_swap_layouts_pack(struct req_capsule *pill,
 }
 
 void mdc_pack_body(struct req_capsule *pill, const struct lu_fid *fid,
-                  u64 valid, size_t ea_size, u32 suppgid, u32 flags)
+                  u64 valid, size_t ea_size, u32 suppgid, u32 flags,
+                  u32 projid)
 {
        struct mdt_body *b = req_capsule_client_get(pill, &RMF_MDT_BODY);
+
        LASSERT(b);
        b->mbo_valid = valid;
        b->mbo_eadatasize = ea_size;
@@ -72,6 +74,9 @@ void mdc_pack_body(struct req_capsule *pill, const struct lu_fid *fid,
                b->mbo_fid1 = *fid;
                b->mbo_valid |= OBD_MD_FLID;
        }
+
+       if (projid != MDT_INVALID_PROJID && req_capsule_ptlreq(pill))
+               lustre_msg_set_projid(pill->rc_reqmsg, projid);
 }
 
 /**
index 9fed4ea..0bd40f6 100644 (file)
@@ -576,7 +576,7 @@ mdc_intent_getxattr_pack(struct obd_export *exp, struct lookup_intent *it,
 
        /* pack the intended request */
        mdc_pack_body(&req->rq_pill, &op_data->op_fid1, op_data->op_valid,
-                     ea_vals_buf_size, -1, 0);
+                     ea_vals_buf_size, -1, 0, op_data->op_projid);
 
        /* get SELinux policy info if any */
        mdc_file_sepol_pack(&req->rq_pill, sepol);
@@ -1080,6 +1080,8 @@ resend:
        if (IS_ERR(req))
                RETURN(PTR_ERR(req));
 
+       lustre_msg_set_projid(req->rq_reqmsg, op_data->op_projid);
+
        if (resends) {
                req->rq_generation_set = 1;
                req->rq_import_generation = generation;
index 4e05efa..42edc22 100644 (file)
@@ -105,7 +105,7 @@ static int mdc_get_root(struct obd_export *exp, const char *fileset,
                ptlrpc_request_free(req);
                RETURN(rc);
        }
-       mdc_pack_body(&req->rq_pill, NULL, 0, 0, -1, 0);
+       mdc_pack_body(&req->rq_pill, NULL, 0, 0, -1, 0, MDT_INVALID_PROJID);
        if (fileset != NULL) {
                char *name = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
 
@@ -232,7 +232,7 @@ static int mdc_getattr(struct obd_export *exp, struct md_op_data *op_data,
 
 again:
        mdc_pack_body(&req->rq_pill, &op_data->op_fid1, op_data->op_valid,
-                     op_data->op_mode, -1, 0);
+                     op_data->op_mode, -1, 0, op_data->op_projid);
        req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER, acl_bufsize);
        req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
                             op_data->op_mode);
@@ -296,7 +296,8 @@ static int mdc_getattr_name(struct obd_export *exp, struct md_op_data *op_data,
 
 again:
        mdc_pack_body(&req->rq_pill, &op_data->op_fid1, op_data->op_valid,
-                     op_data->op_mode, op_data->op_suppgids[0], 0);
+                     op_data->op_mode, op_data->op_suppgids[0], 0,
+                     op_data->op_projid);
        req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
                             op_data->op_mode);
        req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER, acl_bufsize);
@@ -335,7 +336,8 @@ int mdc_xattr_common(struct obd_export *exp, const struct req_format *fmt,
                            const struct lu_fid *fid, int opcode, u64 valid,
                            const char *xattr_name, const char *input,
                            int input_size, int output_size, int flags,
-                           __u32 suppgid, struct ptlrpc_request **request)
+                           __u32 suppgid, __u32 projid,
+                           struct ptlrpc_request **request)
 {
        struct ptlrpc_request *req;
        struct sptlrpc_sepol *sepol;
@@ -408,9 +410,10 @@ int mdc_xattr_common(struct obd_export *exp, const struct req_format *fmt,
                rec->sx_time   = ktime_get_real_seconds();
                rec->sx_size   = output_size;
                rec->sx_flags  = flags;
+               lustre_msg_set_projid(req->rq_reqmsg, projid);
        } else {
                mdc_pack_body(&req->rq_pill, fid, valid, output_size,
-                             suppgid, flags);
+                             suppgid, flags, projid);
                /* Avoid deadlock with modifying RPCs on MDS_REQUEST_PORTAL.
                 * See LU-15245.
                 */
@@ -458,10 +461,9 @@ err_free_rq:
 }
 
 static int mdc_setxattr(struct obd_export *exp, const struct lu_fid *fid,
-                       u64 obd_md_valid, const char *name,
-                       const void *value, size_t value_size,
-                       unsigned int xattr_flags, u32 suppgid,
-                       struct ptlrpc_request **req)
+                       u64 obd_md_valid, const char *name, const void *value,
+                       size_t value_size, unsigned int xattr_flags,
+                       u32 suppgid, u32 projid, struct ptlrpc_request **req)
 {
        LASSERT(obd_md_valid == OBD_MD_FLXATTR ||
                obd_md_valid == OBD_MD_FLXATTRRM);
@@ -469,12 +471,12 @@ static int mdc_setxattr(struct obd_export *exp, const struct lu_fid *fid,
        return mdc_xattr_common(exp, &RQF_MDS_REINT_SETXATTR,
                                fid, MDS_REINT, obd_md_valid, name,
                                value, value_size, 0, xattr_flags, suppgid,
-                               req);
+                               projid, req);
 }
 
 static int mdc_getxattr(struct obd_export *exp, const struct lu_fid *fid,
                        u64 obd_md_valid, const char *name, size_t buf_size,
-                       struct ptlrpc_request **req)
+                       u32 projid, struct ptlrpc_request **req)
 {
        struct mdt_body *body;
        int rc;
@@ -489,7 +491,7 @@ static int mdc_getxattr(struct obd_export *exp, const struct lu_fid *fid,
               exp->exp_obd->obd_name, name, PFID(fid));
        rc = mdc_xattr_common(exp, &RQF_MDS_GETXATTR, fid, MDS_GETXATTR,
                              obd_md_valid, name, NULL, 0, buf_size, 0, -1,
-                             req);
+                             projid, req);
        if (rc < 0)
                GOTO(out, rc);
 
@@ -929,6 +931,7 @@ static int mdc_close(struct obd_export *exp, struct md_op_data *op_data,
         */
        req->rq_request_portal = MDS_READPAGE_PORTAL;
        ptlrpc_at_set_req_timeout(req);
+       lustre_msg_set_projid(req->rq_reqmsg, op_data->op_projid);
 
        if (!obd->u.cli.cl_lsom_update ||
            !(exp_connect_flags2(exp) & OBD_CONNECT2_LSOM))
@@ -1016,7 +1019,7 @@ out:
 
 static int mdc_getpage(struct obd_export *exp, const struct lu_fid *fid,
                       u64 offset, struct page **pages, int npages,
-                      struct ptlrpc_request **request)
+                      __u32 projid, struct ptlrpc_request **request)
 {
        struct ptlrpc_request   *req;
        struct ptlrpc_bulk_desc *desc;
@@ -1039,6 +1042,7 @@ restart_bulk:
 
        req->rq_request_portal = MDS_READPAGE_PORTAL;
        ptlrpc_at_set_req_timeout(req);
+       lustre_msg_set_projid(req->rq_reqmsg, projid);
 
        desc = ptlrpc_prep_bulk_imp(req, npages, 1,
                                    PTLRPC_BULK_PUT_SINK,
@@ -1347,7 +1351,8 @@ static int ll_mdc_read_page_remote(void *data, struct page *page0)
                page_pool[npages] = page;
        }
 
-       rc = mdc_getpage(rp->rp_exp, fid, rp->rp_off, page_pool, npages, &req);
+       rc = mdc_getpage(rp->rp_exp, fid, rp->rp_off, page_pool, npages,
+                        op_data->op_projid, &req);
        if (rc < 0) {
                /* page0 is special, which was added into page cache early */
                cfs_delete_from_page_cache(page0);
@@ -1741,7 +1746,7 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp,
        if (IS_ERR(req))
                RETURN(PTR_ERR(req));
 
-       mdc_pack_body(&req->rq_pill, NULL, 0, 0, -1, 0);
+       mdc_pack_body(&req->rq_pill, NULL, 0, 0, -1, 0, MDT_INVALID_PROJID);
 
        /* Copy hsm_progress struct */
        req_hpk = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_PROGRESS);
@@ -1799,7 +1804,7 @@ static int mdc_ioc_hsm_ct_register(struct obd_import *imp, __u32 archive_count,
                RETURN(-ENOMEM);
        }
 
-       mdc_pack_body(&req->rq_pill, NULL, 0, 0, -1, 0);
+       mdc_pack_body(&req->rq_pill, NULL, 0, 0, -1, 0, MDT_INVALID_PROJID);
 
        archive_array = req_capsule_client_get(&req->rq_pill,
                                               &RMF_MDS_HSM_ARCHIVE);
@@ -1841,7 +1846,7 @@ static int mdc_ioc_hsm_current_action(struct obd_export *exp,
        }
 
        mdc_pack_body(&req->rq_pill, &op_data->op_fid1, 0, 0,
-                     op_data->op_suppgids[0], 0);
+                     op_data->op_suppgids[0], 0, op_data->op_projid);
 
        ptlrpc_request_set_replen(req);
 
@@ -1874,7 +1879,7 @@ static int mdc_ioc_hsm_ct_unregister(struct obd_import *imp)
        if (IS_ERR(req))
                RETURN(PTR_ERR(req));
 
-       mdc_pack_body(&req->rq_pill, NULL, 0, 0, -1, 0);
+       mdc_pack_body(&req->rq_pill, NULL, 0, 0, -1, 0, MDT_INVALID_PROJID);
 
        ptlrpc_request_set_replen(req);
 
@@ -1906,7 +1911,7 @@ static int mdc_ioc_hsm_state_get(struct obd_export *exp,
        }
 
        mdc_pack_body(&req->rq_pill, &op_data->op_fid1, 0, 0,
-                     op_data->op_suppgids[0], 0);
+                     op_data->op_suppgids[0], 0, op_data->op_projid);
 
        ptlrpc_request_set_replen(req);
 
@@ -1947,7 +1952,7 @@ static int mdc_ioc_hsm_state_set(struct obd_export *exp,
        }
 
        mdc_pack_body(&req->rq_pill, &op_data->op_fid1, 0, 0,
-                     op_data->op_suppgids[0], 0);
+                     op_data->op_suppgids[0], 0, op_data->op_projid);
 
        /* Copy states */
        req_hss = req_capsule_client_get(&req->rq_pill, &RMF_HSM_STATE_SET);
@@ -2025,7 +2030,7 @@ static int mdc_ioc_hsm_request(struct obd_export *exp,
        /* Cancel existing locks */
        count = mdc_hsm_request_lock_to_cancel(exp, hur, &cancels);
        ldlm_cli_cancel_list(&cancels, count, NULL, NULL, 0);
-       mdc_pack_body(&req->rq_pill, NULL, 0, 0, -1, 0);
+       mdc_pack_body(&req->rq_pill, NULL, 0, 0, -1, 0, MDT_INVALID_PROJID);
 
        /* Copy hsm_request struct */
        req_hr = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_REQUEST);
@@ -2079,7 +2084,7 @@ static int mdc_ioc_hsm_data_version(struct obd_export *exp,
        }
 
        mdc_pack_body(&req->rq_pill, &op_data->op_fid1, 0, 0,
-                     op_data->op_suppgids[0], 0);
+                     op_data->op_suppgids[0], 0, op_data->op_projid);
 
        b = req_capsule_client_get(&req->rq_pill, &RMF_MDT_BODY);
        LASSERT(b);
@@ -2730,7 +2735,7 @@ static int mdc_fsync(struct obd_export *exp, const struct lu_fid *fid,
                RETURN(rc);
        }
 
-       mdc_pack_body(&req->rq_pill, fid, 0, 0, -1, 0);
+       mdc_pack_body(&req->rq_pill, fid, 0, 0, -1, 0, MDT_INVALID_PROJID);
 
        ptlrpc_request_set_replen(req);
 
@@ -2800,7 +2805,7 @@ static int mdc_rmfid(struct obd_export *exp, struct fid_array *fa,
        tmp = req_capsule_client_get(&req->rq_pill, &RMF_FID_ARRAY);
        memcpy(tmp, fa->fa_fids, flen);
 
-       mdc_pack_body(&req->rq_pill, NULL, 0, 0, -1, 0);
+       mdc_pack_body(&req->rq_pill, NULL, 0, 0, -1, 0, MDT_INVALID_PROJID);
        b = req_capsule_client_get(&req->rq_pill, &RMF_MDT_BODY);
        b->mbo_ctime = ktime_get_real_seconds();
 
index 7bb5d6e..891ea3b 100644 (file)
@@ -448,6 +448,21 @@ int cl_object_inode_ops(const struct lu_env *env, struct cl_object *top,
 }
 EXPORT_SYMBOL(cl_object_inode_ops);
 
+void cl_req_projid_set(const struct lu_env *env, struct cl_object *top,
+                      __u32 *projid)
+{
+       struct cl_object *obj;
+
+       ENTRY;
+
+       cl_object_for_each(obj, top) {
+               if (obj->co_ops->coo_req_projid_set)
+                       obj->co_ops->coo_req_projid_set(env, obj, projid);
+       }
+       EXIT;
+}
+EXPORT_SYMBOL(cl_req_projid_set);
+
 /**
  * Helper function removing all object locks, and marking object for
  * deletion. All object pages must have been deleted at this point.
index 0380c43..40770ce 100644 (file)
@@ -45,7 +45,7 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id,
                     struct ost_lvb *lvb, osc_enqueue_upcall_f upcall,
                     void *cookie, struct ldlm_enqueue_info *einfo,
                     struct ptlrpc_request_set *rqset, int async,
-                    bool speculative);
+                    bool speculative, __u32 projid);
 
 int osc_match_base(const struct lu_env *env, struct obd_export *exp,
                   struct ldlm_res_id *res_id, enum ldlm_type type,
index ca0d9d3..e65f6a8 100644 (file)
@@ -559,6 +559,13 @@ int osc_punch_start(const struct lu_env *env, struct cl_io *io,
 }
 EXPORT_SYMBOL(osc_punch_start);
 
+static inline void osc_set_projid_info(const struct lu_env *env,
+                                      struct cl_object *obj, struct obdo *oa)
+{
+       if (!(oa->o_valid & OBD_MD_FLPROJID))
+               cl_req_projid_set(env, obj, &oa->o_projid);
+}
+
 static int osc_io_setattr_start(const struct lu_env *env,
                                 const struct cl_io_slice *slice)
 {
@@ -618,6 +625,7 @@ static int osc_io_setattr_start(const struct lu_env *env,
        memset(oa, 0, sizeof(*oa));
        if (result == 0) {
                oa->o_oi = loi->loi_oi;
+               osc_set_projid_info(env, obj, oa);
                obdo_set_parent_fid(oa, io->u.ci_setattr.sa_parent_fid);
                oa->o_stripe_idx = io->u.ci_setattr.sa_stripe_index;
                oa->o_layout = io->u.ci_setattr.sa_layout;
@@ -798,6 +806,7 @@ static int osc_io_data_version_start(const struct lu_env *env,
        memset(oa, 0, sizeof(*oa));
        oa->o_oi = loi->loi_oi;
        oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
+       osc_set_projid_info(env, slice->cis_obj, oa);
 
        if (dv->dv_flags & (LL_DV_RD_FLUSH | LL_DV_WR_FLUSH)) {
                oa->o_valid |= OBD_MD_FLFLAGS;
@@ -928,6 +937,7 @@ int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj,
        memset(oa, 0, sizeof(*oa));
        oa->o_oi = loi->loi_oi;
        oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
+       osc_set_projid_info(env, osc2cl(obj), oa);
 
        /* reload size abd blocks for start and end of sync range */
        oa->o_size = fio->fi_start;
@@ -1069,6 +1079,7 @@ static int osc_io_ladvise_start(const struct lu_env *env,
        memset(oa, 0, sizeof(*oa));
        oa->o_oi = loi->loi_oi;
        oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
+       osc_set_projid_info(env, obj, oa);
        obdo_set_parent_fid(oa, lio->lio_fid);
 
        ladvise = ladvise_hdr->lah_advise;
@@ -1193,6 +1204,7 @@ int osc_io_lseek_start(const struct lu_env *env,
        memset(oa, 0, sizeof(*oa));
        oa->o_oi = loi->loi_oi;
        oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
+       osc_set_projid_info(env, obj, oa);
        oa->o_size = lsio->ls_start;
        oa->o_mode = lsio->ls_whence;
        if (oio->oi_lockless) {
index e599994..f6689f1 100644 (file)
@@ -941,7 +941,8 @@ static int osc_lock_enqueue(const struct lu_env *env,
        osc_enqueue_upcall_f            upcall   = osc_lock_upcall;
        void                            *cookie  = oscl;
        bool                            async    = false;
-       int                             result;
+       __u32 projid;
+       int result;
 
         ENTRY;
 
@@ -1011,11 +1012,13 @@ enqueue_base:
                upcall = osc_lock_upcall_speculative;
                cookie = osc;
        }
+
+       cl_req_projid_set(env, osc2cl(osc), &projid);
        result = osc_enqueue_base(exp, resname, &oscl->ols_flags,
                                  policy, &oscl->ols_lvb,
                                  upcall, cookie,
                                  &oscl->ols_einfo, PTLRPCD_SET, async,
-                                 oscl->ols_speculative);
+                                 oscl->ols_speculative, projid);
        if (result == 0) {
                if (osc_lock_is_lockless(oscl)) {
                        oio->oi_lockless = 1;
index c2c16ee..7789edc 100644 (file)
@@ -68,7 +68,8 @@ static void osc_release_ppga(struct brw_page **ppga, size_t count);
 static int brw_interpret(const struct lu_env *env, struct ptlrpc_request *req,
                         void *data, int rc);
 
-static void osc_pack_req_body(struct ptlrpc_request *req, struct obdo *oa)
+static inline
+struct ost_body *osc_pack_req_body(struct ptlrpc_request *req, struct obdo *oa)
 {
        struct ost_body *body;
 
@@ -76,6 +77,9 @@ static void osc_pack_req_body(struct ptlrpc_request *req, struct obdo *oa)
        LASSERT(body);
 
        lustre_set_wire_obdo(&req->rq_import->imp_connect_data, &body->oa, oa);
+       lustre_msg_set_projid(req->rq_reqmsg, oa->o_projid);
+
+       return body;
 }
 
 static int osc_getattr(const struct lu_env *env, struct obd_export *exp,
@@ -97,7 +101,6 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp,
        }
 
        osc_pack_req_body(req, oa);
-
        ptlrpc_request_set_replen(req);
 
        rc = ptlrpc_queue_wait(req);
@@ -142,7 +145,6 @@ static int osc_setattr(const struct lu_env *env, struct obd_export *exp,
        }
 
        osc_pack_req_body(req, oa);
-
        ptlrpc_request_set_replen(req);
 
        rc = ptlrpc_queue_wait(req);
@@ -257,7 +259,6 @@ int osc_ladvise_base(struct obd_export *exp, struct obdo *oa,
                     struct ptlrpc_request_set *rqset)
 {
        struct ptlrpc_request *req;
-       struct ost_body *body;
        struct osc_ladvise_args *la;
        struct lu_ladvise *req_ladvise;
        struct lu_ladvise *ladvise = ladvise_hdr->lah_advise;
@@ -280,10 +281,7 @@ int osc_ladvise_base(struct obd_export *exp, struct obdo *oa,
        req->rq_request_portal = OST_IO_PORTAL;
        ptlrpc_at_set_req_timeout(req);
 
-       body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
-       LASSERT(body);
-       lustre_set_wire_obdo(&req->rq_import->imp_connect_data, &body->oa,
-                            oa);
+       osc_pack_req_body(req, oa);
 
        req_ladvise_hdr = req_capsule_client_get(&req->rq_pill,
                                                 &RMF_OST_LADVISE_HDR);
@@ -332,10 +330,7 @@ static int osc_create(const struct lu_env *env, struct obd_export *exp,
                GOTO(out, rc);
        }
 
-       body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
-       LASSERT(body);
-
-       lustre_set_wire_obdo(&req->rq_import->imp_connect_data, &body->oa, oa);
+       osc_pack_req_body(req, oa);
 
        ptlrpc_request_set_replen(req);
 
@@ -367,7 +362,6 @@ int osc_punch_send(struct obd_export *exp, struct obdo *oa,
        struct ptlrpc_request *req;
        struct osc_setattr_args *sa;
        struct obd_import *imp = class_exp2cliimp(exp);
-       struct ost_body *body;
        int rc;
 
        ENTRY;
@@ -386,9 +380,7 @@ int osc_punch_send(struct obd_export *exp, struct obdo *oa,
 
        ptlrpc_at_set_req_timeout(req);
 
-       body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
-
-       lustre_set_wire_obdo(&imp->imp_connect_data, &body->oa, oa);
+       osc_pack_req_body(req, oa);
 
        ptlrpc_request_set_replen(req);
 
@@ -426,8 +418,6 @@ int osc_fallocate_base(struct obd_export *exp, struct obdo *oa,
 {
        struct ptlrpc_request *req;
        struct osc_setattr_args *sa;
-       struct ost_body *body;
-       struct obd_import *imp = class_exp2cliimp(exp);
        int rc;
 
        ENTRY;
@@ -443,11 +433,7 @@ int osc_fallocate_base(struct obd_export *exp, struct obdo *oa,
                RETURN(rc);
        }
 
-       body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
-       LASSERT(body);
-
-       lustre_set_wire_obdo(&imp->imp_connect_data, &body->oa, oa);
-
+       osc_pack_req_body(req, oa);
        ptlrpc_request_set_replen(req);
 
        req->rq_interpret_reply = osc_setattr_interpret;
@@ -510,7 +496,6 @@ int osc_sync_base(struct osc_object *obj, struct obdo *oa,
 {
        struct obd_export *exp = osc_export(obj);
        struct ptlrpc_request *req;
-       struct ost_body *body;
        struct osc_fsync_args *fa;
        int rc;
 
@@ -526,10 +511,7 @@ int osc_sync_base(struct osc_object *obj, struct obdo *oa,
        }
 
        /* overload the size and blocks fields in the oa with start/end */
-       body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
-       LASSERT(body);
-       lustre_set_wire_obdo(&req->rq_import->imp_connect_data, &body->oa, oa);
-
+       osc_pack_req_body(req, oa);
        ptlrpc_request_set_replen(req);
        req->rq_interpret_reply = osc_sync_interpret;
 
@@ -613,7 +595,6 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp,
 {
        struct client_obd *cli = &exp->exp_obd->u.cli;
        struct ptlrpc_request *req;
-       struct ost_body *body;
        LIST_HEAD(cancels);
        int rc, count;
 
@@ -642,10 +623,7 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp,
        req->rq_request_portal = OST_IO_PORTAL; /* bug 7198 */
        ptlrpc_at_set_req_timeout(req);
 
-       body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
-       LASSERT(body);
-       lustre_set_wire_obdo(&req->rq_import->imp_connect_data, &body->oa, oa);
-
+       osc_pack_req_body(req, oa);
        ptlrpc_request_set_replen(req);
 
        req->rq_interpret_reply = osc_destroy_interpret;
@@ -1806,12 +1784,10 @@ retry_encrypt:
                desc->bd_md_offset = iop_pages;
 
 no_bulk:
-       body = req_capsule_client_get(pill, &RMF_OST_BODY);
+       body = osc_pack_req_body(req, oa);
        ioobj = req_capsule_client_get(pill, &RMF_OBD_IOOBJ);
        niobuf = req_capsule_client_get(pill, &RMF_NIOBUF_REMOTE);
-       LASSERT(body != NULL && ioobj != NULL && niobuf != NULL);
-
-       lustre_set_wire_obdo(&req->rq_import->imp_connect_data, &body->oa, oa);
+       LASSERT(ioobj != NULL && niobuf != NULL);
 
        /* 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
@@ -2908,6 +2884,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
        crattr->cra_flags = OBD_MD_FLMTIME | OBD_MD_FLCTIME | OBD_MD_FLATIME;
        cl_req_attr_set(env, osc2cl(obj), crattr);
        lustre_msg_set_jobinfo(req->rq_reqmsg, &crattr->cra_jobinfo);
+       lustre_msg_set_projid(req->rq_reqmsg, body->oa.o_projid);
 
        aa = ptlrpc_req_async_args(aa, req);
        INIT_LIST_HEAD(&aa->aa_oaps);
@@ -3140,11 +3117,11 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id,
                     struct ost_lvb *lvb, osc_enqueue_upcall_f upcall,
                     void *cookie, struct ldlm_enqueue_info *einfo,
                     struct ptlrpc_request_set *rqset, int async,
-                    bool speculative)
+                    bool speculative, __u32 projid)
 {
        struct obd_device *obd = exp->exp_obd;
        struct lustre_handle lockh = { 0 };
-       struct ptlrpc_request *req = NULL;
+       struct ptlrpc_request *req;
        int intent = *flags & LDLM_FL_HAS_INTENT;
        __u64 search_flags = *flags;
        __u64 match_flags = 0;
@@ -3233,41 +3210,50 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id,
        /* users of osc_enqueue() can pass this flag for ldlm_lock_match() */
        *flags &= ~LDLM_FL_BLOCK_GRANTED;
 
+       req = ldlm_enqueue_pack(exp, sizeof(*lvb));
+       if (IS_ERR(req))
+               RETURN(PTR_ERR(req));
+
+       lustre_msg_set_projid(req->rq_reqmsg, projid);
        rc = ldlm_cli_enqueue(exp, &req, einfo, res_id, policy, flags, lvb,
                              sizeof(*lvb), LVB_T_OST, &lockh, async);
+       if (rc)
+               GOTO(out_put, rc);
+
        if (async) {
-               if (!rc) {
-                       struct osc_enqueue_args *aa;
-
-                       aa = ptlrpc_req_async_args(aa, req);
-                       aa->oa_exp         = exp;
-                       aa->oa_mode        = einfo->ei_mode;
-                       aa->oa_type        = einfo->ei_type;
-                       lustre_handle_copy(&aa->oa_lockh, &lockh);
-                       aa->oa_upcall      = upcall;
-                       aa->oa_cookie      = cookie;
-                       aa->oa_speculative = speculative;
-                       if (!speculative) {
-                               aa->oa_flags  = flags;
-                               aa->oa_lvb    = lvb;
-                       } else {
-                               /* speculative locks are essentially to enqueue
-                                * a DLM lock  in advance, so we don't care
-                                * about the result of the enqueue.
-                                */
-                               aa->oa_lvb    = NULL;
-                               aa->oa_flags  = NULL;
-                       }
+               struct osc_enqueue_args *aa;
 
-                       req->rq_interpret_reply = osc_enqueue_interpret;
-                       ptlrpc_set_add_req(rqset, req);
+               aa = ptlrpc_req_async_args(aa, req);
+               aa->oa_exp         = exp;
+               aa->oa_mode        = einfo->ei_mode;
+               aa->oa_type        = einfo->ei_type;
+               lustre_handle_copy(&aa->oa_lockh, &lockh);
+               aa->oa_upcall      = upcall;
+               aa->oa_cookie      = cookie;
+               aa->oa_speculative = speculative;
+               if (!speculative) {
+                       aa->oa_flags  = flags;
+                       aa->oa_lvb    = lvb;
+               } else {
+                       /* speculative locks are essentially to enqueue a DLM
+                        * lock in advance, so we don't care about the result of
+                        * the enqueue.
+                        */
+                       aa->oa_lvb    = NULL;
+                       aa->oa_flags  = NULL;
                }
+
+               req->rq_interpret_reply = osc_enqueue_interpret;
+               ptlrpc_set_add_req(rqset, req);
                RETURN(rc);
        }
 
        rc = osc_enqueue_fini(req, upcall, cookie, &lockh, einfo->ei_mode,
                              flags, speculative, rc);
 
+out_put:
+       ptlrpc_req_put(req);
+
        RETURN(rc);
 }
 
index 7e76bc5..2e6bd4c 100644 (file)
@@ -1269,6 +1269,34 @@ timeout_t lustre_msg_get_service_timeout(struct lustre_msg *msg)
        }
 }
 
+int lustre_msg_get_projid(struct lustre_msg *msg, __u32 *projid)
+{
+       switch (msg->lm_magic) {
+       case LUSTRE_MSG_MAGIC_V2: {
+               struct ptlrpc_body *pb;
+
+               if (msg->lm_buflens[MSG_PTLRPC_BODY_OFF] <
+                   sizeof(struct ptlrpc_body))
+                       return -EOPNOTSUPP;
+
+               pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF,
+                                         sizeof(struct ptlrpc_body));
+
+               if (!pb || !(pb->pb_flags & MSG_PACK_PROJID))
+                       return -EOPNOTSUPP;
+
+               if (projid)
+                       *projid = pb->pb_projid;
+
+               return 0;
+       }
+       default:
+               CERROR("incorrect message magic: %08x\n", msg->lm_magic);
+               return -EOPNOTSUPP;
+       }
+}
+EXPORT_SYMBOL(lustre_msg_get_projid);
+
 int lustre_msg_get_uid_gid(struct lustre_msg *msg, __u32 *uid, __u32 *gid)
 {
        switch (msg->lm_magic) {
@@ -1610,6 +1638,33 @@ void lustre_msg_set_jobinfo(struct lustre_msg *msg, const struct job_info *ji)
 }
 EXPORT_SYMBOL(lustre_msg_set_jobinfo);
 
+void lustre_msg_set_projid(struct lustre_msg *msg, __u32 projid)
+{
+       switch (msg->lm_magic) {
+       case LUSTRE_MSG_MAGIC_V2: {
+               __u32 opc = lustre_msg_get_opc(msg);
+               struct ptlrpc_body *pb;
+
+               /* Don't set projid for ldlm ast RPCs */
+               if (!opc || opc == LDLM_BL_CALLBACK ||
+                   opc == LDLM_CP_CALLBACK || opc == LDLM_GL_CALLBACK)
+                       return;
+
+               pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF,
+                                      sizeof(struct ptlrpc_body));
+               LASSERTF(pb, "invalid msg %px: no ptlrpc body!\n", msg);
+
+               pb->pb_projid = projid;
+               pb->pb_flags |= MSG_PACK_PROJID;
+
+               return;
+       }
+       default:
+               LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
+       }
+}
+EXPORT_SYMBOL(lustre_msg_set_projid);
+
 void lustre_msg_set_cksum(struct lustre_msg *msg, __u32 cksum)
 {
        switch (msg->lm_magic) {
@@ -1714,7 +1769,7 @@ void lustre_swab_ptlrpc_body(struct ptlrpc_body *body)
        __swab64s(&body->pb_last_xid);
        __swab16s(&body->pb_tag);
        BUILD_BUG_ON(offsetof(typeof(*body), pb_padding0) == 0);
-       BUILD_BUG_ON(offsetof(typeof(*body), pb_padding1) == 0);
+       __swab32s(&body->pb_projid);
        __swab64s(&body->pb_last_committed);
        __swab64s(&body->pb_transno);
        __swab32s(&body->pb_flags);
@@ -2831,8 +2886,9 @@ void _debug_req(struct ptlrpc_request *req,
        __u64 req_transno = 0;
        int req_opc = -1;
        __u32 req_flags =  (__u32) -1;
-       __u32 req_uid = (__u32) -1;
-       __u32 req_gid = (__u32) -1;
+       __u32 req_uid = MDT_INVALID_UID;
+       __u32 req_gid = MDT_INVALID_GID;
+       __u32 req_projid = MDT_INVALID_PROJID;
        char *req_jobid = NULL;
 
        spin_lock(&req->rq_early_free_lock);
@@ -2860,6 +2916,7 @@ void _debug_req(struct ptlrpc_request *req,
                req_opc = lustre_msg_get_opc(req->rq_reqmsg);
                req_jobid = lustre_msg_get_jobid(req->rq_reqmsg);
                lustre_msg_get_uid_gid(req->rq_reqmsg, &req_uid, &req_gid);
+               lustre_msg_get_projid(req->rq_reqmsg, &req_projid);
                req_flags = lustre_msg_get_flags(req->rq_reqmsg);
        }
 
@@ -2867,7 +2924,7 @@ void _debug_req(struct ptlrpc_request *req,
        vaf.fmt = fmt;
        vaf.va = &args;
        libcfs_debug_msg(msgdata,
-                        "%pV req@%p x%llu/t%lld(%llu) o%d->%s@%s:%d/%d lens %d/%d e %d to %lld dl %lld ref %d fl " REQ_FLAGS_FMT "/%x/%x rc %d/%d job:'%s' uid:%u gid:%u\n",
+                        "%pV req@%p x%llu/t%lld(%llu) o%d->%s@%s:%d/%d lens %d/%d e %d to %lld dl %lld ref %d fl " REQ_FLAGS_FMT "/%x/%x rc %d/%d job:'%s' uid:%u gid:%u projid:%u\n",
                         &vaf,
                         req, req->rq_xid, req->rq_transno, req_transno,
                         req_opc,
@@ -2884,7 +2941,7 @@ void _debug_req(struct ptlrpc_request *req,
                         atomic_read(&req->rq_refcount),
                         DEBUG_REQ_FLAGS(req), req_flags, rep_flags,
                         req->rq_status, rep_status,
-                        req_jobid ?: "", req_uid, req_gid);
+                        req_jobid ?: "", req_uid, req_gid, req_projid);
        va_end(args);
 }
 EXPORT_SYMBOL(_debug_req);
index efc1d83..1b9e885 100644 (file)
@@ -891,10 +891,10 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)offsetof(struct ptlrpc_body_v3, pb_padding0));
        LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_padding0) == 2, "found %lld\n",
                 (long long)(int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_padding0));
-       LASSERTF((int)offsetof(struct ptlrpc_body_v3, pb_padding1) == 36, "found %lld\n",
-                (long long)(int)offsetof(struct ptlrpc_body_v3, pb_padding1));
-       LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_padding1) == 4, "found %lld\n",
-                (long long)(int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_padding1));
+       LASSERTF((int)offsetof(struct ptlrpc_body_v3, pb_projid) == 36, "found %lld\n",
+                (long long)(int)offsetof(struct ptlrpc_body_v3, pb_projid));
+       LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_projid) == 4, "found %lld\n",
+                (long long)(int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_projid));
        LASSERTF((int)offsetof(struct ptlrpc_body_v3, pb_last_committed) == 40, "found %lld\n",
                 (long long)(int)offsetof(struct ptlrpc_body_v3, pb_last_committed));
        LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_last_committed) == 8, "found %lld\n",
@@ -993,10 +993,10 @@ void lustre_assert_wire_constants(void)
                 (int)offsetof(struct ptlrpc_body_v3, pb_padding0), (int)offsetof(struct ptlrpc_body_v2, pb_padding0));
        LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_padding0) == (int)sizeof(((struct ptlrpc_body_v2 *)0)->pb_padding0), "%d != %d\n",
                 (int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_padding0), (int)sizeof(((struct ptlrpc_body_v2 *)0)->pb_padding0));
-       LASSERTF((int)offsetof(struct ptlrpc_body_v3, pb_padding1) == (int)offsetof(struct ptlrpc_body_v2, pb_padding1), "%d != %d\n",
-                (int)offsetof(struct ptlrpc_body_v3, pb_padding1), (int)offsetof(struct ptlrpc_body_v2, pb_padding1));
-       LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_padding1) == (int)sizeof(((struct ptlrpc_body_v2 *)0)->pb_padding1), "%d != %d\n",
-                (int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_padding1), (int)sizeof(((struct ptlrpc_body_v2 *)0)->pb_padding1));
+       LASSERTF((int)offsetof(struct ptlrpc_body_v3, pb_projid) == (int)offsetof(struct ptlrpc_body_v2, pb_projid), "%d != %d\n",
+                (int)offsetof(struct ptlrpc_body_v3, pb_projid), (int)offsetof(struct ptlrpc_body_v2, pb_projid));
+       LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_projid) == (int)sizeof(((struct ptlrpc_body_v2 *)0)->pb_projid), "%d != %d\n",
+                (int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_projid), (int)sizeof(((struct ptlrpc_body_v2 *)0)->pb_projid));
        LASSERTF((int)offsetof(struct ptlrpc_body_v3, pb_last_committed) == (int)offsetof(struct ptlrpc_body_v2, pb_last_committed), "%d != %d\n",
                 (int)offsetof(struct ptlrpc_body_v3, pb_last_committed), (int)offsetof(struct ptlrpc_body_v2, pb_last_committed));
        LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_last_committed) == (int)sizeof(((struct ptlrpc_body_v2 *)0)->pb_last_committed), "%d != %d\n",
index ccb65e2..c690d5c 100755 (executable)
@@ -5107,7 +5107,7 @@ static int str2quotaid(__u32 *id, const char *arg)
        if (*endptr != '\0')
                return -EINVAL;
        /* UINT32_MAX is not allowed - see projid_valid()/INVALID_PROJID */
-       if (projid_tmp >= UINT32_MAX)
+       if (projid_tmp >= MDT_INVALID_PROJID)
                return -ERANGE;
 
        *id = projid_tmp;
index d86e070..14a594e 100644 (file)
@@ -476,7 +476,7 @@ check_ptlrpc_body(void)
        CHECK_MEMBER(ptlrpc_body, pb_last_xid);
        CHECK_MEMBER(ptlrpc_body, pb_tag);
        CHECK_MEMBER(ptlrpc_body, pb_padding0);
-       CHECK_MEMBER(ptlrpc_body, pb_padding1);
+       CHECK_MEMBER(ptlrpc_body, pb_projid);
        CHECK_MEMBER(ptlrpc_body, pb_last_committed);
        CHECK_MEMBER(ptlrpc_body, pb_transno);
        CHECK_MEMBER(ptlrpc_body, pb_flags);
@@ -504,7 +504,7 @@ check_ptlrpc_body(void)
        CHECK_MEMBER_SAME(ptlrpc_body_v3, ptlrpc_body_v2, pb_last_xid);
        CHECK_MEMBER_SAME(ptlrpc_body_v3, ptlrpc_body_v2, pb_tag);
        CHECK_MEMBER_SAME(ptlrpc_body_v3, ptlrpc_body_v2, pb_padding0);
-       CHECK_MEMBER_SAME(ptlrpc_body_v3, ptlrpc_body_v2, pb_padding1);
+       CHECK_MEMBER_SAME(ptlrpc_body_v3, ptlrpc_body_v2, pb_projid);
        CHECK_MEMBER_SAME(ptlrpc_body_v3, ptlrpc_body_v2, pb_last_committed);
        CHECK_MEMBER_SAME(ptlrpc_body_v3, ptlrpc_body_v2, pb_transno);
        CHECK_MEMBER_SAME(ptlrpc_body_v3, ptlrpc_body_v2, pb_flags);
index 80c2a1d..4e7fa9c 100644 (file)
@@ -934,10 +934,10 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)offsetof(struct ptlrpc_body_v3, pb_padding0));
        LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_padding0) == 2, "found %lld\n",
                 (long long)(int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_padding0));
-       LASSERTF((int)offsetof(struct ptlrpc_body_v3, pb_padding1) == 36, "found %lld\n",
-                (long long)(int)offsetof(struct ptlrpc_body_v3, pb_padding1));
-       LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_padding1) == 4, "found %lld\n",
-                (long long)(int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_padding1));
+       LASSERTF((int)offsetof(struct ptlrpc_body_v3, pb_projid) == 36, "found %lld\n",
+                (long long)(int)offsetof(struct ptlrpc_body_v3, pb_projid));
+       LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_projid) == 4, "found %lld\n",
+                (long long)(int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_projid));
        LASSERTF((int)offsetof(struct ptlrpc_body_v3, pb_last_committed) == 40, "found %lld\n",
                 (long long)(int)offsetof(struct ptlrpc_body_v3, pb_last_committed));
        LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_last_committed) == 8, "found %lld\n",
@@ -1036,10 +1036,10 @@ void lustre_assert_wire_constants(void)
                 (int)offsetof(struct ptlrpc_body_v3, pb_padding0), (int)offsetof(struct ptlrpc_body_v2, pb_padding0));
        LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_padding0) == (int)sizeof(((struct ptlrpc_body_v2 *)0)->pb_padding0), "%d != %d\n",
                 (int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_padding0), (int)sizeof(((struct ptlrpc_body_v2 *)0)->pb_padding0));
-       LASSERTF((int)offsetof(struct ptlrpc_body_v3, pb_padding1) == (int)offsetof(struct ptlrpc_body_v2, pb_padding1), "%d != %d\n",
-                (int)offsetof(struct ptlrpc_body_v3, pb_padding1), (int)offsetof(struct ptlrpc_body_v2, pb_padding1));
-       LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_padding1) == (int)sizeof(((struct ptlrpc_body_v2 *)0)->pb_padding1), "%d != %d\n",
-                (int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_padding1), (int)sizeof(((struct ptlrpc_body_v2 *)0)->pb_padding1));
+       LASSERTF((int)offsetof(struct ptlrpc_body_v3, pb_projid) == (int)offsetof(struct ptlrpc_body_v2, pb_projid), "%d != %d\n",
+                (int)offsetof(struct ptlrpc_body_v3, pb_projid), (int)offsetof(struct ptlrpc_body_v2, pb_projid));
+       LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_projid) == (int)sizeof(((struct ptlrpc_body_v2 *)0)->pb_projid), "%d != %d\n",
+                (int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_projid), (int)sizeof(((struct ptlrpc_body_v2 *)0)->pb_projid));
        LASSERTF((int)offsetof(struct ptlrpc_body_v3, pb_last_committed) == (int)offsetof(struct ptlrpc_body_v2, pb_last_committed), "%d != %d\n",
                 (int)offsetof(struct ptlrpc_body_v3, pb_last_committed), (int)offsetof(struct ptlrpc_body_v2, pb_last_committed));
        LASSERTF((int)sizeof(((struct ptlrpc_body_v3 *)0)->pb_last_committed) == (int)sizeof(((struct ptlrpc_body_v2 *)0)->pb_last_committed), "%d != %d\n",