X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fcmm%2Fmdc_object.c;h=2e884ba084f955cc8bf9c82caa5d80853e9ca8dc;hb=d1efec944c43c93120bed1df05680e59983c41a4;hp=1ac12c90fb39ae44a2db987ddda9fa1d7026191f;hpb=d2d56f38da01001c92a09afc6b52b5acbd9bc13c;p=fs%2Flustre-release.git diff --git a/lustre/cmm/mdc_object.c b/lustre/cmm/mdc_object.c index 1ac12c9..2e884ba 100644 --- a/lustre/cmm/mdc_object.c +++ b/lustre/cmm/mdc_object.c @@ -1,29 +1,43 @@ /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * - * lustre/cmm/mdc_object.c - * Lustre Cluster Metadata Manager (cmm) + * GPL HEADER START * - * Copyright (c) 2006 Cluster File Systems, Inc. - * Author: Mike Pershin + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * This file is part of the Lustre file system, http://www.lustre.org - * Lustre is a trademark of Cluster File Systems, Inc. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. * - * You may have signed or agreed to another license before downloading - * this software. If so, you are bound by the terms and conditions - * of that agreement, and the following does not apply to you. See the - * LICENSE file included with this distribution for more information. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). * - * If you did not agree to a different license, then this copy of Lustre - * is open source software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * In either case, Lustre is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * license text for more details. + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + * + * GPL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Use is subject to license terms. + */ +/* + * This file is part of Lustre, http://www.lustre.org/ + * Lustre is a trademark of Sun Microsystems, Inc. + * + * lustre/cmm/mdc_object.c + * + * Lustre Cluster Metadata Manager (cmm) + * + * Author: Mike Pershin */ #ifndef EXPORT_SYMTAB @@ -38,9 +52,9 @@ #include "cmm_internal.h" #include "mdc_internal.h" -static struct md_object_operations mdc_mo_ops; -static struct md_dir_operations mdc_dir_ops; -static struct lu_object_operations mdc_obj_ops; +static const struct md_object_operations mdc_mo_ops; +static const struct md_dir_operations mdc_dir_ops; +static const struct lu_object_operations mdc_obj_ops; extern struct lu_context_key mdc_thread_key; @@ -72,23 +86,17 @@ static void mdc_object_free(const struct lu_env *env, struct lu_object *lo) OBD_FREE_PTR(mco); } -static int mdc_object_init(const struct lu_env *env, struct lu_object *lo) +static int mdc_object_init(const struct lu_env *env, struct lu_object *lo, + const struct lu_object_conf *_) { ENTRY; lo->lo_header->loh_attr |= LOHA_REMOTE; RETURN(0); } -static int mdc_object_print(const struct lu_env *env, void *cookie, - lu_printer_t p, const struct lu_object *lo) -{ - return (*p)(env, cookie, LUSTRE_CMM_MDC_NAME"-object@%p", lo); -} - -static struct lu_object_operations mdc_obj_ops = { +static const struct lu_object_operations mdc_obj_ops = { .loo_object_init = mdc_object_init, .loo_object_free = mdc_object_free, - .loo_object_print = mdc_object_print, }; /* md_object_operations */ @@ -147,14 +155,15 @@ static int mdc_req2attr_update(const struct lu_env *env, struct mdc_thread_info *mci; struct ptlrpc_request *req; struct mdt_body *body; - struct lov_mds_md *lov; + struct lov_mds_md *md; struct llog_cookie *cookie; + void *acl; ENTRY; mci = mdc_info_get(env); req = mci->mci_req; LASSERT(req); - body = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof(*body)); + body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); LASSERT(body); mdc_body2attr(body, ma); @@ -162,53 +171,74 @@ static int mdc_req2attr_update(const struct lu_env *env, struct lustre_capa *capa; /* create for cross-ref will fetch mds capa from remote obj */ - capa = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF + 1, - sizeof(*capa)); + capa = req_capsule_server_get(&req->rq_pill, &RMF_CAPA1); LASSERT(capa != NULL); LASSERT(ma->ma_capa != NULL); *ma->ma_capa = *capa; } - - if (!(body->valid & OBD_MD_FLEASIZE)) - RETURN(0); - if (body->eadatasize == 0) { - CERROR("OBD_MD_FLEASIZE is set but eadatasize is zero\n"); - RETURN(-EPROTO); - } + if ((body->valid & OBD_MD_FLEASIZE) || (body->valid & OBD_MD_FLDIREA)) { + if (body->eadatasize == 0) { + CERROR("No size defined for easize field\n"); + RETURN(-EPROTO); + } + + md = req_capsule_server_sized_get(&req->rq_pill, &RMF_MDT_MD, + body->eadatasize); + if (md == NULL) + RETURN(-EPROTO); - lov = lustre_swab_repbuf(req, REPLY_REC_OFF + 1, - body->eadatasize, NULL); - if (lov == NULL) { - CERROR("Can't unpack MDS EA data\n"); - RETURN(-EPROTO); + LASSERT(ma->ma_lmm != NULL); + LASSERT(ma->ma_lmm_size >= body->eadatasize); + ma->ma_lmm_size = body->eadatasize; + memcpy(ma->ma_lmm, md, ma->ma_lmm_size); + ma->ma_valid |= MA_LOV; } - LASSERT(ma->ma_lmm != NULL); - LASSERT(ma->ma_lmm_size >= body->eadatasize); - ma->ma_lmm_size = body->eadatasize; - memcpy(ma->ma_lmm, lov, ma->ma_lmm_size); - ma->ma_valid |= MA_LOV; + if (body->valid & OBD_MD_FLCOOKIE) { + /* + * ACL and cookie share the same body->aclsize, we need + * to make sure that they both never come here. + */ + LASSERT(!(body->valid & OBD_MD_FLACL)); + + if (body->aclsize == 0) { + CERROR("No size defined for cookie field\n"); + RETURN(-EPROTO); + } - if (!(body->valid & OBD_MD_FLCOOKIE)) - RETURN(0); + cookie = req_capsule_server_sized_get(&req->rq_pill, + &RMF_LOGCOOKIES, + body->aclsize); + if (cookie == NULL) + RETURN(-EPROTO); - if (body->aclsize == 0) { - CERROR("OBD_MD_FLCOOKIE is set but cookie size is zero\n"); - RETURN(-EPROTO); + LASSERT(ma->ma_cookie != NULL); + LASSERT(ma->ma_cookie_size == body->aclsize); + memcpy(ma->ma_cookie, cookie, ma->ma_cookie_size); + ma->ma_valid |= MA_COOKIE; } - cookie = lustre_msg_buf(req->rq_repmsg, - REPLY_REC_OFF + 2, body->aclsize); - if (cookie == NULL) { - CERROR("Can't unpack unlink cookie data\n"); - RETURN(-EPROTO); +#ifdef CONFIG_FS_POSIX_ACL + if (body->valid & OBD_MD_FLACL) { + if (body->aclsize == 0) { + CERROR("No size defined for acl field\n"); + RETURN(-EPROTO); + } + + acl = req_capsule_server_sized_get(&req->rq_pill, + &RMF_ACL, + body->aclsize); + if (acl == NULL) + RETURN(-EPROTO); + + LASSERT(ma->ma_acl != NULL); + LASSERT(ma->ma_acl_size == body->aclsize); + memcpy(ma->ma_acl, acl, ma->ma_acl_size); + ma->ma_valid |= MA_ACL_DEF; } +#endif - LASSERT(ma->ma_cookie != NULL); - LASSERT(ma->ma_cookie_size == body->aclsize); - memcpy(ma->ma_cookie, cookie, ma->ma_cookie_size); - ma->ma_valid |= MA_COOKIE; RETURN(0); } @@ -284,13 +314,13 @@ static int mdc_attr_set(const struct lu_env *env, struct md_object *mo, } else { mci->mci_opdata.op_fsuid = la->la_uid; mci->mci_opdata.op_fsgid = la->la_gid; - mci->mci_opdata.op_cap = current->cap_effective; + mci->mci_opdata.op_cap = cfs_curproc_cap_pack(); mci->mci_opdata.op_suppgids[0] = mci->mci_opdata.op_suppgids[1] = -1; } rc = md_setattr(mc->mc_desc.cl_exp, &mci->mci_opdata, - NULL, 0, NULL, 0, &mci->mci_req); + NULL, 0, NULL, 0, &mci->mci_req, NULL); ptlrpc_req_finished(mci->mci_req); @@ -310,7 +340,7 @@ static int mdc_object_create(const struct lu_env *env, int rc, symlen; uid_t uid; gid_t gid; - __u32 cap; + cfs_cap_t cap; ENTRY; LASSERT(S_ISDIR(la->la_mode)); @@ -319,7 +349,7 @@ static int mdc_object_create(const struct lu_env *env, mci = mdc_info_init(env); mci->mci_opdata.op_bias = MDS_CROSS_REF; mci->mci_opdata.op_fid2 = *lu_object_fid(&mo->mo_lu); - + /* Parent fid is needed to create dotdot on the remote node. */ mci->mci_opdata.op_fid1 = *(spec->u.sp_pfid); mci->mci_opdata.op_mod_time = la->la_ctime; @@ -406,7 +436,7 @@ static int mdc_ref_add(const struct lu_env *env, struct md_object *mo, } else { mci->mci_opdata.op_fsuid = la->la_uid; mci->mci_opdata.op_fsgid = la->la_gid; - mci->mci_opdata.op_cap = current->cap_effective; + mci->mci_opdata.op_cap = cfs_curproc_cap_pack(); mci->mci_opdata.op_suppgids[0] = mci->mci_opdata.op_suppgids[1] = -1; } @@ -450,7 +480,7 @@ static int mdc_ref_del(const struct lu_env *env, struct md_object *mo, } else { mci->mci_opdata.op_fsuid = la->la_uid; mci->mci_opdata.op_fsgid = la->la_gid; - mci->mci_opdata.op_cap = current->cap_effective; + mci->mci_opdata.op_cap = cfs_curproc_cap_pack(); mci->mci_opdata.op_suppgids[0] = -1; } @@ -481,7 +511,7 @@ int mdc_send_page(struct cmm_device *cm, const struct lu_env *env, } #endif -static struct md_object_operations mdc_mo_ops = { +static const struct md_object_operations mdc_mo_ops = { .moo_attr_get = mdc_attr_get, .moo_attr_set = mdc_attr_set, .moo_object_create = mdc_object_create, @@ -526,7 +556,7 @@ static int mdc_rename_tgt(const struct lu_env *env, struct md_object *mo_p, } else { mci->mci_opdata.op_fsuid = la->la_uid; mci->mci_opdata.op_fsgid = la->la_gid; - mci->mci_opdata.op_cap = current->cap_effective; + mci->mci_opdata.op_cap = cfs_curproc_cap_pack(); mci->mci_opdata.op_suppgids[0] = mci->mci_opdata.op_suppgids[1] = -1; } @@ -542,7 +572,7 @@ static int mdc_rename_tgt(const struct lu_env *env, struct md_object *mo_p, RETURN(rc); } -/* +/* * Return resulting fid in sfid * 0: fids are not relatives * fid: fid at which search stopped @@ -561,10 +591,10 @@ static int mdc_is_subdir(const struct lu_env *env, struct md_object *mo, rc = md_is_subdir(mc->mc_desc.cl_exp, lu_object_fid(&mo->mo_lu), fid, &mci->mci_req); if (rc == 0 || rc == -EREMOTE) { - body = lustre_msg_buf(mci->mci_req->rq_repmsg, REPLY_REC_OFF, - sizeof(*body)); + body = req_capsule_server_get(&mci->mci_req->rq_pill, + &RMF_MDT_BODY); LASSERT(body->valid & OBD_MD_FLID); - + CDEBUG(D_INFO, "Remote mdo_is_subdir(), new src "DFID"\n", PFID(&body->fid1)); *sfid = body->fid1; @@ -573,7 +603,7 @@ static int mdc_is_subdir(const struct lu_env *env, struct md_object *mo, RETURN(rc); } -static struct md_dir_operations mdc_dir_ops = { +static const struct md_dir_operations mdc_dir_ops = { .mdo_is_subdir = mdc_is_subdir, .mdo_rename_tgt = mdc_rename_tgt };