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.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2012, 2014, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
32 * lustre/ofd/ofd_trans.c
34 * This file provides functions for OBD Filter Device (OFD) transaction
37 * Author: Alex Zhuravlev <alexey.zhuravlev@intel.com>
38 * Author: Mikhail Pershin <mike.pershin@intel.com>
41 #define DEBUG_SUBSYSTEM S_FILTER
43 #include "ofd_internal.h"
46 * Create new transaction in OFD.
48 * This function creates a transaction with dt_trans_create()
49 * and makes it synchronous if required by the export state.
51 * \param[in] env execution environment
52 * \param[in] ofd OFD device
54 * \retval struct thandle if transaction was created successfully
55 * \retval ERR_PTR on negative value in case of error
57 struct thandle *ofd_trans_create(const struct lu_env *env,
58 struct ofd_device *ofd)
60 struct ofd_thread_info *info = ofd_info(env);
65 th = dt_trans_create(env, ofd->ofd_osd);
69 /* export can require sync operations */
70 if (info->fti_exp != NULL)
71 th->th_sync |= info->fti_exp->exp_need_sync;
76 * Start transaction in OFD.
78 * This function updates the given \a obj object version and calls
81 * \param[in] env execution environment
82 * \param[in] ofd OFD device
83 * \param[in] obj OFD object affected by this transaction
84 * \param[in] th transaction handle
86 * \retval 0 if successful
87 * \retval negative value in case of error
89 int ofd_trans_start(const struct lu_env *env, struct ofd_device *ofd,
90 struct ofd_object *obj, struct thandle *th)
92 /* version change is required for this object */
94 tgt_vbr_obj_set(env, ofd_object_child(obj));
96 return dt_trans_start(env, ofd->ofd_osd, th);
100 * Stop transaction in OFD.
102 * This function fills thandle::th_result with result of whole operation
103 * and calls dt_trans_stop().
105 * \param[in] env execution environment
106 * \param[in] ofd OFD device
107 * \param[in] th transaction handle
108 * \param[in] rc result code of whole operation
110 * \retval 0 if successful
111 * \retval negative value if case of error
113 int ofd_trans_stop(const struct lu_env *env, struct ofd_device *ofd,
114 struct thandle *th, int rc)
117 return dt_trans_stop(env, ofd->ofd_osd, th);