X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fmdd%2Fmdd_dir.c;h=8692b230622526c5e9dfd99f7b73f6f1b1983cf3;hb=14c1444535f2474268741795fabcec8541741f31;hp=72bbbe7f7699081dd4a7722b96a013685b5f4bb7;hpb=b460ca87c0d01e4de18681fdd936b1a30cbfca21;p=fs%2Flustre-release.git diff --git a/lustre/mdd/mdd_dir.c b/lustre/mdd/mdd_dir.c index 72bbbe7..8692b23 100644 --- a/lustre/mdd/mdd_dir.c +++ b/lustre/mdd/mdd_dir.c @@ -1,30 +1,45 @@ -/* -*- MODE: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * - * mdd/mdd_handler.c - * Lustre Metadata Server (mdd) routines + * GPL HEADER START * - * Copyright (C) 2006 Cluster File Systems, Inc. - * Author: Wang Di + * 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/mdd/mdd_dir.c + * + * Lustre Metadata Server (mdd) routines + * + * Author: Wang Di + */ + #ifndef EXPORT_SYMTAB # define EXPORT_SYMTAB #endif @@ -344,7 +359,7 @@ static inline int mdd_is_sticky(const struct lu_env *env, if (tmp_la->la_uid == uc->mu_fsuid) return 0; - return !mdd_capable(uc, CAP_FOWNER); + return !mdd_capable(uc, CFS_CAP_FOWNER); } /* @@ -1251,24 +1266,27 @@ static int mdd_create(const struct lu_env *env, struct md_op_spec *spec, struct md_attr* ma) { - char *name = lname->ln_name; - struct lu_attr *la = &mdd_env_info(env)->mti_la_for_fix; - struct mdd_object *mdd_pobj = md2mdd_obj(pobj); - struct mdd_object *son = md2mdd_obj(child); - struct mdd_device *mdd = mdo2mdd(pobj); - struct lu_attr *attr = &ma->ma_attr; - struct lov_mds_md *lmm = NULL; - struct thandle *handle; + struct mdd_thread_info *info = mdd_env_info(env); + struct lu_attr *la = &info->mti_la_for_fix; + struct md_attr *ma_acl = &info->mti_ma; + struct mdd_object *mdd_pobj = md2mdd_obj(pobj); + struct mdd_object *son = md2mdd_obj(child); + struct mdd_device *mdd = mdo2mdd(pobj); + struct lu_attr *attr = &ma->ma_attr; + struct lov_mds_md *lmm = NULL; + struct thandle *handle; + struct dynlock_handle *dlh; + char *name = lname->ln_name; int rc, created = 0, initialized = 0, inserted = 0, lmm_size = 0; - struct dynlock_handle *dlh; + int got_def_acl = 0; ENTRY; /* * Two operations have to be performed: * - * - allocation of new object (->do_create()), and + * - an allocation of a new object (->do_create()), and * - * - insertion into parent index (->dio_insert()). + * - an insertion into a parent index (->dio_insert()). * * Due to locking, operation order is not important, when both are * successful, *but* error handling cases are quite different: @@ -1315,6 +1333,21 @@ static int mdd_create(const struct lu_env *env, RETURN(rc); } + if (!S_ISLNK(attr->la_mode)) { + ma_acl->ma_acl_size = sizeof info->mti_xattr_buf; + ma_acl->ma_acl = info->mti_xattr_buf; + ma_acl->ma_need = MA_ACL_DEF; + ma_acl->ma_valid = 0; + + mdd_read_lock(env, mdd_pobj); + rc = mdd_def_acl_get(env, mdd_pobj, ma_acl); + mdd_read_unlock(env, mdd_pobj); + if (rc) + GOTO(out_free, rc); + else if (ma_acl->ma_valid & MA_ACL_DEF) + got_def_acl = 1; + } + mdd_txn_param_build(env, mdd, MDD_TXN_MKDIR_OP); handle = mdd_trans_start(env, mdd); if (IS_ERR(handle)) @@ -1324,10 +1357,6 @@ static int mdd_create(const struct lu_env *env, if (dlh == NULL) GOTO(out_trans, rc = -ENOMEM); - /* - * XXX: Check that link can be added to the parent in mkdir case. - */ - mdd_write_lock(env, son); rc = mdd_object_create_internal(env, mdd_pobj, son, ma, handle); if (rc) { @@ -1338,14 +1367,18 @@ static int mdd_create(const struct lu_env *env, created = 1; #ifdef CONFIG_FS_POSIX_ACL - mdd_read_lock(env, mdd_pobj); - rc = mdd_acl_init(env, mdd_pobj, son, &ma->ma_attr.la_mode, handle); - mdd_read_unlock(env, mdd_pobj); - if (rc) { - mdd_write_unlock(env, son); - GOTO(cleanup, rc); - } else { - ma->ma_attr.la_valid |= LA_MODE; + if (got_def_acl) { + struct lu_buf *acl_buf = &info->mti_buf; + acl_buf->lb_buf = ma_acl->ma_acl; + acl_buf->lb_len = ma_acl->ma_acl_size; + + rc = __mdd_acl_init(env, son, acl_buf, &attr->la_mode, handle); + if (rc) { + mdd_write_unlock(env, son); + GOTO(cleanup, rc); + } else { + ma->ma_attr.la_valid |= LA_MODE; + } } #endif