4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2011, 2012, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/mdt/mdt_lib.c
38 * Lustre Metadata Target (mdt) request unpacking helper.
40 * Author: Peter Braam <braam@clusterfs.com>
41 * Author: Andreas Dilger <adilger@clusterfs.com>
42 * Author: Phil Schwan <phil@clusterfs.com>
43 * Author: Mike Shaver <shaver@clusterfs.com>
44 * Author: Nikita Danilov <nikita@clusterfs.com>
45 * Author: Huang Hua <huanghua@clusterfs.com>
46 * Author: Fan Yong <fanyong@clusterfs.com>
49 #define DEBUG_SUBSYSTEM S_MDS
51 #include "mdt_internal.h"
52 #include <lnet/lib-lnet.h>
55 typedef enum ucred_init_type {
61 void mdt_exit_ucred(struct mdt_thread_info *info)
63 struct lu_ucred *uc = mdt_ucred(info);
64 struct mdt_device *mdt = info->mti_mdt;
67 if (uc->uc_valid != UCRED_INIT) {
68 uc->uc_suppgids[0] = uc->uc_suppgids[1] = -1;
70 cfs_put_group_info(uc->uc_ginfo);
73 if (uc->uc_identity) {
74 mdt_identity_put(mdt->mdt_identity_cache,
76 uc->uc_identity = NULL;
78 uc->uc_valid = UCRED_INIT;
82 static int match_nosquash_list(struct rw_semaphore *sem,
89 rc = cfs_match_nid(peernid, nidlist);
94 /* root_squash for inter-MDS operations */
95 static int mdt_root_squash(struct mdt_thread_info *info, lnet_nid_t peernid)
97 struct lu_ucred *ucred = mdt_ucred(info);
100 LASSERT(ucred != NULL);
101 if (!info->mti_mdt->mdt_squash_uid || ucred->uc_fsuid)
104 if (match_nosquash_list(&info->mti_mdt->mdt_squash_sem,
105 &info->mti_mdt->mdt_nosquash_nids,
107 CDEBUG(D_OTHER, "%s is in nosquash_nids list\n",
108 libcfs_nid2str(peernid));
112 CDEBUG(D_OTHER, "squash req from %s, (%d:%d/%x)=>(%d:%d/%x)\n",
113 libcfs_nid2str(peernid),
114 ucred->uc_fsuid, ucred->uc_fsgid, ucred->uc_cap,
115 info->mti_mdt->mdt_squash_uid, info->mti_mdt->mdt_squash_gid,
118 ucred->uc_fsuid = info->mti_mdt->mdt_squash_uid;
119 ucred->uc_fsgid = info->mti_mdt->mdt_squash_gid;
121 ucred->uc_suppgids[0] = -1;
122 ucred->uc_suppgids[1] = -1;
127 static int new_init_ucred(struct mdt_thread_info *info, ucred_init_type_t type,
130 struct ptlrpc_request *req = mdt_info_req(info);
131 struct mdt_device *mdt = info->mti_mdt;
132 struct ptlrpc_user_desc *pud = req->rq_user_desc;
133 struct lu_ucred *ucred = mdt_ucred(info);
134 lnet_nid_t peernid = req->rq_peer.nid;
136 __u32 remote = exp_connect_rmtclient(info->mti_exp);
143 LASSERT(req->rq_auth_gss);
144 LASSERT(!req->rq_auth_usr_mdt);
145 LASSERT(req->rq_user_desc);
146 LASSERT(ucred != NULL);
148 ucred->uc_valid = UCRED_INVALID;
150 ucred->uc_o_uid = pud->pud_uid;
151 ucred->uc_o_gid = pud->pud_gid;
152 ucred->uc_o_fsuid = pud->pud_fsuid;
153 ucred->uc_o_fsgid = pud->pud_fsgid;
155 if (type == BODY_INIT) {
156 struct mdt_body *body = (struct mdt_body *)buf;
158 ucred->uc_suppgids[0] = body->suppgid;
159 ucred->uc_suppgids[1] = -1;
162 /* sanity check: we expect the uid which client claimed is true */
164 if (req->rq_auth_mapped_uid == INVALID_UID) {
165 CDEBUG(D_SEC, "remote user not mapped, deny access!\n");
169 if (ptlrpc_user_desc_do_idmap(req, pud))
172 if (req->rq_auth_mapped_uid != pud->pud_uid) {
173 CDEBUG(D_SEC, "remote client %s: auth/mapped uid %u/%u "
174 "while client claims %u:%u/%u:%u\n",
175 libcfs_nid2str(peernid), req->rq_auth_uid,
176 req->rq_auth_mapped_uid,
177 pud->pud_uid, pud->pud_gid,
178 pud->pud_fsuid, pud->pud_fsgid);
182 if (req->rq_auth_uid != pud->pud_uid) {
183 CDEBUG(D_SEC, "local client %s: auth uid %u "
184 "while client claims %u:%u/%u:%u\n",
185 libcfs_nid2str(peernid), req->rq_auth_uid,
186 pud->pud_uid, pud->pud_gid,
187 pud->pud_fsuid, pud->pud_fsgid);
192 if (is_identity_get_disabled(mdt->mdt_identity_cache)) {
194 CDEBUG(D_SEC, "remote client must run with identity_get "
198 ucred->uc_identity = NULL;
199 perm = CFS_SETUID_PERM | CFS_SETGID_PERM |
203 struct md_identity *identity;
205 identity = mdt_identity_get(mdt->mdt_identity_cache,
207 if (IS_ERR(identity)) {
208 if (unlikely(PTR_ERR(identity) == -EREMCHG &&
210 ucred->uc_identity = NULL;
211 perm = CFS_SETUID_PERM | CFS_SETGID_PERM |
214 CDEBUG(D_SEC, "Deny access without identity: uid %u\n",
219 ucred->uc_identity = identity;
220 perm = mdt_identity_get_perm(ucred->uc_identity,
225 /* find out the setuid/setgid attempt */
226 setuid = (pud->pud_uid != pud->pud_fsuid);
227 setgid = ((pud->pud_gid != pud->pud_fsgid) ||
228 (ucred->uc_identity &&
229 (pud->pud_gid != ucred->uc_identity->mi_gid)));
231 /* check permission of setuid */
232 if (setuid && !(perm & CFS_SETUID_PERM)) {
233 CDEBUG(D_SEC, "mdt blocked setuid attempt (%u -> %u) from %s\n",
234 pud->pud_uid, pud->pud_fsuid, libcfs_nid2str(peernid));
235 GOTO(out, rc = -EACCES);
238 /* check permission of setgid */
239 if (setgid && !(perm & CFS_SETGID_PERM)) {
240 CDEBUG(D_SEC, "mdt blocked setgid attempt (%u:%u/%u:%u -> %u) "
241 "from %s\n", pud->pud_uid, pud->pud_gid,
242 pud->pud_fsuid, pud->pud_fsgid,
243 ucred->uc_identity->mi_gid, libcfs_nid2str(peernid));
244 GOTO(out, rc = -EACCES);
248 * NB: remote client not allowed to setgroups anyway.
250 if (!remote && perm & CFS_SETGRP_PERM) {
251 if (pud->pud_ngroups) {
252 /* setgroups for local client */
253 ucred->uc_ginfo = cfs_groups_alloc(pud->pud_ngroups);
254 if (!ucred->uc_ginfo) {
255 CERROR("failed to alloc %d groups\n",
257 GOTO(out, rc = -ENOMEM);
260 lustre_groups_from_list(ucred->uc_ginfo,
262 lustre_groups_sort(ucred->uc_ginfo);
264 ucred->uc_ginfo = NULL;
267 ucred->uc_suppgids[0] = -1;
268 ucred->uc_suppgids[1] = -1;
269 ucred->uc_ginfo = NULL;
272 ucred->uc_uid = pud->pud_uid;
273 ucred->uc_gid = pud->pud_gid;
274 ucred->uc_fsuid = pud->pud_fsuid;
275 ucred->uc_fsgid = pud->pud_fsgid;
277 /* process root_squash here. */
278 mdt_root_squash(info, peernid);
280 /* remove fs privilege for non-root user. */
282 ucred->uc_cap = pud->pud_cap & ~CFS_CAP_FS_MASK;
284 ucred->uc_cap = pud->pud_cap;
285 if (remote && !(perm & CFS_RMTOWN_PERM))
286 ucred->uc_cap &= ~(CFS_CAP_SYS_RESOURCE_MASK |
288 ucred->uc_valid = UCRED_NEW;
294 if (ucred->uc_ginfo) {
295 cfs_put_group_info(ucred->uc_ginfo);
296 ucred->uc_ginfo = NULL;
298 if (ucred->uc_identity) {
299 mdt_identity_put(mdt->mdt_identity_cache,
301 ucred->uc_identity = NULL;
308 int mdt_check_ucred(struct mdt_thread_info *info)
310 struct ptlrpc_request *req = mdt_info_req(info);
311 struct mdt_device *mdt = info->mti_mdt;
312 struct ptlrpc_user_desc *pud = req->rq_user_desc;
313 struct lu_ucred *ucred = mdt_ucred(info);
314 struct md_identity *identity = NULL;
315 lnet_nid_t peernid = req->rq_peer.nid;
317 __u32 remote = exp_connect_rmtclient(info->mti_exp);
324 LASSERT(ucred != NULL);
325 if ((ucred->uc_valid == UCRED_OLD) || (ucred->uc_valid == UCRED_NEW))
328 if (!req->rq_auth_gss || req->rq_auth_usr_mdt || !req->rq_user_desc)
331 /* sanity check: if we use strong authentication, we expect the
332 * uid which client claimed is true */
334 if (req->rq_auth_mapped_uid == INVALID_UID) {
335 CDEBUG(D_SEC, "remote user not mapped, deny access!\n");
339 if (ptlrpc_user_desc_do_idmap(req, pud))
342 if (req->rq_auth_mapped_uid != pud->pud_uid) {
343 CDEBUG(D_SEC, "remote client %s: auth/mapped uid %u/%u "
344 "while client claims %u:%u/%u:%u\n",
345 libcfs_nid2str(peernid), req->rq_auth_uid,
346 req->rq_auth_mapped_uid,
347 pud->pud_uid, pud->pud_gid,
348 pud->pud_fsuid, pud->pud_fsgid);
352 if (req->rq_auth_uid != pud->pud_uid) {
353 CDEBUG(D_SEC, "local client %s: auth uid %u "
354 "while client claims %u:%u/%u:%u\n",
355 libcfs_nid2str(peernid), req->rq_auth_uid,
356 pud->pud_uid, pud->pud_gid,
357 pud->pud_fsuid, pud->pud_fsgid);
362 if (is_identity_get_disabled(mdt->mdt_identity_cache)) {
364 CDEBUG(D_SEC, "remote client must run with identity_get "
371 identity = mdt_identity_get(mdt->mdt_identity_cache, pud->pud_uid);
372 if (IS_ERR(identity)) {
373 if (unlikely(PTR_ERR(identity) == -EREMCHG &&
377 CDEBUG(D_SEC, "Deny access without identity: uid %u\n",
383 perm = mdt_identity_get_perm(identity, remote, peernid);
384 /* find out the setuid/setgid attempt */
385 setuid = (pud->pud_uid != pud->pud_fsuid);
386 setgid = (pud->pud_gid != pud->pud_fsgid ||
387 pud->pud_gid != identity->mi_gid);
389 /* check permission of setuid */
390 if (setuid && !(perm & CFS_SETUID_PERM)) {
391 CDEBUG(D_SEC, "mdt blocked setuid attempt (%u -> %u) from %s\n",
392 pud->pud_uid, pud->pud_fsuid, libcfs_nid2str(peernid));
393 GOTO(out, rc = -EACCES);
396 /* check permission of setgid */
397 if (setgid && !(perm & CFS_SETGID_PERM)) {
398 CDEBUG(D_SEC, "mdt blocked setgid attempt (%u:%u/%u:%u -> %u) "
399 "from %s\n", pud->pud_uid, pud->pud_gid,
400 pud->pud_fsuid, pud->pud_fsgid, identity->mi_gid,
401 libcfs_nid2str(peernid));
402 GOTO(out, rc = -EACCES);
408 mdt_identity_put(mdt->mdt_identity_cache, identity);
412 static int old_init_ucred(struct mdt_thread_info *info,
413 struct mdt_body *body)
415 struct lu_ucred *uc = mdt_ucred(info);
416 struct mdt_device *mdt = info->mti_mdt;
417 struct md_identity *identity = NULL;
422 uc->uc_valid = UCRED_INVALID;
423 uc->uc_o_uid = uc->uc_uid = body->uid;
424 uc->uc_o_gid = uc->uc_gid = body->gid;
425 uc->uc_o_fsuid = uc->uc_fsuid = body->fsuid;
426 uc->uc_o_fsgid = uc->uc_fsgid = body->fsgid;
427 uc->uc_suppgids[0] = body->suppgid;
428 uc->uc_suppgids[1] = -1;
430 if (!is_identity_get_disabled(mdt->mdt_identity_cache)) {
431 identity = mdt_identity_get(mdt->mdt_identity_cache,
433 if (IS_ERR(identity)) {
434 if (unlikely(PTR_ERR(identity) == -EREMCHG)) {
437 CDEBUG(D_SEC, "Deny access without identity: "
438 "uid %u\n", uc->uc_fsuid);
443 uc->uc_identity = identity;
445 /* process root_squash here. */
446 mdt_root_squash(info, mdt_info_req(info)->rq_peer.nid);
448 /* remove fs privilege for non-root user. */
450 uc->uc_cap = body->capability & ~CFS_CAP_FS_MASK;
452 uc->uc_cap = body->capability;
453 uc->uc_valid = UCRED_OLD;
458 static int old_init_ucred_reint(struct mdt_thread_info *info)
460 struct lu_ucred *uc = mdt_ucred(info);
461 struct mdt_device *mdt = info->mti_mdt;
462 struct md_identity *identity = NULL;
467 uc->uc_valid = UCRED_INVALID;
468 uc->uc_o_uid = uc->uc_o_fsuid = uc->uc_uid = uc->uc_fsuid;
469 uc->uc_o_gid = uc->uc_o_fsgid = uc->uc_gid = uc->uc_fsgid;
471 if (!is_identity_get_disabled(mdt->mdt_identity_cache)) {
472 identity = mdt_identity_get(mdt->mdt_identity_cache,
474 if (IS_ERR(identity)) {
475 if (unlikely(PTR_ERR(identity) == -EREMCHG)) {
478 CDEBUG(D_SEC, "Deny access without identity: "
479 "uid %u\n", uc->uc_fsuid);
484 uc->uc_identity = identity;
486 /* process root_squash here. */
487 mdt_root_squash(info, mdt_info_req(info)->rq_peer.nid);
489 /* remove fs privilege for non-root user. */
491 uc->uc_cap &= ~CFS_CAP_FS_MASK;
492 uc->uc_valid = UCRED_OLD;
497 int mdt_init_ucred(struct mdt_thread_info *info, struct mdt_body *body)
499 struct ptlrpc_request *req = mdt_info_req(info);
500 struct lu_ucred *uc = mdt_ucred(info);
503 if ((uc->uc_valid == UCRED_OLD) || (uc->uc_valid == UCRED_NEW))
506 mdt_exit_ucred(info);
508 if (!req->rq_auth_gss || req->rq_auth_usr_mdt || !req->rq_user_desc)
509 return old_init_ucred(info, body);
511 return new_init_ucred(info, BODY_INIT, body);
514 int mdt_init_ucred_reint(struct mdt_thread_info *info)
516 struct ptlrpc_request *req = mdt_info_req(info);
517 struct lu_ucred *uc = mdt_ucred(info);
520 if ((uc->uc_valid == UCRED_OLD) || (uc->uc_valid == UCRED_NEW))
523 mdt_exit_ucred(info);
525 if (!req->rq_auth_gss || req->rq_auth_usr_mdt || !req->rq_user_desc)
526 return old_init_ucred_reint(info);
528 return new_init_ucred(info, REC_INIT, NULL);
531 /* copied from lov/lov_ea.c, just for debugging, will be removed later */
532 void mdt_dump_lmm(int level, const struct lov_mds_md *lmm)
534 const struct lov_ost_data_v1 *lod;
538 count = le16_to_cpu(((struct lov_user_md*)lmm)->lmm_stripe_count);
540 CDEBUG(level, "objid "LPX64", magic 0x%08X, pattern %#X\n",
541 le64_to_cpu(lmm->lmm_object_id), le32_to_cpu(lmm->lmm_magic),
542 le32_to_cpu(lmm->lmm_pattern));
543 CDEBUG(level,"stripe_size=0x%x, stripe_count=0x%x\n",
544 le32_to_cpu(lmm->lmm_stripe_size), count);
545 if (count == LOV_ALL_STRIPES)
547 LASSERT(count <= LOV_MAX_STRIPE_COUNT);
548 for (i = 0, lod = lmm->lmm_objects; i < count; i++, lod++)
549 CDEBUG(level, "stripe %u idx %u subobj "LPX64"/"LPX64"\n",
550 i, le32_to_cpu(lod->l_ost_idx),
551 le64_to_cpu(lod->l_object_seq),
552 le64_to_cpu(lod->l_object_id));
555 /* Shrink and/or grow reply buffers */
556 int mdt_fix_reply(struct mdt_thread_info *info)
558 struct req_capsule *pill = info->mti_pill;
559 struct mdt_body *body;
560 int md_size, md_packed = 0;
565 body = req_capsule_server_get(pill, &RMF_MDT_BODY);
566 LASSERT(body != NULL);
568 if (body->valid & (OBD_MD_FLDIREA | OBD_MD_FLEASIZE | OBD_MD_LINKNAME))
569 md_size = body->eadatasize;
573 acl_size = body->aclsize;
575 /* this replay - not send info to client */
576 if (info->mti_spec.no_create == 1) {
581 CDEBUG(D_INFO, "Shrink to md_size = %d cookie/acl_size = %d"
582 " MDSCAPA = %llx, OSSCAPA = %llx\n",
584 (unsigned long long)(body->valid & OBD_MD_FLMDSCAPA),
585 (unsigned long long)(body->valid & OBD_MD_FLOSSCAPA));
589 &RMF_ACL, or &RMF_LOGCOOKIES
590 (optional) &RMF_CAPA1,
591 (optional) &RMF_CAPA2,
592 (optional) something else
595 /* MDT_MD buffer may be bigger than packed value, let's shrink all
596 * buffers before growing it */
597 if (info->mti_big_lmm_used) {
598 LASSERT(req_capsule_has_field(pill, &RMF_MDT_MD, RCL_SERVER));
599 md_packed = req_capsule_get_size(pill, &RMF_MDT_MD,
601 LASSERT(md_packed > 0);
602 /* buffer must be allocated separately */
603 LASSERT(info->mti_attr.ma_lmm !=
604 req_capsule_server_get(pill, &RMF_MDT_MD));
605 req_capsule_shrink(pill, &RMF_MDT_MD, 0, RCL_SERVER);
606 /* free big lmm if md_size is not needed */
608 info->mti_big_lmm_used = 0;
609 } else if (req_capsule_has_field(pill, &RMF_MDT_MD, RCL_SERVER)) {
610 req_capsule_shrink(pill, &RMF_MDT_MD, md_size, RCL_SERVER);
613 if (req_capsule_has_field(pill, &RMF_ACL, RCL_SERVER))
614 req_capsule_shrink(pill, &RMF_ACL, acl_size, RCL_SERVER);
615 else if (req_capsule_has_field(pill, &RMF_LOGCOOKIES, RCL_SERVER))
616 req_capsule_shrink(pill, &RMF_LOGCOOKIES,
617 acl_size, RCL_SERVER);
619 if (req_capsule_has_field(pill, &RMF_CAPA1, RCL_SERVER) &&
620 !(body->valid & OBD_MD_FLMDSCAPA))
621 req_capsule_shrink(pill, &RMF_CAPA1, 0, RCL_SERVER);
623 if (req_capsule_has_field(pill, &RMF_CAPA2, RCL_SERVER) &&
624 !(body->valid & OBD_MD_FLOSSCAPA))
625 req_capsule_shrink(pill, &RMF_CAPA2, 0, RCL_SERVER);
628 * Some more field should be shrinked if needed.
629 * This should be done by those who added fields to reply message.
632 /* Grow MD buffer if needed finally */
633 if (info->mti_big_lmm_used) {
636 LASSERT(md_size > md_packed);
637 CDEBUG(D_INFO, "Enlarge reply buffer, need extra %d bytes\n",
638 md_size - md_packed);
639 rc = req_capsule_server_grow(pill, &RMF_MDT_MD, md_size);
641 /* we can't answer with proper LOV EA, drop flags,
642 * the rc is also returned so this request is
643 * considered as failed */
644 body->valid &= ~(OBD_MD_FLDIREA | OBD_MD_FLEASIZE);
645 /* don't return transno along with error */
646 lustre_msg_set_transno(pill->rc_req->rq_repmsg, 0);
648 /* now we need to pack right LOV EA */
649 lmm = req_capsule_server_get(pill, &RMF_MDT_MD);
650 LASSERT(req_capsule_get_size(pill, &RMF_MDT_MD,
652 info->mti_attr.ma_lmm_size);
653 memcpy(lmm, info->mti_attr.ma_lmm,
654 info->mti_attr.ma_lmm_size);
656 /* update mdt_max_mdsize so clients will be aware about that */
657 if (info->mti_mdt->mdt_max_mdsize < info->mti_attr.ma_lmm_size)
658 info->mti_mdt->mdt_max_mdsize =
659 info->mti_attr.ma_lmm_size;
660 info->mti_big_lmm_used = 0;
666 /* if object is dying, pack the lov/llog data,
667 * parameter info->mti_attr should be valid at this point! */
668 int mdt_handle_last_unlink(struct mdt_thread_info *info, struct mdt_object *mo,
669 const struct md_attr *ma)
671 struct mdt_body *repbody;
672 const struct lu_attr *la = &ma->ma_attr;
676 repbody = req_capsule_server_get(info->mti_pill, &RMF_MDT_BODY);
677 LASSERT(repbody != NULL);
679 if (ma->ma_valid & MA_INODE)
680 mdt_pack_attr2body(info, repbody, la, mdt_object_fid(mo));
682 if (ma->ma_valid & MA_LOV) {
683 CERROR("No need in LOV EA upon unlink\n");
686 repbody->eadatasize = 0;
688 if (ma->ma_cookie_size && (ma->ma_valid & MA_COOKIE)) {
689 repbody->aclsize = ma->ma_cookie_size;
690 repbody->valid |= OBD_MD_FLCOOKIE;
693 if (info->mti_mdt->mdt_opts.mo_oss_capa &&
694 info->mti_exp->exp_connect_flags & OBD_CONNECT_OSS_CAPA &&
695 repbody->valid & OBD_MD_FLEASIZE) {
696 struct lustre_capa *capa;
698 capa = req_capsule_server_get(info->mti_pill, &RMF_CAPA2);
700 capa->lc_opc = CAPA_OPC_OSS_DESTROY;
701 rc = mo_capa_get(info->mti_env, mdt_object_child(mo), capa, 0);
705 repbody->valid |= OBD_MD_FLOSSCAPA;
711 static inline unsigned int attr_unpack(__u64 sa_valid) {
712 unsigned int ia_valid = 0;
714 if (sa_valid & MDS_ATTR_MODE)
715 ia_valid |= ATTR_MODE;
716 if (sa_valid & MDS_ATTR_UID)
717 ia_valid |= ATTR_UID;
718 if (sa_valid & MDS_ATTR_GID)
719 ia_valid |= ATTR_GID;
720 if (sa_valid & MDS_ATTR_SIZE)
721 ia_valid |= ATTR_SIZE;
722 if (sa_valid & MDS_ATTR_ATIME)
723 ia_valid |= ATTR_ATIME;
724 if (sa_valid & MDS_ATTR_MTIME)
725 ia_valid |= ATTR_MTIME;
726 if (sa_valid & MDS_ATTR_CTIME)
727 ia_valid |= ATTR_CTIME;
728 if (sa_valid & MDS_ATTR_ATIME_SET)
729 ia_valid |= ATTR_ATIME_SET;
730 if (sa_valid & MDS_ATTR_MTIME_SET)
731 ia_valid |= ATTR_MTIME_SET;
732 if (sa_valid & MDS_ATTR_FORCE)
733 ia_valid |= ATTR_FORCE;
734 if (sa_valid & MDS_ATTR_ATTR_FLAG)
735 ia_valid |= ATTR_ATTR_FLAG;
736 if (sa_valid & MDS_ATTR_KILL_SUID)
737 ia_valid |= ATTR_KILL_SUID;
738 if (sa_valid & MDS_ATTR_KILL_SGID)
739 ia_valid |= ATTR_KILL_SGID;
740 if (sa_valid & MDS_ATTR_CTIME_SET)
741 ia_valid |= ATTR_CTIME_SET;
742 if (sa_valid & MDS_ATTR_FROM_OPEN)
743 ia_valid |= ATTR_FROM_OPEN;
744 if (sa_valid & MDS_ATTR_BLOCKS)
745 ia_valid |= ATTR_BLOCKS;
746 if (sa_valid & MDS_OPEN_OWNEROVERRIDE)
747 ia_valid |= MDS_OPEN_OWNEROVERRIDE;
751 static __u64 mdt_attr_valid_xlate(__u64 in, struct mdt_reint_record *rr,
765 if (in & ATTR_BLOCKS)
768 if (in & ATTR_FROM_OPEN)
769 rr->rr_flags |= MRF_OPEN_TRUNC;
771 if (in & ATTR_ATIME_SET)
774 if (in & ATTR_CTIME_SET)
777 if (in & ATTR_MTIME_SET)
780 if (in & ATTR_ATTR_FLAG)
783 if (in & ATTR_KILL_SUID)
786 if (in & ATTR_KILL_SGID)
789 if (in & MDS_OPEN_OWNEROVERRIDE)
790 ma->ma_attr_flags |= MDS_OPEN_OWNEROVERRIDE;
793 ma->ma_attr_flags |= MDS_PERM_BYPASS;
795 /*XXX need ATTR_RAW?*/
796 in &= ~(ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE|ATTR_BLOCKS|
797 ATTR_ATIME|ATTR_MTIME|ATTR_CTIME|ATTR_FROM_OPEN|
798 ATTR_ATIME_SET|ATTR_CTIME_SET|ATTR_MTIME_SET|
799 ATTR_ATTR_FLAG|ATTR_RAW|MDS_OPEN_OWNEROVERRIDE|
800 ATTR_FORCE|ATTR_KILL_SUID|ATTR_KILL_SGID);
802 CERROR("Unknown attr bits: "LPX64"\n", in);
807 static int mdt_setattr_unpack_rec(struct mdt_thread_info *info)
809 struct lu_ucred *uc = mdt_ucred(info);
810 struct md_attr *ma = &info->mti_attr;
811 struct lu_attr *la = &ma->ma_attr;
812 struct req_capsule *pill = info->mti_pill;
813 struct mdt_reint_record *rr = &info->mti_rr;
814 struct mdt_rec_setattr *rec;
817 CLASSERT(sizeof(struct mdt_rec_setattr)== sizeof(struct mdt_rec_reint));
818 rec = req_capsule_client_get(pill, &RMF_REC_REINT);
822 /* This prior initialization is needed for old_init_ucred_reint() */
823 uc->uc_fsuid = rec->sa_fsuid;
824 uc->uc_fsgid = rec->sa_fsgid;
825 uc->uc_cap = rec->sa_cap;
826 uc->uc_suppgids[0] = rec->sa_suppgid;
827 uc->uc_suppgids[1] = -1;
829 rr->rr_fid1 = &rec->sa_fid;
830 la->la_valid = mdt_attr_valid_xlate(attr_unpack(rec->sa_valid), rr, ma);
831 la->la_mode = rec->sa_mode;
832 la->la_flags = rec->sa_attr_flags;
833 la->la_uid = rec->sa_uid;
834 la->la_gid = rec->sa_gid;
835 la->la_size = rec->sa_size;
836 la->la_blocks = rec->sa_blocks;
837 la->la_ctime = rec->sa_ctime;
838 la->la_atime = rec->sa_atime;
839 la->la_mtime = rec->sa_mtime;
840 ma->ma_valid = MA_INODE;
842 if (req_capsule_get_size(pill, &RMF_CAPA1, RCL_CLIENT))
843 mdt_set_capainfo(info, 0, rr->rr_fid1,
844 req_capsule_client_get(pill, &RMF_CAPA1));
849 static int mdt_ioepoch_unpack(struct mdt_thread_info *info)
851 struct req_capsule *pill = info->mti_pill;
854 if (req_capsule_get_size(pill, &RMF_MDT_EPOCH, RCL_CLIENT))
856 req_capsule_client_get(pill, &RMF_MDT_EPOCH);
858 info->mti_ioepoch = NULL;
859 RETURN(info->mti_ioepoch == NULL ? -EFAULT : 0);
862 static inline int mdt_dlmreq_unpack(struct mdt_thread_info *info) {
863 struct req_capsule *pill = info->mti_pill;
865 if (req_capsule_get_size(pill, &RMF_DLM_REQ, RCL_CLIENT)) {
866 info->mti_dlm_req = req_capsule_client_get(pill, &RMF_DLM_REQ);
867 if (info->mti_dlm_req == NULL)
874 static int mdt_setattr_unpack(struct mdt_thread_info *info)
876 struct mdt_reint_record *rr = &info->mti_rr;
877 struct md_attr *ma = &info->mti_attr;
878 struct req_capsule *pill = info->mti_pill;
882 rc = mdt_setattr_unpack_rec(info);
886 /* Epoch may be absent */
887 mdt_ioepoch_unpack(info);
889 if (req_capsule_field_present(pill, &RMF_EADATA, RCL_CLIENT)) {
890 rr->rr_eadata = req_capsule_client_get(pill, &RMF_EADATA);
891 rr->rr_eadatalen = req_capsule_get_size(pill, &RMF_EADATA,
893 ma->ma_lmm_size = rr->rr_eadatalen;
894 if (ma->ma_lmm_size > 0) {
895 ma->ma_lmm = (void *)rr->rr_eadata;
896 ma->ma_valid |= MA_LOV;
900 rc = mdt_dlmreq_unpack(info);
904 int mdt_close_unpack(struct mdt_thread_info *info)
909 rc = mdt_ioepoch_unpack(info);
913 rc = mdt_setattr_unpack_rec(info);
916 RETURN(mdt_init_ucred_reint(info));
919 static int mdt_create_unpack(struct mdt_thread_info *info)
921 struct lu_ucred *uc = mdt_ucred(info);
922 struct mdt_rec_create *rec;
923 struct lu_attr *attr = &info->mti_attr.ma_attr;
924 struct mdt_reint_record *rr = &info->mti_rr;
925 struct req_capsule *pill = info->mti_pill;
926 struct md_op_spec *sp = &info->mti_spec;
930 CLASSERT(sizeof(struct mdt_rec_create) == sizeof(struct mdt_rec_reint));
931 rec = req_capsule_client_get(pill, &RMF_REC_REINT);
935 /* This prior initialization is needed for old_init_ucred_reint() */
936 uc->uc_fsuid = rec->cr_fsuid;
937 uc->uc_fsgid = rec->cr_fsgid;
938 uc->uc_cap = rec->cr_cap;
939 uc->uc_suppgids[0] = rec->cr_suppgid1;
940 uc->uc_suppgids[1] = -1;
941 uc->uc_umask = rec->cr_umask;
943 rr->rr_fid1 = &rec->cr_fid1;
944 rr->rr_fid2 = &rec->cr_fid2;
945 attr->la_mode = rec->cr_mode;
946 attr->la_rdev = rec->cr_rdev;
947 attr->la_uid = rec->cr_fsuid;
948 attr->la_gid = rec->cr_fsgid;
949 attr->la_ctime = rec->cr_time;
950 attr->la_mtime = rec->cr_time;
951 attr->la_atime = rec->cr_time;
952 attr->la_valid = LA_MODE | LA_RDEV | LA_UID | LA_GID |
953 LA_CTIME | LA_MTIME | LA_ATIME;
954 memset(&sp->u, 0, sizeof(sp->u));
955 sp->sp_cr_flags = get_mrc_cr_flags(rec);
957 if (req_capsule_get_size(pill, &RMF_CAPA1, RCL_CLIENT))
958 mdt_set_capainfo(info, 0, rr->rr_fid1,
959 req_capsule_client_get(pill, &RMF_CAPA1));
960 mdt_set_capainfo(info, 1, rr->rr_fid2, BYPASS_CAPA);
962 rr->rr_name = req_capsule_client_get(pill, &RMF_NAME);
963 rr->rr_namelen = req_capsule_get_size(pill, &RMF_NAME,
965 LASSERT(rr->rr_name && rr->rr_namelen > 0);
967 if (S_ISLNK(attr->la_mode)) {
968 const char *tgt = NULL;
970 req_capsule_extend(pill, &RQF_MDS_REINT_CREATE_SYM);
971 if (req_capsule_get_size(pill, &RMF_SYMTGT, RCL_CLIENT)) {
972 tgt = req_capsule_client_get(pill, &RMF_SYMTGT);
973 sp->u.sp_symname = tgt;
978 req_capsule_extend(pill, &RQF_MDS_REINT_CREATE_RMT_ACL);
981 rc = mdt_dlmreq_unpack(info);
985 static int mdt_link_unpack(struct mdt_thread_info *info)
987 struct lu_ucred *uc = mdt_ucred(info);
988 struct mdt_rec_link *rec;
989 struct lu_attr *attr = &info->mti_attr.ma_attr;
990 struct mdt_reint_record *rr = &info->mti_rr;
991 struct req_capsule *pill = info->mti_pill;
995 CLASSERT(sizeof(struct mdt_rec_link) == sizeof(struct mdt_rec_reint));
996 rec = req_capsule_client_get(pill, &RMF_REC_REINT);
1000 /* This prior initialization is needed for old_init_ucred_reint() */
1001 uc->uc_fsuid = rec->lk_fsuid;
1002 uc->uc_fsgid = rec->lk_fsgid;
1003 uc->uc_cap = rec->lk_cap;
1004 uc->uc_suppgids[0] = rec->lk_suppgid1;
1005 uc->uc_suppgids[1] = rec->lk_suppgid2;
1007 attr->la_uid = rec->lk_fsuid;
1008 attr->la_gid = rec->lk_fsgid;
1009 rr->rr_fid1 = &rec->lk_fid1;
1010 rr->rr_fid2 = &rec->lk_fid2;
1011 attr->la_ctime = rec->lk_time;
1012 attr->la_mtime = rec->lk_time;
1013 attr->la_valid = LA_UID | LA_GID | LA_CTIME | LA_MTIME;
1015 if (req_capsule_get_size(pill, &RMF_CAPA1, RCL_CLIENT))
1016 mdt_set_capainfo(info, 0, rr->rr_fid1,
1017 req_capsule_client_get(pill, &RMF_CAPA1));
1018 if (req_capsule_get_size(pill, &RMF_CAPA2, RCL_CLIENT))
1019 mdt_set_capainfo(info, 1, rr->rr_fid2,
1020 req_capsule_client_get(pill, &RMF_CAPA2));
1022 rr->rr_name = req_capsule_client_get(pill, &RMF_NAME);
1023 if (rr->rr_name == NULL)
1025 rr->rr_namelen = req_capsule_get_size(pill, &RMF_NAME, RCL_CLIENT) - 1;
1027 LASSERT(rr->rr_namelen > 0);
1029 rc = mdt_dlmreq_unpack(info);
1033 static int mdt_unlink_unpack(struct mdt_thread_info *info)
1035 struct lu_ucred *uc = mdt_ucred(info);
1036 struct mdt_rec_unlink *rec;
1037 struct md_attr *ma = &info->mti_attr;
1038 struct lu_attr *attr = &info->mti_attr.ma_attr;
1039 struct mdt_reint_record *rr = &info->mti_rr;
1040 struct req_capsule *pill = info->mti_pill;
1044 CLASSERT(sizeof(struct mdt_rec_unlink) == sizeof(struct mdt_rec_reint));
1045 rec = req_capsule_client_get(pill, &RMF_REC_REINT);
1049 /* This prior initialization is needed for old_init_ucred_reint() */
1050 uc->uc_fsuid = rec->ul_fsuid;
1051 uc->uc_fsgid = rec->ul_fsgid;
1052 uc->uc_cap = rec->ul_cap;
1053 uc->uc_suppgids[0] = rec->ul_suppgid1;
1054 uc->uc_suppgids[1] = -1;
1056 attr->la_uid = rec->ul_fsuid;
1057 attr->la_gid = rec->ul_fsgid;
1058 rr->rr_fid1 = &rec->ul_fid1;
1059 rr->rr_fid2 = &rec->ul_fid2;
1060 attr->la_ctime = rec->ul_time;
1061 attr->la_mtime = rec->ul_time;
1062 attr->la_mode = rec->ul_mode;
1063 attr->la_valid = LA_UID | LA_GID | LA_CTIME | LA_MTIME | LA_MODE;
1065 if (req_capsule_get_size(pill, &RMF_CAPA1, RCL_CLIENT))
1066 mdt_set_capainfo(info, 0, rr->rr_fid1,
1067 req_capsule_client_get(pill, &RMF_CAPA1));
1069 rr->rr_name = req_capsule_client_get(pill, &RMF_NAME);
1070 rr->rr_namelen = req_capsule_get_size(pill, &RMF_NAME, RCL_CLIENT) - 1;
1071 if (rr->rr_name == NULL || rr->rr_namelen == 0)
1074 if (rec->ul_bias & MDS_VTX_BYPASS)
1075 ma->ma_attr_flags |= MDS_VTX_BYPASS;
1077 ma->ma_attr_flags &= ~MDS_VTX_BYPASS;
1079 info->mti_spec.no_create = !!req_is_replay(mdt_info_req(info));
1081 rc = mdt_dlmreq_unpack(info);
1085 static int mdt_rename_unpack(struct mdt_thread_info *info)
1087 struct lu_ucred *uc = mdt_ucred(info);
1088 struct mdt_rec_rename *rec;
1089 struct md_attr *ma = &info->mti_attr;
1090 struct lu_attr *attr = &info->mti_attr.ma_attr;
1091 struct mdt_reint_record *rr = &info->mti_rr;
1092 struct req_capsule *pill = info->mti_pill;
1096 CLASSERT(sizeof(struct mdt_rec_rename) == sizeof(struct mdt_rec_reint));
1097 rec = req_capsule_client_get(pill, &RMF_REC_REINT);
1101 /* This prior initialization is needed for old_init_ucred_reint() */
1102 uc->uc_fsuid = rec->rn_fsuid;
1103 uc->uc_fsgid = rec->rn_fsgid;
1104 uc->uc_cap = rec->rn_cap;
1105 uc->uc_suppgids[0] = rec->rn_suppgid1;
1106 uc->uc_suppgids[1] = rec->rn_suppgid2;
1108 attr->la_uid = rec->rn_fsuid;
1109 attr->la_gid = rec->rn_fsgid;
1110 rr->rr_fid1 = &rec->rn_fid1;
1111 rr->rr_fid2 = &rec->rn_fid2;
1112 attr->la_ctime = rec->rn_time;
1113 attr->la_mtime = rec->rn_time;
1114 /* rename_tgt contains the mode already */
1115 attr->la_mode = rec->rn_mode;
1116 attr->la_valid = LA_UID | LA_GID | LA_CTIME | LA_MTIME | LA_MODE;
1118 if (req_capsule_get_size(pill, &RMF_CAPA1, RCL_CLIENT))
1119 mdt_set_capainfo(info, 0, rr->rr_fid1,
1120 req_capsule_client_get(pill, &RMF_CAPA1));
1121 if (req_capsule_get_size(pill, &RMF_CAPA2, RCL_CLIENT))
1122 mdt_set_capainfo(info, 1, rr->rr_fid2,
1123 req_capsule_client_get(pill, &RMF_CAPA2));
1125 rr->rr_name = req_capsule_client_get(pill, &RMF_NAME);
1126 rr->rr_tgt = req_capsule_client_get(pill, &RMF_SYMTGT);
1127 if (rr->rr_name == NULL || rr->rr_tgt == NULL)
1129 rr->rr_namelen = req_capsule_get_size(pill, &RMF_NAME, RCL_CLIENT) - 1;
1130 rr->rr_tgtlen = req_capsule_get_size(pill, &RMF_SYMTGT, RCL_CLIENT) - 1;
1131 LASSERT(rr->rr_namelen > 0 && rr->rr_tgtlen > 0);
1133 if (rec->rn_bias & MDS_VTX_BYPASS)
1134 ma->ma_attr_flags |= MDS_VTX_BYPASS;
1136 ma->ma_attr_flags &= ~MDS_VTX_BYPASS;
1138 info->mti_spec.no_create = !!req_is_replay(mdt_info_req(info));
1140 rc = mdt_dlmreq_unpack(info);
1145 * please see comment above LOV_MAGIC_V1_DEF
1147 static void mdt_fix_lov_magic(struct mdt_thread_info *info)
1149 struct mdt_reint_record *rr = &info->mti_rr;
1150 struct lov_user_md_v1 *v1;
1152 v1 = (void *)rr->rr_eadata;
1155 if (unlikely(req_is_replay(mdt_info_req(info)))) {
1156 if (v1->lmm_magic == LOV_USER_MAGIC_V1) {
1157 v1->lmm_magic = LOV_MAGIC_V1_DEF;
1158 } else if (v1->lmm_magic == __swab32(LOV_USER_MAGIC_V1)) {
1159 v1->lmm_magic = __swab32(LOV_MAGIC_V1_DEF);
1160 } else if (v1->lmm_magic == LOV_USER_MAGIC_V3) {
1161 v1->lmm_magic = LOV_MAGIC_V3_DEF;
1162 } else if (v1->lmm_magic == __swab32(LOV_USER_MAGIC_V3)) {
1163 v1->lmm_magic = __swab32(LOV_MAGIC_V3_DEF);
1168 static int mdt_open_unpack(struct mdt_thread_info *info)
1170 struct lu_ucred *uc = mdt_ucred(info);
1171 struct mdt_rec_create *rec;
1172 struct lu_attr *attr = &info->mti_attr.ma_attr;
1173 struct req_capsule *pill = info->mti_pill;
1174 struct mdt_reint_record *rr = &info->mti_rr;
1175 struct ptlrpc_request *req = mdt_info_req(info);
1176 struct md_op_spec *sp = &info->mti_spec;
1179 CLASSERT(sizeof(struct mdt_rec_create) == sizeof(struct mdt_rec_reint));
1180 rec = req_capsule_client_get(pill, &RMF_REC_REINT);
1184 /* This prior initialization is needed for old_init_ucred_reint() */
1185 uc->uc_fsuid = rec->cr_fsuid;
1186 uc->uc_fsgid = rec->cr_fsgid;
1187 uc->uc_cap = rec->cr_cap;
1188 uc->uc_suppgids[0] = rec->cr_suppgid1;
1189 uc->uc_suppgids[1] = rec->cr_suppgid2;
1190 uc->uc_umask = rec->cr_umask;
1192 rr->rr_fid1 = &rec->cr_fid1;
1193 rr->rr_fid2 = &rec->cr_fid2;
1194 rr->rr_handle = &rec->cr_old_handle;
1195 attr->la_mode = rec->cr_mode;
1196 attr->la_rdev = rec->cr_rdev;
1197 attr->la_uid = rec->cr_fsuid;
1198 attr->la_gid = rec->cr_fsgid;
1199 attr->la_ctime = rec->cr_time;
1200 attr->la_mtime = rec->cr_time;
1201 attr->la_atime = rec->cr_time;
1202 attr->la_valid = LA_MODE | LA_RDEV | LA_UID | LA_GID |
1203 LA_CTIME | LA_MTIME | LA_ATIME;
1204 memset(&info->mti_spec.u, 0, sizeof(info->mti_spec.u));
1205 info->mti_spec.sp_cr_flags = get_mrc_cr_flags(rec);
1206 /* Do not trigger ASSERTION if client miss to set such flags. */
1207 if (unlikely(info->mti_spec.sp_cr_flags == 0))
1209 info->mti_replayepoch = rec->cr_ioepoch;
1211 info->mti_cross_ref = !!(rec->cr_bias & MDS_CROSS_REF);
1213 if (req_capsule_get_size(pill, &RMF_CAPA1, RCL_CLIENT))
1214 mdt_set_capainfo(info, 0, rr->rr_fid1,
1215 req_capsule_client_get(pill, &RMF_CAPA1));
1216 if (req_is_replay(req) &&
1217 req_capsule_get_size(pill, &RMF_CAPA2, RCL_CLIENT)) {
1219 mdt_set_capainfo(info, 1, rr->rr_fid2,
1220 req_capsule_client_get(pill, &RMF_CAPA2));
1223 * FIXME: capa in replay open request might have expired,
1224 * bypass capa check. Security hole?
1226 mdt_set_capainfo(info, 0, rr->rr_fid1, BYPASS_CAPA);
1227 mdt_set_capainfo(info, 1, rr->rr_fid2, BYPASS_CAPA);
1231 rr->rr_name = req_capsule_client_get(pill, &RMF_NAME);
1232 if (rr->rr_name == NULL)
1234 rr->rr_namelen = req_capsule_get_size(pill, &RMF_NAME, RCL_CLIENT) - 1;
1236 if (req_capsule_field_present(pill, &RMF_EADATA, RCL_CLIENT)) {
1237 rr->rr_eadatalen = req_capsule_get_size(pill, &RMF_EADATA,
1239 if (rr->rr_eadatalen > 0) {
1240 rr->rr_eadata = req_capsule_client_get(pill,
1242 sp->u.sp_ea.eadatalen = rr->rr_eadatalen;
1243 sp->u.sp_ea.eadata = rr->rr_eadata;
1244 sp->no_create = !!req_is_replay(req);
1245 mdt_fix_lov_magic(info);
1249 * Client default md_size may be 0 right after client start,
1250 * until all osc are connected, set here just some reasonable
1251 * value to prevent misbehavior.
1253 if (rr->rr_eadatalen == 0 &&
1254 !(info->mti_spec.sp_cr_flags & MDS_OPEN_DELAY_CREATE))
1255 rr->rr_eadatalen = MIN_MD_SIZE;
1261 static int mdt_setxattr_unpack(struct mdt_thread_info *info)
1263 struct mdt_reint_record *rr = &info->mti_rr;
1264 struct lu_ucred *uc = mdt_ucred(info);
1265 struct lu_attr *attr = &info->mti_attr.ma_attr;
1266 struct req_capsule *pill = info->mti_pill;
1267 struct mdt_rec_setxattr *rec;
1271 CLASSERT(sizeof(struct mdt_rec_setxattr) ==
1272 sizeof(struct mdt_rec_reint));
1274 rec = req_capsule_client_get(pill, &RMF_REC_REINT);
1278 /* This prior initialization is needed for old_init_ucred_reint() */
1279 uc->uc_fsuid = rec->sx_fsuid;
1280 uc->uc_fsgid = rec->sx_fsgid;
1281 uc->uc_cap = rec->sx_cap;
1282 uc->uc_suppgids[0] = rec->sx_suppgid1;
1283 uc->uc_suppgids[1] = -1;
1285 rr->rr_opcode = rec->sx_opcode;
1286 rr->rr_fid1 = &rec->sx_fid;
1287 attr->la_valid = rec->sx_valid;
1288 attr->la_ctime = rec->sx_time;
1289 attr->la_size = rec->sx_size;
1290 attr->la_flags = rec->sx_flags;
1292 if (req_capsule_get_size(pill, &RMF_CAPA1, RCL_CLIENT))
1293 mdt_set_capainfo(info, 0, rr->rr_fid1,
1294 req_capsule_client_get(pill, &RMF_CAPA1));
1296 mdt_set_capainfo(info, 0, rr->rr_fid1, BYPASS_CAPA);
1298 rr->rr_name = req_capsule_client_get(pill, &RMF_NAME);
1299 if (rr->rr_name == NULL)
1301 rr->rr_namelen = req_capsule_get_size(pill, &RMF_NAME, RCL_CLIENT) - 1;
1302 LASSERT(rr->rr_namelen > 0);
1304 if (req_capsule_field_present(pill, &RMF_EADATA, RCL_CLIENT)) {
1305 rr->rr_eadatalen = req_capsule_get_size(pill, &RMF_EADATA,
1307 if (rr->rr_eadatalen > 0) {
1308 rr->rr_eadata = req_capsule_client_get(pill,
1310 if (rr->rr_eadata == NULL)
1313 rr->rr_eadata = NULL;
1315 } else if (!(attr->la_valid & OBD_MD_FLXATTRRM)) {
1316 CDEBUG(D_INFO, "no xattr data supplied\n");
1324 typedef int (*reint_unpacker)(struct mdt_thread_info *info);
1326 static reint_unpacker mdt_reint_unpackers[REINT_MAX] = {
1327 [REINT_SETATTR] = mdt_setattr_unpack,
1328 [REINT_CREATE] = mdt_create_unpack,
1329 [REINT_LINK] = mdt_link_unpack,
1330 [REINT_UNLINK] = mdt_unlink_unpack,
1331 [REINT_RENAME] = mdt_rename_unpack,
1332 [REINT_OPEN] = mdt_open_unpack,
1333 [REINT_SETXATTR] = mdt_setxattr_unpack
1336 int mdt_reint_unpack(struct mdt_thread_info *info, __u32 op)
1341 memset(&info->mti_rr, 0, sizeof(info->mti_rr));
1342 if (op < REINT_MAX && mdt_reint_unpackers[op] != NULL) {
1343 info->mti_rr.rr_opcode = op;
1344 rc = mdt_reint_unpackers[op](info);
1346 CERROR("Unexpected opcode %d\n", op);