Whamcloud - gitweb
Changed quotes for newer bash
[fs/lustre-release.git] / lustre / mds / mds_lib.c
index a8c5868..bc0fb6f 100644 (file)
@@ -255,17 +255,18 @@ int mds_pack_gskey(struct obd_device *obd, struct lustre_msg *repmsg,
         *sizep = cpu_to_le32(sizeof(*ckey));
 
         OBD_ALLOC(md_key, sizeof(*md_key));
+        if (!md_key)
+                RETURN(-ENOMEM);
       
         buflen = repmsg->buflens[*offset];
         buf = lustre_msg_buf(repmsg, (*offset)++, buflen);
 
         size = fsfilt_get_md(obd, inode, md_key, sizeof(*md_key), 
-                           EA_KEY);
+                             EA_KEY);
         if (size <= 0) {
                 if (size < 0) 
                         CERROR("Can not get gskey from MDS ino %lu rc %d\n",
                                 inode->i_ino, size);
-                (*offset) += 2; /* XXX: ignore crypto in case size == 0 */
                 GOTO(out, rc = size); 
         }
         if (le32_to_cpu(md_key->md_magic) != MD_KEY_MAGIC) {
@@ -309,9 +310,8 @@ int mds_set_gskey(struct obd_device *obd, void *handle,
         LASSERT(ckey->ck_type == MKS_TYPE || ckey->ck_type == GKS_TYPE);   
         
         OBD_ALLOC(md_key, sizeof(*md_key)); 
-        if (ckey->ck_type == MKS_TYPE) { 
+        if (ckey->ck_type == MKS_TYPE)
                 mds_get_gskey(inode, ckey);
-        } 
 
         rc = fsfilt_get_md(obd, inode, md_key, sizeof(*md_key), 
                            EA_KEY);
@@ -606,6 +606,7 @@ static int mds_open_unpack(struct ptlrpc_request *req, int offset,
         r->ur_rdev = rec->cr_rdev;
         r->ur_time = rec->cr_time;
         r->ur_flags = rec->cr_flags;
+        r->ur_ioepoch = rec->cr_ioepoch;
 
         LASSERT_REQSWAB(req, offset + 1);
         r->ur_name = lustre_msg_string(req->rq_reqmsg, offset + 1, 0);
@@ -1053,6 +1054,34 @@ void mds_body_do_reverse_map(struct mds_export_data *med,
         EXIT;
 }
 
+/*
+ * return error if can't find mapping, it's a error so should not
+ * fall into nllu/nllg.
+ */
+int mds_remote_perm_do_reverse_map(struct mds_export_data *med,
+                                   struct mds_remote_perm *perm)
+{
+        uid_t uid;
+        gid_t gid;
+
+        LASSERT(med->med_remote);
+
+        uid = mds_idmap_lookup_uid(med->med_idmap, 1, perm->mrp_auth_uid);
+        if (uid == MDS_IDMAP_NOTFOUND) {
+                CERROR("no map for uid %u\n", perm->mrp_auth_uid);
+                return -EPERM;
+        }
+        gid = mds_idmap_lookup_gid(med->med_idmap, 1, perm->mrp_auth_gid);
+        if (gid == MDS_IDMAP_NOTFOUND) {
+                CERROR("no map for uid %u\n", perm->mrp_auth_uid);
+                return -EPERM;
+        }
+
+        perm->mrp_auth_uid = uid;
+        perm->mrp_auth_gid = gid;
+        return 0;
+}
+
 /**********************
  * MDS ucred handling *
  **********************/