Whamcloud - gitweb
b=23721 remove rdac & mptlinux build; canon ofed
[fs/lustre-release.git] / lustre / mdc / mdc_lib.c
index 4d86793..1e4bc75 100644 (file)
@@ -26,7 +26,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  */
 /*
@@ -55,10 +55,10 @@ static void __mdc_pack_body(struct mdt_body *b, __u32 suppgid)
         LASSERT (b != NULL);
 
         b->suppgid = suppgid;
-        b->uid = current->uid;
-        b->gid = current->gid;
-        b->fsuid = current->fsuid;
-        b->fsgid = current->fsgid;
+        b->uid = cfs_curproc_uid();
+        b->gid = cfs_curproc_gid();
+        b->fsuid = cfs_curproc_fsuid();
+        b->fsgid = cfs_curproc_fsgid();
         b->capability = cfs_curproc_cap_pack();
 }
 
@@ -204,8 +204,8 @@ void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
 
         /* XXX do something about time, uid, gid */
         rec->cr_opcode   = REINT_OPEN;
-        rec->cr_fsuid    = current->fsuid;
-        rec->cr_fsgid    = current->fsgid;
+        rec->cr_fsuid   = cfs_curproc_fsuid();
+        rec->cr_fsgid   = cfs_curproc_fsgid();
         rec->cr_cap      = cfs_curproc_cap_pack();
         if (op_data != NULL) {
                 rec->cr_fid1 = op_data->op_fid1;
@@ -284,8 +284,8 @@ static void mdc_setattr_pack_rec(struct mdt_rec_setattr *rec,
                                  struct md_op_data *op_data)
 {
         rec->sa_opcode  = REINT_SETATTR;
-        rec->sa_fsuid   = current->fsuid;
-        rec->sa_fsgid   = current->fsgid;
+        rec->sa_fsuid   = cfs_curproc_fsuid();
+        rec->sa_fsgid   = cfs_curproc_fsgid();
         rec->sa_cap     = cfs_curproc_cap_pack();
         rec->sa_suppgid = -1;
 
@@ -320,6 +320,7 @@ void mdc_setattr_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
 {
         struct mdt_rec_setattr *rec;
         struct mdt_ioepoch *epoch;
+        struct lov_user_md *lum = NULL;
         
         CLASSERT(sizeof(struct mdt_rec_reint) ==sizeof(struct mdt_rec_setattr));
         rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT);
@@ -335,7 +336,15 @@ void mdc_setattr_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
         if (ealen == 0)
                 return;
 
-        memcpy(req_capsule_client_get(&req->rq_pill, &RMF_EADATA), ea, ealen);
+        lum = req_capsule_client_get(&req->rq_pill, &RMF_EADATA);
+        if (ea == NULL) { /* Remove LOV EA */
+                lum->lmm_magic = LOV_USER_MAGIC_V1;
+                lum->lmm_stripe_size = 0;
+                lum->lmm_stripe_count = 0;
+                lum->lmm_stripe_offset = (typeof(lum->lmm_stripe_offset))(-1);
+        } else {
+                memcpy(lum, ea, ealen);
+        }
 
         if (ea2len == 0)
                 return;
@@ -439,15 +448,15 @@ void mdc_getattr_pack(struct ptlrpc_request *req, __u64 valid, int flags,
         struct mdt_body *b = req_capsule_client_get(&req->rq_pill,
                                                     &RMF_MDT_BODY);
 
-        b->fsuid = current->fsuid;
-        b->fsgid = current->fsgid;
+        b->fsuid = cfs_curproc_fsuid();
+        b->fsgid = cfs_curproc_fsgid();
         b->capability = cfs_curproc_cap_pack();
         b->valid = valid;
         if (op_data->op_bias & MDS_CHECK_SPLIT)
                 b->valid |= OBD_MD_FLCKSPLIT;
         if (op_data->op_bias & MDS_CROSS_REF)
                 b->valid |= OBD_MD_FLCROSSREF;
-        b->flags = flags | MDS_BFLAG_EXT_FLAGS;
+        b->flags = flags;
         b->suppgid = op_data->op_suppgids[0];
 
         b->fid1 = op_data->op_fid1;