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/
31 * lustre/ofd/ofd_trans.c
33 * This file provides functions for OBD Filter Device (OFD) transaction
36 * Author: Alex Zhuravlev <alexey.zhuravlev@intel.com>
37 * Author: Mikhail Pershin <mike.pershin@intel.com>
40 #define DEBUG_SUBSYSTEM S_FILTER
42 #include "ofd_internal.h"
45 * Create new transaction in OFD.
47 * This function creates a transaction with dt_trans_create()
48 * and makes it synchronous if required by the export state.
50 * \param[in] env execution environment
51 * \param[in] ofd OFD device
53 * \retval struct thandle if transaction was created successfully
54 * \retval ERR_PTR on negative value in case of error
56 struct thandle *ofd_trans_create(const struct lu_env *env,
57 struct ofd_device *ofd)
59 struct ofd_thread_info *info = ofd_info(env);
64 th = dt_trans_create(env, ofd->ofd_osd);
68 /* export can require sync operations */
69 if (info->fti_exp != NULL)
70 th->th_sync |= info->fti_exp->exp_need_sync;
75 * Start transaction in OFD.
77 * This function updates the given \a obj object version and calls
80 * \param[in] env execution environment
81 * \param[in] ofd OFD device
82 * \param[in] obj OFD object affected by this transaction
83 * \param[in] th transaction handle
85 * \retval 0 if successful
86 * \retval negative value in case of error
88 int ofd_trans_start(const struct lu_env *env, struct ofd_device *ofd,
89 struct ofd_object *obj, struct thandle *th)
91 /* version change is required for this object */
93 tgt_vbr_obj_set(env, ofd_object_child(obj));
95 return dt_trans_start(env, ofd->ofd_osd, th);
99 * Stop transaction in OFD.
101 * This function fills thandle::th_result with result of whole operation
102 * and calls dt_trans_stop().
104 * \param[in] env execution environment
105 * \param[in] ofd OFD device
106 * \param[in] th transaction handle
107 * \param[in] rc result code of whole operation
109 * \retval 0 if successful
110 * \retval negative value if case of error
112 int ofd_trans_stop(const struct lu_env *env, struct ofd_device *ofd,
113 struct thandle *th, int rc)
116 return dt_trans_stop(env, ofd->ofd_osd, th);