X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fmdt%2Fmdt_xattr.c;h=561a3952207220b95ded64a50ba741f2f63a43b2;hb=a4921671d04d8a8658bbb1aff8ba022b99e6e1ba;hp=271d49774a4050484fcddfd0c869d7f5503d8b16;hpb=9cac270ab1ac1504c230abf6ebbbe5aa119de2a1;p=fs%2Flustre-release.git diff --git a/lustre/mdt/mdt_xattr.c b/lustre/mdt/mdt_xattr.c index 271d497..561a395 100644 --- a/lustre/mdt/mdt_xattr.c +++ b/lustre/mdt/mdt_xattr.c @@ -1,32 +1,46 @@ /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * - * linux/mdt/mdt_xattr.c - * Lustre Metadata Target (mdt) extended attributes management. + * GPL HEADER START * - * Copyright (C) 2002-2006 Cluster File Systems, Inc. - * Author: Peter Braam - * Author: Andreas Dilger - * Author: Phil Schwan - * Author: Huang Hua + * 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/mdt/mdt_xattr.c + * + * Lustre Metadata Target (mdt) extended attributes management. + * + * Author: Peter Braam + * Author: Andreas Dilger + * Author: Phil Schwan + * Author: Huang Hua */ #ifndef EXPORT_SYMTAB @@ -114,6 +128,8 @@ int mdt_getxattr(struct mdt_thread_info *info) struct mdt_body *repbody = NULL; struct md_object *next; struct lu_buf *buf; + __u32 remote = exp_connect_rmtclient(info->mti_exp); + __u32 perm; int easize, rc; ENTRY; @@ -133,11 +149,11 @@ int mdt_getxattr(struct mdt_thread_info *info) next = mdt_object_child(info->mti_object); if (info->mti_body->valid & OBD_MD_FLRMTRGETFACL) { - __u32 perm = mdt_identity_get_perm(uc->mu_identity, - med->med_rmtclient, - req->rq_peer.nid); + if (unlikely(!remote)) + GOTO(out, rc = err_serious(-EINVAL)); - LASSERT(med->med_rmtclient); + perm = mdt_identity_get_perm(uc->mu_identity, remote, + req->rq_peer.nid); if (!(perm & CFS_RMTACL_PERM)) GOTO(out, rc = err_serious(-EPERM)); @@ -183,7 +199,9 @@ int mdt_getxattr(struct mdt_thread_info *info) if (rc > 0 && flags != CFS_IC_NOTHING) { int rc1; - LASSERT(med->med_rmtclient); + if (unlikely(!remote)) + GOTO(out, rc = -EINVAL); + rc1 = lustre_posix_acl_xattr_id2client(uc, med->med_idmap, (posix_acl_xattr_header *)(buf->lb_buf), @@ -261,10 +279,7 @@ int mdt_reint_setxattr(struct mdt_thread_info *info, struct mdt_lock_handle *unused) { struct ptlrpc_request *req = mdt_info_req(info); - struct mdt_export_data *med = mdt_req2med(req); struct md_ucred *uc = mdt_ucred(info); - const char user_string[] = "user."; - const char trust_string[] = "trusted."; struct mdt_lock_handle *lh; struct req_capsule *pill = info->mti_pill; const struct lu_env *env = info->mti_env; @@ -280,6 +295,8 @@ int mdt_reint_setxattr(struct mdt_thread_info *info, __u64 lockpart; int rc; posix_acl_xattr_header *new_xattr = NULL; + __u32 remote = exp_connect_rmtclient(info->mti_exp); + __u32 perm; ENTRY; CDEBUG(D_INODE, "setxattr for "DFID"\n", PFID(rr->rr_fid1)); @@ -297,11 +314,11 @@ int mdt_reint_setxattr(struct mdt_thread_info *info, RETURN(rc); if (valid & OBD_MD_FLRMTRSETFACL) { - __u32 perm = mdt_identity_get_perm(uc->mu_identity, - med->med_rmtclient, - req->rq_peer.nid); + if (unlikely(!remote)) + GOTO(out, rc = err_serious(-EINVAL)); - LASSERT(med->med_rmtclient); + perm = mdt_identity_get_perm(uc->mu_identity, remote, + req->rq_peer.nid); if (!(perm & CFS_RMTACL_PERM)) GOTO(out, rc = err_serious(-EPERM)); } @@ -311,13 +328,19 @@ int mdt_reint_setxattr(struct mdt_thread_info *info, if (!xattr_name) GOTO(out, rc = err_serious(-EFAULT)); - if (strncmp(xattr_name, trust_string, sizeof(trust_string) - 1) == 0) { - if (strcmp(xattr_name + 8, XATTR_NAME_LOV) == 0) + if (strncmp(xattr_name, XATTR_USER_PREFIX, + sizeof(XATTR_USER_PREFIX) - 1) == 0) { + if (strcmp(xattr_name, XATTR_NAME_LOV) == 0) GOTO(out, rc = -EACCES); + if (strcmp(xattr_name, XATTR_NAME_LMA) == 0) + GOTO(out, rc = 0); + if (strcmp(xattr_name, XATTR_NAME_LINK) == 0) + GOTO(out, rc = 0); } if (!(req->rq_export->exp_connect_flags & OBD_CONNECT_XATTR) && - (strncmp(xattr_name, user_string, sizeof(user_string) - 1) == 0)) { + (strncmp(xattr_name, XATTR_USER_PREFIX, + sizeof(XATTR_USER_PREFIX) - 1) == 0)) { GOTO(out, rc = -EOPNOTSUPP); } @@ -354,7 +377,9 @@ int mdt_reint_setxattr(struct mdt_thread_info *info, xattr = req_capsule_client_get(pill, &RMF_EADATA); if (valid & OBD_MD_FLRMTLSETFACL) { - LASSERT(med->med_rmtclient); + if (unlikely(!remote)) + GOTO(out_unlock, rc = -EINVAL); + xattr_len = mdt_rmtlsetfacl(info, child, xattr_name, (ext_acl_xattr_header *)xattr,