X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fofd%2Fofd_trans.c;h=41e097157dc49a1837503e873a91725e4caf1069;hb=HEAD;hp=67cc912b13ee37d25cdeb1d6b73e706ab358d975;hpb=466b89e41c3917a8a836065f72bfa62e57c818bd;p=fs%2Flustre-release.git diff --git a/lustre/ofd/ofd_trans.c b/lustre/ofd/ofd_trans.c index 67cc912..20b14a3 100644 --- a/lustre/ofd/ofd_trans.c +++ b/lustre/ofd/ofd_trans.c @@ -1,48 +1,40 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * 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. - * - * 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). - * - * 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 - * - * 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 - */ +// SPDX-License-Identifier: GPL-2.0 + /* * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2012, 2013, Intel Corporation. + * Copyright (c) 2012, 2014, Intel Corporation. */ + /* * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. * - * lustre/ofd/ofd_recovery.c + * This file provides functions for OBD Filter Device (OFD) transaction + * management. * - * Author: Alex Zhuravlev - * Author: Mikhail Pershin + * Author: Alex Zhuravlev + * Author: Mikhail Pershin */ #define DEBUG_SUBSYSTEM S_FILTER +#include +#include #include "ofd_internal.h" +/** + * Create new transaction in OFD. + * + * This function creates a transaction with dt_trans_create() + * and makes it synchronous if required by the export state. + * + * \param[in] env execution environment + * \param[in] ofd OFD device + * + * \retval struct thandle if transaction was created successfully + * \retval ERR_PTR on negative value in case of error + */ struct thandle *ofd_trans_create(const struct lu_env *env, struct ofd_device *ofd) { @@ -51,16 +43,49 @@ struct thandle *ofd_trans_create(const struct lu_env *env, LASSERT(info); + if (unlikely(ofd->ofd_readonly)) { + CERROR("%s: Deny transaction for read-only OFD device\n", + ofd_name(ofd)); + return ERR_PTR(-EROFS); + } + th = dt_trans_create(env, ofd->ofd_osd); if (IS_ERR(th)) return th; - /* export can require sync operations */ - if (info->fti_exp != NULL) + if (info->fti_exp != NULL) { + struct lu_nodemap *nodemap; + + /* export can require sync operations */ th->th_sync |= info->fti_exp->exp_need_sync; + + nodemap = nodemap_get_from_exp(info->fti_exp); + if (!IS_ERR_OR_NULL(nodemap)) { + th->th_ignore_root_proj_quota = !!(nodemap->nmf_rbac & + NODEMAP_RBAC_IGN_ROOT_PRJQUOTA); + nodemap_putref(nodemap); + } else { + th->th_ignore_root_proj_quota = 1; + } + } + return th; } +/** + * Start transaction in OFD. + * + * This function updates the given \a obj object version and calls + * dt_trans_start(). + * + * \param[in] env execution environment + * \param[in] ofd OFD device + * \param[in] obj OFD object affected by this transaction + * \param[in] th transaction handle + * + * \retval 0 if successful + * \retval negative value in case of error + */ int ofd_trans_start(const struct lu_env *env, struct ofd_device *ofd, struct ofd_object *obj, struct thandle *th) { @@ -71,9 +96,23 @@ int ofd_trans_start(const struct lu_env *env, struct ofd_device *ofd, return dt_trans_start(env, ofd->ofd_osd, th); } -void ofd_trans_stop(const struct lu_env *env, struct ofd_device *ofd, +/** + * Stop transaction in OFD. + * + * This function fills thandle::th_result with result of whole operation + * and calls dt_trans_stop(). + * + * \param[in] env execution environment + * \param[in] ofd OFD device + * \param[in] th transaction handle + * \param[in] rc result code of whole operation + * + * \retval 0 if successful + * \retval negative value if case of error + */ +int ofd_trans_stop(const struct lu_env *env, struct ofd_device *ofd, struct thandle *th, int rc) { th->th_result = rc; - dt_trans_stop(env, ofd->ofd_osd, th); + return dt_trans_stop(env, ofd->ofd_osd, th); }